﻿/*左右div自适应高度*/
function setStyle(){
try{
if(document.getElementById("leftMenu").clientHeight<document.getElementById("content").clientHeight){
document.getElementById("leftMenu").style.height=document.getElementById("content").offsetHeight+"px";
}
else{
document.getElementById("content").style.height=document.getElementById("leftMenu").offsetHeight+"px";
}
}catch(e){}
}
/*搜索*/
window.onload=function()
{
var searchBox=document.getElementById("searchBox");
var searchBtn=document.getElementById("searchBtn");
searchBox.focus();
KeyDown(searchBox);
var kw=request("kw");
if(kw.length>0)searchBox.value=kw;
setStyle();
searchBtn.onclick=function()
{
gotoUrl();
}
}
function gotoUrl()
{
var searchBox=document.getElementById("searchBox");
window.location.href="/search.aspx?kw="+searchBox.value;
}
function KeyDown(obj)
{
    if(obj.addEventListener){//如果是Firefox   
    obj.addEventListener("keypress",fireFoxHandler, true);  
     }else{   
      obj.attachEvent("onkeypress",ieHandler);   
      }  
        
}
function fireFoxHandler(evt){  
         //alert("firefox");  
  if(evt.keyCode==13){  
    gotoUrl();
    }  
}  
function ieHandler(evt){ 
   //alert("IE");  
   if(evt.keyCode==13){  
    gotoUrl();
    }  
}

function request(paras){ 
var url =window.location.href; 
var oRegex = new RegExp( '[\?&]' + paras + '=([^&]+)', 'i' ) ;
 //var oMatch = oRegex.exec( window.top.location.search ) ; //获取当前窗口的URL
 var oMatch = oRegex.exec( url ) ;
 if ( oMatch && oMatch.length > 1 )
  return oMatch[1] ;  //返回值
 else
  return '' ;

} 
function showProductDetail(url)
{
window.location.href=url;
}
