﻿// JScript File

function getElementByIdCrossBrowser(the_id) {
if (typeof the_id != 'string') {
return the_id;
}

if (typeof document.getElementById != 'undefined') {
return document.getElementById(the_id);
} else if (typeof document.all != 'undefined') {
return document.all[the_id];
} else if (typeof document.layers != 'undefined') {
return document.layers[the_id];
} else {
return null;
}
}


function getElementByIdCrossBrowserParent(the_id) {
if (typeof the_id != 'string') {
return the_id;
}

if (typeof parent.document.getElementById != 'undefined') {
return parent.document.getElementById(the_id);
} else if (typeof parent.document.all != 'undefined') {
return parent.document.all[the_id];
} else if (typeof parent.document.layers != 'undefined') {
return parent.document.layers[the_id];
} else {
return null;
}
}


function fireEvent(obj,evt){
	
	var fireOnThis = obj;
	if( document.createEvent ) {
	  var evObj = document.createEvent('MouseEvents');
	  evObj.initEvent( evt, true, false );
	  fireOnThis.dispatchEvent(evObj);
	} else if( document.createEventObject ) {
	  fireOnThis.fireEvent('on'+evt);
	}
}


 
 function firefoxOnBlurFix(fldID)
 {
  //this.focus();
  setTimeout("document.getElementById('"+fldID+"').focus();",1);
  //setTimeout("document.getElementById('"+fldID+"').select();",1);

 }
 		function formatFieldName(cFieldName) {
 		var upr = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890'
 		if (cFieldName.substring(0,1)=='i'||cFieldName.substring(0,1)=='c'||cFieldName.substring(0,1)=='b'){
 			cFieldName = cFieldName.substring(1);
 		}
 		if (cFieldName.substring(0,3)=='dte'){
 			cFieldName = cFieldName.substring(3);
 		}
 		var cFieldNameOut = '';
 		for (i=0; i<cFieldName.length;i++){
 			if (upr.indexOf(cFieldName.charAt(i),0) != -1){
 				cFieldNameOut += ' ' + cFieldName.charAt(i),0;
 			}
 			else {
 				cFieldNameOut += cFieldName.charAt(i),0;
 			}
 		}
 		return cFieldNameOut
 		}
 		
 		
 		function checkEmail(theField) {
       if (theField==''){return (true);}
 		if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(theField)){
 		return (true)
 		}
 		window.alert("Invalid E-mail Address! Please re-enter with the following format: name@domain.com")
 		return (false)
 		}
 		
 			
 		function checkIsNumeric(theField) {
        if (IsNumeric(theField)){return (true);}
        else{
 		window.alert("Invalid entry! Please re-enter with only numbers.")
 		return (false)
 		}
 		}




 		
 		

function showCharCodes (stringIn) {
	//var string = form.textfield.value;
	var str = '';
	for (i = 0; i < stringIn.length; i++) {
		str = str + '&#' + stringIn.charCodeAt(i) + ';';
	}
	//form.textfield2.value = str;
	//form.textfield3.value = myUrlEncode(string);
	
	return str;
}

function myUrlEncode(str) {
	var result = "";
	var i = 0;

	for (i=0; i < str.length; i++) {
		result = result + "%";
		result = result + "0123456789ABCDEF".charAt((str.charCodeAt(i)/16)&0x0F);
		result = result + "0123456789ABCDEF".charAt((str.charCodeAt(i)/1)&0x0F);
	}
	return result;
}










/**
 * Gets the real scroll top
 */
function getScrollTop() {
	if (self.pageYOffset) // all except Explorer
	{
		return self.pageYOffset;
	}
	else if (document.documentElement && document.documentElement.scrollTop)
		// Explorer 6 Strict
	{
		return document.documentElement.scrollTop;
	}
	else if (document.body) // all other Explorers
	{
		return document.body.scrollTop;
	}
}
function getScrollLeft() {
	if (self.pageXOffset) // all except Explorer
	{
		return self.pageXOffset;
	}
	else if (document.documentElement && document.documentElement.scrollLeft)
		// Explorer 6 Strict
	{
		return document.documentElement.scrollLeft;
	}
	else if (document.body) // all other Explorers
	{
		return document.body.scrollLeft;
	}
}


 
function CreateBookmarkLink(title,url) { 
    if (window.sidebar) { // Mozilla Firefox Bookmark		
        window.sidebar.addPanel(title, url,"");	
    } 
    else if( window.external ) { 
    // IE Favorite		
        window.external.AddFavorite( url, title); 
    }	
    else if(window.opera && window.print) { 
    // Opera Hotlist		
    return true; 
    } 
} 



