
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,'')");
String.prototype.nocr=new Function("return this.replace(/(\\r\\n|[\\r\\n])/g,'')");
String.prototype.makeplain=new Function("return this.toLowerCase().replace(/\\s/g,'_')");
String.prototype.startsWith=function(str) {return (this.match("^"+str)==str); }
String.prototype.endsWith=function(s) {	return(new RegExp(s+"$")).test(this); }

function mOv(id) { setImg(id,'img/btn/'+id+'o.gif'); }
function mOut(id) { setImg(id,'img/btn/'+id+'.gif'); }

function mOvI(id,img) { setImg(id,'img/btn/'+img+'o.gif'); }
function mOutI(id,img) { setImg(id,'img/btn/'+img+'.gif'); }

function imOv(ele) { ele.style.backgroundImage=ele.style.backgroundImage.replace(/\./,'o.'); }
function imOut(ele) { ele.style.backgroundImage=ele.style.backgroundImage.replace(/o\./,'.'); }

function styleOn(id,cls) {
	var o=getElement(id);
	if (o!=null) {
		if (o.className=='') o.className=cls;
		else if (o.className.indexOf(' '+cls)==-1) o.className+=' '+cls;
	}
}
function styleOff(id,cls) {
	var o=getElement(id);
	if (o!=null) {
		if (o.className==cls) o.className='';
		else if (o.className.startsWith(cls)) o.className=o.className.substring(cls.length);
		else if (o.className.indexOf(' '+cls)!=-1) o.className=o.className.replace(' '+cls,'');
	}
}

var od_tid=null;
var od_id=null;
function odOv(id) {
	od_id=id;
	showod_tid=setTimeout(doShowOD,400);
}
function odOut(id) {
	if (showod_tid!=null) clearTimeout(showod_tid);
	closeEle(id);
}
function doShowOD() {
	if (od_id!=null) {
		clearTimeout(showod_tid);
		openEle(od_id);

		showod_tid=null;
		od_id=null;
	}
}

