String.prototype.trim=function(){
  var x=this;
  x=x.replace(/^\s*(.*)/,"$1");
  x=x.replace(/(.*?)\s*$/,"$1");
  return x;
}
String.prototype.unescape=function(){
	if(this!=null&&this==""){return null;}
	return unescape(this);
}
String.prototype.contains=function(value,ignoreCase){
	var src=this;
	if(ignoreCase){src=src.toLowerCase();value=value.toLowerCase();}
	return (src.indexOf(value)>-1);
}
String.prototype.startsWith=function(value,ignoreCase){
	var src=this;
	if(ignoreCase){src=src.toLowerCase();value=value.toLowerCase();}
	return (src.indexOf(value)==0);
}
String.prototype.endsWith=function(value,ignoreCase){
	var src=this;
	if(ignoreCase){src=src.toLowerCase();value=value.toLowerCase();}
	var at=src.lastIndexOf(value);
	if(at<0){return false;}
	if((at+value.length)==src.length){return true;}return false;
}
String.prototype.replaceAll=function(searchFor,replaceWith,ignoreCase){
	var f="g";if(ignoreCase){f+="i";}
	var re=new RegExp(searchFor,f);
	return this.replace(re,replaceWith);
}
String.prototype.equals=function(val,ignoreCase){
	if(val==null){return false;}
	var src=this;
	if(ignoreCase){src=src.toLowerCase();val=val.toLowerCase();}
	return (src==val);
}

document.getElementsByClassName=function(cn,p) {
	p=blaze.getElement(p);
	if(!p){p=document.body};
	var els=p.getElementsByTagName("*");
	var o=[];
	var re=new RegExp("(^|\\s)"+cn+"(\\s|$)");
	for(var i=0;i<els.length;i++){
		if(els[i].className.match(re)){o.push(els[i]);}
	}
	return o;
}

document.getOuterHTML=function(node){
	var t=document.createElement("div");
	t.appendChild(node.cloneNode(true));
	return t.innerHTML;
}

if(typeof(HTMLElement)!="undefined"&&!HTMLElement.prototype.outerHTML){
	try{
		var e="HTMLElement.prototype.outerHTML getter=function(){return document.getOuterHTML(this);}";
		eval(e);
	}catch(ex){}
}

Blaze=function(server,refresh){
	if(window.blaze){return window.blaze;}
	this.base=null;
	this.server=null;
	this.refresh=false;
	this.classes=[];
	this.scripts=[];
	this.services={};
	this.services.onfault=null;
	this.services.onerror=null;
	this.services.onload=null;
	this.loader=null;
	this.threads=[];
	this.logLevel=1;
	this.logHandler=this.out;
	this.setServer(refresh,this.getBase()+"/loader/");
	var caller=this;
	this.addEvent(function(){caller.correctPNG();});
}

Blaze.prototype.createPackage=function(ns){
	var parts=ns.split(".");
	var root=window;
	for(var i=0;i<parts.length;i++){
		if(root[parts[i]]==null||typeof(root[parts[i]])=="undefined"){root[parts[i]]=new Object();}
		root=root[parts[i]];
	}
	return root;
}
Blaze.prototype.findMember=function(ns,root){
	if(!root){root=window;}
	var parts=ns.split(".");
	for(var i=0;i<parts.length;i++){
		if(root[parts[i]]){root=root[parts[i]];}else{return null;}
	}
	return root;
}
Blaze.prototype.setServer=function(refresh,server){
	this.refresh=refresh;
	if(server!=null){
		this.server=server;
		this.converterUrl=this.server+"SoapProxy.aspx";
		//this.loadScript(this.server+"SoapProxy.js");
	}
}
Blaze.prototype.getLoader=function(o){
	return new BlazeLoader(o);
}
Blaze.prototype.getImporter=function(oninit,onstatuschange){
	return new BlazeImporter(oninit,onstatuschange);
}
Blaze.prototype.getBase=function(url){
	if(this.base==null){
		var scripts=document.getElementsByTagName("script");
		for(var i=0;i<scripts.length;i++){
			var src=scripts[i].src;
			if(src&&src.toLowerCase().indexOf("blaze/loader/blaze.js")>-1){
				this.base=src.substring(0,src.indexOf("blaze/")+6);
				this.base=(this.base.replaceAll("//", "/").replaceAll(":/","://"));
			}
		}
	}
	var o=this.base;
	if(url!=null){o+=url;o=o.replaceAll("//","/").replace(":/","://");}
	return o;
}
Blaze.prototype.getRoot=function(url){
	if(url.startsWith("~")){
		var root=this.getBase();
		root=root.substring(0,root.length-6);
		return root+=url.substring(2);
	}
	return url;
}

Blaze.prototype.useService=function(name,wsdl) {
	wsdl=this.getAbsoluteUrl(this.getRoot(wsdl));
	var url=this.converterUrl+"?wsdl="+escape(wsdl);
	if(this.refresh){url+="&refresh=true";}
	return this.load(name,url,this.services);
}

Blaze.prototype.useClass=function(name,args,url){
	if(name.indexOf("/")>-1){url=name;}
	if(!url){url=this.getPackageUrl(name)}
	url=this.getRoot(url);
	if(url.indexOf("://")>-1&&url.indexOf(location.host)<0){
		url=this.getBase("/loader/JsProxy.aspx")+"?src="+escape(url);
	}
	return this.load(name,url,this.classes,args,true);
}

Blaze.prototype.getPackageUrl=function(name){
	var pkg="";var file=null;
	var parts=name.split(".");
	for(var i=0;i<parts.length;i++){
		pkg+="/"+parts[i];file=parts[i];
	}
	var url=this.getBase()+"/lib"+pkg+"/"+file+".js";
	return url.replaceAll("//","/").replaceAll(":/", "://");
}

