var window_div_flag = false;

function getPageHeight(){
	var height1 = 0;
	if(window.innerHeight){
		height1 = parseInt(window.innerHeight);
	}else if(document.documentElement && document.documentElement.clientHeight){
		height1 = parseInt(document.documentElement.clientHeight);
	}else{
		height1 = parseInt(document.body.clientHeight);
	}
	return height1;
}

function getPageWidth(){
	var width1 = 0;
	if(window.innerWidth){
		width1 = parseInt(window.innerWidth);
	}else if(document.documentElement && document.documentElement.clientWidth){
		width1 = parseInt(document.documentElement.clientWidth);
	}else{
		width1 = parseInt(document.body.clientWidth);
	}
	return width1;
}

function getScrollHeight(){
	var top1 = 0;
	if(document.documentElement && document.documentElement.scrollHeight) {
		top1 = parseInt(document.documentElement.scrollHeight);
	} else if (document.body) {
		top1 = parseInt(document.body.scrollHeight);
	}
	return top1;
}

function getScrollWidth(){
	var left1 = 0;
	if(document.documentElement && document.documentElement.scrollWidth) {
		left1 = parseInt(document.documentElement.scrollWidth);
	} else if (document.body) {
		left1 = parseInt(document.body.scrollWidth);
	}
	return left1;
}

function getScrollX() {
	var scrollX = 0;
	if (typeof window.pageXOffset == 'number') scrollX = window.pageXOffset;
	else if (document.documentElement && document.documentElement.scrollLeft) scrollX = document.documentElement.scrollLeft;
	else if (document.body && document.body.scrollLeft) scrollX = document.body.scrollLeft;
	else if (window.scrollX) scrollX = window.scrollX;
	return scrollX;
}

function getScrollY() {
	var scrollY = 0;
	if (typeof window.pageYOffset == 'number') scrollY = window.pageYOffset;
	else if (document.documentElement && document.documentElement.scrollTop) scrollY = document.documentElement.scrollTop;
	else if (document.body && document.body.scrollTop) scrollY = document.body.scrollTop;
	else if (window.scrollY) scrollY = window.scrollY;
	return scrollY;
}

function goto_display_showdiv(divname, div_id){
	goto_hidden_showdiv();
	var potname = 'div_pot_' + div_id;
	$(divname).style.top = $(potname).offsetTop + 'px';
	$(divname).style.left = '300px';
	$(divname).style.display = 'inline';
	window_div_flag = divname;
}

function goto_hidden_showdiv(){
	if(window_div_flag){
		$(window_div_flag).style.display = 'none';
		window_div_flag = false;
	}
}

function black2ground(){
	var tmph1 = getScrollHeight();
	var tmph2 = getPageHeight();
	var tmpw1 = getScrollWidth();
	var tmpw2 = getPageWidth();

	if(!$('blackimglayer_bg')) {
		div = document.createElement('div');
		div.id = 'blackimglayer_bg';
		div.style.position = 'absolute';
		div.style.left = div.style.top = '0px';
		//div.style.width = '100%';
		div.style.width = ((tmpw1>tmpw2) ? tmpw1 : tmpw2) + 'px';
		
		div.style.height = ((tmph1>tmph2) ? tmph1 : tmph2) + 'px';
		div.style.backgroundColor = '#000000';
		div.style.display = 'none';
		div.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=40,finishOpacity=100,style=0)';
		div.style.opacity = 0.4;
		div.style.zIndex = 2;
		$('append_parent').appendChild(div);

		div = document.createElement('div');
		div.id = 'blackimglayer';
		div.style.position = 'absolute';
		div.display = 'none';
		div.style.zIndex = 999;
		div.style.padding = 0;
		div.className = 'popupmenu_popup';
		//div.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=80,finishOpacity=100,style=0)';
		//div.style.opacity = 0.8;
		$('append_parent').appendChild(div);
	}
	$('blackimglayer_bg').style.display = 'inline';
}

function print2front(w_width, w_height, title){
	$('blackimglayer').style.left = ((getPageWidth() - w_width) / 2) + 'px';
	var top_v = ((getPageHeight() - w_height) / 2 + getScrollY());
	$('blackimglayer').style.top = (top_v>0 ? top_v : 10) + 'px';
	$('blackimglayer').style.width = w_width + 'px';
	$('blackimglayer').style.height = w_height + 'px';

	$('blackimglayer').innerHTML = '<table width="100%" border="0" cellspacing="0" cellpadding="0">' +
' <tr bgcolor="#00CCCC">' +
'  <td align="left">&nbsp;&nbsp;<B>' + title +  '</B></td>' +
'  <td align="right"><img style="vertical-align: middle; cursor: pointer;" onclick="print2close()" src="http://2010.51.net/images/close.gif" title="关闭">&nbsp;&nbsp;</td>' +
' </tr>' +
' <tr>' +
'  <td colspan="2" valign="top" align="center"><div id="blackimgbox" style="overflow-x: hidden; overflow-y: auto; width: 100%; height: ' + (w_height - 20) + '; padding: 10px;">&nbsp;</div></td>' +
' </tr>' +
'</table>';
	$('blackimglayer').style.display = 'inline';
}

