﻿
/*
背景变灰
*/
var isIe=(document.all)?true:false;
//设置select的可见状态
function setSelectState(state)
{
var objl=document.getElementsByTagName('select');
for(var i=0;i<objl.length;i++)
{
objl[i].style.visibility=state;
}
}
function mousePosition(ev)
{
if(ev.pageX || ev.pageY)
{
return {x:ev.pageX, y:ev.pageY};
}
return {
x:ev.clientX + document.body.scrollLeft - document.body.clientLeft,y:ev.clientY + document.body.scrollTop - document.body.clientTop
};
}
//弹出方法
function showMessageBox(wTitle,content,pos,wWidth)
{
closeWindow();
var bWidth=parseInt(document.documentElement.scrollWidth);
var bHeight=parseInt(document.body.scrollHeight);
if(isIe){
setSelectState('hidden');}
var back=document.createElement("div");
back.id="back";
var styleStr="top:0px;left:0px;position:absolute;background:#000;width:"+bWidth+"px;height:"+bHeight+"px;";
styleStr+=(isIe)?"filter:alpha(opacity=0);":"opacity:0;";
back.style.cssText=styleStr;
document.body.appendChild(back);
showBackground(back,50);

}
//让背景渐渐变暗
function showBackground(obj,endInt)
{
if(isIe)
{
obj.filters.alpha.opacity+=1;
if(obj.filters.alpha.opacity<endInt)
{
setTimeout(function(){showBackground(obj,endInt)},5);
}
}else{
var al=parseFloat(obj.style.opacity);al+=0.01;
obj.style.opacity=al;
if(al<(endInt/100))
{setTimeout(function(){showBackground(obj,endInt)},5);}
}
}
//关闭窗口
function closeWindow()
{
if(document.getElementById('back')!=null)
{
document.getElementById('back').parentNode.removeChild(document.getElementById('back'));
}

if(isIe){
setSelectState('');}
}
//测试弹出
function testMessageBox(ev)
{
var objPos = mousePosition(ev);
messContent="<div style='padding:20px 0 20px 0;text-align:center'>消息正文</div>";
showMessageBox('窗口标题',messContent,objPos,350);
}
/*
背景变灰
*/

var popup_dragging = false;
var popup_target;
var popup_mouseX;
var popup_mouseY;
var popup_mouseposX;
var popup_mouseposY;
var popup_oldfunction;
function popup_display(x)
{
var win = window.open();
for (var i in x) win.document.write(i+' = '+x[i]+'<br>');
}
// ----- popup_mousedown -------------------------------------------------------
function popup_mousedown(e)
{
var ie = navigator.appName == "Microsoft Internet Explorer";
if ( ie && window.event.button != 1) return;
if (!ie && e.button != 0) return;
popup_dragging = true;
popup_target = this['target'];
popup_mouseX = ie ? window.event.clientX : e.clientX;
popup_mouseY = ie ? window.event.clientY : e.clientY;
if (ie)
popup_oldfunction = document.onselectstart;
else popup_oldfunction = document.onmousedown;
if (ie)
document.onselectstart = new Function("return false;");
else document.onmousedown = new Function("return false;");
}
// ----- popup_mousemove -------------------------------------------------------
function popup_mousemove(e)
{
if (!popup_dragging) return;
var ie = navigator.appName == "Microsoft Internet Explorer";
var element = document.getElementById(popup_target);
var mouseX = ie ? window.event.clientX : e.clientX;
var mouseY = ie ? window.event.clientY : e.clientY;
element.style.left = (element.offsetLeft+mouseX-popup_mouseX)+'px';
element.style.top = (element.offsetTop +mouseY-popup_mouseY)+'px';
popup_mouseX = ie ? window.event.clientX : e.clientX;
popup_mouseY = ie ? window.event.clientY : e.clientY;
}
// ----- popup_mouseup ---------------------------------------------------------
function popup_mouseup(e)
{
if (!popup_dragging) return;
popup_dragging = false;
var ie = navigator.appName == "Microsoft Internet Explorer";
var element = document.getElementById(popup_target);
if (ie)
document.onselectstart = popup_oldfunction;
else document.onmousedown = popup_oldfunction;
}
// ----- popup_exit ------------------------------------------------------------
function popup_exit(e)
{
var ie = navigator.appName == "Microsoft Internet Explorer";
var element = document.getElementById(popup_target);
popup_mouseup(e);
element.style.visibility = 'hidden';
element.style.display = 'none';
}
// ----- popup_show ------------------------------------------------------------

