
var Mouseover={init:function(){var _1=new Array();var _2=this;Element.descendants(document.body).each(function(_3){if(_3.readAttribute("mosrc")!=null){_3.Cmosrc=_3.readAttribute("mosrc");_3.Csrc=_3.readAttribute("src");Event.observe(_3,"mouseover",_2.handleMOver.bind(_3));Event.observe(_3,"mouseout",_2.handleMOut.bind(_3));_1.push(_3.Cmosrc);}});_1.each(this.preloadImage);},handleMOver:function(){this.src=this.Cmosrc;},handleMOut:function(){this.src=this.Csrc;},preloadImage:function(_4){(function(){var _5=new Element("IMG",{"src":_4,"width":1,"height":1});_5.setOpacity(0);_5.setStyle({position:"absolute",top:"0px",left:"0px","z-index":"0"});document.body.insert(_5,{position:"bottom"});}).defer();}};Event.observe(document,"dom:loaded",function(){Mouseover.init();});
var ShowHide={name:"Show Hide",init:function(){this.cutoff=new Date();this.cutoff.setFullYear(this.cutoff.getFullYear()-18);this.cutoff.setHours(0,0,0,0);Element.descendants(document.body).each(function(_1){if(_1.readAttribute("showhide")!=null){var _2=ShowHide.setupShowhide(_1);_2();}
if(_1.readAttribute("agecondition")!=null){var _2=ShowHide.ageConditionSetup(_1);_2();}});},ageConditionSetup:function(_3){var _4=this.makeShowHideList(_3.readAttribute("agecondition").split(" "));var _5=_4[0];var _6=_4[1];var _7=function(){var _8=_3.showhidelist[_3.selectedIndex];var _9=_8.options[_8.selectedIndex];var _a=_5.options[_5.selectedIndex];var _b=_3.options[_3.selectedIndex];if(_9.text=="Select"||_b.text=="Select"||_a.text=="Select"){ShowHide.makeVisible(_6,false);return;}
var _c=new Date(_a.value,_b.value-1,_9.value);var _d=ShowHide.cutoff.getTime()<_c.getTime();ShowHide.makeVisible(_6,_d);};Event.observe(_3,"change",_7);Event.observe(_5,"change",_7);Event.observe(_3,"sb:show",_7);Event.observe(_5,"sb:show",_7);_3.showhidelist.each(function(_e){Event.observe(_e,"change",_7);Event.observe(_e,"sb:show",_7);});return _7;},setupShowhide:function(_f){if(!_f.showhidelist){_f.showhidelist=this.makeShowHideList(_f.readAttribute("showhide").split(" "));}
_f.shchangehandler=function(){var _10=_f.showhidelist.flatten().compact();ShowHide.makeVisible(_10,false);if(!_f.visible()){return;}
var _11=_f.showhidelist[_f.selectedIndex];ShowHide.makeVisible(_11,true);};Event.observe(_f,"change",_f.shchangehandler);Event.observe(_f,"sb:show",_f.shchangehandler);return _f.shchangehandler;},makeVisible:function(_12,_13){if(_12 instanceof Array){_12.each(function(_14){if(_14!=undefined){ShowHide.makeItemVisible(_14,_13);}});}else{if(_12!=undefined){this.makeItemVisible(_12,_13);}}},makeShowHideList:function(_15){return _15.collect(function(_16){if(_16==""||_16=="none"){return undefined;}else{if($(_16)!=undefined){return $(_16);}else{if($$("."+_16)!=undefined){return $$("."+_16);}else{alert("Unknown class/id \""+_16+"\"");}}}});},makeItemVisible:function(_17,_18){if(_18){if(window.attachEvent){_17.style.display="block";}else{_17.style.display="table-row";}}else{_17.style.display="none";}
ShowHide.setEnabled(_17,_18);},setEnabled:function(_19,_1a){if(!_19.descList){_19.descList=$A(_19.getElementsByTagName("input")).concat($A(_19.getElementsByTagName("select"))).map(Element.extend);}
var _1b=function(_1c){if(_1a&&_1c.enable){_1c.enable();}else{if(_1c.disable){_1c.disable();}}};_19.descList.each(_1b);_1b(_19);}};function Level(_1d,_1e){var src=Event.element(_1d);src.showhidelist=ShowHide.makeShowHideList(_1e);var _20=ShowHide.processElement(src);_20();src.onchange=null;}
document.observe("dom:loaded",function(){ShowHide.init();});



