function js_date2string( str )
{
	return str.substring( 0, 4 ) + str.substring( 5, 7 ) + str.substring( 8, 10 );
}

function js_compose_params_s002()
{
	var fm = document.fm_search_again;
  fm.action = "s000.php";
	fm.submit();
	return true;
}

function js_compose_params_sidebar()
{
		var fm = document.fm_search_sidebar;
  	var f = 0;
		for (var i=0; i < fm.fx.length; i++)
  	{
  		if (fm.fx[i].checked)
  	  {
  	    f += parseInt(fm.fx[i].value);
  	  }
  	}
  	if ( fm.p1.value == '0' )
  		fm.p1.value = '';
  	if ( fm.p2.value == '9999999999' )
  		fm.p2.value = '';

  	//if (( fm.p1.value != '' ) || ( fm.p2.value != '' ) )
  		//f += parseInt(fm.fz.value) << 6;
  		//f += 64;
		//f += ( parseInt(fm.fy.value) << 8 );

		fm.f.value = f +'';
		if(fm.action == '')
			 fm.action = "s000.php";
		fm.submit();
		return false;
}

function js_compose_params_detail()
{
	var now_day=new Date();
	var now_year=now_day.getFullYear() + "";
	var now_month=( now_day.getMonth() + 1 ) + "";
	var now_day=now_day.getDate() + "";
	var str_today = now_year + now_month + now_day;
	var fm = document.fm_search_detail;
	var f = 0;
	for (var i=0; i < fm.fx.length; i++)
	{
		if (fm.fx[i].checked)
		{
			f += parseInt(fm.fx[i].value);
		}
	}
	var numcheck = /^\d*$/;
	if((fm.p1.value != '' && !numcheck.test(fm.p1.value)) || (fm.p2.value != '' && !numcheck.test(fm.p2.value)))
	{
		alert("價格範圍請輸入數字！");
		return false;
	}

	//if (( fm.p1.value != '' ) || ( fm.p2.value != '' ) )
		//f += parseInt(fm.fz.value) << 6;
	//f += ( parseInt(fm.fy.value) << 8 );
	fm.f.value = f +'';
	if ( fm.f1a.checked )
		fm.f1.value = ( ( fm.f1x.value == '' )? str_today:js_date2string(fm.f1x.value) ) + ( ( fm.f1y.value == '' )? str_today:js_date2string(fm.f1y.value) );
	if ( fm.f2a.checked )
		fm.f2.value = ( ( fm.f2x.value == '' )? str_today:fm.f2x.value ) + ( ( fm.f2y.value == '' )? str_today:fm.f2y.value );
	fm.action = "s000.php";
	fm.submit();
	return true;
}

function js_ini_date(ele_set)
{
	var now_day=new Date();
	var now_year=now_day.getFullYear() + "";
	var now_month=( now_day.getMonth() + 1 ) + "";
	var now_day=now_day.getDate();
	now_month = ( now_month < 10 )? "0" + now_month : now_month + "";
	now_day = ( now_day < 10 )? "0" + now_day : now_day + "";
	var str_today = now_year + "/" + now_month + "/" + now_day;
	var fm = document.fm_search_detail;

  if ( ele_set == 1 )
  {
		if ( fm.f1x.value == '' )
			fm.f1x.value = str_today;
		if ( fm.f1y.value == '' )
			fm.f1y.value = str_today;
	}
  else if ( ele_set == 2 )
  {
		if ( fm.f2x.value == '' )
			fm.f2x.value = str_today;
		if ( fm.f2y.value == '' )
			fm.f2y.value = str_today;
	}
	return false;
}

//carol add 20071206 head search bar (big5)
function js_headsearch()
{
	var fm = document.fm_head_searchbar;
	if(fm.k.value.length ==0)
	{
		alert("請輸入關鍵字");
		return false;
	}
	else if(fm.k.value.length > 255)
	{
		alert("關鍵字請勿輸入超過255個字 !!!");
		return false;
	}
	else
	{
  	fm.action = "http://search.ruten.com.tw/search/s000.php";
		fm.submit();
		return true;
	}
}