 function ClassPopup () {	
	//initialize variables
	window.popupWin = null;
	this.fadeDiv = null;
	
	
	var newwindow;
	this.poptastic = function (url,feature)
	{
		
		newwindow=window.open(url,'name',feature);
		if (window.focus) {newwindow.focus()}
	}

	
	/**
	 *	Shows a popup
	 *
	 *	lnk	<Anchor>	Takes the document to show from the HREF
	 *	modal <bool>	If true will show a modal popup and will refresh on popup unloading
	 *	width <int>		Width in pixels of the popup, use 0 for default
	 *	height <int>	Height in pixels of the popup, use 0 for default
	 */
	this.popup = function ( lnk, modal, width, height ) {

		var extraArgs = '';
		var href = this.popupScript + '?url=' + encodeURIComponent(lnk.href);
		
		if (modal) {
			href += '&modal=true';
			
			this.fadePage( 50 );
		
			if (window.showModalDialog) {
				if (width) extraArgs += 'dialogWidth: '+width+'px;';
				if (height) extraArgs += 'dialogHeight: '+height+'px;';
				window.showModalDialog( href, window, extraArgs + 'resizable: 1; center: 1;' );
				return false;
			} else {
				extraArgs = 'dependant=1,'; //for Netscape/Mozilla/Firefox
				//Make sure the opener window can't get the focus
				window.onfocus = function (evt) {
					if (window.popupWin) window.popupWin.focus();
				}
			}
		}
	
		if (width) extraArgs += 'width='+width+',';
		if (height) extraArgs += 'height='+height+',';

//		alert(extraArgs);
		
		
		window.popupWin = window.open( href, lnk.target, extraArgs + 'status=0,menubar=0,toolbar=0,resizable=1' );
		if (! window.popupWin.opener) 
			window.popupWin.opener = window;
				
		return false;
	};
	
	/**
	 *	This is a wrarper around the popup method to allow to only pass the url as parameter instead of a link object
	 *
	 *	href		<string>	An url string with the address of the page to open
	 *	modal 	<bool>		If true will show a modal popup and will refresh on popup unloading
	 *	width 	<int>		Width in pixels of the popup, use 0 for default 
	 *	height 	<int>		Height in pixels of the popup, use 0 for default
	 */
	this.popupHref = function ( href, modal, width, height ) {
		var o = new Object();
		o.href = href;
		o.target = '_blank';
		this.popup( o, modal, width, height );
	};
	
	
	/**
	 *	Fades the current page by a percentatge 
	 *
	 *	x	<int>	Percentatge of transparency (0-100)
	 *	bg	<color>	Which color should be the fading layer (#ccc by default)
	 */	
	this.fadePage = function( x, bg ) {
		if (! this.fadeDiv) {
			this.fadeDiv = document.createElement('DIV');
			this.fadeDiv.style.display = 'block';
			this.fadeDiv.style.left = 0; this.fadeDiv.style.top = 0;
			this.fadeDiv.style.width = '100%';
			this.fadeDiv.style.height = '100%';
			if (document.all) this.fadeDiv.style.position = 'absolute';
			else this.fadeDiv.style.position = 'fixed';
			
			document.body.appendChild( this.fadeDiv );
		}


		this.fadeDiv.style.background = bg?bg:'#ccc';
	
		this.fadeDiv.style.Opacity = x/100;
		this.fadeDiv.style.KhtmlOpacity = x/100;
		this.fadeDiv.style.MozOpacity = x/100;
		this.fadeDiv.style.filter = 'alpha(opacity='+x+')';			
	};
	
	/**
	 *	Removes the fading layer if set
	 */
	this.clearFadePage = function () {
		if (this.fadeDiv) {
			this.fadeDiv.parentNode.removeChild(this.fadeDiv)
			this.fadeDiv = null;
		}
	};
	
}


/*
	Instantiate the talenta class
*/

