﻿// JScript 文件
//当鼠标停留在九宫格的商品图片上时，显示出一个flash放大效果图。当鼠标从九宫格或者Flash放大图上离开是，这个Flash就不显示了

var parentPosition;       //用来显示flash放大图片的层
var BigImg;         //用来显示大图片
var time1;
var resPostionCode="";

function CreateDiv()
{
    parentPosition=document.getElementById("BigImagePosition");
    BigImg=document.getElementById("imgbigpicture");
}

function setBigImgPosition(object1)
{
    window.setTimeout
    if(parentPosition==null)
    {
        CreateDiv();
    }
    var bigimgurl=object1.src.toString();
	bigimgurl=bigimgurl.replace("ProListImage","ProBigImage");
	bigimgurl=bigimgurl.replace("/List/","/ViewBig/");
	BigImg.src=bigimgurl;
	//parentPosition.innerHTML="<img src="+bigimgurl+"/>";
    var a=0;
	if(document.body.offsetWidth-970>0)
	{
	    a=(document.body.offsetWidth-970)/2;
	}
	//var a=document.getElementById("BigImage");
	var top_img=document.getElementById("list_top_img");
	var top_height=top_img.clientHeight+250;
	var x=object1.offsetParent.offsetParent.offsetParent.offsetLeft+object1.offsetWidth+190+a;
	
	var y=object1.offsetParent.offsetParent.offsetParent.offsetTop+top_height;
	
	//parentPosition.style.top=object1.offsetParent.offsetParent.offsetParent.offsetTop+top_height;
	var b=object1.offsetParent.offsetParent.offsetParent.offsetLeft+parentPosition.clientWidth+174+a;
	
	var c=document.body.offsetWidth;
	if(b+100>c||x+100>c)//大于页面宽度时
	{
	    
	    b=object1.offsetParent.offsetParent.offsetParent.offsetLeft-parentPosition.clientWidth+174+a;  //显示在左边
	    x=b;
	}
	
	$("#BigImagePosition").css("top",y);
	$("#BigImagePosition").css("left",x);
	
	if(time1)
	{
	    window.clearTimeout(time1);
	}
	time1=window.setTimeout("showbigimage()",1000);
	return;
}

function showbigimage()
{
    if(time1)
    {
        $("#BigImagePosition").show("slow");
    }
}

function setBigImgPosition2(object1)
{
    if(parentPosition==null)
    {
        CreateDiv();
    }
    var bigimgurl=object1.src.toString();
	bigimgurl=bigimgurl.replace("ProListImage","ProBigImage");
	bigimgurl=bigimgurl.replace("/List/","/ViewBig/");
	BigImg.src=bigimgurl;
	
	var a=0;
	if(document.body.offsetWidth-970>0)
	{
	    a=(document.body.offsetWidth-970)/2;
	}
	var top_img=document.getElementById("list_top_img");
	var top_height=top_img.clientHeight;
	
	if(!$.browser.msie)
	{
	    //alert("非IE浏览器");
	    top_height=0;
	}
	var x=object1.offsetParent.offsetParent.offsetParent.offsetLeft+object1.offsetWidth+190+a;
	
	var y=object1.offsetParent.offsetParent.offsetParent.offsetParent.offsetTop+top_height;
	
	//var yoffset=object1.offsetParent.offsetParent.offsetParent.offsetParent.offset();
	//parentPosition.style.top=object1.offsetParent.offsetParent.offsetParent.offsetParent.offsetTop+top_height;
	var b=object1.offsetParent.offsetParent.offsetParent.offsetLeft+parentPosition.clientWidth+174+a;
	
	var c=document.body.offsetWidth;
	if((b+100)>c||x+100>c)//大于页面宽度时
	{
	    b=object1.offsetParent.offsetParent.offsetParent.offsetLeft-parentPosition.clientWidth+174+a;  //显示在左边
	    x=b;
	}
	//parentPosition.style.left=x;
	//parentPosition.style.display="block";
	$("#BigImagePosition").css("top",y);
	$("#BigImagePosition").css("left",x);
	//$("#BigImagePosition").show("slow");
	if(time1)
	{
	    window.clearTimeout(time1);
	}
	time1=window.setTimeout("showbigimage()",1000);
	
	return;
}
function hiddenImg()
{
    if(time1)
	{
	    window.clearTimeout(time1);
	}
    $("#BigImagePosition").hide();
    //parentPosition.style.display="none";
    //BigImg.src="";
}

function setTipPosition_intial(srcId)
{
    var object1=document.getElementById("img_"+srcId);
    var a=0;
	if(document.body.offsetWidth-970>0)
	{
	    a=(document.body.offsetWidth-970)/2;
	}
	var top_img=document.getElementById("list_top_img");
	var top_height=top_img.clientHeight+250;
	var x=object1.offsetParent.offsetParent.offsetParent.offsetLeft+object1.offsetWidth+190+a;
	var y=object1.offsetParent.offsetParent.offsetParent.offsetTop+top_height;
	var objtarget=$("#tip_"+srcId);
	var b=object1.offsetParent.offsetParent.offsetParent.offsetLeft+document.getElementById("tip_"+srcId.toString()).clientWidth+174+a;
	objtarget.css("top",y+210);
	objtarget.css("left",x-60);
}

function setTipPosition(srcId)
{
    setTipPosition_intial(srcId);
    resPostionCode=resPostionCode+"setTipPosition_intial("+srcId+");"
}

function setTipPosition2_intial(srcId)
{
	var object1=document.getElementById("img_"+srcId);
	var a=0;
	if(document.body.offsetWidth-970>0)
	{
	    a=(document.body.offsetWidth-970)/2;
	}
	var top_img=document.getElementById("list_top_img");
	var top_height=top_img.clientHeight;
	
	if(!$.browser.msie)
	{
	    //alert("非IE浏览器");
	    top_height=0;
	}
	var x=object1.offsetParent.offsetParent.offsetParent.offsetLeft+object1.offsetWidth+190+a;
	
	var y=object1.offsetParent.offsetParent.offsetParent.offsetParent.offsetTop+top_height;
	var objtarget=$("#tip_"+srcId);
	var b=object1.offsetParent.offsetParent.offsetParent.offsetLeft+document.getElementById("tip_"+srcId.toString()).clientWidth+174+a;
	
	
	objtarget.css("top",y+210);
	objtarget.css("left",x-60);
}

function setTipPosition2(srcId)
{
    setTipPosition2_intial(srcId);
    resPostionCode=resPostionCode+"setTipPosition2_intial("+srcId+");"
}

window.onresize=function()
{
    eval(resPostionCode);
}


