
	/**
	* Global js application
	*/
	var Application = function(){
		return {
			popup : function(url, w, h, name) {
				name = name ? name : '';
				window.open(url, name, "width=" + w + ", height=" + h + ", left=150, top=100, resizable=1, scrollbars=1");
			},

			addOnload: function ( f ){
				var old = window.onload;
				if (typeof(old) != "function" && typeof(f) == "function") {
					window.onload = f;
				} else {
					window.onload = function() {
						if (old) old();
						if (typeof(f) == "function") f();
					}
				}
			},

			addOnunload: function ( f ){
				var old = window.onunload;
				if (typeof(old) != "function" && typeof(f) == "function") {
					window.onunload = f;
				} else {
					window.onunload = function() {
						if (old) old();
						if (typeof(f) == "function") f();
					}
				}
			}
		}
	}();

	/**
	* Element handling
	*/
	Application.Element = function() {
		return {
			getById: function (id){
				if(is.NS)
					return document.layers[id]
				else if(is.element)
					return document.getElementById(id)
				else if(is.IE)
					return document.all[id]
				else
					return -1
			},

			addDefaultValue: function(element, defaultValue){
				if ( element.value == '' ) element.value = defaultValue;
			},

			removeDefaultValue: function(element, defaultValue){
				if ( element.value == defaultValue ) element.value = '';
			}
		}
	}();

	/**
	* Browser handling
	*/
	Application.Browser = function() {
		return {

		}
	}();

	/**
	* Cookie handling
	*/
	Application.Cookie = function() {
		return {
			set: function( name, value, options ) {
				options = typeof(options) == 'undefined' ? {} : options;
				if ( options.expire ) {
					var expire = new Date()
					expire.setTime( options.expire.getTime() + ( minutes * 60 * 1000 ) )
				}
				var cookie = escape( name ) +
					'=' + escape(value) +
					(options.expire ? '; EXPIRES=' + expire.toGMTString() : '') +
					(options.path ? '; PATH=' + options.path : '') +
					(options.domain ? '; DOMAIN=' + options.domain : '') +
					(options.secure ? '; SECURE' : '');
				document.cookie = cookie
			},

			get: function(name){
				var dc 		= document.cookie
				var prefix 	= name + "="
				var begin 	= dc.indexOf("; " + prefix)
				if( begin == -1 ){
					begin = dc.indexOf(prefix)
					if( begin!=0 ) return null
				} else {
					begin += 2
				}
				var end=document.cookie.indexOf( ";" ,begin )
				if( end == -1 ) end = dc.length
				return unescape( dc.substring( begin + prefix.length, end ) )
			}

		}
	}();

	Application.Ajax = function(){
		var xmlhttp, bComplete = false;
		try {
			xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {
				try {
					xmlhttp = new XMLHttpRequest();
				} catch (e) {
					xmlhttp = false;
				}
			}
		}
		if (!xmlhttp) return null;
		this.connect = function(sURL, sMethod, sVars, fnDone) {
			if (!xmlhttp) return false;
			bComplete	= false;
			sMethod		= sMethod.toUpperCase();
			try {
				if (sMethod == "GET") {
					xmlhttp.open(sMethod, sURL+"?"+sVars, true);
					sVars = "";
				} else {
					xmlhttp.open(sMethod, sURL, true);
					xmlhttp.setRequestHeader("Method", "POST "+sURL+" HTTP/1.1");
					xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
				}
				xmlhttp.onreadystatechange = function(){
					if (xmlhttp.readyState == 4 && !bComplete) {
						bComplete = true;
						fnDone(xmlhttp);
					}
				};
				xmlhttp.send(sVars);
			} catch(z) {
				return false;
			}
			return true;
		};
		return this;
	}

	var App = Application //prefixing namespace

	/* Short hand */
	function getEle(id){ return Application.Element.getById(id) }

	/* Deprecated but in use */
	function addWindowOnload( f ){ Application.addOnload(f) }

	/* not yet implemented i Application - TODO */
	var is
	is=new browserHandling()
	function browserHandling(){
		this.IE=0
		this.NS=0
		this.element=(document.getElementById) ? 1 : 0
		this.NSapp=(navigator.appName=="Netscape") ? 1 : 0
		this.IEapp=(navigator.appName=="Microsoft Internet Explorer") ? 1 : 0
		var ual=navigator.userAgent.toLowerCase()
		this.OPERAapp=(ual.indexOf("opera") != -1)
		this.MAC=(ual.indexOf("mac") != -1)
		this.WIN=(ual.indexOf("windows") != -1)
		this.appver=navigator.appVersion
		if(this.IEapp)
			this.IE=(document.all) ? 1 : 0
		else if(this.NSapp && !this.element)
			this.NS=(document.layers) ? 1 : 0
		if(this.NSapp)
			this.version=parseFloat(this.appver)
		else
			this.version=parseFloat(this.appver.substr(this.appver.indexOf("MSIE") + 5, 3))
		this.GECKO=(ual.indexOf("gecko") != -1)
		this.FIREBIRD=(ual.indexOf("firebird") != -1)
		this.NS6=(ual.indexOf("netscape6/6") != -1)
		this.MEDIAPLAYER=(this.GECKO && ual.indexOf("(ax") != -1) || (this.IE && this.version >= 5 && !this.OPERAapp)
	}
