
	var undefined = "undefined" ;
	
	var DEBUG = true , EDIT = false ,  TRACE = false;
	
	// 	/^(?!\[Please Select\]).*$
		// 	Page
	function
	
	Page()
	{
		
	}
	
	Page.attributeStart = document.createElement("div").attributes.length;
	Page.browser = navigator.userAgent.match(/Gecko|Safari|Opera|MSIE/g)[navigator.userAgent.match(/Gecko|Safari|Opera|MSIE/g).length-1];
	Page.controls = [];
	Page.defaults = {};
	Page.elements = [];
	Page.formatters = {};
	Page.parsers = {"option":["option",Option]};
	Page.protocols = /^(data|file|ftp|http|https|javascript|mailto)\:(.+)$/i
	Page.resources = /^(js|rgb|url)\((.*)\)$/i
	Page.templates = {};
	Page.types = /^(array|object)\((.*)\)$/i
	Page.zIndexBack = -1;
	Page.zIndexFront = 1;
	Page.zIndexMaximum = 32767;
	Page.zIndexMinimum = -32768;
	Page.nodeNames = {HTMLImageElement:"img",HTMLIFrameElement:"iframe",HTMLDocument:"html"}
	
	Page.bind = function(control,name,context)
	{
		var a = Page.resources.exec(context) , s = a[1].toLowerCase();
		
		if(Page.bind[s])
		{
		//	if(control.onBinding) control.onBinding(name);
			
			if(Page.bind[s](control,name,a[2])!==false)
			{
				if(control.onBound) control.onBound(name);
			};
		}
		else
			throw new Error("Resource '"+a[1]+"(...)' not registered");
	}
	
	Page.bind["js"] = function(control,name,context) { control[name] = Page.parseContext(context); }
	
	Page.bind["rgb"] = function(control,name,context)
	{
		var rgb = context.split(",");
		
		control[name] = {r:parseFloat(rgb[0]),g:parseFloat(rgb[1]),b:parseFloat(rgb[2]),toString:function(){return "rgb("+this.r+","+this.g+","+this.b+")";}};
	}
	
	Page.bind["url"] = function(control,name,context)
	{
		var asynchrone = true;
		
		if(context!="")
		{
			var c = /^([^\?\#]*)?(?:\?([^\#]*))?(?:\#(.*))?$/.exec(context) , url=c[1]||(location.protocol+"//"+location.hostname+":"+location.port+location.pathname) , get=c[2] , post=c[3] , request = new XMLHttpRequest() , response = new XMLHttpResponse()

			request.open(post?"POST":"GET",url+"?"+((new Date()).getTime())+(get?"&"+get:""),(asynchrone===true));
		//	request.setHeader("","");
			request.send(post||"");
			
			if(asynchrone)
			{
				response.open("SET",url,false);
				response.setRequest(request);
				
				if(control.onBound)
				{
					response.addHandler(control,name);
					response.addHandler(control,control.onBound,[name]);
				}
				else
					response.addHandler(null,Page.Control.onBound,[name]);
				
				response.recieve();
				
				return false;
			}
			else
			{		
				if(request.readyState==4&&request.status==200)
					control.data = eval(request.responseText);
				else
					control.data = [];
			}
		}
	}
		
	Page.construct = function(control,name,context)
	{
		var a = Page.types.exec(context) , s = a[1].toLowerCase();
		
		if(Page.construct[s])
		{
		//	if(control.onConstructing) control.onConstructing)(name);
			
			if(Page.bind[s](control,name,a[2])!==false)
			{
				if(control.onConstructed) control.onConstructed(name);
			};
		}
		else
			throw new Error("Type '"+a[1]+"(...)' not registered");
	}
	
	Page.contextOf = function(elementID)
	{
		return (Page.nameOf(elementID)+"["+Page.controls[elementID].index+"]");
	}
	
	Page.contextOfElement = function(element)
	{
		return Page.contextOfID(element.id);
	}
	
	Page.createControl = function(element)
	{
		return new ((Page.parsers[element.nodeName]==null?Page.extendControl(element):Page.parsers[element.nodeName])[1])();
	}
	
	Page.createNodeAsString = function(type,attributes,content)
	{
		var a = ['<'+Page.nodeNames[type]];
		
		for(var name in attributes) a[a.length] = (name+'="'+attributes[name]+'"');
		
		if(content==null)
			a[a.length] = '/>';
		else
			a.push('>',content,'</'+Page.nodeNames[type]+'>');
		
		return (a.join(' '));
	}
	
	Page.createTag = function(type,attributes,content)
	{
		if(Page.createTag[String(type)]!=null)
			return Page.createTag[type](attributes,content);
		else
			return Page.createNodeAsString("HTMLImageElement",attributes,content)
	}
	
	if(!/Opera|Gecko|KHTML|Safari|MSIE\s*([789]\.|\d{2})/i.test(navigator.userAgent))
	Page.createTag["HTMLImageElement"] = function(a)
	{	
		if(/\.png$/i.test(a.src))
		{
			var image = '<div style="position:relative; height:'+a.height+'px; width:'+a.width+'px; filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\''+a.src+'\',sizingMethod=\'scale\');">'

			if(a.usemap)
			{
				image += '<a href="#" height="'+a.height+'" usemap="'+a.usemap+'" width="'+a.width+'" border="0" />'; //style="visibility:hidden;"
			}
			
			return (image+'</div>');
		}
		else
			return Page.createNodeAsString("HTMLImageElement",a,null);
	}
	
	Page.createTag["HTMLSelectElement"] = function(a)
	{	
		return '<select/>';
	}
	
	Page.createTag["HTMLOptionElement"] = function(a)
	{	
		return '<option/>';
	}
		
	Page.extendControl = function(element)
	{
		var constructor , name = element.nodeName.split(':')[element.nodeName.split(':').length-1];
		
		if(name!=name.toUpperCase()&&name!=name.toLowerCase())
			eval("constructor = "+name);
		else
		{
			name = name.substring(0,1).toUpperCase()+name.substring(1).toLowerCase();
			
			eval("constructor = (typeof("+name+")=='undefined'?null:"+name+")");
			
			if(constructor==null)
			{
				// Loop or create constructor;
			}
		}
		
		constructor.name = name;
		
		this.defaults[name] = new constructor();
		
		for(var $ in Page.Control.prototype) if(constructor.prototype[$]==null) constructor.prototype[$] = Page.Control.prototype[$];
			
		return (Page.parsers[element.nodeName]=[name,constructor]);
	}
	
	Page.finalize = function()
	{	
	//	Page.onFinalizing();
		
	//	for(var i=0;i<Page.elements.length;i++)
	//	{
	//		Page.elements[i].parentNode.removeChild(Page.elements[i]);
	//	}
		
	//	Page.onFinalized();
	}
	
	if(Page.attributeStart>0)
		Page.getAttributes = function(control) { var A = control.element.attributes; a = []; for(var i=Page.attributeStart-3;i<A.length;i++) a.push(A[i]); a.push(A["style"],A["id"]); return a; }
	else
		Page.getAttributes = function(control) { return control.element.attributes; }
	
	Page.getElements = function()
	{
		var e = []; var all = (document.all?document.all:document.getElementsByTagName("*"));
		
		for(var i=0;i<all.length;i++)
		{
			if(all[i].nodeType==1&&(all[i].prefix=="fugro-ict"||all[i].scopeName=="fugro-ict")) e.push(all[i]);
		}

		return e;
	}
	
	Page.initialize = function()
	{
		Page.elements = Page.getElements();
		
		Object.registerInterface("anchor",{name:"",href:""});
		Object.registerInterface("image",{src:"",height:0,width:0});
		Object.registerInterface("style",{style:""});
		
		for(var i=0;i<Page.elements.length;i++)
		{
			var e = Page.elements[i] , id = e.attributes["id"] , a = e.attributes;
			
			if(id)
			{
				var c = Page.createControl(e);
				
				if(e.prependChild==null) e.prependChild = Page.Element.prependChild;
			
			//	Page.elements.push(e);
				Page.elements[id.value] = e;
	
				Page.controls.push(c);
				Page.controls[id.value] = c;
				
				if(!c.constructor.count) c.constructor.count = 0;	
				
				c.index = c.constructor.count;
				c.constructor[c.constructor.count++] = c;
			}
		}
		
		Page.onParsing();
		Page.onParsed();
		
		Page.onInitializing();
		Page.onInitialized();
	}
	
	Page.link = function(control,name,context)
	{
		var a = Page.protocols.exec(context) , s = a[1].toLowerCase();
		
		if(Page.link[s])
		{
		//	if(control.onLinking) control.onLinking(name);
			
			if(Page.link[s](control,name,a[2])!==false)
			{
			//	if(control.onLinked) control.onLinked(name);
			};
		}
		else
			control[name] = context;
	}
	
	if(Page.browser=="MSIE")
	Page.link["data"] = function(control,name,context)
	{
		var d = context.split(/[,;]/);
		
		switch(d.length)
		{
			case 1:

				switch(d[0])
				{
					case "image/gif": case "image/png":

						control[name].src = (location.protocol+"://"+location.host+"/Grfx/Untitled."+d[0].split("/")[1]);

					break;
			
				}
				
			break;
			
			default: throw "Data protocol not supported by this browser";
		}
	}
	else
	Page.link["data"] = function(control,name,context)
	{
		var d = context.split(/[,;]/);
		
		if(d.length==1)
		{
			switch(d[0])
			{
				case "image/gif": control[name].src = "data:image/gif;base64,R0lGODlhAQABAIAAAP///////yH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="; break;
				
				case "image/png": control[name].src = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAAAXNSR0IArs4c6QAAAANQTFRF////p8QbyAAAAAF0Uk5TAEDm2GYAAAABYktHRACIBR1IAAAACXBIWXMAAAsTAAALEwEAmpwYAAAACklEQVQI12NgAAAAAgAB4iG8MwAAAABJRU5ErkJggg=="; break;
			}
		}
	}
		
	Page.nameOf = function(elementID)
	{
		return Page.nameOfElement(document.getElementById(elementID));
	}

	Page.nameOfElement = function(element)
	{
		return ((Page.parsers[element.nodeName]==null?Page.extendControl(element):Page.parsers[element.nodeName])[0]);
	}
	
	Page.onInitialized = function()
	{
		for(var i=0;i<Page.controls.length;i++) if(Page.controls[i].onInitialized) Page.controls[i].onInitialized();
	}
	
	Page.onInitializing = function()
	{
		for(var i=0;i<Page.controls.length;i++)
		{
			var c = Page.controls[i] , p = c.constructor.prototype , e = Page.elements[i] , s = e.attributes;
			
		//	try
		//	{
				if(c.onInitializing) c.onInitializing();
				
				for(var cn=0;cn<e.childNodes.length;cn++) // FireFox 2.0.0.16 vind niet alle childNodes
				{
					var node = e.childNodes[cn];
					
					if(node.id) Page.templates[node.id] = unescape(node.innerHTML);
					
					if(/^(div|span)$/i.test(node.nodename)&&c["initialize"+node.className])
					{
						c["initialize"+node.className](node);
					}
				}
				
				Page.Control.prototype.initializeChildren.apply(c,[e]);
		//	}
		//	catch(error)
		//	{
		//		Page.onError(error,c,"Control '"+e.id+"' failed while initializing");
		//	}
		}
	}
	
	Page.onError = function(error,control,message) { if(DEBUG) throw message; }
	
	Page.onFinalized = function() { for(var i=0;i<Page.controls.length;i++) if(Page.controls[i].onFinalized) Page.controls[i].onFinalized(); }
	
	Page.onFinalizing = function() { for(var i=0;i<Page.controls.length;i++) if(Page.controls[i].onFinalizing) Page.controls[i].onFinalizing(); }
	
	Page.onParsed = function() { for(var i=0;i<Page.controls.length;i++) if(Page.controls[i].onParsed) Page.controls[i].onParsed(Page.elements[i]); }
	
	Page.onParsing = function()
	{	
		for(var i=0;i<Page.controls.length;i++)
		{
			var c = Page.controls[i] , a = Page.elements[i].attributes;
			
			if(c.onParsing) c.onParsing(Page.elements[i]);
			
			for(var n in c.constructor.prototype)
			{
				if(a[n]!=null) Page.Control.parseMember(c,n,a[n].value);
			}

//			alert(Object.toSource(c));
		}	
	}
	
	Page.parseContext = function(context) { return eval(context); }

	Page.registerProtocol = function(name,method) {	Page.protocols = new RegExp(String(Page.protocols.source).replace("^(","^("+name+"|"),"i"); Page.link[name.toLowerCase()] = method; }
	
	Page.registerResource = function(name,method) { Page.resources = new RegExp(String(Page.resources.source).replace("^(","^("+name+"|")); Page.bind[name.toLowerCase()] = method; }

	Page.registerType = function(name,constructor) { Page.types = new RegExp(String(Page.types.source).replace("^(","^("+name+"|")); Page.construct[name.toLowerCase()] = constructor; }

	Page.typeOf = function(elementID) { return Page.typeOfElement(document.getElementById(elementID)); }
	
	Page.typeOfElement = function(element) { return ((Page.parsers[element.nodeName]==null?Page.extendControl(element):Page.parsers[element.nodeName])[1]); }
		
	Page.Control = function() { this.element = document.createElement(this.constructor.defaultNodeName); }
	
	Page.Control.defaultNodeName = "div";
	
	Page.getScrollBarButtonsSize = function() // TEMPORAL SOLUTION
	{
		switch(Page.browser)
		{
			case "Safari": return {height:20,width:20}; // Perfect
			case "MSIE":   return {height:46.5,width:46.5};
			case "Gecko":  return {height:9.5,width:9.5}; // outerVertical : 40 ... 4 pixels teveel
			case "Opera":  return {height:10,width:10}; // Perfect
		}
	}
	
	Page.getScrollBarSize = function() // TEMPORAL SOLUTION
	{
		switch(Page.browser)
		{
			case "Safari": return {height:0,width:0};
			case "MSIE":   return {height:0,width:22};
			case "Gecko":  return {height:0,width:0};
			case "Opera":  return {height:0,width:0};
		}
	}
	
	Page.Control.prototype.enableScrollBar = function(type,object)
	{
		if(this.enableScrollBar[type])
			return this.enableScrollBar[type].apply(this,[object]);
		else
			throw new Error("Scrollbar of type '"+type+"' not supports");
	}

	Page.Control.prototype.enableScrollBar["vertical"] = function(o)
	{
		var e = this.element.prependChild(document.createElement("iframe")) , d = e.contentDocument||e.contentWindow.document||e.document , s = Math.ceil((o.size/o.step)*((o.maximum-o.minimum)+1));
		
		e.frameBorder = 0;
		e.height = (o.size+(Page.getScrollBarButtonsSize().height*2));
		e.scrolling = "yes";
		e.style.position = "absolute";
		e.style.zIndex = 100000;
		e.style.marginLeft = "600px";
		e.width = 22;
		
		var b = {interval:null,timeout:null};
		
		this.initializeScrollBar
		(
			e , d , {height:(s+(Page.getScrollBarButtonsSize().height*2)),width:1}
		,
			function()
			{
				var y = d.scrollTop||d.body.scrollTop||e.pageYOffset||arguments[0].currentTarget.pageYOffset , l = Math.round(y/(o.size/o.step)) , h = l+o.step;
				
				if(l<o.minimum) l = o.minimum;
				if(h>o.maximum) h = o.maximum;
	
				if(o.method&&b.timeout==null)
				{					
					b.timeout = setTimeout(function(){try{o.method({firstIndex:l,lastIndex:(h-1),length:(h-l)});}catch(er){};b.timeout=null;},10);
				}
			}
		);
	}
	
	
	Page.Control.prototype.enableScrollBar["horizontal"] = function(o)
	{
		var e = this.element.appendChild(document.createElement("iframe")) , d = e.contentDocument||e.contentWindow.document||e.document , s = Math.ceil((o.size/o.step)*((o.maximum-o.minimum)+1));
		
		e.frameBorder = 0;
		e.height = 22;
		e.scrolling = "yes";
		e.style.position = "absolute";
		e.style.zIndex = 100000;
		e.style.marginLeft = "300px";
		e.style.marginTop = "300px";
		e.width = (o.size+(Page.getScrollBarButtonsSize().width*2));
		
		this.initializeScrollBar
		(
			e , d , {height:10,width:(s+(Page.getScrollBarButtonsSize().width*2))}
		,
			function()
			{
				var x = d.scrollLeft||d.body.scrollLeft||e.pageXOffset||arguments[0].currentTarget.pageXOffset , l = Math.round(x/(o.size/o.step)) , h = l+o.step;
				
				if(l<o.minimum) l = o.minimum;
				if(h>o.maximum) h = o.maximum;
				
				if(o.method) o.method({firstIndex:l,lastIndex:(h-1),length:(h-l)});
			}
		);
	}
	
	Page.Control.prototype.initializeScrollBar = function(e,d,o,m)
	{	
		if(/Gecko|Safari/.test(Page.browser))
		{
			d.open();
			
			d.write('<body style="height:'+o.height+'px;width:'+o.width+'px;margin:0px 0px 0px 0px;"/>');

			setTimeout( function() { e.contentWindow.onscroll = m; d.close(); },10);
		}
		else
		{
			setTimeout
			(
				function()
				{	
					var c = d.body.appendChild(d.createElement("div"));

					c.innerHTML = "&#160;";
					c.style.height = (o.height+"px");
					c.style.margin = "0px 0px 0px 0px";
					c.style.width = (o.width+"px");
				
					d.body.onscroll = m;
					d.body.style.margin = "0px 0px 0px 0px";
				}
			,
				10
			);
		}
	}
		
	Page.Control.prototype.initializeChildren = function(parent)
	{
		for(var cn=0;cn<parent.childNodes.length;cn++)
		{
			var node = parent.childNodes[cn] , nodeName = (node.nodeType==1?node.nodeName.toLowerCase():"");
			
			switch(nodeName)
			{
				case "ul": if(this.initList) this.initList(node); break;
				case "ol": if(this.initList) this.initList(node); break;
				case "li": if(this.initListItem) this.initListItem(node); break;
			}
			
			if(node.childNodes.length>0) this.initializeChildren(node);
		}
	}
	
	Page.Control.parseMember = function(c,n,v) // case "function": c[n] = new Function(c.constructor.name+".prototype."+name+".apply(this,arguments);"+v); break; // Need Page.registerType()
	{
		if(v==null)
			return;
		else if(Page.resources.test(v))
			Page.bind(c,n,v);
		else if(Page.protocols.test(v))
			Page.link(c,n,v);
		else
		{
			var p = c.constructor.prototype[n] , f = c[n] , d = Page.defaults[c.constructor.name][n];
			
			if(d==null&&p==null)
			{
				if(v=="")
					c[n] = null;
				else if(/^\{.*\}$/.test(v))
					c[n] = Object.parse(v);
				else if(/^\[.*\]$/.test(v))
					c[n] = Array.parse(v);
				else
					c[n] = Value.parse(v);
			}
			else if(p!=null)
			{
				if(v=="")
					c[n] = null;
				else if(p.constructor&&p.constructor.parse)
					c[n] = p.constructor.parse(v);
				else if(/^\{.*\}$/.test(v))
				{
					var o = Object.parse(v); for(var k in o) f[k] = o[k];
				}
				else if(/^\[.*\]$/.test(v))
				{
					var a = Array.parse(v); for(var i=0;i<a.length;i++) f[i] = a[i];
				}
				else
					c[n] = Value.parse(v);
			}
			else if(d!=null)
			{
				if(v=="")
				{
					switch(d.construcor)
					{
						case Array: c[n] = ([].concat(d)); break;
						
						case Object: f = {}; for(var k in d) f[k] = d[k]; c[n] = f; break;
						
						default:
						
							if(typeof(d)=="object")
								throw "Cannot create instance of "+String(d);
							else
						 		c[n] = d;
					}
				}
				else if(d.constructor&&d.constructor.parseInto&&f!=null)
					c[n] = d.constructor.parseInto(v,f);
				else if(d.constructor&&d.constructor.parse)
					c[n] = d.constructor.parse(v);
				else if(/^\{.*\}$/.test(v))
				{
					var o = Object.parse(v); if(f==null) f = new d.constructor(); for(var k in o) f[k] = o[k];
				}
				else if(/^\[.*\]$/.test(v))
				{
					var a = Array.parse(v); if(f==null) f = new d.constructor(); for(var i=0;i<a.length;i++) f[i] = a[i];
				}
				else
					c[n] = Value.parse(v);
			}
			else
			{
				if(v=="")
				{
					switch(d.construcor)
					{
						case Array: c[n] = ([].concat(d)); break;
						
						case Object: f = {}; for(var k in d) f[k] = d[k]; c[n] = f; break;
						
						default:
						
							if(typeof(d)=="object")
								throw "Cannot create instance of "+String(d);
							else
						 		c[n] = d;
					}
				}
				else if(p.constructor&&p.constructor.parseInto&&f!=null)
					c[n] = p.constructor.parseInto(v,(f!=p?f:new d.constructor()));
				else if(p.constructor&&p.constructor.parse)
					c[n] = p.constructor.parse(v);
				else if(/^\{.*\}$/.test(v))
				{
					var o = Object.parse(v); for(var k in o) f[k] = o[k];
				}
				else if(/^\[.*\]$/.test(v))
				{
					var a = Array.parse(v); for(var i=0;i<a.length;i++) f[i] = a[i];
				}
				else
					c[n] = Value.parse(v);
			}
		}
		
/*		if(DEBUG&&c[n]!=null)
		{
			switch(c[n].constructor)
			{
				case Array: c.element.title += (n+"="+Array.toSource(c[n])+";"); break;
				
				case Object: c.element.title += (n+"="+Object.toSource(c[n])+";"); break;
				
				default: c.element.title += (n+"="+c[n]+";"); break;
				
			}	
		}
*/	}

	Page.Control.prototype.render = function(instance)
	{					
		var e = (this.contentElement!=null?this.contentElement:this.element);
		
		if(!instance) return;

		switch(instance.constructor)
		{
			case Array: this.renderMultipleTemplates(this.contentElement,instance); break;
			
			case Object: this.renderSingleTemplate(this.contentElement,instance); break;
		}	
	}
	
	Page.Control.prototype.renderSingleTemplate = function(e,object)
	{			
		var p = this.processor;
		
		p.clearParameters();

		for(var n in object)
		{
			p.setParameter(null,n,object[n]);
		}

		e.innerHTML = "";
		e.appendChild(p.transformToFragment("{}",document));
	}
	
	Page.Control.prototype.renderMultipleTemplates = function(e,array)
	{			
		var p = this.processor , s = "";

		for(var i=0;i<array.length;i++)
		{
			var o = array[i];
			
			p.clearParameters();
			
			for(var n in o)
			{
				p.setParameter(null,n,o[n]);
			}

			s += "<div>"+(p.transformToFragment("{}",document).innerHTML)+"</div>";
		}
			
		e.innerHTML = s;
	}
	
	Page.Control.prototype.setResourceOf = function(name,value)
	{
		var o = this[name];
				
		if(o==null)
			this[name] = v;
		else if(Object.supports(o,"image"))
			o.src = v;
		else if(Object.supports(o,"anchor"))
			 control[name].href = v;
		else if(Object.supports(o,"style"))
			 control[name].backgroundImage = ("url("+v+")");

	}
	
	if(navigator.userAgent.indexOf("Gecko")>=0||window.opera)
	Page.Control.setOpacity = function(element,value)
	{
		element.style.opacity = value;	
	}
	else
	Page.Control.setOpacity = function(element,value)
	{
		if(element.style.filter.indexOf("progid:DXImageTransform.Microsoft.Alpha")>=0)
			element.filters.item("DXImageTransform.Microsoft.Alpha").opacity = Math.floor(value*100);
		else
			element.style.filter += "progid:DXImageTransform.Microsoft.Alpha(opacity="+Math.floor(value*100)+")"
	}
	
	if(/Opera|Gecko|KHTML|Safari|MSIE\s*([789]\.|\d{2})/i.test(navigator.userAgent))
	Page.Control.setImageSource = function(element,url)
	{
		element.src = url;	
	}
	else
	Page.Control.setImageSource = function(element,url)
	{	
		if(element.nodeName.toLowerCase()=="img")
			element.src = url;
		else
		{
			if(element.style.filter.indexOf("progid:DXImageTransform.Microsoft.AlphaImageLoader")>=0)
				element.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+url+"')"
			//	element.filters.item("progid:DXImageTransform.Microsoft.AlphaImageLoader").src = url;
			else
				element.style.filter += "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+url+"')"
		}
	}
	
	if(/Opera|Gecko|KHTML|Safari|MSIE\s*([789]\.|\d{2})/i.test(navigator.userAgent))
	Page.Control.getImageSource = function(element)
	{
		return element.src;	
	}
	else
	Page.Control.getImageSource = function(element)
	{	
		if(element.nodeName.toLowerCase()=="img")
			return element.src;
		else
		{			
			if(element.style.filter.indexOf("progid:DXImageTransform.Microsoft.AlphaImageLoader")>=0)
				return element.style.filter.replace(/.*?src\=\'([^\']*)\'.*/,"$1");
			else
				return "";	
		}
	}
	
	Page.Element = function(name)
	{
		var element = document.createElement(name);
		
		if(this.className)
			element.className = this.className;
		if(this.title)
			element.title = this.title;
			
		for(var k in this.style) element.style[k] = this.style[k];
		
		return element;
	}
	
	Page.Element.prototype.className = "";
	Page.Element.prototype.id = "";
	Page.Element.prototype.style = {};
	Page.Element.prototype.title = "";
	
	Page.applyTemplate = function(element,template,object)
	{
		var html = element.innerHTML;
				
		for(var key in object)
		{
			html = html.replace(new RegExp("\\{\\$"+key+"\\}","g"),object[key]);
			html = html.replace(new RegExp("\\{\\$"+key+"\\:\\'([^\\{]*)\\{\\$\\}([^\\']*)\\'\\}","g"),"$1"+object[key]+"$2");
		}
		
		element.innerHTML = (html.replace(/\{\$[0-9A-Za-z-_]+\}|\{\$[0-9A-Za-z-_]+\:\'[^\{]*\{\$\}[^\']*\'\}/g,""));
		
	//	this.tooltipIDRendered = this.tooltipID
	}
	
	Page.Element.applyStyle = function(element,context)
	{
		var c = context.split(";");
		
		for(var i=0;i<c.length;i++)
		{
			if(c[i])
			{
				var p = c[i].split(":") , k = p[0].split("-") , v = p[1];
				
				if(k.length>1) k[1] = (k[1].charAt(0).toUpperCase()+k[1].substring(1));
				if(k.length>2) k[2] = (k[2].charAt(0).toUpperCase()+k[2].substring(1));

				element.style[k.join('')] = v;
			}
		}
	}
	
	Page.Element.prependChild = function(newNode)
	{ 
		return (this.hasChildNodes()?this.insertBefore(newNode,this.firstChild):this.appendChild(newNode));
	}
	
	Page.Element.createButton = function(type,text,methods)
	{
		if(Page.Element.createButton[type])
		{
			var e = Page.Element.createButton[type]();
			
			e.value = text;
			
			if(methods) for(var name in methods) e[name] = methods[name];
		}
	}
	
	Page.Element.createButton["submit"] = function() { var e = document.createElement("input"); e.type = "button"; return e; }
	Page.Element.createButton["reset"] = function() { var e = document.createElement("input"); e.type = "reset"; return e; }
	Page.Element.createButton["button"] = function() { var e = document.createElement("input"); e.type = "button"; return e; }
	
	Page.Element.createInput = function(value)
	{
		var e,t;
		
		if(value==null)
			t = "undefined";
		else
		{
			switch(value.constructor)
			{
				case Array: t="array"; break; case Object: t="object"; break; case Date: t="date"; break; default: t=typeof(value); break;
			}
		}
		
		return Page.Element.createInput[t](value);		
	}

	Page.Element.createInput["undefined"] = function()
	{
		var e = document.createElement("input");
		
		e.type = "password";
		
		return e;
	}
		
	Page.Element.createInput["boolean"] = function(b)
	{
		var e = document.createElement("input");
		
		e.type = "checkbox";
		
		if(b) e.checked = true;
		
		return e;
	}
	
	Page.Element.createInput["number"] = function(n)
	{
		var e = document.createElement("textarea");
		
		e.rows = 1;
		e.style.overflowY = "scroll";
		e.style.height = "16px";
		e.value = n;
		
		return e;
	}
	
	Page.Element.createInput["string"] = function(s)
	{
		var e = document.createElement("input");
		
		e.type = "text";
		e.value = s;
		
		return e;
	}
	
	Page.Element.createInput["object"] = function(o)
	{
		var e = document.createElement("select") , v = o.toString();
		
		for(var k in o) if(typeof(o[k])!='function') e.options[e.options.length] = new Option(o[k],k);
		
		if(o[v]) e.value = v;
		
		return e;
	}
	
	Page.Element.createInput["array"] = function(a)
	{
		var e = document.createElement("span") , h = document.createElement("input") , i = document.createElement("input") , b = document.createElement("button");

		h.type = "hidden";
		
		b.innerHTML = "?";
		b.onclick = function(){ alert(Array.toSource(a)); }
		b.style.padding = "0px 0px 0px 0px";
		i.disabled = true;
		
		e.value = new Property("value");
		e.value.set = function(){ h.value = arguments[0]; i.value = arguments[0].length; }
		e.value.get = function(){ return h.value; }
		e.value.compile(e);
		e.value.set(String(a.length));

		e.appendChild(h);
		e.appendChild(b);
		e.appendChild(i);
		
		return e;
	}

	Page.Element.createInput["date"] = function(d)
	{
		var e = document.createElement("input");
		
		e.type = "text";
		e.value = String(d);
		
		return e;
	}
	
	Page.Element.setNaming = function(e,key)
	{
		e.innerHTML = (key.charAt(0).toUpperCase()+key.substring(1).replace(/([A-Z])/g," $1"));
	};
//	HTML	
	HTML = {HTMLDivElement:"div",HTMLDocument:"html",HTMLIFrameElement:"iframe",HTMLImageElement:"img",HTMLSpanElement:"span"};
	
	(	function(o)
		{
			var c = function() { throw "Cannot convert WrappedNative to function" };
			var i = function(e,a) { if(a.length>0&&a[0]) e.id=a[0]; if(a.length>1&&a[1]) e.title=a[1]; if(a.length>2&&a[2])	for(var n in a[2]) e.style[n]=a[2][n]; };
			
			for(var t in o)
			{
				if(window[t]==null) window[t] = c;
				
				window[t].initialize = i;
				window[t].attributes = null;
				window[t].style = null;
			}
		}
	)(HTML);
	
	(	function(o)
		{
	
			
			for(var t in o)
			{
				if(window[t]!=null)
				{
					var code = ["var e = document.createElement(\""+o[t]+"\")",,"if(arguments.length>0) "+t+".initialize(e,arguments);return e"];
					 
					if(window[t].attributes&&window[t].style)
						code[1] = "for(var p in {attributes:null,style:null}) for(var n in "+t+"[p]) e[p][n] = "+t+"[p][n]";
					else if(window[t].attributes)
						code[1] = "for(var n in "+t+".attributes) e.attributes[n] = "+t+".attributes[n]";
					else if(window[t].style)
						code[1] = "for(var n in "+t+".style) e.style[n] = "+t+".style[n]";
					
					window[t].create = new Function(code.join(";"));
				}
			}
		}
	)(HTML);
	
	// 	Page
	window.onload = new Function("Page.initialize();");
//	window.onload = new Function("Page.initialize();");

	Page.isReady = false;
	
	if(document.addEventListener)
		document.addEventListener("DOMContentLoaded", function(){Page.isReady=true;Page.initialize();}, false)
	else if(/Safari/i.test(navigator.userAgent))
		var _timer = setInterval(function(){if(/loaded|complete/.test(document.readyState)){ clearInterval(_timer); Page.isReady=true; Page.initialize() }},10);
	else if(document.all&&!window.opera)
	{
		document.write('<script type="text/javascript" id="contentloadtag" defer="defer" src="javascript:void(0)"><\/script>')
		var contentloadtag=document.getElementById("contentloadtag");
		contentloadtag.onreadystatechange=function()
		{
			if (this.readyState=="complete")
			{
				Page.isReady=true; Page.initialize();
			}
		}
	}
	
	window.onload = function()
	{
		setTimeout("if(!Page.isReady) Page.initialize()", 0)
	}

	window.onunload = new Function('return Page.finalize(arguments.length>0?arguments[0]:window.event)');
