//Regexp for testing email addy validity
var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/

sfHover = function() {
	var sfEls = document.getElementById("items").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
			}
			sfEls[i].onmouseout=function() {
				this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
				}
			}
		} 
if (window.attachEvent) window.attachEvent("onload", sfHover);


function activateNavImg(argID, argImgNo, argState){
    dispatcher(argID, "imgs/_nav" + argImgNo + "_" + argState + ".jpg");
}

function dispatcher(argID, argImgSrc){
	if (document.images && document.getElementById){
		var img = document.getElementById(argID);
		if (img != null){
			img.src = argImgSrc;
		}
	}
}
// Preloader
var i = 0;
imageObj = new Image();
images = new Array();
images[0]="imgs/_nav1_1.jpg";
images[1]="imgs/_nav2_1.jpg";
images[2]="imgs/_nav3_1.jpg";
images[3]="imgs/_nav4_1.jpg";
images[4]="imgs/_nav5_1.jpg";
images[5]="imgs/_nav6_1.jpg";
images[6]="imgs/_masthead-background.jpg";
images[7]="imgs/_nav7_1.jpg";
for(i=0; i<=8; i++){
	imageObj.src=images[i];
	}

// -----------------------------------------------
//  Page tools
// -----------------------------------------------
function InstantiateAddToFavorites() {
  var title = document.title;
  var url = document.URL;
  if( document.all ) {
    window.external.AddFavorite( url, title);
  } else if (window.sidebar) { 
    window.sidebar.addPanel(title, url,""); 
  } else if( window.opera && window.print ) {
  return true;
  }
}

function InstantiateEmailPage(){
	str = 'mailto:?subject=A Web Link From The Fort Myers Housing Authority&body=' + escape(document.URL);
	document.location.href=str;
}

function InstantiatePrintPage(){
	window.print();
}

function InstantiateChangeFontSize(argSize){
	var ContainerDiv = document.getElementById("fontcontrol");
	var sClassName = 'font' + argSize;
	ContainerDiv.className = sClassName;
}
// -----------------------------------------------

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

// -----------------------------------------------
//  Vendor registration
// -----------------------------------------------
function CkVendorReg(){
  if (document.frmVendorReg.fn.value.length <= 0){
  alert('Please enter a FIRST NAME.');
  document.frmVendorReg.fn.focus();
  return false;
  }
  if (document.frmVendorReg.ln.value.length <= 0){
  alert('Please enter a LAST NAME.');
  document.frmVendorReg.ln.focus();
  return false;
  }  
  if (document.frmVendorReg.company.value.length <= 0){
  alert('Please enter a COMPANY NAME.');
  document.frmVendorReg.company.focus();
  return false;
  }
  if (document.frmVendorReg.addr.value.length <= 0){
  alert('Please enter a MAILING ADDRESS.');
  document.frmVendorReg.addr.focus();
  return false;
  }
  if (document.frmVendorReg.city.length <= 0){
  alert('Please enter a CITY.');
  document.frmVendorReg.city.focus();
  return false;
  }
  if (document.frmVendorReg.state.value.length <= 0){
  alert('Please select a STATE.');
  document.frmVendorReg.state.focus();
  return false;
  }  
  if (document.frmVendorReg.zip.value.length < 4){
  alert('Please enter at least a 5-digit ZIP CODE.');
  document.frmVendorReg.zip.focus();
  return false;
  } 
  if (document.frmVendorReg.email.value.length <= 0){
  alert('Please enter an EMAIL ADDRESS.');
  document.frmVendorReg.email.focus();
  return false;
  }
  if (document.frmVendorReg.pwd.value.length <= 0){
  alert('Please enter a PASSWORD for this vendor.');
  document.frmVendorReg.pwd.focus();
  return false;
  }
  if (document.frmVendorReg.pwd.value != document.frmVendorReg.pwd2.value){
  alert('The passwords don\'t match. Please make sure you confirm your password.');
  document.frmVendorReg.pwd.focus();
  return false;
  }
  if (document.frmVendorReg.wordvar.value.length <= 0){
  alert('Please enter the WORD VERIFICATION CODE to complete your registration.');
  document.frmVendorReg.wordvar.focus();
  return false;
  }  
  if (re.test(document.frmVendorReg.email.value)){
  return true;
  }
  alert("There\'s a problem with the email address you entered.")
  document.frmVendorReg.email.focus();
  return false;   
}

// -----------------------------------------------
//  Vendor login validation in page form
// -----------------------------------------------
function CkVendorLoginInPage(){
  if(document.frmVendorLogin.email.value.length <= 0){
  alert('Please enter a valid EMAIL ADDRESS.');
  document.frmVendorLogin.email.focus();
  return false;
  }
  if(document.getElementById("pwd")){
    if(document.frmVendorLogin.pwd.value.length <= 0){
    alert('Please enter your PASSWORD.');
    document.frmVendorLogin.pwd.focus();
    return false;
    } 
  }
  if (!re.test(document.frmVendorLogin.email.value)){
  alert('Please enter a valid EMAIL ADDRESS.');
  document.frmVendorLogin.email.focus();
  return false;
  }
}

// -----------------------------------------------
//  Ask question validation
// -----------------------------------------------
function CkAskQues(){
  if (document.frmAskQues.fn.value.length <= 0){
  alert('Please enter a FIRST NAME.');
  document.frmAskQues.fn.focus();
  return false;
  }
  if (document.frmAskQues.ln.value.length <= 0){
  alert('Please enter a LAST NAME.');
  document.frmAskQues.ln.focus();
  return false;
  }
  if (document.frmAskQues.msgsub.value == 0){
  alert('Please indicate the nature of your question.');
  document.frmAskQues.msgsub.focus();
  return false;
  }  
  if (document.frmAskQues.pbody.value.length <= 0){
  alert('Please enter a question or comment.');
  document.frmAskQues.pbody.focus();
  return false;
  }     
  if (document.frmAskQues.wordvar.value.length <= 0){
  alert('Please enter the WORD VERIFICATION CODE to complete your submission.');
  document.frmAskQues.wordvar.focus();
  return false;
  }  
  if (document.frmAskQues.email.value.length > 0){
	  if (!re.test(document.frmAskQues.email.value)){
	  alert("There\'s a problem with the email address you entered.")
	  document.frmAskQues.email.focus();
	  return false;
	  }
  }   
}

function SetContact(argPrefix){
  var tld = 'hac' + 'fm.com';
  var str = 'ma' + 'il' + 'to:' + argPrefix + '@' + tld;
  document.location.href = str;
  }