Blaze.prototype.getRelativeUrl=function(url,fn){
	if(!fn){fn="Blaze.js";}
	var s=document.getElementsByTagName("script");
	for(var i=0;i<s.length;i++){
		var chr=s[i].src.indexOf(fn);
		if(chr>-1){
			var root=s[i].src.substring(0,chr);
			if(url.substring(0,1)=="/"){
				var p=url.substring(10).indexOf(url,"/")-10;
				root=root.substring(0,p);
			}
			return root+url;
		}
	}
	return url;
}

Blaze.prototype.getAbsoluteUrl=function(url){
	if(url.indexOf("://")>0){return url;}
	var svr=location.protocol+"//"+location.host;
	if(url.substring(0,1)!="/"){
		var path=location.pathname;
		path=path.substring(0,path.lastIndexOf("/")+1);
		url=path+url;
	}
	return svr+url;
}

Blaze.prototype.include=function(url,tag,id){
	if(!url){throw new Error("An include URL is required");}
	if(!tag){tag="script";}
	if(url.indexOf(".css")>-1){tag="link";}

	var h=document.body;
	var hd=document.getElementsByTagName("head");
	if(hd&&hd[0]){h=hd[0];}
	if(!h){return;}
	
	//if(!id){id="";}
	tag=tag.toLowerCase();

	var el=null;
	switch(tag){
		case "link":
			el=blaze.makeElement(tag,{id:id,href:url,rel:"stylesheet",type:"text/css"});
			h.insertBefore(el,h.firstChild);
		case "script":
			el=blaze.makeElement(tag,{id:id,src:url,language:"javascript",type:"text/javascript"}," ");
			h.appendChild(el);
	}
	return el;
}

Blaze.prototype.completedHandler=function(object){
	var h=new BlazeLoader(object);
	blaze.setTimeout(h,"success",null,1);
	return h;
}

Blaze.prototype.log=function(val,lvl,tgt){
	if(!lvl){lvl=2;}
	if(lvl<=this.logLevel){this.logHandler(val,tgt);}
}

Blaze.prototype.out=function(val,el){
	if(!el){el=document.body;}
	if(el){this.addElement(el,"div",null,val);}else{document.write("<div>"+val+"</div>");}
}

Blaze.prototype.exists=function(o){
	var o=this.makeArray(o);
	for(var i=0;i<o.length;i++){
		if(typeof(o[i])=="undefined"){return false;}
		if(o[i]==null){return false;}
	}
	return true;
}

Blaze.prototype.load=function(name,src,col,args,noInit){
	var h=new BlazeLoader();
	var caller=this;
	h.onsuccess=function(result) {
		var argList = "";
		var code=result.responseText;
		try{
			var method=window.eval(code);
		}catch(ex){
			if(ex.lineNumber){
				ex.lineNumber=ex.lineNumber-122;
				ex.fileName=src;
			}
			throw ex;
		}
		if(!noInit) {
			if(typeof(method)=="function") {
				method.apply(this,args);col[name]=method;
			}
			if(typeof(method)=="string"){
				var l="";
				for(var i=0;i<l.length;i++) {
					if(l != ""){l+=",";}
					if(typeof(args[i])=="string"){l+="'"+args[i]+"'";}else{l+=args[i];}
				}
				var stmt = "new "+method+"("+l+")";
				try {
					col[name]=window.eval(stmt);
				}catch(ex){
					if(ex.lineNumber){
						ex.lineNumber=ex.lineNumber-142;
						ex.fileName=src;
					}
					throw ex;
				}
			}
		} else {
			col[name]=true;
		}
	}
	h.onfail=function(result){
		throw new Error('Could not import "'+name+'" ['+src+']\n('+result.status+') '+result.statusText);
	}
	h=this.request(src,h);
	return h;
}

Blaze.prototype.isArray=function(a){
	return (typeof(a)=="object"&&typeof(a.length)=="number");
}
Blaze.prototype.makeArray=function(a){
	if(a==null){return [];}
	if(this.isArray(a)==false){
		var tmp=a;a=new Array(0);a[0]=tmp;
	}
	return a;
}

Blaze.prototype.isExternal=function(url){
	var host=location.protocol+"//"+location.host;
	return !url.startsWith(host,true);
}

Blaze.prototype.loadScript=function(src,useBase,h){
	var isExternal=false;
	if(src.indexOf(";")<0&&this.isExternal(src)){
		if(src.indexOf(".js")<0&&src.indexOf("://")<0){
			src=this.getPackageUrl(src);
		}else{
			if(useBase){
				src=this.getBase(src);
			}else{
				src=this.getRoot(src);
			}
			isExternal=true;
		}
	}
	var loader=new BlazeLoader(src);
	var i=this.scripts.push(loader);
	src=this.getAbsoluteUrl(src);
	if(isExternal){src=this.getBase("/loader/JsProxy.aspx")+"?i="+(i-1)+"&src="+escape(src);}

	if(h==null||typeof(h)=="object"){
		if(!h){
			h=document.getElementsByTagName("head");
			if(h&&h.length>-1){h=h[0];}else{h=null;}
		}
		if(!h){h=document.body;}
	}
	
	if(h&&h.appendChild){
		var s=document.createElement("script");
		s.setAttribute("type","text/javascript");
		s.setAttribute("language","javascript");
		if(isExternal){
			s.setAttribute("src",src);
			if(!s.canHaveChildren){s.text=" ";}
		}else{
			s.innerHTML=src;
		}
		h.appendChild(s);
	}else{
		var html=null;
		if(isExternal){
			html='<scr'+'ipt type="text/javascript" language="javascript" src="'+ src +'"></scr'+'ipt>';
		}else{
			html='<scr'+'ipt type="text/javascript" language="javascript">'+ src +'</scr'+'ipt>';
		}
		document.write(html);
	}
	if(!isExternal){loader.success();}
	return loader;
}