// ----- popup_mousepos --------------------------------------------------------
function popup_mousepos(e)
{
var ie = navigator.appName == "Microsoft Internet Explorer";
popup_mouseposX = ie ? window.event.clientX : e.clientX;
popup_mouseposY = ie ? window.event.clientY : e.clientY;
}
// ----- Attach Events ---------------------------------------------------------
if (navigator.appName == "Microsoft Internet Explorer")
document.attachEvent('onmousedown', popup_mousepos);
else document.addEventListener('mousedown', popup_mousepos, false);
if (navigator.appName == "Microsoft Internet Explorer")
document.attachEvent('onmousemove', popup_mousemove);
else document.addEventListener('mousemove', popup_mousemove, false);
if (navigator.appName == "Microsoft Internet Explorer")
document.attachEvent('onmouseup', popup_mouseup);
else document.addEventListener('mouseup', popup_mouseup, false);


function mouseovers(id,img)
{
var top_dhl_dhl1=document.getElementById(id);
top_dhl_dhl1.style.background="url(images/"+img+")";

}
function mouseouts(id,img)
{

var top_dhl_dhl1=document.getElementById(id);
top_dhl_dhl1.style.background="url(images/"+img+")";
}

  var prox;
    var proy;
    var proxc;
    var proyc;
	var isIe=(document.all)?true:false;
	function setSelectState(state)
{
var objl=document.getElementsByTagName('select');
for(var i=0;i<objl.length;i++)
{
objl[i].style.visibility=state;
}
}
function mousePosition(ev)
{
if(ev.pageX || ev.pageY)
{
return {x:ev.pageX, y:ev.pageY};
}
return {
x:ev.clientX + document.body.scrollLeft - document.body.clientLeft,y:ev.clientY + document.body.scrollTop - document.body.clientTop
};
}
//????
function closeWindow()
{
if(document.getElementById('back')!=null)
{
document.getElementById('back').parentNode.removeChild(document.getElementById('back'));
}
if(document.getElementById('mesWindow')!=null)
{
document.getElementById('mesWindow').parentNode.removeChild(document.getElementById('mesWindow'));
}
if(isIe){
setSelectState('');}
}