function getImage(id) {
	if (document.images && document.images[id])
		return document.images[id];
	else
		return null;
}
function setImg(id,src) {
	if (src!=null) {
		var img=getImage(id);
		if (img) img.src=src;
	}
}
function getElement(sName) {
	return document.getElementById(sName);
}
function show(sID) {
	var o=getElement(sID);
	if (o) o.style.visibility="visible";
}
function hide(sID) {
	var o=getElement(sID);
	if (o) o.style.visibility="hidden";
}
function openEle(sID) {
	var o=getElement(sID);
	if (o) o.style.display="block";
}
function closeEle(sID) {
	var o=getElement(sID);
	if (o) o.style.display="none";
}
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 popRadio(url) {
	var w = window.open("","_new","width=416,height=333,scrollbars=no");
	w.location.href=fixURL(url);
	w.focus();
}
function isInteger(sName) {
	var sVal=getElement(sName).value;
	var re=/(^\d+$)/;
	return (re.test(sVal));
}
function isValidEmail(email) {
	var reg = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/i;
	return reg.test(email);
}
function isDate(dd,mm,yyyy) {
	var bValid=false;
	if (dd.length<=2 && mm.length<=2 && yyyy.length<=4) {
		if (calcAge(dd,mm,yyyy)<120) {
			mm=(1*mm)-1;
			var dateTest=new Date(yyyy,mm,dd);
			if (dateTest.getDate()==dd && dateTest.getMonth()==mm && dateTest.getFullYear()==yyyy)
				bValid=true;
		}
	}
	return bValid;
}
function calcAge(dd,mm,yyyy) {
	var bdd=parseInt(dd);
	var bmm=parseInt(mm);
	var byyyy=parseInt(yyyy);
	var now = new Date();
	var ndd=now.getDate();
	var nmm=now.getMonth()+1;
	var nyyyy=now.getFullYear();

	if (nmm>bmm || (nmm==bmm && ndd>=bdd))
		return nyyyy-byyyy;
	else
		return nyyyy-byyyy-1;
}
function loadJS(jsfile) {
	var script=document.createElement('script');
	script.setAttribute('type','text/javascript');
	script.setAttribute('src',jsfile);

	var head=document.getElementsByTagName('head')[0];
	head.appendChild(script);
}
function setLanguage(s) {
	makeCookie('language',s,365,'/','',false);
	window.location.reload();
}
function setCookie(sIn) {
    document.cookie='wrc='+sIn;
}
function makeCookie(Name,Value,Expiry,Path,Domain,Secure) {
	if (Expiry != null && !isNaN(Expiry)) {
		var datenow = new Date();
		datenow.setTime(datenow.getTime() + Math.round(86400000*Expiry));
		Expiry = datenow.toGMTString();
	}
	Expiry = (Expiry) ? '; expires='+Expiry : '';
	Path = (Path)?'; path='+Path:'';
	Domain = (Domain) ? '; domain='+Domain : '';
	Secure = (Secure) ? '; secure' : '';

	document.cookie = Name + '=' + escape(Value) + Expiry + Path + Domain + Secure;
}
function readCookie(Name) {
	var cookies = ' ' + document.cookie;
	if (cookies.indexOf(' ' + Name + '=') == -1) return null;

	var start = cookies.indexOf(' ' + Name + '=') + (Name.length + 2);
	var finish = cookies.substring(start,cookies.length);
	finish = (finish.indexOf(';') == -1) ? cookies.length : start + finish.indexOf(';');

	return unescape(cookies.substring(start,finish));
} 
function formatHMS(ms) {
	var sTemp="";
	var sPM=(ms<0?"-":"+");
	var timeleft=Math.abs(ms);
	var h=Math.floor(timeleft/1000/60/60);
	timeleft=timeleft-h*1000*60*60;
	var m=Math.floor(timeleft/1000/60);
	timeleft=timeleft-m*1000*60;
	var s=Math.floor(timeleft/1000);
	timeleft=timeleft-s*1000;
	var milli="."+(timeleft+"").substring(0,1);
	if (h>0) sTemp=sPM+h+":"+format00(m+"")+":"+format00(s+"")+milli;
	else if (m>0) sTemp=sPM+m+":"+format00(s+"")+milli;
	else sTemp=sPM+s+milli;
	return sTemp;
}
function format00(sIn) {
	var sTemp="00"+sIn;
	return (sTemp.substring(sTemp.length-2,sTemp.length));
}
function goURL(sURL) {
	location.replace(fixURL(sURL));
}
function fixURL(sURL) {
	var b=document.getElementsByTagName('base');
	if (b && b[0] && b[0].href) {
		if (b[0].href.substr(b[0].href.length-1)=='/' && sURL.charAt(0)=='/') sURL=sURL.substr(1);
		sURL=b[0].href+sURL;
	}
	return sURL;
}
function GetBrowser() {
   var agt=navigator.userAgent.toLowerCase();
   if (((agt.indexOf("msie")!=-1) && (agt.indexOf("opera")==-1)))
       return "IE";
   else if (((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1) && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1) && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1)))
       return "Netscape";
   else
       return "unknown";
}
function GetPlayerMajorVer(sIn) {
	var strVer=new String(sIn);
	s=strVer.split(".");
	return s[0];
}
function embedAudio(sPath,w,h,bStart) {
	var br=GetBrowser();
	if (br=="Netscape") {
		document.write("<div class=\"audio\"><embed name=\"vid\" type=\"video/x-ms-asf-plugin\" src=\""+sPath+"\" width=\""+w+"\" height=\""+h+"\" showcontrols=\"1\" autostart=\""+bStart+"\" animationstart=\"1\" autorewind=\"0\" autosize=\"0\" showdisplay=\"0\" showstatusbar=\"1\" sendopenstatechangeevents=\"true\" transparentatstart=\"true\" pluginspage=\"http://www.microsoft.com/Windows/MediaPlayer/\"></embed></div>");
	}
	else {
		document.write("<div class=\"audio\"><object id=\"player\" classid=\"CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6\" width=\""+w+"\" height=\""+h+"\"><param name=\"autoStart\" value=\""+bStart+"\"><param name=\"URL\" value=\""+sPath+"\"><param name=\"uiMode\" value=\"full\"><param name=\"stretchToFit\" value=\"false\"><embed name=\"player\" type=\"video/x-ms-asf-plugin\" src=\""+sPath+"\" width=\""+w+"\" height=\""+h+"\" showcontrols=\"1\" autostart=\""+bStart+"\" animationstart=\"1\" autorewind=\"0\" autosize=\"0\" showdisplay=\"0\" showstatusbar=\"1\" sendopenstatechangeevents=\"true\" transparentatstart=\"true\" pluginspage=\"http://www.microsoft.com/Windows/MediaPlayer/\"></embed></object></div>");
		if (GetPlayerMajorVer(player.versionInfo)!=11 && GetPlayerMajorVer(player.versionInfo)!=10)
			document.write("<p>You do not have the latest version of Windows Media Player. <a href=\"http://www.microsoft.com/windows/windowsmedia/download/alldownloads.aspx\" target=\"_blank\">Please visit Microsoft.com to download it</a>.</p>");
	}
}
function doLoad() {
	if (typeof(goMovieOnLoad)=='function') goMovieOnLoad();
	if (typeof(goPageOnLoad)=='function') goPageOnLoad();
	if (typeof(loadBg)=='function') loadBg();
	if (typeof(goPopRallyRadio)=='function') goPopRallyRadio();
}
function doUnload() {

}
