var dynamicFileLoadTracker="";
var ajaxTrueLock=false;

function toEscape(str) {
	str=str.replace(/\&/g,']|-a-|[');
	str=str.replace(/\+/g,']|-u-|[');
	return str;
}
function urlEscape(str) {
	str=str.replace(/#/g,']-p-[');
	str=str.replace(/%/g,']-m-[');
	str=str.replace(/\?/g,']-q-[');
	str=str.replace(/\&/g,']-a-[');
	str=str.replace(/\//g,']-s-[');
	str=str.replace(/\+/g,']-u-[');
	str=str.replace(/\s/g,']-c-[');
	str=str.replace(/\"/g,']-d-[');
	str=str.replace(/\'/g,']-i-[');
	return str;
}
function lockAjax(time) { // time: 0 = no unlock, undefined = default 1500
	ajaxTrueLock=true;
	if (typeof (time)!=="undefined") {
		if (time!=0) setTimeout("ajaxTrueLock=false;",time);
	} else setTimeout("ajaxTrueLock=false;",1500);
}
function startRequest(filePath,params,fn,arg1,arg2,arg3,arg4,arg5) {
	var xmlhttp;
	if (window.XMLHttpRequest) {
		xmlhttp=new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	} else {
		alert("Your Browser Does Not Support XMLHTTP!");
	}
	filePath+="?timeStamp="+new Date().getTime();
	xmlhttp.open("POST", filePath, true);
	xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlhttp.setRequestHeader("Content-length", params.length);
	xmlhttp.setRequestHeader("Connection", "close");
	xmlhttp.send(params);
	xmlhttp.onreadystatechange=function() {
		if (xmlhttp.readyState==4 && xmlhttp.status==200) {	
			if (typeof(fn)!='undefined') eval(fn);
		}
	}
}
function dynamicJsCssLoader(filePath, fileType, callback, debug) {		
	callback=(typeof callback == 'function')?callback:0;
	if (dynamicFileLoadTracker.indexOf("["+filePath+"]")==-1) {	
		debug=debug || ((!isNaN(callback))?callback:0);		
		if (fileType=="js") {			
			var fileref=document.createElement('script')
			fileref.setAttribute("type","text/javascript")
			if (typeof(debug)!="undefined" && debug==1) fileref.setAttribute("src", filePath+"?"+Math.floor(Math.random()*1001))
			else fileref.setAttribute("src", filePath)
			if (callback) {			
				// Firefox,chrome,safari, Opera...
				fileref.onload=function() {
					callback.call();					
				};
				// IE
				fileref.onreadystatechange=function() {
					if (this.readyState === 'loaded' || this.readyState === 'complete') {
						callback.call();
					}
				}
	  		}
		}
		else if (fileType=="css"){
			var fileref=document.createElement("link")
			fileref.setAttribute("rel", "stylesheet")
			fileref.setAttribute("type", "text/css")
			if (typeof(debug)!="undefined" && debug==1) fileref.setAttribute("href", filePath+"?"+Math.floor(Math.random()*1001))
			else fileref.setAttribute("href", filePath)
		}
		if (typeof fileref!="undefined")
			document.getElementsByTagName("head")[0].appendChild(fileref)
		dynamicFileLoadTracker+="["+filePath+"]";
	} else {
		if (callback) callback.call();		
	}
}
function preloader(iPath) {
	if (iPath=="/img/menu_popup.png") iPath="http://fs.lifeplat.com/img/menu_popup.png";
	img=new Image(); 
	img.src=iPath;
}
function showLoading(divId) {
	document.getElementById(divId).innerHTML="<table style='height:100%;' align='center'><tr><td><div style='height:100px;width:120px;background-image:url(/img/loading.gif);'></div></td></tr></table>";
}