//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,}))$/
var tld = '';

// ------------------------- Begin sf

sfHover = function() {
	var sfEls = document.getElementById("nav").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);


// ------------------------- End sf

function CkEmailAddy(){
  if (!re.test(document.frmEmailSignup.email.value)){
  alert('Please enter a valid email address.');
  document.frmEmailSignup.email.focus();  
  return false;
  } 
 }

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

// Jump menu mods that open new browser window for external files/pages
function MM_jumpMenuNewWindow(targ,selObj,restore){ //v3.0
  var s = selObj.options[selObj.selectedIndex].value;
  window.open(s);
  if (restore) selObj.selectedIndex=0;
}

function CkEmailSignup(){
  if (!re.test(document.frmEmailSignup.email.value)){
  alert('Please enter a valid email address.');
  document.frmEmailSignup.email.focus();  
  return false;
  } 
 } 

function confirmExit(){
   var msg = confirm('You are now leaving the Charlotte Housing Authority (CHA) web site.\nOur web site offers links to many external organizations, such as\neducational institutions and non-profit organizations. While we offer\nthese links for your convenience, we do not control the content of\nthese sites and cannot attest to the accuracy of the information\nprovided. Please click ok to proceed.')

   if (msg==true) {  //if user pressed OK
     return true;  // location.href already in place
   } 
   else {  //if user pressed Cancel
     return false;  // blank action
   }

}

// ------------------------ Legacy syntax from 2.0 ----------------------------------

function checkResume(){
  if(document.frm1.fn.value.length <= 0){
  alert('Please enter your first name.');
  document.frm1.fn.focus();
  return false;
  }
  if(document.frm1.ln.value.length <= 0){
  alert('Please enter your last name.');
  document.frm1.ln.focus();
  return false;
  }
  if(document.frm1.resfile.value.length <= 0 && document.frm1.msg.value.length <= 0){
  alert('Please upload a file or paste your resume in the space provided.');
  document.frm1.msg.focus();
  return false;
  }
  if(document.frm1.wordvar.value.length <= 0){
  alert('Please enter the word verification numbers.');
  document.frm1.wordvar.focus();
  return false;
  }
  frm1.Submit.value='Please Wait...';
  document.getElementById("loading").style.display="block";
  return true;  
}

function openPhotoGallery(argGalleryID){
	var galwindow;
	galwindow = window.open('photo_gallery.asp?id='+ argGalleryID,'thegallery','height=700,width=800,resizable=no,scrollbars=no,toolbar=no,status=no');
	if (window.focus){
		galwindow.focus();
	}
  }

