var AjaxData = "";

function fncNavTo(Link,Delay){setTimeout("window.location.href='"+Link+"'",Delay);}
function fncPostTo(Link,Delay){document.form1.action=Link;setTimeout("document.form1.submit()",Delay);}
function fncDisplay(obj,str){eval("document.getElementById('"+obj+"').style.display="+str+";");}
function fncFocus(obj,delay){setTimeout("document.form1."+obj+".focus();",delay);}
function fncInnerHTML(obj,str){eval("obj=document.getElementById('"+obj+"')");obj.innerHTML=str;}
function fncGetValue(obj){eval("obj=document.form1."+obj);return obj.value;}
function fncValue(obj,value){eval("obj=document.form1."+obj);obj.value=value;}
function fncClassName(obj,str){eval("document.getElementById('"+obj+"').className='"+str+"';");}
function fncDisplay(obj,str){eval("document.getElementById('"+obj+"').style.display='"+str+"';");}
function fncSetStyle(obj,str1,str2){eval("document.getElementById('"+obj+"').style."+str1+"='"+str2+"';");}
function fncLeft(str, n){if (n <= 0)return "";else if (n > String(str).length)return str;else return String(str).substring(0,n);}
function fncRight(str, n){if (n <= 0)return "";else if (n > String(str).length)return str;else {var iLen = String(str).length;return String(str).substring(iLen, iLen - n);}}
function fncDisabled(obj,str){eval("obj=document.form1."+obj);obj.disabled=str;}
function fncRandomOrder(){return (Math.round(Math.random())-0.5);}
function fncSelectedIndex(obj,int){eval("obj=document.form1."+obj);obj.selectedIndex=int;}

var rimPath=null;var rjsPath=null;var rPath2Root=null;function InitRelCode(){var iImg;var jImg;var tObj;if(!document.layers){iImg=document.images['dmbif'];jImg=document.images['dmbjs'];tObj=jImg;}else{tObj=document.layers['dmbri'];if(tObj){iImg=tObj.document.images['dmbif'];jImg=tObj.document.images['dmbjs'];}}if(!tObj){window.setTimeout("InitRelCode()",700);return false;}rimPath=_gp(iImg.src);rjsPath=_gp(jImg.src);rPath2Root=rjsPath+"../";return true;}function _purl(u){return xrep(xrep(u,"%%REP%%",rPath2Root),"\\","/");}function _fip(img){if(img.src.indexOf("%%REL%%")!=-1) img.src=rimPath+img.src.split("%%REL%%")[1];return img.src;}function _gp(p){return p.substr(0,p.lastIndexOf("/")+1);}function xrep(s,f,n){if(s) s=s.split(f).join(n);return s;}InitRelCode();
function LoadMenus() {if(!rjsPath){window.setTimeout("LoadMenus()", 10);return false;}var navVer = navigator.appVersion;
if(navVer.substr(0,3) >= 4)
if((navigator.appName=="Netscape") && (parseInt(navigator.appVersion)==4)) {
document.write('<' + 'script language="javascript" type="text/javascript" src="' + rjsPath + 'nsmenu.js"><\/script\>');
} else {
document.write('<' + 'script language="javascript" type="text/javascript" src="' + rjsPath + 'iemenu.js"><\/script\>');
}return true;}LoadMenus();


function fncBaseURL() {
    var url = location.href;  // entire url including querystring - also: window.location.href;
    var baseURL = url.substring(0, url.indexOf('/', 14));
    if (baseURL.indexOf('http://localhost') != -1) {
        // Base Url for localhost
        var url = location.href;  // window.location.href;
        var pathname = location.pathname;  // window.location.pathname;
        var index1 = url.indexOf(pathname);
        var index2 = url.indexOf("/", index1 + 1);
        var baseLocalUrl = url.substr(0, index2);
        return baseLocalUrl + "/";
    }
    else {
        // Root Url for domain name
        return baseURL + "/";
    }
}

function fncDoAjax(Page,CallBackFunction){
	AjaxData = "";
	var xmlhttp=null;
	if (window.XMLHttpRequest){xmlhttp=new XMLHttpRequest();}
	else if (window.ActiveXObject){xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");}
	else{alert("Your browser does not support XMLHTTP!");return;}
	xmlhttp.onreadystatechange=function() {
	if (xmlhttp.readyState==4) {
		AjaxData = xmlhttp.responseText;
		if(CallBackFunction != ""){eval(CallBackFunction);return;}
	}}
	xmlhttp.open("GET", Page, true);
	xmlhttp.send(null);
}
function fncDoSjax(Page){
	AjaxData = "";
	var xmlhttp=null;
	if (window.XMLHttpRequest){xmlhttp=new XMLHttpRequest();}
	else if (window.ActiveXObject){xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");}
	else{alert("Your browser does not support XMLHTTP!");return;}
	if (xmlhttp){
		xmlhttp.open("GET", Page, false);
		xmlhttp.send(null);
		return xmlhttp.responseText; 
	}else{
		return false;
	}
}

function fncValidateTextAllowed(ElementName,UIName,IsOptional,MinCharacters,GoodCharacters){
	eval("var FormElement=document.form1."+ElementName+";");
	var Value = FormElement.value;
	if (IsOptional == 1 && FormElement.value == "") {return true;}
	if (IsOptional == 0 && FormElement.value == "") {alert(UIName+" is not optional. Please input a value.");FormElement.focus();return false;}
	if (Value.length < MinCharacters) {alert(UIName+" requires a minimum of "+MinCharacters+" characters.");FormElement.focus();return false;}
	if (GoodCharacters == ""){return true;}
	var IsValidated=true;
	for (i = 0; i < Value.length && IsValidated == true; i++) { 
		Char = Value.charAt(i).toUpperCase();
		if (GoodCharacters.indexOf(Char) < 0) {alert(UIName+" contains prohibited characters.");FormElement.focus();return false;}
	}
	return true;
}
function fncValidateEmail(ElementName,UIName,IsOptional) {
	eval("var FormElement=document.form1."+ElementName+";");
	if(IsOptional == 0 && FormElement.value == ""){
		alert(UIName+' is not optional.');
		FormElement.focus();
		return false;
	}
	if(IsOptional == 1 && FormElement.value == "") return true;
	var filter =/^\w+[\+\.\w-]*@([\w-]+\.)*\w+[\w-]*\.([a-z]{2,4}|\d+)$/;
	if (!filter.test(FormElement.value)) {
		alert(UIName+' is invalid. Please provide a proper email address.');
		FormElement.focus();
		return false;
	}
	return true;
}
function fncValidateURL(ElementName,UIName,IsOptional) {
	eval("obj=document.form1."+ElementName);	
	if (IsOptional == 1 && obj.value == "") {return true;}
	if (IsOptional == 0 && obj.value == "") {alert(UIName+" is not optional. Please input an URL.");FormElement.focus();return false;}
	var filter = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/
	if (!filter.test(obj.value)) {
		alert('Please provide a valid URL.');
		obj.focus();
		return false;
	}
	return true;
}

function fncLogThis(i,id){
	sql = "update public_cms set clicks = clicks%2B1 where id = "+id+";"
	if(i == 1) fncDoAjax("_scripts/asp/ajax.asp?function=exsql&sql="+sql,"");
	if(i == 2) fncDoAjax("../_scripts/asp/ajax.asp?function=exsql&sql="+sql,"");
}