// JScript 文件
   var pid;
   var req; //定义变量，用来创建xmlhttprequest对象
   
        function select(id,tb) // 创建xmlhttprequest,ajax开始(typeid为分类等级（1为一级分类），dp1为大类id，dp2小类id,dp2_add_str小类添加的默认项（如“选择二级分类")
        {
          testMessageBox(event)
               var now = new Date();
               strTime = escape(now.toLocaleString());
             pid=id;
            
           var url="";
            url="product_diplay.aspx?strTime="+strTime+"&id="+id+"&tb="+tb; //要请求的服务端地址
         // document.write(url);
            if(window.XMLHttpRequest) //非IE浏览器，用xmlhttprequest对象创建
            {
                req=new XMLHttpRequest();
            }
            else if(window.ActiveXObject) //IE浏览器用activexobject对象创建
            {
                req=new ActiveXObject("Microsoft.XMLHttp");
            }
            
            if(req) //成功创建xmlhttprequest
            {
                req.open("GET",url,true); //与服务端建立连接(请求方式post或get，地址,true表示异步)
               
                req.onreadystatechange =function select_callback()
                    {
                    
                     
                      
                      if(req.readyState==4)
                      {
                       
                             if(req.status==200)
                             {
                                   var list=req.responseText;
                                  
                                   var classList=list.split("|");
                                   var imgurl,pname;
                                  
                                    for(var i=0;i<classList.length;i++)
                                    {
                                   imgurl=classList[0];
                                   pname=classList[1];
                                      
                                   }
                                   show('fd',event,imgurl,pname);
                               }
                               else
                               
                               {
                                    alert("您所请求的页面有异常。");
                                    return;
                              }
                        }
                     }; //指定回调函数
 
                req.send(null); //发送请求
            }
     }
     var req1;
     function pnext(tb)
     {
      var now = new Date();
               strTime = escape(now.toLocaleString());
           
           var url="";
            url="next.aspx?strTime="+strTime+"&id="+pid+"&tb="+tb; //要请求的服务端地址
//         document.write(url);
            if(window.XMLHttpRequest) //非IE浏览器，用xmlhttprequest对象创建
            {
                req1=new XMLHttpRequest();
            }
            else if(window.ActiveXObject) //IE浏览器用activexobject对象创建
            {
                req1=new ActiveXObject("Microsoft.XMLHttp");
            }
            
            if(req1) //成功创建xmlhttprequest
            {
                req1.open("GET",url,true); //与服务端建立连接(请求方式post或get，地址,true表示异步)
               
                req1.onreadystatechange =function select_callback()
                    {
                    
                     
                      
                      if(req1.readyState==4)
                      {
                       
                             if(req1.status==200)
                             {
                                   var list=req1.responseText;
                                    //document.write(list);
                                   var classList=list.split("|");
                                   var imgurl,pname;
                                  
                                    for(var i=0;i<classList.length;i++)
                                    {
                                   imgurl=classList[0];
                                   pname=classList[1];
                                   pid=classList[2];
                                   }
                                  
                                   
                                   show('fd',event,imgurl,pname);
                               }
                               else
                               
                               {
                                    alert("您所请求的页面有异常。");
                                    return;
                              }
                        }
                     }; //指定回调函数
 
                req1.send(null); //发送请求
            }
     }
      var req2;
     function prev(tb)
     {
      var now = new Date();
               strTime = escape(now.toLocaleString());
           
           var url="";
            url="prev.aspx?strTime="+strTime+"&id="+pid+"&tb="+tb; //要请求的服务端地址
         
            if(window.XMLHttpRequest) //非IE浏览器，用xmlhttprequest对象创建
            {
                req2=new XMLHttpRequest();
            }
            else if(window.ActiveXObject) //IE浏览器用activexobject对象创建
            {
                req2=new ActiveXObject("Microsoft.XMLHttp");
            }
            
            if(req2) //成功创建xmlhttprequest
            {
                req2.open("GET",url,true); //与服务端建立连接(请求方式post或get，地址,true表示异步)
               
                req2.onreadystatechange =function select_callback()
                    {
                    
                     
                      
                      if(req2.readyState==4)
                      {
                       
                             if(req2.status==200)
                             {
                                   var list=req2.responseText;
                                    //document.write(list);
                                   var classList=list.split("|");
                                   var imgurl,pname;
                                  
                                    for(var i=0;i<classList.length;i++)
                                    {
                                   imgurl=classList[0];
                                   pname=classList[1];
                                   pid=classList[2];
                                   }
                                  
                                   
                                   show('fd',event,imgurl,pname);
                               }
                               else
                               
                               {
                                    alert("您所请求的页面有异常。");
                                    return;
                              }
                        }
                     }; //指定回调函数
 
                req2.send(null); //发送请求
            }
     }
    function show(id,ev,img1,names){/*--??--*/
	//closeWindow();
	//document.getElementById("proview_cons").innerHTML="<img src=images/ajax-loading.gif />Loading";
	//document.getElementById("proview_con").innerHTML="";
	
	var bWidth=parseInt(document.documentElement.scrollWidth);
	var bHeight=parseInt(document.documentElement.scrollHeight)<592?592:parseInt(document.documentElement.scrollHeight);
	//if(isIe){
	//setSelectState('hidden');}
//	var back=document.createElement("div");
//	back.id="back";
//	var styleStr=" width:"+bWidth+"px;height:"+bHeight+"px;";
//	styleStr+=(isIe)?"filter:alpha(opacity=100);":"opacity:1;";
//	back.style.cssText=styleStr;
//	document.body.appendChild(back);
	
        clearInterval(prox);
        clearInterval(proy);
        clearInterval(proxc);
        clearInterval(proyc);
        var o = document.getElementById(id);
		var imgs=document.getElementById("img_3d");
		
       
		imgs.src=img1;
		var   image=new   Image();   
		image.src=img1;
		
        o.style.display = "block";
		
	    var name_li=document.getElementById("tt");
	    name_li.innerHTML=names;
	            o.style.width = "5px";
        o.style.height = "5px"; 


　　


		o.style.left =-image.width/2 ;//(document.documentElement.scrollLeft+popup_mouseposX-10)+'px';
		var x=image.width+16;
		var y=image.height+16+25;
		
		o.style.top="0px";//(document.documentElement.scrollTop +popup_mouseposY-250)+'px';
		
        prox = setInterval(function(){openx(o,x,y)},35);
	   
		
		
    }    
    function openx(o,x,y){/*--??x--*/
        var cx = parseInt(o.style.width);
		var cl=parseInt(o.style.left);
        if(cx < x)
        {
		//alert("cx"+cx+"cl"+cl+"x"+x);
            o.style.width = (cx + Math.ceil((x-cx)/5)) +"px";
			//o.style.left = (cl + Math.ceil((150-cl)/5)) +"px";
        }
        else
        {
            clearInterval(prox);
            proy = setInterval(function(){openy(o,y)},20);
        }
    }    
    function openy(o,y){/*--??y--*/    
        var cy = parseInt(o.style.height);
		var ct=parseInt(o.style.top);
        if(cy < y)
        {
		
            o.style.height = (cy + Math.ceil((y-cy)/5)) +"px";
			//o.style.top=(ct+Math.ceil((180-ct)/5)) +"px";
        }
        else
        {
            clearInterval(proy);  
			
        }
    } 
	
	 function closeed(id){/*--??--*/

	    closeWindow();
        clearInterval(prox);
        clearInterval(proy);
        clearInterval(proxc);
        clearInterval(proyc);        
        var o = document.getElementById(id);
        if(o.style.display == "block")
        {
            proyc = setInterval(function(){closey(o)},30);  
            //alert(proyc); 
            // proxc = setInterval(function(){closey(o)},10);           
        } 
		//document.getElementById("div_close").style.display='none';       
    }       
    
    function closey(o){/*--??y--*/    
        var cy = parseInt(o.style.height);
        if(cy > 0)
        {
       
            o.style.height =(cy - Math.ceil(cy/10)) +"px";
           
            if(cy=="1")
            {
            //alert(cy);
            clearInterval(proyc);
             o.style.display="none";
            
            }
          
        }
//        else
//        {
//       // proxc = setInterval(function(){closex(o)},30);
//       // alert(o.style.height); 
//         clearInterval(proyc); 
////        o.style.width="0px"
////        o.style.height="0px";
//        o.style.display="none";
//        //o.style.height="0px"
//      // alert(proyc+"b"+cy); 
//           
//             clearInterval(proxc);               
//            
//        }
    }    
    function closex(o){/*--??x--*/
        var cx = parseInt(o.style.width);
        if(cx > 0)
        {
        //alert(proyc+"c"); 
            o.style.width = (cx - Math.ceil(cx/5)) +"px";
        }
        else
        {
            //alert(proyc+"d"); 
            clearInterval(proxc);
            o.style.display = "none";
        }
    }    
    
    
   
function showBackground(obj,endInt)
{
obj.filters.alpha.opacity+=1;
if(obj.filters.alpha.opacity<endInt)
{
setTimeout(function(){showBackground(obj,endInt)},8);
}
}