Blaze.prototype.getJSON=function(json){
	if(json==null){return;}
	if(typeof(json)=="string"){
		window.__json=null;
		eval("__json="+json);
		json=__json;
	}
	if(typeof(json)!="object"){return null;}
	return json;
}

Blaze.prototype.getStyleValue=function(el,prop){
	if(el.currentStyle){
		prop=prop.toLowerCase();
		var a=prop.split("-");
		prop="";
		for(var i=0;i<a.length;i++){
			var s=a[i];
			if(i>0){s=s.substring(0,1).toUpperCase()+s.substring(1);}
			prop+=s;
		}
		return el.currentStyle[prop];
	}else{
		return document.defaultView.getComputedStyle(el,'').getPropertyValue(prop);
	}
}

Blaze.prototype.loadStyle=function(href,useBase,id,el){
	if(!document.body){return;}
	if(useBase){href=this.getBase(href);}else{href=this.getRoot(href);}
	var style=document.createElement("link");
	if(id){
		style.setAttribute("id",id);
		style.setAttribute("name",id);
	}
	style.setAttribute("rel","stylesheet");
	style.setAttribute("type","text/css");
	style.setAttribute("href",href);
	if(!el){
		var h=document.getElementsByTagName("head");
		if(h&&h.length>0){el=h[0];}else{el=document.body;}
	}
	el.insertBefore(style,el.firstChild);
	el.appendChild(style.cloneNode(true));
}

Blaze.prototype.addStyleRule=function(selector,attributes,stylesheetID){
	var isIE=(document.all);
	var ss=null;
	if(stylesheetID){
		if(isIE){
			ss=document.styleSheets[stylesheetID];
		}else{
			ss=document.getElementById(stylesheetID);
			if(ss!=null){ss=ss.sheet;}
		}
	}
	if(!ss){ss=document.styleSheets[0];}
	if(isIE){
		ss.addRule(selector,attributes);
	}else{
		var attributes=selector+" {"+attributes+"}";
		ss.insertRule(attributes,ss.cssRules.length);
	}
}

Blaze.prototype.addClassName=function(el,cn){
	if(!cn){return;}
	el=blaze.getElement(el);
	if(!el.className){el.className="";}
	if(el.className.indexOf(cn)<0){el.className+=" "+cn;}
	el.className=el.className.trim();
}

Blaze.prototype.removeClassName=function(el,cn){
	if(!cn){return;}
	el=blaze.getElement(el);
	if(!el){return;}
	if(!el.className){el.className="";}
	if(el.className.indexOf(cn)>-1) {
		el.className=(" "+el.className).replace(" "+cn, "");
		el.className=el.className.trim();
	}
}

Blaze.prototype.swapClassName=function(el,c1,c2){
	el=blaze.getElement(el);
	if(el.className.indexOf(cn)>-1){
		el.className=(" "+el.className).replace(" "+c1," "+c2);
		el.className=el.className.trim();
	}
}

Blaze.prototype.toggleSelects=function(show){
	if(!document.all){return false;}
	var sl=document.getElementsByTagName("select");
	if(!sl||sl.length<1){return false;}
	for(var i=0;i<sl.length;i++){
		sl[i].style.visibility=(show)?"visible":"hidden";
	}
	return true;
}

Blaze.prototype.getX=function(el){
	var c=this.getCoords(el);
	if(c){return c.x;}
	return null;
}

Blaze.prototype.getY=function(el){
	var c=this.getCoords(el);
	if(c){return c.y;}
	return null;
}

Blaze.prototype.getCoords=function(el){
	var x=0,y=0;
	if(!el){return;}
	if(document.getElementById||document.all){
		while(el.offsetParent){
			if(el.offsetParent.style.position!="relative"){
				x+=el.offsetLeft;
				y+=el.offsetTop;
			}
			el=el.offsetParent;
		}
	}else if(document.layers){
		x=el.x;y=el.y;
	}
	return {x:x,y:y};
}

Blaze.prototype.getValue=function(el){
	var el=this.getElement(el);
	if(!el){return null;}
	if(el.tagName=="INPUT"){return el.value;}else{return el.innerHTML;}
}

Blaze.prototype.setValue=function(el,val){
	var el=this.getElement(el);
	if(!el){return null;}
	if(el.tagName=="INPUT"){el.value=val;}else{el.innerHTML=val;}
}

Blaze.prototype.populate=function(object,prefix,container,element,setValue){
	if(!object){return false;}
	if(!container){container=document;}
	if(typeof(object)=="object"){
		for(var key in object){
			var el=this.getElement(key,prefix,container);
			if(el) {
				var result=this.populateElement(object[key],el,setValue);
				if(setValue){object[key]=result;}
			}
		}
	}else{
		if(element){
			element=this.getElement(element,prefix,container);
			var result=this.populateElement(object,element,setValue);
			if(setValue){object=result;}
		}
	}
}

Blaze.prototype.retrieve=function(object,prefix,container,element){
	if(prefix&&prefix.tagName){container=prefix;prefix=null;}
	this.populate(object,prefix,container,element,true);
}

Blaze.prototype.scatter=Blaze.prototype.populate;
Blaze.prototype.gather=Blaze.prototype.retrieve;

Blaze.prototype.populateDocument=function(object,prefix){
	this.populate(object,prefix);
}

Blaze.prototype.populateForm=function(object,form){
	if(!object||!object.__keys){return;}
	if(!form){
		for(var i=0;i<document.forms.length;i++){
			this.populateForm(object,document.forms[i]);
		}return;
	}
	if(form!="object"){form=document.getElementById(form);}
	this.populate(object,null,form);
}

Blaze.prototype.populateMethod=function(service,fn){
	service=this.getService(service);
	fn=this.getMethod(service,fn);
	if(!service||!fn){return;}

	var code=fn.toString();
	code=code.substring(code.indexOf("function (")+10);
	code=code.substring(0,code.indexOf(")"));
	if(code.indexOf("(")>0){code=code.substring(code.indexOf("(")+1);}

	args=code.split(",");
	var params=new Array(args.length);
	for(var i=0;i<args.length;i++){
		var arg=args[i].trim();
		params[i]=null;
		var el=document.getElementById(arg);
		if(el){params[i]=this.populateElement(params[i],el,true);}
	}
	return fn.apply(object,params);
}

