/*****------------------div弹出层所需JS start-------------------------------*/
/**window.location.href='index_new.php';
 * @author Administrator
 */
function g(id){
	return document.getElementById(id);
}

function getwidth(id){
	var obj = id;
	var width = '';
	if (obj.currentStyle){
		width = obj.currentStyle.width;
	}else {
		width = document.defaultView.getComputedStyle(obj,null).width;
	}
	if('auto' == width){
		width = '500px';
	}
	return width;
}

function getheight(id){
	var obj = id;
	var height = '';
	if (obj.currentStyle){
		height = obj.currentStyle.height;
	}else {
		height = document.defaultView.getComputedStyle(obj,null).height;
	}
	if('auto' == height){
		height = '225px';
	}
	return height;
}

function getpageheight(){
	if(window.innerHeight && window.scrollMaxY) {
		// Mozilla
		return window.innerHeight + window.scrollMaxY;
	} else if(document.body.scrollHeight > document.body.offsetHeight){
		// all but IE Mac
		return document.body.scrollHeight;
	} else if(document.body) { // IE Mac
		return document.body.offsetHeight;
	}
}

var IframeCover=function(){
	var cover=null;
	/**
	 * 生成一个遮罩
	 */
	var getInstance=function(){
		if(null===cover){
			cover=document.createElement('iframe');
			cover.frameBorder=0;
			cover.style.filter="alpha(opacity=50)";
			cover.style.opacity="0.5";
			cover.style.position='absolute';
			cover.style.backgroundColor='white';
			cover.style.left=0;
			cover.style.top=0;
			cover.zIndex=999;
			
//			cover.style.display='none';
			document.body.appendChild(cover);
			
		}
		return cover;
	}
	/**
	 * 显示遮罩
	 */
	var showCover=function(){
		var c=getInstance();
		if(c){
			//c.style.height=(document.body.scrollHeight+100)+'px';
			c.style.height=(getpageheight())+'px';			
			c.style.width=document.body.scrollWidth+'px';
			c.style.display='block';
		}
	}
	/**
	 * 隐藏遮罩
	 */
	var hideCover=function(){
		if(cover)cover.style.display='none';
	}
	
	return {show:showCover,hide:hideCover};
	
}();


var alertDiv=null;//模拟alert的Div
var resizeAction=null;
var scrollAction=null;

function showAlertDiv(divId){
	/***----------display cover-------------*/
	IframeCover.show();
	$("iframe").css("z-index", 900);
	/***----------display cover-------------*/

	alertDiv=g(divId);
	s=alertDiv.style;
	var dd=document.documentElement;
	s.display = "block";
	s.left = dd.scrollLeft + (dd.clientWidth - Number(getwidth(alertDiv).substring(0, getwidth(alertDiv).length-2))) / 2+"px";
	s.top = dd.scrollTop + (dd.clientHeight - Number(getheight(alertDiv).substring(0, getheight(alertDiv).length-2))) / 2+"px";
	dd=null;
	s.zIndex = 1000;
	$("#"+divId).css("z-index", 1000);
	//	s.visibility='visible'

//	var items=document.getElementsByTagName("select");
//	for(var i=0;i<items.length;i++){
//		items[i].disabled=true;
//	}
	resizeAction=window.onresize;
	window.onresize=sizefresh;
	scrollAction=window.onscroll;
	window.onscroll=sizefresh;
	return true;
}
function hideAlertDiv(divId){
	/***----------hide cover-------------*/
	IframeCover.hide();
	$("iframe").css("z-index", 0);
	/***----------hide cover-------------*/

	alertDiv=g(divId);
	s=alertDiv.style;
	s.zIndex = 1;
	$("#"+divId).css("z-index", 1);
	s.display = "none";
	alertDiv=null;

//	var items=document.getElementsByTagName("select");
//	for(var i=0;i<items.length;i++){
//		items[i].disabled=false;
//	}
	window.onresize=resizeAction;
	window.onscroll=scrollAction;
	
	closeactionf();
}
//wanglidan@ceopen.cn关闭刷新页面
function hideAlertDivwld(divId){
	/***----------hide cover-------------*/
	IframeCover.hide();
	/***----------hide cover-------------*/

	alertDiv=g(divId);
	s=alertDiv.style;
	s.zIndex = 1;
	$("#"+divId).css("z-index", 1);
	s.display = "none";
	alertDiv=null;

//	var items=document.getElementsByTagName("select");
//	for(var i=0;i<items.length;i++){
//		items[i].disabled=false;
//	}
	window.onresize=resizeAction;
	window.onscroll=scrollAction;
	location.reload();
//	window.location.href='index_new.php';
}
function sizefresh(){
	if(alertDiv){
		IframeCover.show();
		s=alertDiv.style;
		var dd=document.documentElement;
		s.left = dd.scrollLeft + (dd.clientWidth - Number(getwidth(alertDiv).substring(0, getwidth(alertDiv).length-2))) / 2+"px";
		s.top = dd.scrollTop + (dd.clientHeight - Number(getheight(alertDiv).substring(0, getheight(alertDiv).length-2))) / 2+"px";
		dd=null;
	}
}

