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 ShowTables(sBody,swidth,ajaxURL){
if(!$('shield'))
{
	document.body.style.height="100%";
	//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 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";
	
	if(!sheight){
		var sheight=document.body.clientHeight/2;
		alertFram.style.height = 'auto';
	}else{
		alertFram.style.height = sheight+"px";
	}
	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) : 0;

	var objhh=alertFram.clientHeight+8;
    var bodshh=screen.height;
	alertFram.style.top=(bodshh-objhh)/3+"px";

	//alertFram.style.top=t_h+"px";
	alertFram.style.left=t_w+"px";
    
    strHtml="<div id=\"dialog\" style=\"z-index:200;padding:2px;margin:0;border:1px solid #039;background:#e7edf2;width:"+swidth+"px;\">\n";
    strHtml+="<div style=\"background:#06c;border-bottom:1px solid #e7edf2;height:25px;line-height:25px;color: #ff0;text-align:right;cursor:move;\" id=\"stitle\" onmousedown=\"oMove(parentNode.parentNode);\"><a href=\"javascript:void(0);\" onclick=\"remove();\" class=\"F12 Fweight C_Yellow\">[Close]</a></div>\n";
    strHtml+="<div style=\"background:#fff;\" id=\"dialogBody\">"+sBody+"</div>\n";
    strHtml+="</div>\n";
   
    alertFram.innerHTML = strHtml;
    alertFram.focus();
    document.body.appendChild(alertFram);
    document.body.appendChild(shield);
	if(ajaxURL){
		showlist('dialogBody',''+ajaxURL+'');
	}

    var c = 50;
    this.doAlpha = function(){
      if (c++ > 50){clearInterval(ad);return 0;}else{return 1;}
			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);
	alertFram.focus();
	}
}
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);-moz-opacity:0.3;opacity:0.3;"; }
	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);-moz-opacity:0.3;opacity:0.3;"; }
	}
	obj.onmouseup = function()
	{
		obj.onmousemove = null;
		obj.style.filter = null;
		obj.releaseCapture();
		//if (enableOpacity) { obj.style.filter = "Alpha(opacity=100);-moz-opacity:0.3;opacity:0.3;"; }
	}
}