function print2close(){
	$('blackimglayer').style.display = 'none';
	$('blackimglayer_bg').style.display = 'none';
}

function iClickAct(width, height, htmls, title){
	black2ground();
	print2front(width, height, title);
	$('blackimgbox').innerHTML = htmls;
}

function print2front2(w_width, w_height, title){
	$('blackimglayer').style.left = ((getPageWidth() - w_width) / 2) + 'px';
	var top_v = ((getPageHeight() - w_height) / 2 + getScrollY());
	$('blackimglayer').style.top = (top_v>0 ? top_v : 10) + 'px';
	$('blackimglayer').style.width = w_width + 'px';
	$('blackimglayer').style.height = w_height + 'px';
	var footTop = w_height - 24;
	var mainHeight = w_height - 55;
	var htmlWidth = w_width-16;
	var titleWidth = w_width-30;

	$('blackimglayer').innerHTML = '<div style="position:absolute;width:100%;height:31px;border:0px;top:0px;left:0px;">' +
'  <img src="/images/dl_06.gif" width="100%" height="31" border="0"/>' +
'</div>' +
'<div style="position:absolute;width:' + titleWidth + 'px;height:28px;border:0px;top:8px;left:8px;">' +
'  <font color=#FFFFFF><B>' + title + '</B></font>' +
'</div>' +
'<div style="position:absolute;width:14px;height:14px;border:0px;top:8px;right:8px;">' +
'  <a href="javascript:void(0);" onclick="print2close()"><img src="/images/close1.gif" width="14" height="14" border="0"/></a>' +
'</div>' +
'<div style="position:absolute;width:100%;height:' + mainHeight + 'px;border:0px;top:31px;left:0px;">' +
'  <img src="/images/dl_06_bj.gif" width="100%" height="100%" border="0"/>' +
'</div>' +
'<div style="position:absolute;width:100%;height:24px;border:0px;top:' + footTop + 'px;left:0px;">' +
'  <img src="/images/dl_07.gif" width="100%" height="24" border="0"/>' +
'</div>' +
'<div id="blackimgbox" style="position:absolute;color:#656565;padding:8px;width:' + htmlWidth + 'px;border:0px;top:31px;left:0px;">' +
'</div>';
	$('blackimglayer').style.display = 'inline';
}

function iClickAct2(width, height, htmls, title){
	black2ground();
	print2front2(width, height, title);
	$('blackimgbox').innerHTML = htmls;
}

function iClickAct3(width, height, htmls){
	black2ground();
	print2front3(width, height, htmls);
}

function print2front3(w_width, w_height, htmls){
	$('blackimglayer').style.left = ((getPageWidth() - w_width) / 2) + 'px';
	var top_v = ((getPageHeight() - w_height) / 2 + getScrollY());
	$('blackimglayer').style.top = (top_v>0 ? top_v : 10) + 'px';
	$('blackimglayer').style.width = w_width + 'px';
	$('blackimglayer').style.height = w_height + 'px';

	$('blackimglayer').innerHTML = htmls;
	$('blackimglayer').style.display = 'inline';
}

var preloadimg1 = new Image();
var preloadimg2 = new Image();
var preloadimg3 = new Image();
var preloadimg4 = new Image();
var preloadimg5 = new Image();
var preloadimg6 = new Image();
var preloadimg7 = new Image();
var preloadimg8 = new Image();
var preloadimg9 = new Image();
var preloadimg10 = new Image();
var preloadimg11 = new Image();
preloadimg1.src = '/images/dl_06.gif';
preloadimg2.src = '/images/close1.gif';
preloadimg3.src = '/images/dl_06_bj.gif';
preloadimg4.src = '/images/dl_07.gif';
preloadimg5.src = '/images/kszc.gif';
preloadimg6.src = '/images/tj.gif';
preloadimg7.src = '/images/dl_03.gif';
preloadimg8.src = '/images/wjmm.gif';
preloadimg9.src = '/images/dll1.gif';
preloadimg10.src = '/images/dll.gif';
preloadimg11.src = '/authcode.php?ac=6';
