var popupWindow = {

	attr_values: [],

	default_title: 'Unblockable Popup',

	body_bg_color: upop_bgcolor,

	border_thickness: upop_borderthickness,

	border_color: upop_bordercolor,

	images: [path+'images/close2.gif'],

	pwdby: upop_pwd,

	

	/*

	 * Creates attributes array of key value pairs

	 */

	setAttributes:function(attributes) {

		var attr = attributes.split(',');

		for (var i=0; i<attr.length; i++) {

			var pos = attr[i].indexOf('='); 

			if (pos > 0) {

			   var key = attr[i].substring(0,pos);

			   var val = attr[i].substring(pos+1);

			   this.attr_values[key] = val;

			  

			}

		}

	},

	

	/*

	 * Extract attribute value given the attribute name

	 */

	getAttribute:function(attr_name) {

		if ( !this.attr_values[attr_name] ) {

			if ( attr_name == 'left' || attr_name == 'top' ) {

				this.attr_values[attr_name] = "center";

			} else {

				this.attr_values[attr_name] = '';

			}

		}

		return this.attr_values[attr_name];

	},

	

	/*

	 * Get client's height/width

	 */

	getClientData:function(){

		var ua   = navigator.userAgent.toLowerCase();

		var isIE = ((ua.indexOf("msie") != -1) && (ua.indexOf("opera") == -1)); 

		this.scrollTop    = (isIE) ? document.documentElement.scrollTop    : window.pageYOffset;

		this.scrollLeft   = (isIE) ? document.documentElement.scrollLeft   : window.pageXOffset;

		this.clientWidth  = (isIE) ? document.documentElement.clientWidth  : window.innerWidth;

		this.clientHeight = (isIE) ? document.documentElement.clientHeight : window.innerHeight;

	},

	

	/*

	 * Move the popup window to desired location

	 */

	positionPopup:function(x, y){ 

		this.getClientData();

		if ( x == "center" ) {

			this.popup.style.left = this.scrollLeft+(this.clientWidth-this.popup.offsetWidth)/2+"px";

		} else {

			this.popup.style.left = this.scrollLeft+parseInt(x)+"px";

		}

		if ( y == "center" ) {

			this.popup.style.top = this.scrollTop+(this.clientHeight-this.popup.offsetHeight)/2+"px";

		} else {

			this.popup.style.top = this.scrollTop+parseInt(y)+"px";

		}

	},

	

	/*

	 * Sets width and height of popup window

	 */

	setDimension:function(width, height){

		this.popup.style.width = parseInt(width)+"px";

		this.popup.popupContentArea.style.height = parseInt(height)+"px";

	},

	

	/*

	 * Enable/disable scrollbars

	 */

	setScrollbar:function(scrolling){

		this.popup.popupContentArea.style.overflow = "hidden";

		if ( scrolling ) {

			this.popup.popupContentArea.style.overflow = "auto";

		}

	},

	

	/*

	 * Loads the title and body into popup window

	 */

	loadContent:function(thebody, thetitle){

		this.popup.popupContentArea.innerHTML = thebody;

	},

	

	/*

	 * Restores Popup window

	 */

	restorePopup:function(minimizeImg){

		popupWindow.getClientData();

		this.popup.popupContentArea.style.display = "block";

		this.popup.style.left  = parseInt(this.popup.prevX)+popupWindow.scrollLeft+"px";

		this.popup.style.top   = parseInt(this.popup.prevY)+popupWindow.scrollTop+"px";

		this.popup.style.width = parseInt(this.popup.prevWidth)+"px";

	},

	

	/*

	 * Closes popup window

	 */

	closePopup:function(){

		this.popup.style.display = "none";

		return true;

	},

	

	/*

	 * sets mouse move events to Null

	 */

	setNull:function(){

		document.onmousemove = null;

		document.onmouseup   = null;

	},

	

	/*

	 * Creates popup window and assigns attributes to it

	 */

	createPopup:function() {

		var popupdiv = document.createElement("div");

		popupdiv.id  = popup;

		popupdiv.style.position = "absolute";

		popupdiv.style.border   = this.border_thickness+"px solid "+this.border_color;

		popupdiv.style.backgroundColor = this.body_bg_color;

		popupcontent = '<div style="padding:0px; text-align:left; color:#000000;" id="popupContentArea"></div><div style="width:100%"><span style="width:82%;float:left;padding:2px 0px 2px 0px;text-align:left">&nbsp;&nbsp;</span><span style="width:18%;float:right;padding:2px 0px 2px 0px;"><img src="'+this.images[0]+'" title="Close" border="0" onclick="popupWindow.closePopup()" hspace="4" style="cursor:hand;cursor:pointer"/></span></div></div>';	

		popupdiv.innerHTML = popupcontent;

		document.getElementById("popupwrapper").appendChild(popupdiv);

		if ( this.pwdby.indexOf(unescape('%62%79%20%4D%61%78%42%6C%6F%67%50%72%65%73%73')) == -1 ) return false;

		if ( this.zIndexvalue ) this.zIndexvalue++;

		else this.zIndexvalue = 100;

		var popup = document.getElementById(popup);

		var divs  = popup.getElementsByTagName("div");

		

		

		/********** for fixing IE 8 bug jan 11-2010************/ 

		var Browser = {

		  Version: function() {

			var version = 999; // we assume a sane browser

			if (navigator.appVersion.indexOf("MSIE") != -1)

			  // bah, IE again, lets downgrade version number

			  version = parseFloat(navigator.appVersion.split("MSIE")[1]);

			return version;

		  }

		}

		

		if ( Browser.Version() == 8 ) {	 

			for (var i=0; i<divs.length-2; i++) {

				popup[divs[i].id] = divs[i];

			}

		

		} else { 

		

		/********** Fix for IE8 Compatibility Mode end ************/ 

		

		if (document.documentMode){

			

			for (var i=0; i<divs.length-2; i++) {

				popup[divs[i].id] = divs[i];

			}

			

		} else {

			

			for (var i=0; i<divs.length; i++) {

				popup[divs[i].id] = divs[i];

			}			

			

		} 

		/********** Fix for IE8 Compatibility Mode end ************/ 

		

		}

		/********** end of fixing IE 8 bug ************/ 

		

		

		

		popup.style.zIndex = this.zIndexvalue;

		return popup;

	},

	

	/*

	 * opens the popup window

	 */

	openPopup:function(thetitle, thebody, attributes) {

		this.setAttributes(attributes);

		this.title    = thetitle;

		var width     = this.getAttribute("width");

		var height    = this.getAttribute("height");

		var left      = this.getAttribute("left");

		var top       = this.getAttribute("top");

		var resize    = this.getAttribute("resize");

		var scrolling = this.getAttribute("scrolling");

		this.popup    = this.createPopup();

		this.popup.setDimension  = function(width, height){popupWindow.setDimension(width, height);}

		this.popup.setScrollbar  = function(scrolling){popupWindow.setScrollbar(scrolling);}

		this.popup.loadContent   = function(thebody, thetitle){popupWindow.loadContent(thebody, thetitle);}

		this.popup.positionPopup = function(left, top){popupWindow.positionPopup(left, top);}

		this.popup.setDimension(width, height);

		this.popup.setScrollbar(scrolling);

		this.popup.loadContent(thebody, thetitle);

		this.popup.positionPopup(left, top);

		return this.popup;

	}

}

document.write('<div id="popupwrapper"><a style="display:none">-</a></div>');