//降低divId1 显示divId2
function showAlertDiv2(divId1, divId2){	
	alertDiv=g(divId2);
	
	alertDiv1 = g(divId1);
	alertDiv2 = g(divId2);
	alertDiv1.style.zIndex = 10;
	$("#"+divId1).css("z-index", 10);
	
	$("iframe").css("z-index", 900);
	
	s=alertDiv2.style;
	var dd=document.documentElement;
	s.display = "block";
	s.left = dd.scrollLeft + (dd.clientWidth - Number(getwidth(alertDiv2).substring(0, getwidth(alertDiv2).length-2))) / 2+"px";
	s.top = dd.scrollTop + (dd.clientHeight - Number(getheight(alertDiv2).substring(0, getheight(alertDiv2).length-2))) / 2+"px";
	dd=null;
	s.zIndex = 1000;
	$("#"+divId2).css("z-index", 1000);
	
	return true;
	
}

//关闭divId1 显示divId2 
function changeDiv(divId1, divId2, divId22, content){
	alertDiv=g(divId2);
	
	alertDiv1 = g(divId1);
	alertDiv2 = g(divId2);
	alertDiv1.style.zIndex = 1;
	$("#"+divId1).css("z-index", 1);
	alertDiv1.style.display = "none";
	
	$("iframe").css("z-index", 900);
	
	s=alertDiv2.style;
	if('' != content){
		$('#' + divId22).html(content);
	}
	var dd=document.documentElement;
	s.display = "block";
	s.left = dd.scrollLeft + (dd.clientWidth - Number(getwidth(alertDiv2).substring(0, getwidth(alertDiv2).length-2))) / 2+"px";
	s.top = dd.scrollTop + (dd.clientHeight - Number(getheight(alertDiv2).substring(0, getheight(alertDiv2).length-2))) / 2+"px";
	dd=null;
	s.zIndex = 1000;
	
	return true;
}

//降关闭divId1 提升divId2
function hideAlertDiv2(divId1, divId2){
	alertDiv=g(divId2);
	
	alertDiv1 = g(divId1);
	s1 = alertDiv1.style;
	s1.zIndex = 1;
	$("#"+divId1).css("z-index", 1);
	s1.display = "none";
	alertDiv1=null;
	
	$("iframe").css("z-index", 900);
	
	alertDiv2 = g(divId2);
	alertDiv2.style.zIndex = 1000;
	$("#"+divId2).css("z-index", 1000);
}

//关闭时的操作
function closeactionf(){
	if(typeof("playflag") != 'undefined'){
		playflag = true;
	}
	if(typeof("startplay") == 'function'){
		startplay();
	}
}
//	showAlertDiv('needLogin')
/*****------------------div弹出层所需JS end-------------------------------*/

