﻿if(document.getElementById("alogin"))
{
    if(location.href.indexOf("returl")>0)
    {
		document.getElementById("alogin").href=location.href;
	}
    else
    {
        document.getElementById("alogin").href="http://www.juqile.cn/UserCenter/Login.aspx?returl="+location.href;
    }
}
if(document.getElementById("aregister"))
{
    if(location.href.indexOf("returl")>0)
    {
		document.getElementById("aregister").href=location.href;
	}
    else
    {
        document.getElementById("aregister").href="http://www.juqile.cn/UserCenter/Register.aspx?returl="+location.href;
    }
}
if(document.getElementById("alogout"))
{
    if(location.href.indexOf("returl")>0)
    {
		document.getElementById("alogout").href=location.href;
	}
    else
    {
        document.getElementById("alogout").href="http://www.juqile.cn/UserCenter/logout.aspx?returl="+location.href;
    }
}


function UrlDecode(str){ 
  var ret=""; 
  for(var i=0;i<str.length;i++){ 
   var chr = str.charAt(i); 
    if(chr == "+"){ 
      ret+=" "; 
    }else if(chr=="%"){ 
     var asc = str.substring(i+1,i+3); 
     if(parseInt("0x"+asc)>0x7f){ 
      ret+=asc2str(parseInt("0x"+asc+str.substring(i+4,i+6))); 
      i+=5; 
     }else{ 
      ret+=asc2str(parseInt("0x"+asc)); 
      i+=2; 
     } 
    }else{ 
      ret+= chr; 
    } 
  } 
  return ret; 
}


var Request = new function()
{
	this.search=window.location.search;
	
	this.QueryString = new Array();
	
	var tmparray = this.search.substr(1,this.search.length).split("&")
	for(var i = 0;i<tmparray.length;i++)
	{
		var tmpStr2 = tmparray[i].split("=");
		this.QueryString[tmpStr2[0]] = tmpStr2[1];
	}	
}
if(Request.QueryString["keyword"]!=null&&Request.QueryString["keyword"]!="")
{
    document.getElementById("Keyword").value=UrlDecode(Request.QueryString["keyword"]);
}


function DrawImage(img,width,height){
if(width==null) width=127;
if(height==null) height=156;
var image=new Image(); 
image.src=img.src; 
	if(image.width>0 && image.height>0)
	{
	  if(image.width!=width)
	  {
	  	rate=image.height/image.width;
	  	newHeight=rate*width;
	  	img.width=width;
	  	img.height=newHeight;
	  } 
	}
	if(img.height>height)
	{
		rate=image.width/image.height;
		newWidth=rate*height;
		img.height=height;
		img.width=newWidth;
	}
}



function showSort(id)
{
var o =document.getElementById("UL_"+id);
var oH =document.getElementById("H3_"+id);
oH.className=(oH.className=="open")?"":"open";
o.className=(o.className=="open")?"":"open";
}


function winOpen()
    {
        var popup=window.open('http://www.juqile.cn/ordercenter/shoppingcart_list.aspx','shoppingCart')
        popup.focus();
    }
    function ChangeImg(o)
    {
        var arr=document.getElementById("smallimg").childNodes;
        
        for(var i=0;i<arr.length-1;i++)
        {
            arr[i].className="imga";
        }
        
        if(o.src.toLowerCase()!=document.getElementById("bigProImg").src.toLowerCase().replace("mid","40_50"))
        {
            o.className="imgb";
            document.getElementById("bigProImg").src=o.src.replace("40_50","mid");
        }
        else
        {
            o.className="imga";
        }
    }
