// JScript 文件    
function onEnterClick(event)
{
    if(event.keyCode==13)
    {
       event.keyCode=9;
       if(CheckIsValate())
       {
            if(location.href.indexOf("msn.")>0)
                GoSearch('http://msn.brand.yoka.com');
            else
                GoSearch('http://brand.yoka.com');
       }
    }
}

function CheckIsValate()
    {
        var tbPriceMin=document.getElementById("txtPriceMin");
        var tbPriceMax=document.getElementById("txtPriceMax");
        var numReg = new RegExp("^\\d*$");
        if(tbPriceMin !=null && tbPriceMin.value != "")
        {   
            //if(isNaN(tbPriceMin.value))
            if(!tbPriceMin.value.match(numReg))
            {
                alert("价格必须为数字");
                tbPriceMin.focus();
                return false;
            }
        }
        if(tbPriceMax !=null && tbPriceMax.value != "")
        {
            //if(isNaN(tbPriceMax.value))
            if(!tbPriceMax.value.match(numReg))
            {
                alert("价格必须为数字");
                tbPriceMax.focus();
                return false;
            }
        }
        return true;
    }

function SetSelect(select,value)
{
    try
    {
        for(i=0; i < select.options.length; i++)
        {
            if(select.options[i].value == value)
            {
                select.options[i].selected="selected";
            }
         }
    }
    catch(error){}
}
function GoSearch()            
{
    return GoSearch('');
}
function GoSearch(host)
{
    var catalog= document.getElementById('ctl00_ContentPlaceHolder1_ddlCatalog2') !=null ? document.getElementById('ctl00_ContentPlaceHolder1_ddlCatalog2').value : 0;
    var key= document.getElementById('ctl00_ContentPlaceHolder1_txtKeyword') !=null ? document.getElementById('ctl00_ContentPlaceHolder1_txtKeyword').value : "";
    var domain= document.getElementById('ddlBrand') !=null ? document.getElementById('ddlBrand').value :"all";
    var pricemin=document.getElementById('txtPriceMin') !=null ? document.getElementById('txtPriceMin').value : 0;
    var pricemax=document.getElementById('txtPriceMax') !=null ?document.getElementById('txtPriceMax').value : 0;
    var order=99;
    catalog=catalog<1?0:catalog;
    if (key=='请输入关键字') key='';
    key=key==''?'all':key;
    key=key.replace(/[\s　]/g,"~28");
    key=key.replace("'","~27");
    key=key.replace("‘","~27");
    key=key.replace("’","~27");
    key=key.replace("+","~29");
    key=key.replace("（","(");
    key=key.replace("）",")");

	pricemin=pricemin==''?0:pricemin;
	pricemax=pricemax==''?0:pricemax;
	pricemin = parseInt(pricemin);
	pricemax = parseInt(pricemax);

	if(pricemin > pricemax & pricemax > 0)     //判断大小   转化位置
	{
	    var tmpPrice = pricemin;
	    pricemin = pricemax;
	    pricemax = tmpPrice;
	}

    var mylocation='/cosmetics/'+domain+'/product_'+catalog+'_'+pricemin+'_'+pricemax+'_'+order+'_'+key+'_0_1.htm';
    if(domain!='' & domain!='all' & catalog==0 & pricemin==0 & pricemax==0 & order==0 & key=='all')
	   mylocation='/cosmetics/'+domain +'/';
   if(host == null)
        window.open( encodeURI(mylocation));
    else
        window.open(encodeURI(host+ mylocation));
    return false;
}

function Trim(str)   
{   
      //return str.replace(/(^\s*)|(\s*$)/g, "");   
      return str.replace(/\s/gi,"");
} 


