﻿
// JScript 文件
var xRequest;  //声明一个XMLHtttpRequest对象

//声明一个取得信息的方法


function getProductDetail(imageSrc, productNumber) {
            var url="/GoodsInfoList/ProDetaiAjax.aspx?productNumber="+productNumber; //提交给后台执行页面      	
            //判断老版本IE和新版本IE的浏览器
            try{
                xRequest = new ActiveXObject("Msxml2.XMLHTTP");//创建旧版本的IE请求对象
            } catch (e) {
                 try {
                    if(window.XMLHttpRequest){
	                    xRequest = new XMLHttpRequest();//创建新版本IE请求对象
                    }else if (typeof ActiveXObject != "undefined"){
	                    xRequest = new ActiveXObject("Microsoft.XMLHTTP"); //创建COM组件
                    }
                } catch (E){
                    xRequest = false;
                }
            }
            	 	
            //创建非IE浏览器的请求对象
             if (!xRequest && typeof XMLHttpRequest != 'undefined'){
                xRequest = new XMLHttpRequest();
             }	 

             
            //判断对象为false
            if(xRequest){  
                xRequest.open("GET",url,true); //建立与服务器的请求
                xRequest.onreadystatechange = CallBackInfo; //指定回调方法
                xRequest.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
                xRequest.setRequestHeader("content","text/html");
                xRequest.setRequestHeader("charset","utf-8");
                xRequest.send(null); //发送请求
            }else{
                alert("无法创建连接。。。");
            }		
   }
	

//声明回调方法
function CallBackInfo(){ 
   
	if (xRequest.readyState == 4){ //如果正确发送异步请求
		if(xRequest.status == 200){  //并且响应成功		    
			showProductDetail();  //那么接收返回的数据
		}else{
			alert("不能得到服务器的数据：" + xRequest.statusText); //给出错误信息
		}
	}else{
		return;
	}
}	

function showProductDetail()
{
    if(xRequest.responseText != "")
    {
      ddrivetip(xRequest.responseText.toString(), "#ffffff", "300");  
      var timer1 = setTimeout(hideimage, 2000);
      clearTimeout(timer1);
    }
}


function hideimage(){
    hideddrivetip();
}


var offsetxpoint = -80
var offsetypoint = 20
var ie = document.all
var ns6 = document.getElementById && !document.all
var enabletip = false
function ietruebody() {
    return (document.compatMode && document.compatMode != "BackCompat") ? document.documentElement : document.body
}

function ddrivetip(thetext, thecolor, thewidth) {
    if (ns6 || ie) {
        if (typeof thewidth != "undefined") document.getElementById("dhtmltooltip").style.width = thewidth + "px"
        if (typeof thecolor != "undefined" && thecolor != "") document.getElementById("dhtmltooltip").style.backgroundColor = thecolor
        document.getElementById("dhtmltooltip").innerHTML = thetext
        enabletip = true
        return false
    }
}

function positiontip(e) {
    if (enabletip) {
        var curX = (ns6) ? e.pageX : event.x + ietruebody().scrollLeft;
        var curY = (ns6) ? e.pageY : event.y + ietruebody().scrollTop;
        var rightedge = ie && !window.opera ? ietruebody().clientWidth - event.clientX - offsetxpoint : window.innerWidth - e.clientX - offsetxpoint - 20
        var bottomedge = ie && !window.opera ? ietruebody().clientHeight - event.clientY - offsetypoint : window.innerHeight - e.clientY - offsetypoint - 20
        var leftedge = (offsetxpoint < 0) ? offsetxpoint * (-1) : -1000
        document.getElementById("dhtmltooltip").style.left = "5px"
        document.getElementById("dhtmltooltip").style.left = curX + offsetxpoint + "px"
        document.getElementById("dhtmltooltip").style.top = curY + offsetypoint + "px"
        document.getElementById("dhtmltooltip").style.visibility = "visible"
    }
}

function hideddrivetip() {
    if (ns6 || ie) {
        enabletip = false
        document.getElementById("dhtmltooltip").style.visibility = "hidden"
        document.getElementById("dhtmltooltip").style.left = "-1000px"
        document.getElementById("dhtmltooltip").style.backgroundColor = ''
        document.getElementById("dhtmltooltip").style.width = ''
    }
}
document.onmousemove = positiontip



