function SetCookie(cookieName, cookieValue, nHours)
{ 
var today = new Date(); 
var expire = new Date(); 
if (nHours == null || nHours == 0) 
nHours = 1; 
expire.setTime(today.getTime() + 1000 * 60 * 60 * 24 * nHours); 
document.cookie = cookieName + "=" + escape(cookieValue) + ";expires=" + expire.toGMTString(); 
} 

function ReadCookie(cookieName)
{ 
var theCookie = "" + document.cookie; 
var ind = theCookie.indexOf(cookieName); 
if (ind == - 1 || cookieName == "") 
return ""; 
var ind1 = theCookie.indexOf(';', ind); 
if (ind1 == - 1) 
ind1 = theCookie.length; 
return unescape(theCookie.substring(ind + cookieName.length + 1, ind1)); 
}

function readCookie(name){
  var cookieValue = "";
  var search = name + "=";
  if(document.cookie.length > 0){ 
    offset = document.cookie.indexOf(search);
    if (offset != -1){ 
      offset += search.length;
      end = document.cookie.indexOf(";", offset);
      if (end == -1) end = document.cookie.length;
      cookieValue = unescape(document.cookie.substring(offset, end))
    }
  }
  return cookieValue;
}

function setListStyle(style)
{
	if(style==1)
	{
		g('TBmobileData').className='mobileList2col';
		g('proStyle_1').className='selected';
		g('proStyle_2').className='';
		//alert(1);
	}
	else
	{
		g('TBmobileData').className='mobileList';
		g('proStyle_1').className='';
		g('proStyle_2').className='selected';
		//alert(2);
	}
	
}

function setPageOrder(order)
{
	SetCookie('o',order,'1');
    location.href=location.href;
}

function setPageSize(size)
{
	SetCookie('ps',size,'1');
    location.href=location.href;
}

function initStatus()
{
	var o=ReadCookie('o');
	if(o=='2')
	{
	    g('priceDown').className='selected';
	}
	else
	{
	    g('priceUp').className='selected';
	}
	
	var ps=ReadCookie('ps');
	if(ps=='80')
	{
	    g('pagesize80').className='selected';
	}
	else if(ps=='60')
	{
	    g('pagesize60').className='selected';
	}	
	else
	{
	    g('pagesize40').className='selected';
	}
}

function txtbox_getFocus(e)
{
    //e.className='redborder';
    e.focus();
}

function txtbox_onlyNumber()
{
    return event.keyCode>=48 && event.keyCode<=57;
}

function doSearchByNum()
{
    var key='';
    var o=g('searchNum').getElementsByTagName('input');
    for(i=0;i<o.length-1;i++)
    {
        if(o[i].value=='')
        {
            key+='_';
        }
        else
        {
            key+=o[i].value;
        }
    }
    //alert(key);
    location.href='/product/?keyword='+key;
}

function doSearchByNum_high()
{
    var key='';
    var o=g('searchNum_high').getElementsByTagName('input');
    for(i=0;i<o.length-1;i++)
    {
        if(o[i].value=='')
        {
            key+='_';
        }
        else
        {
            key+=o[i].value;
        }
    }
    //alert(key);
    location.href='/product/?keyword='+key;
}

function moreSearchShow(){
    $("#searchItemBox").animate({height:300},"slow");
    $("#on-off").html('ÊÕ Æð');
    $("#on-off").attr("class","up");
    //document.getElementById('on-off').onclick=function(){};
}
function moreSearchHide(){
    $("#searchItemBox").animate({height:180},"slow");
    $("#on-off").html('Õ¹ ¿ª');
    $("#on-off").attr("class","down");
    //document.getElementById('on-off').onclick=function(){};
}
