

function _$(id){

   return document.getElementById(id);

}

function showlast(){



   if (document.getElementById("lastdiv").style.display=='none'){
      document.getElementById("lastdiv").style.display='';
       document.getElementById("lasttxt").innerHTML='隐藏最近查看';
  }else{

       document.getElementById("lastdiv").style.display='none';
         document.getElementById("lasttxt").innerHTML='显示最近查看';
  }

}



function hide(dd){
   document.getElementById(dd).style.display='none';


}

function getCookie(name)
　{

　 var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
　 if(arr !=null) return unescape(arr[2]); return null;
　}
function getInnerWidth(){
	if(window.innerWidth){
		return 'window.innerWidth';
	}else if(document.documentElement&&document.documentElement.clientWidth){
		return 'document.documentElement.clientWidth';
	}else if(document.body){
		return 'document.body.clientWidth';
	}
}

function getInnerHeight(){
	if(window.innerHeight){
		return 'window.innerHeight';
	}else if(document.documentElement&&document.documentElement.clientHeight){
		return 'document.documentElement.clientHeight';
	}else if(document.body){
		return 'document.body.clientHeight';
	}
}


//
var xmlHttp = false;
var xmlHttp1 = false;
var xmlHttp2 = false;
var xmlHttp3 = false;

 //创建XMLHTTP对象
 function getXMLHTTPObj()
 {
  var C = null;
  try
  {
   C = new ActiveXObject("Msxml2.XMLHTTP");
  }
  catch(e)
  {
   try
   {
    C = new ActiveXObject("Microsoft.XMLHTTP");
   }
   catch(sc)
   {
    C = null;
   }
  }

  if( !C && typeof XMLHttpRequest != "undefined" )
  {
   C = new XMLHttpRequest();
  }

  return C;
 }





//shubiaoweizhi


var mousePos;
function temp(){
   return {         x:-1000,
	                     y:-1000,
						 offx:-1000,
						 offy:-1000



						 };

}
mousePos = temp();
//

   //mouseaction
//


 //创建XMLHTTP对象
 function getXMLHTTPObj()
 {
  var C = null;
  try
  {
   C = new ActiveXObject("Msxml2.XMLHTTP");
  }
  catch(e)
  {
   try
   {
    C = new ActiveXObject("Microsoft.XMLHTTP");
   }
   catch(sc)
   {
    C = null;
   }
  }

  if( !C && typeof XMLHttpRequest != "undefined" )
  {
   C = new XMLHttpRequest();
  }

  return C;
 }




//类别展开
function updatePage() {
  if (xmlHttp.readyState == 4) {

    var response = xmlHttp.responseText;
    document.getElementById("protype").innerHTML = response;
  }
}

function clearProtype(){


   document.getElementById('protype').style.display='none';
   //document.getElementById('protype').innerHTML='';


}


function Protype(typeid) {


  //if (document.getElementById("protype").style.display=='none'){
	   document.getElementById("protype").innerHTML='<img  style="margin:15px" src=/images/load.gif  />';
	document.getElementById("protype").style.display='';
  var url = "/ajax/getProtype.jsp?typeid="+typeid;
  // var ev = mousePosition(window.event);

   var sh = document.body.clientHeight;
  var sw = document.body.clientWidth;     //971px(body宽度）


  var bian = (window.screen.width-sw)/2;  //窗口宽度-body宽度 然后 除以2 ，就是边的宽度


 var dx ,dy;

   if (sw + bian-mousePos.x+mousePos.offx<365){

      dx = mousePos.x-mousePos.offx-365+137;

   }else{
      dx = mousePos.x-mousePos.offx;

   }


      dy = mousePos.y-mousePos.offy+18;



    // document.getElementById("tempdiv").innerHTML = "dx="+dx+"  "+"dy="+dy;

     document.getElementById("protype").style.left = dx+"px";
	  document.getElementById("protype").style.top = dy+"px";

    document.getElementById('protype').style.display='';




//window.status="ev.x="+ev.x+",ev.y="+ev.y+",dx="+dx+",dy="+dy;



    xmlHttp = getXMLHTTPObj();

  xmlHttp.open("GET", url, true);

  xmlHttp.onreadystatechange = updatePage;

  xmlHttp.send(null);

  //}
}

//类别展开---end