function getURLParam( name ){  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");  var regexS = "[\\?&]"+name+"=([^&#]*)";  var regex = new RegExp( regexS );  var results = regex.exec( window.location.href );  if( results == null )    return "";  else    return results[1];}




//maxL=700;
var bName = navigator.appName;
function taLimit(taObj,maxL) {
	if (taObj.value.length>=maxL) 
	{
	    taObj.value = taObj.value.substring(0, maxL);
	    return false;
	
	}
	else
	{
	    return true;
	}
}
function taCount(taObj,Cnt,maxL) { 
	objCnt=getElementByIdCrossBrowser(Cnt);
	objVal=taObj.value;
	if (objVal.length>maxL) objVal=objVal.substring(0,maxL);
	if (objCnt) {
		if(bName == "Netscape"){	
			objCnt.textContent=maxL-objVal.length;}
		else{objCnt.innerText=maxL-objVal.length;}
	}
	return true;
}
//function createObject(objId) {
//	if (document.getElementById) return document.getElementById(objId);
//	else if (document.layers) return eval("document." + objId);
//	else if (document.all) return eval("document.all." + objId);
//	else return eval("document." + objId);
//}



function textCounter(field,cntfield,maxlimit) {
    
    var cntfieldObj = getElementByIdCrossBrowser(cntfield);
    
    if (field.value.length > maxlimit) // if too long...trim it!
    field.value = field.value.substring(0, maxlimit);
    // otherwise, update 'characters left' counter
    else
    cntfieldObj.innerText = maxlimit - field.value.length;
}



function changeAction(url) {
    document.Form1.action = url;
}















// JScript File - Menu Begin

var cssdropdown={
disappeardelay: 250, //set delay in miliseconds before menu disappears onmouseout
disablemenuclick: false, //when user clicks on a menu item with a drop down menu, disable menu item's link?
enableswipe: 1, //enable swipe effect? 1 for yes, 0 for no

//No need to edit beyond here////////////////////////
dropmenuobj: null, ie: document.getElementById, firefox: document.getElementById&&!document.all, swipetimer: undefined, bottomclip:0,

getposOffset:function(what, offsettype)
{
 var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
 var parentEl=what.offsetParent;
 while (parentEl!=null)
 {
  totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
  parentEl=parentEl.offsetParent;
 }
 return totaloffset;
},

swipeeffect:function()
{
 if (this.bottomclip<parseInt(this.dropmenuobj.offsetHeight))
 {
  this.bottomclip+=10+(this.bottomclip/10) //unclip drop down menu visibility gradually
  this.dropmenuobj.style.clip="rect(0 auto "+this.bottomclip+"px 0)"
 }
 else
  return
  this.swipetimer=setTimeout("cssdropdown.swipeeffect()", 10)
},

showhide:function(obj, e)
{
 if (this.ie || this.firefox)
 this.dropmenuobj.style.left=this.dropmenuobj.style.top="-500px"
 if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover")
 {
  if (this.enableswipe==1)
  {
   if (typeof this.swipetimer!="undefined")
    clearTimeout(this.swipetimer)
   obj.clip="rect(0 auto 0 0)" //hide menu via clipping
   this.bottomclip=0
   this.swipeeffect()
  }
 obj.visibility="visible"
 }
 else if (e.type=="click")
  obj.visibility="hidden"
},

iecompattest:function(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
},

clearbrowseredge:function(obj, whichedge)
{
 var edgeoffset=0
 if (whichedge=="rightedge")
 {
  var windowedge=this.ie && !window.opera? this.iecompattest().scrollLeft+this.iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15
  this.dropmenuobj.contentmeasure=this.dropmenuobj.offsetWidth
  if (windowedge-this.dropmenuobj.x < this.dropmenuobj.contentmeasure)  //move menu to the left?
   edgeoffset=this.dropmenuobj.contentmeasure-obj.offsetWidth
 }
 else
 {
  var topedge=this.ie && !window.opera? this.iecompattest().scrollTop : window.pageYOffset
  var windowedge=this.ie && !window.opera? this.iecompattest().scrollTop+this.iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
  this.dropmenuobj.contentmeasure=this.dropmenuobj.offsetHeight
  if (windowedge-this.dropmenuobj.y < this.dropmenuobj.contentmeasure)
  { //move up?
   edgeoffset=this.dropmenuobj.contentmeasure+obj.offsetHeight
   if ((this.dropmenuobj.y-topedge)<this.dropmenuobj.contentmeasure) //up no good either?
    edgeoffset=this.dropmenuobj.y+obj.offsetHeight-topedge
  }
 }
 return edgeoffset
},

dropit:function(obj, e, dropmenuID)
{
 if (this.dropmenuobj!=null) //hide previous menu
 this.dropmenuobj.style.visibility="hidden" //hide menu
 this.clearhidemenu()
 
 if (this.ie||this.firefox)
 {
 
 this.dropmenuobj=document.getElementById(dropmenuID)
 
 if (this.dropmenuobj!=null){
  obj.onmouseout=function(){cssdropdown.delayhidemenu()}
 }
 
  obj.onclick=function(){return !cssdropdown.disablemenuclick} //disable main menu item link onclick?

  
  //this.dropmenuobj=document.getElementById(dropmenuID)
  
  if (this.dropmenuobj!=null) 
  {
        this.dropmenuobj.onmouseover=function(){cssdropdown.clearhidemenu()}
        this.dropmenuobj.onmouseout=function(){cssdropdown.dynamichide(e)}
        this.dropmenuobj.onclick=function(){cssdropdown.delayhidemenu()}
        this.showhide(this.dropmenuobj.style, e)
        this.dropmenuobj.x=this.getposOffset(obj, "left")
        this.dropmenuobj.y=this.getposOffset(obj, "top")
        this.dropmenuobj.style.left=this.dropmenuobj.x-this.clearbrowseredge(obj, "rightedge")+"px"
        this.dropmenuobj.style.top=this.dropmenuobj.y-this.clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+1+"px"
  }
 
 }
},

contains_firefox:function(a, b)
{
 while (b.parentNode)
  if ((b = b.parentNode) == a)
   return true;
 return false;
},

dynamichide:function(e)
{ 
    if (this.firefox){
        this.delayhidemenu()
    }
    else {
        var evtobj=window.event? window.event : e
        if (this.ie&&!this.dropmenuobj.contains(evtobj.toElement))
            this.delayhidemenu()
        else if (this.firefox&&e.currentTarget!= evtobj.relatedTarget&& !this.contains_firefox(evtobj.currentTarget, evtobj.relatedTarget))
            this.delayhidemenu()
    }
},

delayhidemenu:function()
{
 this.delayhide=setTimeout("cssdropdown.dropmenuobj.style.visibility='hidden'",this.disappeardelay) //hide menu
},

clearhidemenu:function()
{
 if (this.delayhide!="undefined")
 clearTimeout(this.delayhide)
},

startchrome:function()
{
 for (var ids=0; ids<arguments.length; ids++)
 {
  var menuitems=document.getElementById(arguments[ids]).getElementsByTagName("a")
  for (var i=0; i<menuitems.length; i++)
  {
   if (menuitems[i].getAttribute("rel"))
   {
    var relvalue=menuitems[i].getAttribute("rel")
    menuitems[i].onmouseover=function(e)
    {
     var event=typeof e!="undefined"? e : window.event
     cssdropdown.dropit(this,event,this.getAttribute("rel"))
    }
   }
  }
 }
}

}


function targetURL(cURL){
    var urlBase = '';
    document.location.href= urlBase + cURL;
}

function getElementByIdCompatible (the_id) {
    if (typeof the_id != 'string') {
        return the_id;
    }

    if (typeof document.getElementById != 'undefined') {
        return document.getElementById(the_id);
    } else if (typeof document.all != 'undefined') {
        return document.all[the_id];
    } else if (typeof document.layers != 'undefined') {
        return document.layers[the_id];
    } else {
        return null;
    }
}

function helpSetPos (obj) {
    var output = "";
    var mytop=0, myleft=0;
    i=0;
    //var path = obj.id;
    
    while(obj != null) {
      mytop+= obj.offsetTop;
//      if (obj.offsetTop > 250)
//      {
//      mytop = mytop - 181;
//      }
      myleft+= obj.offsetLeft;
      //path = path + " > " + obj.id + " - " + obj.offsetTop;
      obj= obj.offsetParent;
      
    }
    //window.alert(path);
  
    helpTextObj = getElementByIdCompatible("helpTextPop")

    
        helpTextObj.style.top = mytop + 25 + 'px';
        helpTextObj.style.left = myleft + 10 + 'px';
     return true;
  }



function showHelpTip(formObj,cMsg)
{
 helpTextPopObj = getElementByIdCompatible("helpTextPop")

 helpTextObj = getElementByIdCompatible("helpText")
 helpTextObj.innerHTML=cMsg;

 helpSetPos(formObj);
 helpTextPopObj.style.display='inline';
}

function hideHelpTip()
{
 helpTextPopObj = getElementByIdCompatible("helpTextPop")
 helpTextPopObj.style.display='none';
}


