var isIE = (document.all) ? true : false; //document.all 只有ie支持此属性
var ieVersion = 7; //IE版本，默认为7
if (isIE) {
    ieVersion = parseFloat(navigator.appVersion.split("MSIE")[1]);
}
var de = document.documentElement;
function getBodyObj() {
    return (document.documentElement) ? document.documentElement : document.body;
}

//滚动条位置window.screen.availHeight
function scrollX() { return window.pageXOffset || de && de.scrollLeft || document.body.scrollLeft || 0; }
function scrollY() { return window.pageYOffset || de && de.scrollTop || document.body.scrollTop || 0; }
//可视尺寸
function windowW() { return window.innerWidth || de && de.clientWidth || document.body.clientWidth || 0; }
function windowH() { return window.innerHeight || de && de.clientHeight || document.body.clientHeight || 0; }
//页面尺寸（最小不小于可视尺寸）
function pageW() { var s = document.body.scrollWidth; var c = windowW(); return s > c ? s : c; }
function pageH() { var s = document.body.scrollHeight; var c = windowH(); return s > c ? s : c; }



function ShowMags(alertimg,stxt,touri){
if(!$('shield'))
{
	document.body.style.height="100%";
	//document.body.style.overflow = 'hidden';
	//document.body.style.scroll='no';
	
	var bodyww=document.body.clientWidth;
	var bodyhh=document.body.clientHeight;
	var bodsww=document.body.offsetWidth;
	var bodshh=document.documentElement.scrollHeight;
	if(bodyhh > bodshh) {var shieldHH=bodyhh;}else{var shieldHH=bodshh;}
	
	//图片路径
	var imgpath = "/images/dialog/";
	//提示框的宽和高
	var swidth="357";
	var sheight="171";
	//文字显示区的高度
	var txtheight="115";
	
	if(!alertimg){var alertimg="2";}
	
	var showtxt=stxt;
	if(!touri)
	{
		var closeds="onclick=\"remove();\"";
	}
	else
	{
		var closeds="onclick=\"remove();"+touri+"\"";
	}

	var shield = document.createElement("DIV");
    shield.id = "shield";
    shield.style.position = "absolute";
    shield.style.left = "0px";
    shield.style.top = "0px";
    shield.style.width = pageW()+"px";
    shield.style.height = pageH()+"px";
    shield.style.background = "Gray";
    shield.style.textAlign = "center";
    shield.style.zIndex = "10000";
    shield['style']['filter'] = "alpha(opacity=50);";
    shield['style']['-moz-opacity'] = "0.50";
    shield['style']['opacity'] = "0.50";
	document.body.style.overflow = "hidden";
    
    var alertFram = document.createElement("DIV");
    
    alertFram.id="alertFram";
    alertFram.style.position = "absolute";
    alertFram.style.width = swidth+"px";
    alertFram.style.height = sheight+"px";
    alertFram.style.background = "";
    alertFram.style.textAlign = "center";
    alertFram.style.zIndex = "10002";
	
	var bodshh=screen.height;
	var objhh=alertFram.clientHeight+8;
	
	var body_obj = document.documentElement;
	if(!isIE){var body_obj = document.body;}
	t_w = ((body_obj.offsetWidth - swidth) > 0) ? parseInt((body_obj.offsetWidth - swidth)/2) : 0;
	t_h = ((body_obj.clientHeight - sheight) > 0) ? parseInt((body_obj.clientHeight - sheight)/2) : (bodshh-objhh)/3-80;

	alertFram.style.top=t_h+"px";
	alertFram.style.left=t_w+"px";

    
  	strHtml="<div id=\"dialog\" style=\"z-index:200;padding:0;margin:0;\">\n";
  	strHtml+="<div style=\"float:left;background:url("+imgpath+"T_top_left.gif) no-repeat;width:4px;height:27px\"></div>\n";
  	strHtml+="<div style=\"float:left;background:url("+imgpath+"T_top_bg.gif) repeat-x;width:"+(swidth-8)+"px;height:27px;line-height:27px;color: #2c71af;\" id=\"stitle\" onmousedown=\"oMove(parentNode.parentNode);\">\n";
    strHtml+="<div style=\"float:left;width:18px;height:22px;padding-top:5px;\"><img src=\""+imgpath+"T_top_ico.gif\" style=\"\" /></div>\n";
	strHtml+="<div style=\"float:left;width:auto;\"><b>友情提示</b></div>\n";
	strHtml+="<div style=\"float:right;width:14px;height:21px;cursor:pointer;\" "+closeds+"><span style=\"display:block;padding-top:6px;\"><img src=\""+imgpath+"T_top_close_01.gif\" border=\"0\" id=\"closeimg\" onmouseover=\"document.getElementById('closeimg').src='"+imgpath+"T_top_close_02.gif'\" onmouseout=\"document.getElementById('closeimg').src='"+imgpath+"T_top_close_01.gif'\" /></span></div>\n";
	strHtml+="<div style=\"clear:both\"></div>\n";
	strHtml+="</div>\n";
  	strHtml+="<div style=\"float:left;background:url("+imgpath+"T_top_right.gif) no-repeat;width:4px;height:27px\"></div>\n";
  	strHtml+="<div style=\"clear:both\"></div>\n";
  	strHtml+="<div style=\"float:left;background:url("+imgpath+"T_body_left.gif) repeat-y;width:4px;height: "+txtheight+"px;\" id=\"T_body_left\"></div>\n";
  	strHtml+="<div style=\"float:left;background:#fbfeff;width:349px;height: "+txtheight+"px;\" id=\"T_body_body\">\n";
    strHtml+="<div style=\"margin:2px;padding:2px;color: #06559b;\">\n";
    strHtml+="<div style=\"float:left;margin-top:8px;width:75px;height:75px;background:url("+imgpath+"alert_ico_"+alertimg+".gif) left center no-repeat;\"></div>\n";
	strHtml+="<div style=\"float:left;width:auto;padding:20px 0 0 10px;text-align:left;font-size:14px;\">"+showtxt+"</div>\n";
	strHtml+="<div style=\"clear:both\"></div>\n";
	strHtml+="</div>\n";
  	strHtml+="</div>\n";
  	strHtml+="<div style=\"float:left;background:url("+imgpath+"T_body_right.gif) repeat-y;width:4px;height: "+txtheight+"px;\" id=\"T_body_right\"></div>\n";
  	strHtml+="<div style=\"clear:both;margin:0px;padding:0px;\"></div>\n";
  	strHtml+="<div style=\"float:left;background:url("+imgpath+"T_bottom_left.gif) no-repeat;width:4px;height:44px\"></div>\n";
	strHtml+="<div style=\"float:left;background:url("+imgpath+"T_bottom_bg.gif) repeat-x;width:349px;height:32px;text-align:right;padding-top:12px\"><span style=\"padding-right: 15px\"><a href=\"#\" onclick=\"remove();"+touri+"\" id=\"MagsQX\"><img src=\""+imgpath+"yes.gif\" border=\"0\" /></a></span></div>\n";
  	strHtml+="<div style=\"float:left;background:url("+imgpath+"T_bottom_right.gif) no-repeat;width:4px;height:44px\"></div>\n";
  	strHtml+="<div style=\"clear:both\"></div>\n";
	strHtml+="</div>\n";

    alertFram.innerHTML = strHtml;
    document.body.appendChild(alertFram);
    document.body.appendChild(shield);

    var c = 50;
    this.doAlpha = function(){
        if (c++ > 50){clearInterval(ad);return 0;}
		shield['style']['filter'] = "alpha(opacity="+c+");";
    shield['style']['-moz-opacity'] = "0."+c;
		shield['style']['opacity'] = "0."+c;
    }
	
	if (ieVersion != 7) { //hidden select
        var oSelects = document.getElementsByTagName("select");
        for (var i = 0; i < oSelects.length; i++) {
            oSelects[i].disabled = true;
            oSelects[i].style.visibility = "hidden";
        }
    }
	
	this.remove=function(){
		document.body.removeChild(alertFram);
		document.body.removeChild(shield);
		if (ieVersion != 7) { //show select
			var oSelects = document.getElementsByTagName("select");
			for (var i = 0; i < oSelects.length; i++) {
				oSelects[i].disabled = false;
				oSelects[i].style.visibility = "visible";
			}
		}

		document.body.scroll="yes";
		document.body.style.overflow='';
		document.body.onselectstart = function(){return true;};
	}
	var ad = setInterval("doAlpha()",10);
	$('MagsQX').focus();
	document.body.onselectstart = function(){return false;};
	}
}
function oMove(obj){
	var otop,oleft;
	var enableOpacity = true;
	var ie = navigator.appName == "Microsoft Internet Explorer";
	if(!ie)
	{
		oy = obj.clientY;
		ox = obj.clientX;
	}
	else
	{
		oy = window.event.clientY;
		ox = window.event.clientX;
	}
	otop = oy - obj.offsetTop;
	oleft = ox - obj.offsetLeft;
	if (enableOpacity) { obj.style.filter = "Alpha(opacity=30)"; }
	obj.setCapture();
	obj.onmousemove = function()
	{
		if(!ie){ 
			x = obj.pageX; 
			y = obj.pageY; 
		}
		else{ 
			x = window.event.clientX; 
			y = window.event.clientY; 
		}
		obj.style.left = x - oleft;
		obj.style.top = y - otop;
		if (enableOpacity) { obj.style.filter = "Alpha(opacity=30)"; }
	}
	obj.onmouseup = function()
	{
		obj.onmousemove = null;
		obj.style.filter = null;
		obj.releaseCapture();
		if (enableOpacity) { obj.style.filter = "Alpha(opacity=100)"; }
	}
}