var SC = new Object();
SC = {
	browser:function()
	{
		var ua, s, i;
		this.isIE = false;
		this.isNS = false;
		this.isOP = false;
		this.isSF = false;
		ua = navigator.userAgent.toLowerCase();
		s = "opera";
		if ((i = ua.indexOf(s)) >= 0) {
		  this.isOP = true;return;
		}
		s = "msie";
		if ((i = ua.indexOf(s)) >= 0) {
		  this.isIE = true;return;
		}
		s = "netscape6/";
		if ((i = ua.indexOf(s)) >= 0) {
		  this.isNS = true;return;
		}
		s = "gecko";
		if ((i = ua.indexOf(s)) >= 0) {
		  this.isNS = true;return;
		}
		s = "safari";
		if ((i = ua.indexOf(s)) >= 0) {
		  this.isSF = true;return;
		}
	},

	dialogLoc:function(w,h) {
		w = w || 0;
		h = h || 0;
		var dde = document.documentElement;
		if (window.innerWidth) {
		  var ww = window.innerWidth;
		  var wh = window.innerHeight;
		  var bgX = window.pageXOffset;
		  var bgY = window.pageYOffset;
		} else {
		  var ww = dde.offsetWidth;
		  var wh = dde.offsetHeight;
		  var bgX = dde.scrollLeft;
		  var bgY = dde.scrollTop;
		}
		bgX = (bgX + ((ww - w)/2));
		bgY = (bgY + ((wh - h)/2));
		if(dde.offsetHeight && dde.offsetHeight > wh)
		{
			ww = dde.offsetWidth;
			wh = dde.offsetHeight;
		}
		return {left:bgX,top:bgY,width:ww,height:wh};
	},

	dialogShow:function(obj,w,h) {
		if(typeof obj != 'object') obj = document.getElementById(obj);
		try{
			var allselect = obj.getElementsByTagName("SELECT");
			for (var i=0; i<allselect.length; i++){
				allselect[i].style.visibility = "visible";
				allselect[i].style.display = '';
			}
		}catch(e){}
		w = w || parseInt(obj.style.width);
		h = h || parseInt(obj.style.height);
		this.dialogLoc(w,h).top;
		obj.style.top = this.dialogLoc(w,h).top + "px";
		obj.style.left = this.dialogLoc(w,h).left + "px";
		obj.style.position = "absolute";
		obj.style.zIndex = "1001";
		obj.style.display = "block";
	},

	screenConvert:function() {
		var browser = new this.browser();
		var objScreen = document.getElementById("ScreenOver");
		if(!objScreen)
		{
			var objScreen = document.createElement("div");
			document.body.appendChild(objScreen);
		}
		var oS = objScreen.style;
		objScreen.id = "ScreenOver";
		oS.display = "block";
		oS.top = oS.left = oS.margin = oS.padding = "0px";
		
		var ww = this.dialogLoc().width;
		var wh = this.dialogLoc().height;
		if (document.body.clientHeight) {
			if(wh > document.body.clientHeight)
			{
				if(browser.isIE)
					oS.height = wh - 4 + "px";
				else
					oS.height = wh + "px";
			}
			else
			{
				oS.height = document.body.clientHeight + "px";
			}
		} else {
			//oS.height = "100%";
			if(browser.isIE)
				oS.height = wh - 4 + "px";
			else
				oS.height = wh + "px";
		}
		if (document.body.clientWidth) {
			if(ww > document.body.clientWidth)
			{
				oS.width = ww + "px";
			}
			else
			{
				oS.width = document.body.clientWidth + "px";
			}
		} else {
			oS.width = "100%";
		}
		oS.position = "absolute";
		oS.zIndex = "1000";
		if ((!browser.isSF) && (!browser.isOP)) {
			oS.background = "#181818";
		} else {
			oS.background = "#F0F0F0";
		}
		oS.filter = "alpha(opacity=40)";
		oS.opacity = 40/100;
		oS.MozOpacity = 40/100;
		try
		{
			var allselect = document.getElementsByTagName("select");
			for (var i=0; i<allselect.length; i++)
			{
				allselect[i].style.visibility = "hidden";
				allselect[i].style.display = 'none';
			}
		}catch(e){}
	},

	screenClean:function(){
		var objScreen = document.getElementById("ScreenOver");
		if (objScreen) objScreen.style.display = "none";
		try
		{
			var allselect = document.getElementsByTagName("select");
			for (var i=0; i<allselect.length; i++) 
			{
				allselect[i].style.visibility = "visible";
				allselect[i].style.display = '';				
			}
		}catch(e){}
	},

	show:function(obj,w,h)
	{
		if(window.navigator.userAgent.indexOf("MSIE")>=1 && document.readyState!="complete")
		{
			 window.setTimeout(function(){SC.show(obj,w,h);},500);
			 return;	
		}
	   this.screenConvert();
	   this.dialogShow(obj,w,h);
	},

	close:function(obj)
	{
		this.screenClean();
		var objDialog = document.getElementById(obj);
		if (objDialog) objDialog.style.display = "none";
	}
}