﻿//icatt namspace
if (typeof(__icatt) == 'undefined'){
	eval("function __icatt(){};")
}

if (typeof(icatt) == 'undefined'){
	eval("var icatt = new __icatt();")
}


//constructor popup object
__icatt.prototype = {


	popup : {
	
		windowList: new Array(),
		layerList : new Array(),

		exists : function(name){
			if (this.windowList[name]) return true;
			if (this.layerList[name]) return true;
			return false;
		},
		
		setFocus : function (name){
			if (this.exists(name)) this.windowList[name].focus();
		},
		
		//icatt.popup.Window object...
		Window : function (name,oWindow,type){
			this.name = name;
			this.window = oWindow;
			this.type = type;
		},
		
		openWindow :  function (name,url,height,width,top,left,features,replaceHistory){
		
			//var w = new icatt.popup.Window(name,this,'asfd')
			
			if (this.exists(name)) 
				this.closeWindow(name);
			
			var param = new String();
			
			var heightParam     = (height)   ? "height="  + height   : "";
			var widthParam      = (width)    ? ",width=" + width    : "";
			var topParam        = (top)	     ? ",top=" + top      : "";
			var leftParam       = (left)     ? ",left=" + left     : "";
			var featuresParam   = (features) ? "," + features : "";
			
			param = heightParam + widthParam + topParam + leftParam + featuresParam
			
			//alert (param)
			
			try {
				this.windowList[name] = window.open(url,name,param,replaceHistory)
				this.windowList[name].focus();
			} catch (e) {
				//popup blocker?
			}
		},

		//Schrijft een layer met daarbinnen Iframe
		openIframe :  function (name,url,height,width,top,left,features){
		
			if (this.exists(name)) return;
		},

		//TODO 
		//AJAX
		openLayer :  function (name,html,height,width,top,left,features){
		
			if (this.exists(name)) return;
		},


		closeWindow : function (name){
			
			var oWin = this.windowList[name]
			
			if (oWin) {
				try {oWin.close();} catch (e) {} finally {this.windowList[name] = null}
			}
			
		} //closeWindow
		
	} //popup 
	
} // __icatt

icatt = new __icatt();

//PLAYGROUND
//=============================================================

//__icatt.prototype.bla = new icatt.popup.Window('shared prop!!')

//var tt = new __icatt();;

//alert(tt.bla.name)
//alert(icatt.bla.name)

//debugger


//function bla() {};

//bla.prototype =
//{
//	bla : new Array(),
//	bli : function(){ return this.bla.length;},
//	blo : {
//		blo : new Array(),
//		blu : function(){alert('bla.blo.blu!!!')}
//	}
//}

//var BLA = new bla()

//BLA.blo.blu();


//icatt.popup.openWindow('test','http://www.icatt.nl',400,600,0,0,'location=1,scrollbars=1,status=1,toolbar=1,titlebar=1,resizable=1,menubar=1',false);

//alert('next')

//icatt.popup.openWindow('test','http://www.xs4all.nl',400,600,0,0,'location=1,scrollbars=1,status=1,toolbar=1,titlebar=1,resizable=1,menubar=1',false);

//alert('focus!!')

//icatt.popup.setFocus('test')

