﻿// JavaScript Document
function productNewOrTop(objID,showID)
{
	try
	{
		document.getElementById("nprd").className="topproduct";
		document.getElementById("tprd").className="topproduct";
		document.getElementById("top").style.display="none";
		document.getElementById("new").style.display="none";
	}
	catch(e){}
	if(document.getElementById(objID)!= null)
	{
		document.getElementById(objID).className ="newproduct";
		document.getElementById(showID).style.display="";
	}
}

function loadcolor(objID)
{
	if(document.getElementById(objID)!=null)
	{
		var ul = document.getElementById(objID).getElementsByTagName("ul");
		for(var i=0; i< ul.length;i++)
		{
			ul[i].onmouseover = function(){this.style.background='#EBEBEB';};
			ul[i].onmouseout = function(){this.style.background='#ffffff';};
		}
	}
}
function loaddivcolor(objID)
{
	//prdocuts
	if(document.getElementById(objID)!=null)
	{
		var ul = document.getElementById(objID).getElementsByTagName("div");
		for(var i=0; i< ul.length;i++)
		{
			ul[i].onmouseover = function(){this.style.background='#EBEBEB';};
			ul[i].onmouseout = function(){this.style.background='#ffffff';};
		}
	}
}

function lost(obj)
{
    if(document.getElementById(obj)!= null)    
    {
        document.getElementById(obj).value="";        
    }
}

function showdiv(obj,hitID)
{
    //positions
    //document.getElementById("positions").className = "pos";
    var tdlist = document.getElementById("positions").getElementsByTagName("td");
    for(var i=0; i< tdlist.length;i++)
    {
        tdlist[i].style.position = "";
    }
    document.getElementById(obj).parentNode.style.position = "relative";
	if(document.getElementById("postmail")!= null)
    {
		
		var pID = document.getElementById("postmail").parentElement;		
        var div = document.getElementById("postmail");		
        pID.removeChild(div);
		
    }
    
    var newDiv = document.createElement("div");
	newDiv.id = "postmail";
	newDiv.style.position = "absolute";
	newDiv.style.zIndex = "1";
	newDiv.style.width = "200px";
	newDiv.style.height = "100px";
	newDiv.style.top = "10px";
	newDiv.style.left = "10px"; // 屏幕居中
	newDiv.style.background = "#dcdcdc";
	newDiv.className="haha";
	newDiv.style.border = "1px solid #dcdcdc";	
	newDiv.style.padding = "5px";
	
	document.getElementById(obj).parentNode.appendChild(newDiv);	
	var img = document.createElement("img");
	img.style.position = "absolute";
	img.style.top = "0px";
	img.style.left = "195";
	img.src = "images/close.gif";
	img.style.cursor="pointer";
	img.onclick = function()
	{
	    var pIDs = document.getElementById("postmail").parentElement;		
        var divs = document.getElementById("postmail");		
        pIDs.removeChild(divs);
	};
	document.getElementById("postmail").appendChild(img);
	
	var showdetails = document.createElement("div");
	showdetails.id = "showdetails";
	showdetails.style.position = "absolute";
	showdetails.style.zIndex = "1";
	showdetails.style.width = "200px";
	showdetails.style.height = "85px";
	showdetails.style.top = "15px";
	showdetails.style.left = "0px"; // 屏幕居中
	showdetails.style.color = "#000";	
	showdetails.style.padding = "5px";	
	
	document.getElementById("postmail").appendChild(showdetails);
	
	loadAjax(hitID);
}

function loadAjax(hidID)
{
    document.getElementById("showdetails").className = "mycss";
    document.getElementById("showdetails").innerHTML = "数据加载中....";
    dealAct("loadheard.Aspx?ID="+hidID+"&"+Math.random());
}
var xmlHttp;

function createXMLHttpRequest() { //创建一个xmlHttpRequest对象
    if (window.ActiveXObject) {
        xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    } 
    else if (window.XMLHttpRequest)
    {
        xmlHttp = new XMLHttpRequest();
    }
}

function dealAct(url){
     //请求页面url
    createXMLHttpRequest();
    xmlHttp.onreadystatechange = handleStateChange; //请求状态改变事件触发handleStateChange功能
    xmlHttp.open("GET",url); //采用get方法提交数据
    xmlHttp.send(null);    
   // alert(url+"&"+Math.random());
}

function handleStateChange(){
    if(xmlHttp.readyState == 4){    //表示请求状态 4为完成
            if(xmlHttp.status == 200){ //http状态指示码，200表示ok
                      document.getElementById("showdetails").innerHTML = xmlHttp.responseText; //将服务器返回信息作为文本插入到infoId指示的容器中。
                     
                }
        }
        else"";
}

function lastphoto()
{
    
    if(document.getElementById("details") != null)
    { 
        
        var lbcontent = document.getElementById("details");//contentDetails
        var comtentPhoto = lbcontent.getElementsByTagName("img");
	
        for(var i = 0;i< comtentPhoto.length;i++)
        {
            //alert("d");
            comtentPhoto[i].onerror=function(){this.src="images/error.gif";}
            comtentPhoto[i].style.cursor = "hand";
            comtentPhoto[i].onclick = function(){window.open(this.src)}
            var img = new Image();
            img.src = comtentPhoto[i].src;		
            var oldw = img.width;
			var oldh = img.height;
            if(img.width > 580)
            {				
                comtentPhoto[i].width = 720;
				comtentPhoto[i].height = 720 * (oldh*1 / oldw*1);
            }            
        }
    }
       
}

function loaddivcolor(objID)
{
	//prdocuts
	if(document.getElementById(objID)!=null)
	{
		var ul = document.getElementById(objID).getElementsByTagName("div");
		for(var i=0; i< ul.length;i++)
		{
			ul[i].onmouseover = function(){this.className="prddiv2";};
			ul[i].onmouseout = function(){this.className="prddiv";};
		}
	}
}