DimPopup = function (elem,options) {
	//option default settings
	options = options || {};
	var HasBackground = (options.HasBackground!=null)?options.HasBackground:true;
	var BackgroundColor = options.BackgroundColor || '#000000';
	var BackgroundOpacity = options.BackgroundOpacity || 30; // 1-100
	BackgroundOpacity = (BackgroundOpacity > 0) ? BackgroundOpacity : 1;
	var BackgroundOnClick = options.BackgroundOnClick || function(){};
	var BackgroundCursorStyle = options.BackgroundCursorStyle || "default";
	var Zindex = options.Zindex || 90000;
	var AddLeft = options.AddLeft || 0; //in px
	var AddTop = options.AddTop || 0; //in px

	var popup = document.getElementById(elem);
	if (!popup) {return;}
	//set the popup layer styles
	var winW = Window.getWindowWidth();
	var winH = Window.getWindowHeight();
	//display the popup layer
	popup.style.display = "block";
	popup.style.visibility = "visible";
	var elemW = GetWidth(popup);
	var elemH = GetHeight(popup);
	var browser = navigator.appName;
	if(browser!="Microsoft Internet Explorer"){
		popup.style.position = "fixed";
		popup.style.left = (winW/2 - elemW/2 + AddLeft) + "px";
		popup.style.top = (winH/2 - elemH/2 + AddTop - 10) + "px";
	}else{
		popup.style.position = "absolute";
		popup.style.left = (winW/2 - elemW/2 + AddLeft) + "px";
		popup.style.top = document.body.scrollTop + 100 + "px";
	}
	popup.style.zIndex = Zindex + 1;
	if (HasBackground) {		
		if (!DimPopup._BackgroundDiv) {
			DimPopup._BackgroundDiv = document.createElement('div');
			DimPopup._BackgroundDiv.style.display = "none";
			DimPopup._BackgroundDiv.style.width = "100%";
			DimPopup._BackgroundDiv.style.position = "absolute";
			DimPopup._BackgroundDiv.style.top = "0px";
			DimPopup._BackgroundDiv.style.left = "0px";
			document.body.appendChild(DimPopup._BackgroundDiv);
		}
		DimPopup._BackgroundDiv.onclick =  BackgroundOnClick;
		DimPopup._BackgroundDiv.style.background = BackgroundColor;	
		DimPopup._BackgroundDiv.style.height = Window.getScrollHeight() + "px";
		DimPopup._BackgroundDiv.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=" + BackgroundOpacity +")";
		DimPopup._BackgroundDiv.style.MozOpacity = BackgroundOpacity / 100;		DimPopup._BackgroundDiv.style.opacity = BackgroundOpacity / 100;
		DimPopup._BackgroundDiv.style.zIndex = Zindex;
		DimPopup._BackgroundDiv.style.cursor = BackgroundCursorStyle;
		//Display the background
		DimPopup._BackgroundDiv.style.display = "";
		document.body.scroll='no';
	}
}
DimPopup.Close = function(id) {	if (id) {		
	document.body.scroll='yes';
	document.getElementById(id).style.display = "none";		document.getElementById(id).style.visibility = "hidden";	} 	if  (DimPopup._BackgroundDiv) {		DimPopup._BackgroundDiv.style.display = "none";	}}


GetWidth = function(elem) {
	function _convertValue(val) {
		if (!val) {return;}
		val = parseInt(val.replace("px",""));
		if (!val || isNaN(val)) {return 0;}
		return val;
	}
	var currentStyle;
	if (elem.currentStyle)	{ currentStyle = elem.currentStyle; }
	else if (window.getComputedStyle) {	currentStyle = document.defaultView.getComputedStyle(elem, null); }
	else { currentStyle = elem.style; }
	
	return (elem.offsetWidth -
			_convertValue(currentStyle.marginLeft) -
			_convertValue(currentStyle.marginRight) -
			_convertValue(currentStyle.borderLeftWidth) -
			_convertValue(currentStyle.borderRightWidth));
}

GetHeight = function(elem) {
	function _convertValue(val) {
		if (!val) {return;}
		val = parseInt(val.replace("px",""));
		if (!val || isNaN(val)) {return 0;}
		return val;
	}
	var currentStyle;
	if (elem.currentStyle)	{ currentStyle = elem.currentStyle; }
	else if (window.getComputedStyle) {	currentStyle = document.defaultView.getComputedStyle(elem, null); }
	else { currentStyle = elem.style; }
	return (elem.offsetHeight -
	        _convertValue(currentStyle.marginTop) -
    	    _convertValue(currentStyle.marginBottom) -
        	_convertValue(currentStyle.borderTopWidth) -
        	_convertValue(currentStyle.borderBottomWidth));	
}

Window = {	
	//Returns an integer representing the width of the browser window (without the scrollbar).
	getWindowWidth : function() {
	return (document.layers||(document.getElementById&&!document.all)) ? window.outerWidth : (document.all ? document.body.clientWidth : 0);
	},
	
	//Returns an integer representing the height of the browser window (without the scrollbar).
	getWindowHeight : function() {	
	return window.innerHeight ? window.innerHeight :(document.getBoxObjectFor ? Math.min(document.documentElement.clientHeight, document.body.clientHeight) : ((document.documentElement.clientHeight != 0) ? document.documentElement.clientHeight : (document.body ? document.body.clientHeight : 0)));
	},	
	
	//Returns an integer representing the scrollWidth of the window. 
	getScrollWidth : function() {
	return document.all ? Math.max(Math.max(document.documentElement.offsetWidth, document.documentElement.scrollWidth), document.body.scrollWidth) : (document.body ? document.body.scrollWidth : ((document.documentElement.scrollWidth != 0) ? document.documentElement.scrollWidth : 0));
	},
	
	//Returns an integer representing the scrollHeight of the window. 
	getScrollHeight : function(){		
		return document.all ? Math.max(Math.max(document.documentElement.offsetHeight, document.documentElement.scrollHeight), Math.max(document.body.offsetHeight, document.body.scrollHeight)) : (document.body ? document.body.scrollHeight : ((document.documentElement.scrollHeight != 0) ? document.documentElement.scrollHeight : 0));
	},			
	
	//Returns an integer representing the scrollLeft of the window (the number of pixels the window has scrolled from the left).
	getScrollLeft : function() {
		return document.all ? (!document.documentElement.scrollLeft ? document.body.scrollLeft : document.documentElement.scrollLeft) : ((window.pageXOffset != 0) ? window.pageXOffset : 0);
	},
	
	//Returns an integer representing the scrollTop of the window (the number of pixels the window has scrolled from the top).
	getScrollTop : function() {
		return document.all ? (!document.documentElement.scrollTop ? document.body.scrollTop : document.documentElement.scrollTop) : ((window.pageYOffset != 0) ? window.pageYOffset : 0);
	}
}