function showOrHide(sohID) {
	var element = document.getElementById(sohID);

	if (element) {
		if ($(element).style.display == 'none') {
			$(element).show();
		}
		else {
			$(element).hide();
		}
	}
}


var DynResize = {
	init: function() {
		this.elements = $(new Array());
		var oThis = this;
		
		Element.descendants(document.body).each( function(elem) {
			if(elem.readAttribute('dynresize') != null) {
				elem.vals = elem.readAttribute('dynresize').split(' ');
				elem.resizeMe = oThis.resizeMe;
				oThis.elements.push(elem);
			}
		});
		
		Event.observe(window,'resize',this.windowResizeHandler.bind(this));
		
		this.windowResizeHandler();
	},
	windowResizeHandler: function() {
		this.elements.invoke('resizeMe');
	},
	resizeMe: function() {

		 if (typeof window.availWidth != 'undefined')
		 {
			  var width = window.availWidth;
			  var height = window.availHeight;
		 }
		 else if (typeof document.documentElement != 'undefined'
			 && typeof document.documentElement.clientWidth !=
			 'undefined' && document.documentElement.clientWidth != 0)
		 {
			   var width = document.documentElement.clientWidth;
			   var height = document.documentElement.clientHeight;
		 }
		 else
		 {
			   var width = document.getElementsByTagName('body')[0].clientWidth;
			   var height = document.getElementsByTagName('body')[0].clientHeight;
		 }
		 
		 if(width && height) {
		 	if(this.vals[0] != 'none')
				this.style.width = (width - this.vals[0]) + 'px';
			if(this.vals[1] != 'none')
				this.style.height = (height - this.vals[1]) + 'px';
		 }
		 
	}

};


Event.observe(window,'load',function(event) {
	DynResize.init();
});
function doHighlight(bodyText, searchTerm, highlightStartTag, highlightEndTag) 
{
  if ((!highlightStartTag) || (!highlightEndTag)) {
	highlightStartTag = "<span style=\"background-color:yellow; color:black;\">";
    highlightEndTag = "</span>";
  }
  
  var newText = "";
  var i = -1;
  var lcSearchTerm = searchTerm.toLowerCase();
  var lcBodyText = bodyText.toLowerCase();
    
  while (bodyText.length > 0) {
    i = lcBodyText.indexOf(lcSearchTerm, i+1);
    if (i < 0) {
      newText += bodyText;
      bodyText = "";
    } else {
      // skip anything inside an HTML tag
      if (bodyText.lastIndexOf(">", i) >= bodyText.lastIndexOf("<", i)) {
        // skip anything inside a <script> block
        if (lcBodyText.lastIndexOf("/script>", i) >= lcBodyText.lastIndexOf("<script", i)) {
          newText += bodyText.substring(0, i) + highlightStartTag + bodyText.substr(i, searchTerm.length) + highlightEndTag;
          bodyText = bodyText.substr(i + searchTerm.length);
          lcBodyText = bodyText.toLowerCase();
          i = -1;
        }
      }
    }
  }
  
  return newText;
}

function highlightSearchTerms(searchText, treatAsPhrase, warnOnFailure, highlightStartTag, highlightEndTag)
{
  // if the treatAsPhrase parameter is true, then we should search for 
  // the entire phrase that was entered; otherwise, we will split the
  // search string so that each word is searched for and highlighted
  // individually
  if (treatAsPhrase) {
    searchArray = [searchText];
  } else {
    searchArray = searchText.split(" ");
  }
  
  if (!document.body || typeof(document.body.innerHTML) == "undefined") {
    if (warnOnFailure) {
      alert("Sorry, for some reason the text of this page is unavailable. Searching will not work.");
    }
    return false;
  }
  
  var bodyText = document.body.innerHTML;
  for (var i = 0; i < searchArray.length; i++) {
    bodyText = doHighlight(bodyText, searchArray[i], highlightStartTag, highlightEndTag);
  }
  
  document.body.innerHTML = bodyText;
  return true;
}

