String.prototype.trim=new Function("return this.replace(/^\\s+|\\s+$/g,'')");
String.prototype.nocr=new Function("return this.replace(/(\\r\\n|[\\r\\n])/g,'')");


function rollover(sName) {
	ele=document.getElementById(sName);
	if (ele !=null){
		ele.style.backgroundImage = "url('img/nav/navbg.gif')";
	}
}
function rollout(sName) {
	ele=document.getElementById(sName);

	if (ele !=null){
		ele.style.backgroundImage = "";
	}
}
function srollover(sName) {
	ele=document.getElementById(sName);
	if (ele !=null){
		ele.style.backgroundImage = "url('img/nav/snavbg.gif')";
	}
}
function srollout(sName) {
	ele=document.getElementById(sName);

	if (ele !=null){
		ele.style.backgroundImage = "";
	}
}

function getImage(id) {
	if (document.images && document.images[id])
		return document.images[id];
	else
		return null;
}
function setImg(id,i,src) {
	if (src!=null) {
		var img=getImage(id+i);
		if (img) img.src=src;
	}
}
function getElement(sName) {
	return document.getElementById(sName);
}
function popWindow(w,h) {
	var wclwin=window.open("","wclwin","toolbar=no,location=no,directories=no,margin=0,status=no,menubar=no,scrollbars=yes,resizable=no,width="+w+",height="+h);
	wclwin.focus();
}
function doPrint(){
		window.print();
	}
function isInteger(sName) {
	var sVal=getElement(sName).value;
	var re=/(^\d+$)/;
	return (re.test(sVal));
}
function isNumber(sName) {
	var sVal=getElement(sName).value;
	if (sVal.indexOf('.')!=sVal.lastIndexOf('.'))return false;
	var re=/(^\d.+$)/;
	return (re.test(sVal));
}
String.prototype.ltrim=new Function("return this.replace(/^\\s+/,'')");
String.prototype.rtrim=new Function("return this.replace(/\\s+$/,'')");
String.prototype.trim=new Function("return this.replace(/^\\s+|\\s+$/g,'')");
function makeElink(user,host,domain) {
	
	var atsign = "&#64;";
	var addr = user + atsign + host + domain;
	document.write("<" + "a" + " " + "href=" + "mail" + "to:" + addr + ">" + addr + "<\/a>");
}
function extractXML(sXML,sTag) {
	var iFrom=sXML.indexOf("<"+sTag+">");
	var iTo=sXML.indexOf("</"+sTag+">",iFrom);
	return (iFrom!=-1 && iTo!=-1 ? sXML.substring(iFrom+(sTag.length+2),iTo) : "");
}

function cacheBust(sURL) {
	return sURL+(sURL.indexOf('?')==-1 ? '?' : '&')+'cbzz='+(new Date()).getTime();
}
function Fetcher() {
	var me=this;
	this.fnCB=null;
	this.xmlHttp=null;
	try { this.xmlHttp=new XMLHttpRequest(); }
	catch (trymicrosoft) {
	

		try { this.xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); }
		catch (othermicrosoft) {
			try { this.xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); }
			catch (failed) {
				this.xmlHttp=null;
				alert('fail');
			}  
		}
	}
	this.now=function(sURL) {		

		var sRet="";
		if (this.xmlHttp) {
			this.xmlHttp.open("GET",cacheBust(sURL),false);
			this.xmlHttp.send(null);
  			if (this.xmlHttp.readyState==4)
				sRet=this.xmlHttp.responseText.nocr().trim();
		}
		return sRet;
	}	
	this.whenever=function(sURL,fnCB) {
		
		if (this.xmlHttp) {
			this.fnCB=fnCB;
			this.xmlHttp.open("GET",cacheBust(sURL),true);
			this.xmlHttp.onreadystatechange=this.loader;
			this.xmlHttp.send(null);
		}
	}
	this.loader=function() {
		if (me.xmlHttp) {
			if (me.xmlHttp.readyState==4 && me.xmlHttp.status==200) {
				me.fnCB(me.xmlHttp.responseText.nocr().trim());
			}
		}
	}
	this.abortme=function() {
		if (me.xmlHttp) {
			if (me.xmlHttp.readyState!=4 && me.xmlHttp.readyState!=0) {
				me.abort();
			}
		}
	}
	
}
