﻿// JScript 文件

function ge(str){return document.getElementById(str);}
function gE(z,y){return z.getElementsByTagName(y)}
function ce(z){return document.createElement(z)}
function de(z){z.parentNode.removeChild(z)}

	//  获取文档信息
var Get = {
	winWidth  :function(){ return document.documentElement.clientWidth;},
	winHeight :function(){ return document.documentElement.clientHeight;},
	docWidth  :function(){ return document.documentElement.scrollWidth;},
	docHeight :function(){ return document.body.scrollHeight;},
	scrollTop :function(){ return document.documentElement.scrollTop?document.documentElement.scrollTop:document.body.scrollTop; },
	scrollLeft:function(){ return document.documentElement.scrollLeft} 
}

function getSon(o,el){
	var lia = gE(o,el)
		geta = new Array;
	for(i=0; i< lia.length; i++){
		if(lia[i].parentNode == o)
			geta.push(lia[i]);
	}
	return geta;
}

function getEvent(){     //同时兼容ie和ff的写法　　取得操作对像
	 if(document.all)    return window.event;        
	 func=getEvent.caller;            
	 while(func!=null){    
		 var arg0=func.arguments[0];
		 if(arg0){
			 if((arg0.constructor==Event || arg0.constructor ==MouseEvent)
				 || (typeof(arg0)=="object" && arg0.preventDefault && arg0.stopPropagation)){    
				 return arg0;
			 }
		 }
		 func=func.caller;
	 }
	 return null;
}

function getEventSrcElement(){
    return getEvent().srcElement||getEvent().target;
}

	//遮罩层的创建
function createMask(zindex){
	removeMask();
	var mask=document.createElement("div");
	var windowWidth = document.body.scrollWidth;
	var windowHeight = Math.max(document.body.scrollHeight,document.documentElement.clientHeight);
	mask.setAttribute("id","layerMask");
	mask.style.cssText="position:absolute;left:0px; top:0px;z-index:"+zindex+";background:#333; width:"+windowWidth+"px;height:"+windowHeight+"px;filter:alpha(opacity=35); -moz-opacity:0.35; opacity:0.35;";
	//mask.innerHTML = "<iframe id='coverFrame' src='javascript:false;' scrolling='no' frameborder='0' style='z-index:-1;position:absolute;background-color:#000;filter:alpha(Opacity=35);opacity: 0.05; top:0px; left:0px;width:100%;height:"+windowHeight+"px;'></iframe>";
	document.body.appendChild(mask);
	//
	window.onresize=function(){
		var windowWidth = document.body.scrollWidth ;
		var windowHeight = document.documentElement.scrollHeight;
		var lm=ge("layerMask");
		if(lm){
			lm.style.width=windowWidth+"px";
			lm.style.height=windowHeight+"px";
		}
	}
}
	//遮罩层的移除
function removeMask(){
	var lm=ge("layerMask");
	if(lm!=null) lm.parentNode.removeChild(lm);
}

function showMsg(divId){createMask();var o=ge(divId);o.style.display="";vertical(o);}

function closeMsg(divId){removeMask();ge(divId).style.display="none";}

function vertical(o){
    var wh = Get.winHeight(),
        st = Get.scrollTop(),
        dh = Get.docHeight();
    o.style.top = (wh-o.offsetHeight)/2+st;        
}