var Validator={name:"validator",init:function(){var _1=$$(".validator");_1.each((function(_2){_2.getElements().each(this.registerElemListeners.bind(this));_2.onsubmit=this.validateSubmit.bindAsEventListener(this);_2.descendants().each(function(_3){if(_3.readAttribute("validation")=="submit"){Event.observe(_3,"click",Validator.submitTarget.bindAsEventListener(Validator));}});}).bind(this));},registerElemListeners:function(_4){var _5=_4.readAttribute("validation");var _6=this;if(_5=="password"){_6=$(_4.readAttribute("passid"));Event.observe(_6,"keyup",(function(_7){return this.keyup(_4);}).bindAsEventListener(this));Event.observe(_6,"blur",(function(_8){return this.validate(_4);}).bindAsEventListener(this));}
if(_4.tagName.toLowerCase()=="select"||(_4.readAttribute("type")&&$(_4).readAttribute("type").toLowerCase()=="checkbox")){Event.observe(_4,"change",(function(_9){return this.validate(Event.element(_9));}).bindAsEventListener(this));}else{Event.observe(_4,"keyup",(function(_a){return this.keyup(Event.element(_a));}).bindAsEventListener(this));Event.observe(_4,"blur",(function(_b){return this.validate(Event.element(_b));}).bindAsEventListener(this));}
_4.origColor=_4.style.backgroundColor;_4.untouched=true;},submitTarget:function(_c){var _d=$$(".validator");var _e=Event.element(_c);var _f=_d.find(function(_10){return _e.descendantOf(_10);});if(!_f){alert("Submit button was not properly placed on the page!");}
if(_f.submitted){return;}
var _11=_f.getElements().map(Validator.validate).all();if(_11){if(_f.SOMITarget){_f.SOMITarget();}
_f.submitted=true;_f.submit();}},validateSubmit:function(_12){var _13=Event.element(_12);var _14=_13.getElements().map(Validator.validate);var res=_14.all();if(res){_13.getInputs("submit").each(function(_16){_16.disable();});}
if(!res){Event.stop(_12);}},setError:function(_17,_18){if(!_17.stdError){_17.stdError=$(_17.name+"Error");}
var _19=new Array(null,_17.stdError,_17.displayID);$R(0,_19.size(),true).each(function(num){if(!_19[num]){return;}
if(num==_18){$(_19[num]).show();}else{$(_19[num]).hide();}});if(_18==0){_17.style.backgroundColor=_17.origColor;}else{_17.style.backgroundColor=Validator.alert_color;}
if(_17.readAttribute("validation")=="password"){this.setError($(_17.readAttribute("passid")),_18);}},keyup:function(_1b){if(!_1b.untouched){this.validate(_1b);}},recursiveVisible:function(_1c){return _1c.ancestors().concat([_1c]).all(function(e){return e.visible?e.visible():true;});},validate:function(_1e){_1e.untouched=false;var _1f=$(_1e).readAttribute("validation");var _20=0;if(_1f==null){return true;}
if(!Validator.recursiveVisible(_1e)){return true;}
if(_20==0&&_1f.indexOf("required")!=-1){_20=Validator.val_required(_1e)?0:1;}
if(_20==0&&_1f.indexOf("dropdownstrict")!=-1){_20=Validator.val_dropdownstrict(_1e)?0:1;}
if(_20==0&&_1f.indexOf("postalcode")!=-1){_20=Validator.val_postalcode(_1e)?0:1;}
if(_20==0&&_1f.indexOf("containsdigits")!=-1){_20=Validator.val_containsdigits(_1e)?0:1;}
if(_20==0&&_1f.indexOf("email")!=-1){_20=Validator.val_email(_1e)?0:1;}
if(_20==0&&_1f.indexOf("password")!=-1){var _21=$(_1e.readAttribute("passid"));var _22=_1e.value==_21.value;if(_21.untouched){_22=true;}
_20=_22?0:1;}
if(_20==0&&_1f.indexOf("twowords")!=-1){_20=Validator.val_twowords(_1e)?0:1;}
if(_20==0&&_1f.indexOf("telephone")!=-1){_20=Validator.val_telephone(_1e)?0:1;}
if(_20==0&&_1f.indexOf("servercall")!=-1){_1e.lastSCQuery=_1e.value;Validator.val_servercall(_1e);_20=_1e.servercallPassed?0:2;}
Validator.setError(_1e,_20);return _20==0;},val_required:function(_23){if(_23.tagName.toLowerCase().startsWith("select")){if(_23.selectedIndex==-1){return false;}
if(_23.options[_23.selectedIndex].innerHTML.startsWith("Select")){return false;}
if(_23.options[_23.selectedIndex].value.startsWith("none")){return false;}
return true;}else{if(_23.type.startsWith("text")){return!(_23.value.blank());}else{if(_23.type.startsWith("checkbox")){return _23.checked;}else{alert("Form scripting error. Unsupported input type "+_23.type+" for validation type 'required'");return true;}}}},val_dropdownstrict:function(_24){return _24.strict;},val_email:function(_25){var val=_25.value;var at=val.indexOf("@");var dot=val.lastIndexOf(".");return(at!=-1&&dot!=-1&&at>=1&&(dot-at)>=3&&(val.length-dot)>=3);},val_postalcode:function(_29){var val=_29.value;if(val.length==0){return true;}
var re=/[a-z][0-9][a-z][ ]?[0-9][a-z][0-9]/i;return val.match(re);},val_containsdigits:function(_2c){var val=_2c.value;if(val.length==0){return true;}
for(var i=0;i<val.length;i++){if(val[i]>="0"&&val[i]<="9"){return true;}}
return false;},val_twowords:function(_2f){return _2f.value.strip().indexOf(" ")!=-1;},val_telephone:function(_30){var _31=0;if(_30.value.length==0){return true;}
_30.value.strip().toArray().each(function(c){if(c>="0"&&c<="9"){_31++;}});return _31==10;},val_servercall:function(_33){var _34=_33.value;if(!_33.displayID){_33.displayID=$(_33.readAttribute("displayID"));}
if(!_33.calltype){_33.calltype=_33.readAttribute("calltype");}
if(_33.servercallPassed===undefined){_33.servercallPassed=true;}
if(!_33.calltype||!_33.displayID){alert("Error: either \"calltype\" or \"displayID\" have not been set for element "+_33.name+" using validation servercall.");return;}
if(_33.SCInProgress===true){return;}
_33.SCInProgress=true;new Ajax.Request(this.validator_url,{method:"post",parameters:{type:_33.calltype,value:_33.value},onSuccess:function(_35){if(_33.value!=_34){_33.servercallPassed=true;}else{if(_35.responseText.indexOf("true")!=-1){_33.servercallPassed=true;}else{if(_35.responseText.indexOf("false")!=-1){_33.servercallPassed=false;}else{_33.servercallPassed=true;}}}
Validator.validate(_33);_33.SCInProgress=false;},onFailure:function(_36){alert("Ajax query failed.  Server unreachable at "+Validator.validator_url+". Will retry in 5 seconds.");_33.servercallPassed=true;_33.SCInProgress=false;}});},alert_color:"#990000",validator_url:"validator.php"};Event.observe(window,"load",function(){Validator.init();});function externalLinks() {   
 if (!document.getElementsByTagName) return;   
 var anchors = document.getElementsByTagName("a");   
 for (var i=0; i<anchors.length; i++) {   
   var anchor = anchors[i];   
   if (anchor.getAttribute("href") &&   
       anchor.getAttribute("rel") == "external")   
     anchor.target = "_blank";   
 }   
}   
window.onload = externalLinks;