Blaze.prototype.coalesce=function(val){
	if(val==null||val+""=="null"){
		for(var i=0;i<arguments.length;i++){
			val=arguments[i];
			if(val!=null&&val!="null"){return val;}
		}
	}
	return val;
}

Blaze.prototype.populateElement=function(val,el,setValue){
	if(!el){return;}
	if(!el.tagName){
		var a=[];
		for(var i=0;i<el.length;i++){
			var val=this.populateElement(val,el[i],setValue);
			if(val!=null){a[a.length]=val;}
		}
		return a;
	}
	if(el.tagName=="INPUT"||el.tagName=="TEXTAREA"||el.tagName=="BUTTON"){
		if(el.type=="checkbox"||el.type=="radio"){
			var isBoolean=false;
			if(val!=null){
				isBoolean=(typeof(val)=="boolean"||val.toLowerCase()=="true"||val.toLowerCase()=="false");
			}
			if(!setValue){
				if(isBoolean) {
					el.checked=val;return val;
				} else {
					el.checked=(el.value==this.coalesce(val,""));return el.value;
				}
			} else {
				if(isBoolean) {
					return el.checked;
				} else {
					if(el.checked){return el.value;}else{return null;}
				}
			}
		}
		if(!setValue){el.value=this.coalesce(val,"");} return el.value;
	}
	if(el.tagName=="SELECT"){
		if(setValue){
			if(el.selectedIndex>-1){return el.options[el.selectedIndex].value;}else{return null;}
		} else {
			for(var i=0;i<el.options.length;i++){
				if(el.options[i].value==val){
					el.selectedIndex=i;
					return el.options[i].value;
				}
			}
		}
	}
	try {el.innerHTML=val;}catch(ext){el.innerText=val;}
	return val;
}

Blaze.prototype.cancelEvent=function(e){
	if(!e){e=window.event;}
	if(!e){e=this.Event;}
	if(!e){return;}
	e.cancelBubble=true;
	if(e.stopPropagation){e.stopPropagation();}
}

Blaze.prototype.createIcon=function(icon,w,h){
	icon=this.getRoot(icon);
	if(document.all&&icon.endsWith(".png",true)){
		if(w==null){w=16;}
		if(h==null){h=16;}
		var span=document.createElement("span");
		span.style.width=w+"px";
		span.style.height=h+"px";
		span.style.display="inline-block";
		span.className="icon";
		span.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+icon+"',sizingMethod='crop')";
	}else{
		var span=document.createElement("img");
		span.src=icon;
		if(w){span.width=w;}
		if(h){span.height=h;}
	}
	return span;
}

