//div做的弹出式窗口
var winid = "lfdivwin_";//为避免多次调用出错，请在这里设置一个唯一的值
var divwinDefaultLeft = 100;
var divwinDefaultTop = 100;//注意：这里是整型，不能加px
var divwinDefaultWidth = 400;
var divwinDefault = 200;

//bottom = "<a href=\"#\" onclick=\"document.getElementById(\'"+ winid +"div1\').style.display=\'none\';document.getElementById(\'"+ winid +"div2\').style.display=\'none\';\">关闭</a>";
//alert(bottom);
//调用入口：openwin(url)

//如果需要修改窗体的样式，请修改.dis(遮罩)和.dis2(显示)
document.write('<style>');
document.write('.'+ winid +'dis{ width:100%;  background: #FFFFFF; position:absolute; left:0; right:0; top:0; bottom:0; -moz-opacity:0.5; filter:alpha(opacity=50);z-index:99; height:100%; }');
document.write('.'+ winid +'dis2{ width:'+ divwinDefaultWidth +'px; position:absolute; left:'+ divwinDefaultLeft +'px; right:0; top:'+ divwinDefaultTop +'px; bottom:0;z-index:100;height:'+ divwinDefault +'px;}');
document.write('</style>');
//生成控件
document.write('<div id="'+ winid +'div1" style="display:none " class="'+ winid +'dis">');

//iframe
document.write('<iframe width="100%" height="100%"  class="'+ winid +'dis"></iframe>');


document.write('</div>');
document.write('<div id="'+ winid +'div2" class="'+ winid +'dis2" style="display:none ">');


//窗口头
document.write('<div class="DivWinDiv">');
document.write('<table width="100%" height="100%" border="0" cellspacing="0" cellpadding="0" >');
document.write('<tr>');
document.write('<td height="1">');
document.write('<div style="float:left">');
document.write('<table border=0 cellpadding=0 cellspacing=0>');
document.write('<tr>');
document.write('<td nowrap class="DivWinHeader"><span id="DivWinTitle">...</span></td>');
document.write('<td nowrap><img class="DivWinCornerImg" src='+sWebRootPath+'/images/1x1.gif></td>');
document.write('</tr>');
document.write('</table>');
document.write('</div>');
document.write('<div style="float:right">');
document.write('<img class="BoatImgClose" onclick="closeDivWindow()" src='+sWebRootPath+'/images/1x1.gif>');
document.write('</div>');
document.write('</td>');
document.write('</tr>');
document.write('<tr>');
document.write('<td>');

document.write('<iframe id="'+ winid +'f1"  name="'+ winid +'f1" frameborder="0" height="100%" width="100%" scrolling="auto" marginheight="0" marginwidth="0"></iframe>');

//窗口尾
document.write('</td>');
document.write('</tr>');
document.write('</table>');
document.write('</div>');

document.write('</div>');

function openDivWin(_title,_URL,iWidth,iHeight,iTop,iLeft){//iWidth,iHeight都是数字类型，不要加"px"
	$('DivWinTitle').innerHTML = _title;
	divwinDefaultLeft = (document.body.clientWidth - iWidth) / 2;
	divwinDefaultTop = (document.body.clientHeight - iHeight) / 2;
	if (typeof(iLeft)=="undefined" || iLeft==""){
		document.getElementById(winid + "div2").style.left = divwinDefaultLeft + "px";//设置左边距
	}else{
		document.getElementById(winid + "div2").style.left = iLeft + "px";//设置左边距
	}
	if (typeof(iTop)=="undefined" || iTop==""){
		document.getElementById(winid + "div2").style.top = divwinDefaultTop + "px";//设置上边距
	}else{
		document.getElementById(winid + "div2").style.left = iTop + "px";//设置左边距
	}
	document.getElementById(winid + "div2").style.width = iWidth + "px";//重新设置内嵌div的宽度
	document.getElementById(winid + "div2").style.height = iHeight + "px";//重新设置内嵌div的高度
	document.getElementById(winid + "f1").width = iWidth;//重新设置内嵌窗体的宽度
	document.getElementById(winid + "f1").height = "99%";//重新设置内嵌窗体的高度
	
	document.getElementById(winid + "div1").style.top = document.body.scrollTop + "px";
	document.getElementById(winid + "div1").style.left = document.body.scrollLeft + "px";

	if (typeof(iTop)=="undefined" || iTop==""){
		document.getElementById(winid + "div2").style.top = divwinDefaultTop + document.body.scrollTop + "px";
	}else{
		document.getElementById(winid + "div2").style.top = iTop + "px";
	}
	if (typeof(iLeft)=="undefined" || iTop==""){
		document.getElementById(winid + "div2").style.left = divwinDefaultLeft + document.body.scrollLeft + "px";
	}else{
		document.getElementById(winid + "div2").style.left = iLeft+ "px";
	}
	var parentdiv = document.getElementById(winid + "div1");
	parentdiv.style.display = 'block';
	Effect.Appear(winid + "div2");
	new Draggable(winid + "div2",{revert:true,handle:'DivWinHeader'});
	OpenPage(_URL,winid +"f1","");
}

function closeDivWindow(){
	//document.getElementById(winid + "div2").style.display="none";
	//document.getElementById(winid + "div1").style.display="none";
	Effect.Fade(winid + "div2");
	document.getElementById(winid + "div1").style.display="none";
	window.open(sWebRootPath+"/Blank.jsp",winid +"f1","");
}

window.onscroll = function(){
	//alert();
	document.getElementById(winid + "div1").style.top = document.body.scrollTop + "px";
	document.getElementById(winid + "div1").style.left = document.body.scrollLeft + "px";
	document.getElementById(winid + "div2").style.left = divwinDefaultLeft + document.body.scrollLeft + "px";
	document.getElementById(winid + "div2").style.top = divwinDefaultTop + document.body.scrollTop + "px";
} 



