﻿

var divTop,divLeft,divWidth,divHeight,docHeight,docWidth,objTimer;

function setShowBox()
{
	try{
	divTop = parseInt(document.getElementById("showBox").style.top,10)
	divLeft = parseInt(document.getElementById("showBox").style.left,10)
	divHeight = parseInt(document.getElementById("showBox").offsetHeight,10)
	divWidth = parseInt(document.getElementById("showBox").offsetWidth,10)
	docWidth = document.documentElement.clientWidth;
	docHeight = document.documentElement.clientHeight;
	document.getElementById("showBox").style.top = parseInt(document.documentElement.scrollTop,10) + docHeight + 10+"px";
	document.getElementById("showBox").style.left = parseInt(document.documentElement.scrollLeft,10) + docWidth - divWidth+"px";
	document.getElementById("showBox").style.visibility="visible"
	objTimer = window.setInterval("moveDiv()",10)	
	}
	catch(e){}
}

function resizeDiv()
{
	try{
	divHeight = parseInt(document.getElementById("showBox").offsetHeight,10)
	divWidth = parseInt(document.getElementById("showBox").offsetWidth,10)
	docWidth = document.documentElement.clientWidth;
	docHeight = document.documentElement.clientHeight;
	document.getElementById("showBox").style.top = docHeight - divHeight + parseInt(document.documentElement.scrollTop,10)+"px";
	document.getElementById("showBox").style.left = docWidth - divWidth + parseInt(document.documentElement.scrollLeft,10)+"px";
	}
	catch(e){}
}

function moveDiv()
{
	try
	{
	if(parseInt(document.getElementById("showBox").style.top,10) <= (docHeight - divHeight + parseInt(document.documentElement.scrollTop,10)))
	{
	window.clearInterval(objTimer)
	objTimer = window.setInterval("resizeDiv()",500)
	}
	else
	{
	divTop = parseInt(document.getElementById("showBox").style.top,10)
	document.getElementById("showBox").style.top = (divTop - 1)+"px";
	}
	}
	catch(e){}
}

function hideDiv()
{    
	document.getElementById('infoBuy').style.display='none';
	document.getElementById('floatshowBox').style.display='block';
	document.getElementById("showBox").style.width="51px";
}

function reshowDiv()
{    
	document.getElementById('infoBuy').style.display='block';
	document.getElementById('floatshowBox').style.display='none';
	document.getElementById("showBox").style.width="398px";
}

function showBox()
{
    var strTemp;
    strTemp = '<div id="showBox" style="width:398px; overflow:hidden; visibility:hidden; z-index:99999; position:absolute; background-color:#ffffff; top:0; left:0; ">';
    strTemp += '<div id="infoBuy">';
    strTemp += '<div style="width:398px; height:27px; background:transparent url(/images/imgs/group.jpg) no-repeat scroll left top;">';
    strTemp += '<img src="/images/imgs/iclose.gif"  alt="关闭对话框" onclick="hideDiv();" style="float:right; margin:5px 6px 0 0; width:20px; height:20px; border:0; cursor:pointer;" />';
    strTemp += '</div>';
    strTemp += '<div style="width:398px; height:257px; overflow:hidden; border-left:solid 1px #C2C2C2; border-bottom:solid 1px #C2C2C2; border-right:solid 1px #C2C2C2; ">';
    strTemp += '<iframe id="frameEnroll2" width="398" height="257" scrolling="no" frameborder="0" marginheight="0" marginwidth="0" src="http://www.gxhouse.com/newPublic/BuyBox.aspx?web=http://www.gxhouse.com/"></iframe>';
    strTemp += '</div>';
    strTemp += '</div>';
    strTemp += '<div id="floatshowBox" style="display:none">';
    strTemp += '<img src="http://www.gxhouse.com/images/imgs/groupsmall.jpg"  alt="显示团购" onclick="reshowDiv();" style="float:right; margin:3px 10px 0 0; width:38px; height:137px; border:0; cursor:pointer;" />';
    strTemp += '</div>';
    strTemp += '</div>';
    document.write(strTemp);
}

showBox();
setTimeout("setShowBox()",2000);
window.onresize = resizeDiv;
