/*
ewPopup.js
copyright 2005-2007 Wolfgang Wintersteller - w.wintersteller@eWinus.com

Popup Class:
creating registrating and handling popup- windows in this application
*/


function ewPopupHandler(){

	var active=null;
	this.setFocus=function(){
		if(this.active!=null){
			try{
				this.active.focus();
				var exc=this.active.document.body;
			}
			catch(e){
				return false;
			}
			return true;
		}
		this.active=null;
		return false;
	}
}

function ewPopup(){
	
	var win;
	this.center=function(){
		for(var item in window){
			if(item=="screen"){
				return true; 
				break;
			}
		}
		return false;
	};
	this.scan=function(){
		if(active!=null)
			active.focus();
	};
	this.close=function(){
win.close();
//		if(active!=null){
//			active.close();
//			active=null;
//		}
	};
	this.create=function(file,height,width,resize,statusbar){
	
		var size=resize? "yes":"no";
		var status=statusbar? "yes":"no";
			if(this.center()){
				width=(width=="max")? screen.width : width;
				height=(height=="max")? screen.height : height;
				if(screen.width<width || screen.height<height)
					size="yes";
				var wndTop=(screen.height-height)/2;
				var wndLeft=(screen.width-width)/2;
			}
			else{	//older NN versions
				//use java installation
				if(navigator.appName=="Netscape" && navigator.javaEnabled()){
					/*/ center the window /*/
					var toolkit=java.awt.Toolkit.getDefaultToolkit();
					var screen_size=toolkit.getScreenSize();
					
					width=(width=="max")? screen_size.width : width;
					height=(height=="max")? screen_size.height : height;
					// if the screen is smaller than the window, override the resize setting
					if(screen_size.width<width || screen_size.height<height) 
						size="yes";
					var wndTop=(screen_size.height-height)/2;
					var wndLeft=(screen_size.width-width)/2;
				}
				else{
					/*/ use the default window position /*/
					// override the resize setting
					size="yes";
					var wndTop="";
					var wndLeft="";
				}				
			}

			// collect the attributes
			var attribs="width="+width+",height="+height+",resizable="+size+",scrollbars="+size+","+ 
			"status="+status+",toolbar=no,directories=no,menubar=no,location=no,top="+wndTop+",left="+wndLeft;
			win = window.open(file,'',attribs);
			return win;
			//return window.open(file,'',attribs);
			//active.focus();
	};
}

//CONSTRUCTOR IN MAIN FILE
var popup=new ewPopup();

function openSitemap(){
	var smp_popup=new ewPopup();
	var href = document.location+"";
	if (href.indexOf('#') != -1)
		href = href.substring(0,href.indexOf('#'));
	smp_popup.create("sitemap.asp",352,422,false,false);
}

//var loginpopup=new ewPopup();
function openLoginform(){
	//if(!popupHandler.setFocus()){
		//popupHandler.active = 
		popup.create("loginform.asp?admin=login",176,280,false,false);
	//}
//	var href = document.location+"";
//	if (href.indexOf('#') != -1)
//		href = href.substring(0,href.indexOf('#'));
//	popup.create("loginform.asp?admin=login",176,280,false,false);
}
function reloadAfterLogin() {

	popup.close();
	document.location.reload(true);
}