Blaze.prototype.request=function(url,h,post){
	var http=this.createHttp();
	if(!h){
		h=new BlazeLoader(http);
	}else{
		h.object=http;
	}
	http.onreadystatechange=function(){
		if(http.readyState==4||http.readyState=='complete'){
			if(http.status&&http.status==200){
				h.success();
			} else {
				h.fail();
			}
			http.abort();
		}
	}

	var t="application/x-www-form-urlencoded";
	var m="GET";
	if(post){
		m="POST";
		if(typeof(post)=="object"){
			t="text/xml";
		}
	}

	try{
		if(this.isMozilla){netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");}
		http.open(m,url,true);
		http.setRequestHeader("Content-Type",t);
		http.send(post);
	}catch(e){throw new Error("Could not open HTTP connection: "+url);}
	return h;
}

Blaze.prototype.toPost=function(o){
	var s="";
	for(var a in o){
		var b=this.makeArray(o[a]);
		for(var i=0;i<b.length;i++){
			if(s!=""){s+="&";}
			s+=escape(a)+"="+escape(b[i]);
		}
	}
	return s;
}

Blaze.prototype.requestSync=function(url,post){
	var http=this.createHttp();
	if(this.isMozilla){netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");}
	var t="application/x-www-form-urlencoded";
	var m="GET";
	if(post){
		m="POST";
		if(typeof(post)=="object"){t="text/xml";}
	}
	http.open(m,url,false);
	http.setRequestHeader("Content-Type",t);
	http.send(post);
	return http;
}

Blaze.prototype.createHttp=function(){
	try {
		if(window.XMLHttpRequest){
			var req=new XMLHttpRequest();
			if(req.readyState==null){
				req.readyState=1;
				req.addEventListener("load",function(){
					req.readyState=4;
					if(typeof(req.onreadystatechange)=="function"){req.onreadystatechange();}
				},false);
			}
			return req;
		}
		if(window.ActiveXObject){
			return new ActiveXObject("Microsoft.XMLHTTP");
		}
	} catch (ex) {}
	throw new Error("Your browser does not support XmlHttp objects");
}

Blaze.prototype.getNodeValue=function(el){
	if(el.firstChild){return el.firstChild.nodeValue;}else{return el.nodeValue;}
}

Blaze.prototype.setPropertyFromNode=function(el,o,append){
	var n=el.nodeName;
	if(n){
		var at=n.indexOf(":");
		if(at>-1){
			var p=n.substring(0,at);
			if(!o[p]){o[p]=new Object();}
			o=o[p];
			n=n.substring(at+1);
		}
		if(append){
			o[n]+=getNodeValue(el);
		}else{
			o[n]=getNodeValue(el);
		}
	}
}

Blaze.prototype.fixNull=function(val){
	if(val!=null&&val==""){return null;}
	return val;
}

Blaze.prototype.setOpacity=function(el,op){
	if(op>1){op=op/100};
	if(op==0&&el.style.visibility!="hidden"){el.style.visibility="hidden";return;}
	if(el.style.visibility!="visible"){el.style.visibility="visible";}
	if(window.ActiveXObject){el.style.filter="alpha(opacity="+(op*100)+")";return;}
	el.style.opacity=op;
}

Blaze.prototype.getElement=function(name,prefix,container){
	if(name==null){return null;}
	if(typeof(name)!="string"&&typeof(name)!="number"){if(name.tagName){return name;}return null;}
	if(prefix){name=prefix+name;}
	if(container==null){container=document;}
	if(container.elements){
		return container.elements[name];
	}
	if(container.getElementById){
		return container.getElementById(name);
	}
	return null;
}

Blaze.prototype.getElements=function(names,parent){	
	if(!parent){parent=document;}
	var a=names.split(" ");
	var els=[];
	for(var i=0;i<a.length;i++){
		var n=parent.getElementsByTagName(a[i]);
		if(n){
			for(var j=0;j<n.length;j++){els[els.length]=n[j];}
		}
	}
	return els;
}

Blaze.prototype.toggleElement=function(element,display){
	var el=this.getElement(element);
	if(el){
		if(display==null){if(el.style.display=="none"){display="";}}
		el.style.display=display;
	}
}

Blaze.prototype.callMethod=function(service,method){
	service=this.getService(service);
	method=this.getMethod(service,method);
	if(!service||!method){return null;}
	var prms=[];
	if(arguments.length>2){
		for(var i=2;i<arguments.length;i++) {
			prms[i-2]=arguments[i];
		}
	}
	return method.apply(service,prms);
}

Blaze.prototype.getMethod=function(service,fn){
	service=this.getService(service);
	if(!service||!fn){return null;}
	if(typeof(fn)=="string"){fn=service[fn];}
	return fn;
}

Blaze.prototype.getService=function(service){
	if(!service){return null;}
	if(typeof(service)=="string"){service=this.services[service];}
	return service;
}

Blaze.prototype.addEvent=function(fn,en,obj){
	if(!obj){obj=window;}
	if(!en){en="load";}
	en=en.toLowerCase();if(en.startsWith("on")){en=en.substring(2);}
	fn=this.makeArray(fn);
	for(var i=0;i<fn.length;i++){
		if(obj.addEventListener){
			obj.addEventListener(en,fn[i],false);
		}else if(obj.attachEvent){
			obj.attachEvent("on"+en,fn[i]);
		}else{
			if(!obj["__"+en+"__"]){obj["__"+en+"__"]=[];}
			obj["__"+en+"__"].push(fn[i]);
		}
	}
	if(obj["__"+en+"__"]){
		if(typeof(obj["on"+en])=="function"){obj["__"+en+"__"].push(obj["on"+en]);}
		obj["on"+en]=function(){
			for(var i=0;i<this["__"+en+"__"].length;i++){
				this["__"+en+"__"]();
			}
		}
	}
}

Blaze.prototype.removeEvent=function(fn,en,obj){
	if(!obj){obj=window;}
	if(!en){en="load";}
	en=en.toLowerCase();if(en.startsWith("on")){en=en.substring(2);}
	if(obj.removeEventListener){obj.removeEventListener(en,fn);return;}
	if(obj.detachEvent){obj.detachEvent("on"+en,fn);return;}
	if(obj["__"+en+"__"]){
		for(var i=0;i<obj["__"+en+"__"].length;i++){
			if(obj["__"+en+"__"][i]==fn){
				obj["__"+en+"__"].splice(i,1);
				return;
			}
		}
	}
}

Blaze.prototype.showProperties=function(o,el){
	var out="";
	if(o.__keys){
		for(var i=0;i<o.__keys.length;I++){
			var k=o.__keys[i];
			out+=k+": "+o[k]+"; ";
		}
	}
	if(el){el.innerHTML=out;}
	return out;
}

Blaze.prototype.deselect=function(){
	if(document.selection&&document.selection.empty){document.selection.empty();return;}
	if(window.getSelection&&window.getSelection().removeAllRanges){window.getSelection().removeAllRanges();return;}
}

Blaze.prototype.makeElement=function(tagName,attributes,html,parent){
	if(tagName==null){
		var el=document.createTextNode(html);
	}else{
		if(typeof(tagName)=="string"){
			var el=document.createElement(tagName);
		}else{
			if(tagName.tagName){var el=tagName;}else{return;}
		}
		if(attributes){
			for(var a in attributes){
				var o=attributes[a];
				if(typeof(o)!="function"){
					switch(a.toLowerCase()){
						case "class":el.className=o;break;
						case "colspan":el.colSpan=o;break;
						default:el.setAttribute(a,o);break;
					}
				}
			}
		}
		if(html!=null){
			if(html.tagName!=null){el.appendChild(html);}else{el.innerHTML=html;}
		}
	}
	if(parent!=null){parent.appendChild(el);}
	return el;
}
Blaze.prototype.addElement=function(node,tagName,attributes,html){
	var el=this.makeElement(tagName,attributes,html);
	if(!node){node=document.body;}
	node.appendChild(el);
	return el;
}
Blaze.prototype.addBeforeElement=function(node,tagName,attributes,html){
	if(!node.parentNode){return;}
	var el=this.makeElement(tagName,attributes,html);
	node.parentNode.insertBefore(el,node);return el;
}
Blaze.prototype.addAfterElement=function(node,tagName,attributes,html){
	var el=this.makeElement(tagName,attributes,html);
	node.parentNode.insertBefore(el,node.nextSibling);return el;
}

Blaze.prototype.setTimeout=function(obj,fn,args,sleep){
	if(typeof(!obj||obj[fn])!="function"){throw new Error(fn+" is an invalid method!");}
	var t=new BlazeThread(obj,fn,args);
	return window.setTimeout('window.blaze.threads["'+t.id+'"].run();',sleep);
}

Blaze.prototype.getObject=function(name,i){
	var o=null;
	if(i==null){i=0;}
	if(navigator.appName.indexOf("Microsoft")!=-1){
		o=window[name]
	}else{
		o=document[name]
	}
	if(!o&&i<50){blaze.setTimeout(this,"getObject",[name,i+1],100);}
	return o;
}

Blaze.prototype.redirectWrite=function(reverse){
	if(reverse){if(typeof(document.__write)=="function"){document.write=document.__write;}return;}
	document.__write=document.write;
	document.write=function(val){
		if(document.body&&val&&val.toLowerCase().indexOf("<script ")>-1){
			document.body.innerHTML+=val;
		}else{
			document.__write(val);
		}
	}
}

Blaze.prototype.correctPNG=function() {
	var ua=navigator.userAgent;
  if(!window.XMLHttpRequest&&ua.indexOf("MSIE")>0&&ua.indexOf("Opera")<0){
		var images=document.getElementsByTagName("IMG");
		for(var i=0;i<images.length;i++){
			var img=images[i];
			var src=img.src;
 			if (src.indexOf(".png")>0){
				var iID="";
				if(img.id){iID='id="'+img.id+'" ';}
				var iCls="img";
				if(img.className){iCls+=" "+img.className;}
				iCls='class="'+iCls+'" ';
				var iTtl = "";
				if(img.title){imgTtl='title="'+img.title+'" ';}else{'title="'+img.alt+'" ';}
				var iSty="padding:0px;margin:0;"+img.style.cssText+"display:inline-block;";
				var iAtrs=img.attributes;
				var iScm=img.getAttribute("scaleMethod");
				if(!iScm){iScm="scale";}

				for(var j=0;j<iAtrs.length;j++){
					var iAtr=iAtrs[j];
					if(iAtr.nodeName=="align"){
						if(iAtr.nodeValue=="left"){iSty="float:left;"+iSty;}
						if(iAtr.nodeValue=="right"){iSty="float:right;"+imgSty;}
					}
				}
 				var w=img.width;
				var h=img.height;
				if(w<1||h<1){
					var temp=document.body.appendChild(img.cloneNode());
					temp.style.display="block";
					w=temp.width;
					h=temp.height;
					document.body.removeChild(temp);
				}
				var o='<span '+iID+iCls+iTtl+' style="width:'+w+'px;height:'+h+'px;'+iSty+'filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\''+src+'\',sizingMethod=\''+iScm+'\');"></span>';
				img.outerHTML=o;
				i--;
			}
		}
	}
}

Blaze.prototype.isEmpty=function(val){
	if(val==null){return true;}
	if((val+"").trim()==""){return true;}
	return false;
}

BlazeThread=function(obj,fn,args){
	this.object=obj;
	if(!this.object){this.object=window;}
	if(typeof(fn)=="string"){fn=this.object[fn];}
	if(typeof(fn)!="function"){fn=null;}
	this.fn=fn;
	this.args=blaze.makeArray(args);
	this.index=blaze.threads.length;
	this.id="t_"+this.index;
	blaze.threads[this.id]=this;
}
BlazeThread.prototype.run=function(){
	if(typeof(this.fn)=="function"){
		if(!this.args){this.args=[];}
		return this.fn.apply(this.object,this.args);
	}
}
BlazeThread.prototype.clear=function(){
	if(this.index>-1){blaze.threads.splice(this.index,1);}
}

BlazePackage=function(name,parent){this.name=name;this.parent=parent;}
BlazePackage.prototype.toString=function(){return this.name;}

BlazeLoader=function(object,defer){
	this.defer=defer;
	this.parent=null;
	this.number=null;
	this.dependents=null;
	this.inProgress=0;
	this.object=object;
	this.completed=false;
	this.onsuccess=null;
	this.onfail=null;
	this.onstatuschange=null;
	this.timeout=0;
	this.isComplete=false;
}
BlazeLoader.timeout=5000;
BlazeLoader.pause=250;

BlazeLoader.prototype.add=function(thread){
	if(this.dependents==null){
		thread.number=0;
		this.dependents=new Array(0);
	} else {
		thread.number=this.dependents.length;
	}
	thread.parent=this;
	this.dependents[thread.number]=thread;
	this.inProgress++;
	return thread.number;
}

BlazeLoader.prototype.clear=function(thread,failed){
	if(thread.number==null){return;}
	if(thread.number>=this.dependents.length){return;}

	var completed=true;
	this.dependents[thread.number].completed=(!failed);

	this.inProgress--;
	if(typeof(this.onstatuschange)=="function"){this.onstatuschange(this.getStatus());}
	for(var i=0;i<this.dependents.length;i++){
		if(typeof(this.dependents[i])=="object"){
			if(this.dependents[i].completed==false){completed=false;}
		}
	}
	this.completed=completed;
	if(!this.defer&&completed){this.success();}
	if(this.inProgress<1){this.reset();}
}

BlazeLoader.prototype.getTimeout=function(){
	return (this.dependents.length*BlazeLoader.pause);
}

BlazeLoader.prototype.complete=function(){
	this.defer=false;
	if(this.completed||!this.hasDependents()){this.success();return true;}
	if(this.timeout>=this.getTimeout()){this.success();return false;}
	var p=BlazeLoader.pause;
	if(!p){p=250;}
	blaze.setTimeout(this,"complete",null,p);
	this.timeout+=p;
}

BlazeLoader.prototype.hasDependents=function(){
	return (this.dependents!=null&&this.dependents.length>0);
}

BlazeLoader.prototype.success=function(){
	if(this.isComplete){return;}
	this.isComplete=true;
	if(typeof(this.onsuccess)=="function"){this.onsuccess(this.object);}
	if(this.parent!=null&&this.number!=null){this.parent.clear(this,false);}
}

BlazeLoader.prototype.fail=function(){
	if(typeof(this.onfail)=="function"){this.onfail(this.object);}
	if(this.parent&&this.number){this.parent.clear(this,true);}
	this.completed=true;
}

BlazeLoader.prototype.reset=function(){
	this.dependents=null;
	this.inProgress=0;
}

BlazeLoader.prototype.getStatus=function(){
	var dn=this.dependents.length;
	if(dn<1){return 1;}
	if(this.inProgress<1){return 0;}
	return ((dn-this.inProgress)/dn);
}

BlazeImporter=function(onsuccess,onstatuschange){
	this.onsuccess=onsuccess;
	this.onstatuschange=onstatuschange;
	this.importing=[];
	this.loader=null;
	this.setHandlers();
}
BlazeImporter.prototype.setHandlers=function(){
	if(this.loader==null){
		this.loader=new BlazeLoader(null,true);
	}
	this.applyHandler("onsuccess");
	this.applyHandler("onstatuschange");
}
BlazeImporter.prototype.applyHandler=function(en){
	if(this.loader[en]!=this[en]){this.loader[en]=this[en];}
}
BlazeImporter.prototype.add=function(nm,url){
	if(!url){this.addClass(nm);return;}
	if(url.contains(".js")){this.addClass(nm,url);}else{this.addService(nm,url);}
}
BlazeImporter.prototype.addClass=function(nm,args,url){
	if(!blaze.classes[nm]&&!this.importing[nm]){
		this.setHandlers();
		this.importing[nm]=true;
		this.loader.add(blaze.useClass(nm,args,url));
	}
}
BlazeImporter.prototype.addService=function(nm,url){
	if(!blaze.services[nm]&&!this.importing[nm]){
		this.setHandlers();
		this.importing[nm]=true;
		this.loader.add(blaze.useService(nm,url));
	}
}

BlazeImporter.prototype.load=function(){
	this.loader.complete();
}

window.blaze=new Blaze();
window.registerNS=blaze.createPackage;
window["$"]=blaze.getElement;

SoapProxy=function(){
	this.isIE=false;this.isNS=true;
}

var soap=new SoapProxy();

SoapProxy.prototype.createEnvelope=function(namespace,method,names,values){
	var s='',val=null;
	s+='<?xml version="1.0" encoding="utf-8"?>';
	s+='<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns="'+ namespace +'">';
	s+='<soap:Body>';
	s+='<'+ method +'>';
	for(var i=0;i<names.length;i++) {
		s+='<'+ names[i] +'>'+ this.serialize(values[i]) +'</'+ names[i] +'>';
	}
	s+='</'+ method +'>';
	s+='</soap:Body>';
	s+='</soap:Envelope>';
	return s;
}

SoapProxy.prototype.secure=function(){return false;}

SoapProxy.prototype.getXml=function(url,post,action,callback,caller){
	var method="GET";
	var async=(callback!=null);
	if(post!=null){method="POST";}

	var req=this.createHttp();
	req.open(method,url,async);
	req.setRequestHeader("Content-Type","text/xml")
	if(action!=null&&action!=""){
		req.setRequestHeader("SOAPAction",action);
	}
	if(async){
		if(!caller){caller=this;}
		var handler=new SOAPHandler(req);
		this.addHandler(handler,"onload");
		this.addHandler(handler,"onfault");
		this.addHandler(handler,"onerror");
		
		req.onreadystatechange=function(){
			if(req&&(req.readyState==4||req.readyState=='complete')){
				if(req.status){
					callback(req,handler,caller);
				}else{
					throw new Error("Cannot contact the web service");
				}
			}
		}
	}
	req.send(post);
	if(async){
		return handler;
	}else{
		if(req.status==200){return req.responseXML;}
		return null;
	}
}

SoapProxy.prototype.addHandler=function(h,fn){
	if(typeof(blaze.services[fn])=="function"){h[fn]=blaze.services[fn];}
}

SoapProxy.prototype.createHttp=blaze.createHttp;

SoapProxy.prototype.loadXml=function(xmlString){
	var doc=null;
	try{
		if(document.ActiveXObject){
			this.isIE=true;this.isNS=false;
			doc=new ActiveXObject("Microsoft.XMLDOM");
			doc.loadXML(xmlString);
		}else{
			var parser=new DOMParser();
			doc=parser.parseFromString(xmlString,"text/xml");
		}
		return doc;
	}catch(ex){
		throw new Error("Cannot parse the web service feed");
	}
}
SoapProxy.prototype.selectSingleNode=function(parent,local,prefix){
	var a=this.selectNodes(parent,local,prefix);
	for(var i=0;i<a.length;i++){
		if(a[i].parentNode==parent){return a[i];}
	}
	return this.selectNode(parent,local,prefix,0);
}

SoapProxy.prototype.selectNode=function(parent,local,prefix,index){
	if(!parent){return null;}
	var a=this.selectNodes(parent,local,prefix);
	if(!index){index=0;}
	if(a&&a.length>index){return a[index];}
	return null;
}

SoapProxy.prototype.selectNodes=function(parent,local,prefix){
	if(!parent){return null;}
	var tn=local;if(prefix){tn=prefix+":"+local;}
	var t=parent.getElementsByTagName(tn);
	if(!t||t.length<1){t=parent.getElementsByTagName(local);}
	return t;
}

SoapProxy.prototype.isAncestorOf=function(parent,child){
	var p=child;
	while(p=p.parentNode){
		if(p==parent){return true;}
	}
	return false;
}

SoapProxy.prototype.getValue=function(node){
	if(node){
		if(node.firstChild){node=node.firstChild;}
		return node.nodeValue;
	}
	return null;
}

SoapProxy.prototype.getBody=function(doc,tag){
	if(!tag){tag="Body";}
	var node=this.selectSingleNode(doc,"Envelope","soap");
	if(node!=null){node=this.selectSingleNode(node,tag,"soap");}
	return node;
}

SoapProxy.prototype.getFault=function(doc){
	var node=this.getBody(doc);
	if(node!=null){return this.selectSingleNode(node,"Fault","soap");}
	return null;
}

SoapProxy.prototype.getNode=function(node,name,local){
	var parent=node;
	if(typeof(local)!="undefined"&&!local){parent=this.getBody(node);}
	if(!parent){parent=node;}
	return this.selectSingleNode(parent,name);
}

SoapProxy.prototype.prepare=function(response){
	var doc=response.responseXML;
	return doc;
}

SoapProxy.prototype.getArray=function(node,objType){
	var a=[];
	if(node!=null){
		for(var i=0;i<node.childNodes.length;i++){
			var child=node.childNodes[i];
			a[i]=this.convertType(child,objType);
		}
	}
	return a;
}

SoapProxy.prototype.isArray=function(objType){
	if(objType&&objType.toLowerCase&&objType.toLowerCase().indexOf("array")>-1){return true;}
	return false;
}

SoapProxy.prototype.hasChildElements=function(node){
	if(node==null){return false;}
	for(var i=0;i<node.childNodes.length;i++){
		if(node.childNodes[i].nodeType==1){return true;}
	}
	return false;
}

var __tempObject=null;
var __tempChildNode=null;

SoapProxy.prototype.convertType=function(node,objType){
	var val=null;
	if(this.hasChildElements(node)){
		if(this.isArray(objType)){
			val=this.getArray(node,node.firstChild.tagName);
		}else{
			__tempChildNode=node;
			var stmt="var __tempObject = new "+node.tagName+"(__tempChildNode);";
			try{window.eval(stmt);}catch(ex){}
			val=__tempObject;
		}
	}else{
		val=this.getValue(node);
		
		if(objType){
			var colon=objType.indexOf(":");
			if(colon>-1){objType=objType.substring(colon+1);}
			objType=objType.toLowerCase();
		}
		switch(objType) {
			case "int":
				try{val=new Number(val);}catch(ex){}break;
			case "float":
				try{val=new Number(val);}catch(ex){}break;
			case "date":
				try{val=this.createDate(val);}catch(ex){}break;
			case "datetime":
				try{val=this.createDate(val);}catch(ex){}break;
			case "boolean":
				if(val.toLowerCase()=="true"){
					val=true;
				}else{
					val=false;
				}
				break;
		}
	}
	return val;
}
	
SoapProxy.prototype.serialize=function(obj){
	var o='';var isObj=false;
	try{if(obj.__keys.length>0){isObj=true;}}catch(ex){}
	if(isObj){
		for(var i=0;i<obj.__keys.length;i++){
			var key=obj.__keys[i];
			o+='<'+key+'>'+this.serialize(obj[key])+'</'+key+'>';
		}
		return o;
	}
	if(obj!=null){
		if(this.isDate(obj)){return this.formatDate(obj);}
		return obj+"";
	}else{return"";}
}

SoapProxy.prototype.isDate=function(dt){
	return (typeof(dt.getTime)=="function");
}

SoapProxy.prototype.createDate=function(str){
	if(!str){return null;}
	if(str.length<10){return null;}
	var dt=str.substring(5,7)+"/"+str.substring(8,10)+"/"+str.substring(0,4);
	if(str.length>=19){
		dt+=" "+str.substring(11,13)+":"+str.substring(14,16)+":"+str.substring(17,19);
	}
	var dt=new Date(dt);
	return dt;
}

SoapProxy.prototype.formatDate=function(dt){
	var o="";
	var y=dt.getFullYear();
	var m=dt.getMonth()+1;if(m<10){m="0"+m;}
	var d=dt.getDate();if(d<10){d="0"+d;}
	var h=dt.getHours();if(h<10){h="0"+h;}
	var n=dt.getMinutes();if(n<10){n="0"+n;}
	var s=dt.getSeconds();if(s<10){s="0"+s;}
	return y+"-"+m+"-"+d+"T"+h+":"+n+":"+s;
}

SoapProxy.prototype.init=function(obj,node,keys,types){
	obj.__keys=keys;
	for(var i=0;i<keys.length;i++){
		obj[keys[i]]=null;
		if(node){
			var t=null;
			var el=soap.getNode(node,keys[i],true);
			if(types&&types.length>i){t=types[i];}
			if(el){obj[keys[i]]=soap.convertType(el,t);}
		}
	}
}

SoapProxy.prototype.extend=function(tgt,src){
	for(var a in src){tgt[a]=src[a];}
}

SoapProxy.prototype.createCallback=function(response,handler){
	var fault=new SOAPFault(response);
	if(fault.hasFault){
		handler.onfault(fault);return null;
	}else{
		if(response.status!=200){
			handler.onerror(response);return null;
		}
		try {
			return soap.prepare(response);
		} catch(ex){
			handler.onerror(response,ex);return null;
		}
	}
}

function SOAPHandler(object){
	this.object=object;
	this.onload=function(object){}
	this.onfault=function(fault){}
	this.onerror=function(response,exception){
		if(exception){throw exception;}
	}
}

function SOAPFault(response){
	this.faultCode=null;
	this.faultString=null;
	this.faultActor=null;
	this.detail=null;
	this.hasFault=false;
	this.xml=null;
	this.doc=null;
	if(response){
		if(response.status!=200||response.responseText.toLowerCase().indexOf("fault")>0){
			this.xml=response.responseText;
			this.doc=response.responseXML;
			if(this.doc){
				var fault=soap.getFault(this.doc);
				if(fault) {
					this.faultCode=soap.getValue(soap.getNode(fault,"faultcode"));
					this.faultString=soap.getValue(soap.getNode(fault,"faultstring"));
					this.faultActor=soap.getValue(soap.getNode(fault,"faultactor"));
					this.detail=soap.getValue(soap.getNode(fault,"detail"));
					this.hasFault=true;
				}
			}
		}
	}
}

SOAPFault.prototype.toString=function(){return this.xml;}