//大图显示
function callServer(proid) {

  if (document.getElementById("prodiv").style.display=='none'){
	  document.getElementById('prodiv').innerHTML='<img  style="margin:15px" src=/images/load.gif  />';
  var url = "/ajax/getPropic.jsp?proid="+proid;
  // var ev = mousePosition(window.event);

   var sh = document.body.clientHeight;
  var sw = document.body.clientWidth;
var bian = (window.screen.width-sw)/2;  //窗口宽度-body宽度 然后 除以2 ，就是边的宽度


 var dx ,dy;
  dx = mousePos.x -100;

   if (sh-mousePos.y<200){

      dy = mousePos.y-200;
   }else{
      dy = mousePos.y+20;

   }

     document.getElementById("prodiv").style.left = dx+"px";
	  document.getElementById("prodiv").style.top = dy+"px";

    document.getElementById('prodiv').style.display='';




//window.status="ev.x="+ev.x+",ev.y="+ev.y+",dx="+dx+",dy="+dy;



    xmlHttp1 = getXMLHTTPObj();

  xmlHttp1.open("GET", url, true);

  xmlHttp1.onreadystatechange = updatePage2;

  xmlHttp1.send(null);

  }
}


function updatePage2() {
  if (xmlHttp1.readyState == 4) {

    var response = xmlHttp1.responseText;
    document.getElementById("prodiv").innerHTML = response;
  }
}

function clearDiv(){

   document.getElementById('prodiv').style.display='none';
   //document.getElementById('prodiv').innerHTML='<img  style="margin:15px" src=/images/load.gif  />';

}


//大图显示  end

//2008.3.14


//最近浏览
function updateLastview() {
  if (xmlHttp2.readyState == 4) {

    var response = xmlHttp2.responseText;
    document.getElementById("lastview").innerHTML = response;
  }
}

function lastview() {

  var str = "";
  if (getCookie("lastviewids")!=null){
     str =  "&lastviewids="+getCookie("lastviewids");
  }
     var url = "/ajax/ajax.jsp?action=LASTVIEW"+str;
 //alert(url);
    xmlHttp2 = getXMLHTTPObj();

  xmlHttp2.open("GET", url, true);

  xmlHttp2.onreadystatechange = updateLastview;

  xmlHttp2.send(null);


}


function fitsize(){
// alert(getInnerWidth());
    if (eval(getInnerWidth())<=1024){

         document.getElementById("lastdiv").style.display='none';

    }else{
       document.getElementById("lastdiv").style.display='';

    }



}
if (document.getElementById("lastdiv")){
	fitsize();
}

//最近浏览---end

// 鼠标位置
function mousePosition(ev){
   return {         x:ev.pageX || (ev.clientX +      (document.documentElement.scrollLeft || document.body.scrollLeft)),
	                     y:ev.pageY || (ev.clientY +      (document.documentElement.scrollTop || document.body.scrollTop)),
						 offx:ev.layerX||ev.offsetX,
						 offy:ev.layerY||ev.offsetY



						 };

}
function mouseMove(ev){
    ev = ev || window.event;
    mousePos = mousePosition(ev);
	//document.getElementById("tempdiv").innerHTML=mousePos.offx+"    "+mousePos.offy;

}
document.onmousemove = mouseMove;

// 鼠标位置 ---end




//setInterval('fitsize()',20);


//鼠标悬停加入搜藏


function showfavor(proid) {

   _$("favordiv"+proid).style.top="-2px";
   _$("favordiv"+proid).style.left="-2px";
   //_$("favordiv"+proid).innerHTML="<a href='/go/addmyfavorpro.jsp?proid="+proid+"' target=_blank><img border=0 src='/images/favor.gif' border=0 \></a>";
   _$("favordiv"+proid).style.display='';

}
function hidefavor(proid){
    _$("favordiv"+proid).style.display='none';
}
//鼠标悬停加入搜藏__end

//购物车
var xmlHttp4 = false;
function updateProcar() {
  if (xmlHttp4.readyState == 4) {

    var response = xmlHttp4.responseText;
    document.getElementById("procardiv").innerHTML = response;

    showlast2();
  }
}

function procar() {

 var url = "/ajax/ajax.jsp?action=PROCAR";
 //alert(url);
    xmlHttp4 = getXMLHTTPObj();

  xmlHttp4.open("GET", url, true);

  xmlHttp4.onreadystatechange = updateProcar;
  xmlHttp4.setRequestHeader("If-Modified-Since","0");
  xmlHttp4.send(null);




}





//购物车 end


//缺货标志
var xmlHttp5 = false;

function updateSoldout() {
  if (xmlHttp5.readyState == 4) {

    var response = xmlHttp5.responseText;
    document.getElementById("soldout").innerHTML = response;
     // alert(response);
    if (response.indexOf("SOLDOUT")!=-1){
       document.getElementById("soldout_txt").innerHTML = "缺货";

    }
    document.getElementById("soldout_txt").style.display="";
  }
}

function soldout(proid) {

     var url = "/ajax/ajax.jsp?action=SOLDOUT&proid="+proid;

    xmlHttp5 = getXMLHTTPObj();

  xmlHttp5.open("GET", url, true);

  xmlHttp5.onreadystatechange = updateSoldout;

  xmlHttp5.send(null);


}
//缺货标志  end

function showlast2(){

    if (eval(getInnerWidth())<=1024){

         document.getElementById("lasttxt").innerHTML='显示最近查看';

    }else{
       document.getElementById("lasttxt").innerHTML='隐藏最近查看';

    }
}

//登录
var xmlHttp6 = false;

function updateLog() {
  if (xmlHttp6.readyState == 4) {

    var response = xmlHttp6.responseText;
    document.getElementById("title_log").innerHTML = response;
  }
}

function log(userid,password) {

     var url = "/ajax/log.jsp?userid="+userid+"&password="+password;
	  

    xmlHttp6 = getXMLHTTPObj();

  xmlHttp6.open("GET", url, true);

  xmlHttp6.onreadystatechange = updateLog;
  xmlHttp6.setRequestHeader("If-Modified-Since","0");
  xmlHttp6.send(null);


}

function updateLogout() {
  if (xmlHttp6.readyState == 4) {

    var response = xmlHttp6.responseText;
    document.getElementById("title_log").innerHTML = response;
  }
}
function logout(){
	//alert("success");
     var url = "/ajax/logout.jsp";
	// alert(userid);
//alert(password);
    xmlHttp6 = getXMLHTTPObj();

  xmlHttp6.open("GET", url, true);

  xmlHttp6.onreadystatechange = updateLogout;
  xmlHttp6.setRequestHeader("If-Modified-Since","0");
  xmlHttp6.send(null);
	
}


//登录end
//店址
var xmlHttp7 = false;
function updateSendInfo() {
  if (xmlHttp7.readyState == 4) {

    var response = xmlHttp7.responseText;
    document.getElementById("sendinfo").innerHTML = response;
  }
}

function sendinfo(id) {

 var url = "/ajax/ajax.jsp?action=SENDINFO&id="+id;
 //alert(url);
    xmlHttp7 = getXMLHTTPObj();

  xmlHttp7.open("GET", url, true);

  xmlHttp7.onreadystatechange = updateSendInfo;
  xmlHttp7.setRequestHeader("If-Modified-Since","0");
  xmlHttp7.send(null);


}

//店址 end

//同级类别导航
var xmlHttp8 = false;
function updateOneGradeType() {
  if (xmlHttp8.readyState == 4) {

    var response = xmlHttp8.responseText;

    document.getElementById("onegradetype").innerHTML = response;


  }
}

function onegradetype(typeid) {

 var url = "/ajax/ajax.jsp?action=ONEGRADETYPE&typeid="+typeid;
 //alert(url);
    xmlHttp8 = getXMLHTTPObj();

  xmlHttp8.open("GET", url, true);

  xmlHttp8.onreadystatechange = updateOneGradeType;
   document.getElementById("onegradetype").style.display='';
  xmlHttp8.setRequestHeader("If-Modified-Since","0");
  xmlHttp8.send(null);
  document.getElementById("onegradetype").style.top ='20px';
   document.getElementById("onegradetype").style.right ='80px';



}

//同级类别导航


var xmlHttp9 = false;
function updateBeiWang() {
  if (xmlHttp9.readyState == 4) {
    var response = xmlHttp9.responseText;
    document.getElementById("beiwang").innerHTML = response;
  }
}

function beiwang() {
  var url = "/ajax/ajax.jsp?action=beiwang";
  xmlHttp9 = getXMLHTTPObj();
  xmlHttp9.open("GET", url, true);
  xmlHttp9.onreadystatechange = updateBeiWang;
  xmlHttp9.setRequestHeader("If-Modified-Since","0");
  xmlHttp9.send(null);
}

//商品评价
var xmlHttp10 = false;
function updatePingjia() {
  if (xmlHttp10.readyState == 4) {
    var response = xmlHttp10.responseText;
    document.getElementById("pingjia").innerHTML = response;
  }
}

function pingjia(proid) {
  var url = "/ajax/ajax.jsp?action=pingjia&proid="+proid;
  xmlHttp10 = getXMLHTTPObj();
  xmlHttp10.open("GET", url, true);
  xmlHttp10.onreadystatechange = updatePingjia;
  xmlHttp10.setRequestHeader("If-Modified-Since","0");
  xmlHttp10.send(null);
}



//end











