function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
    setOverState();
}

var preloadFlag = false;
function preloadImages() {
	if (document.images) {
		nav_home_over = newImage("/images/nav_home_over.gif");
		nav_overview_over = newImage("/images/nav_overview_over.gif");
		nav_services_over = newImage("/images/nav_services_over.gif");
		nav_enrollment_over = newImage("/images/nav_enrollment_over.gif");
		nav_employment_over = newImage("/images/nav_employment_over.gif");
		nav_contact_us_over = newImage("/images/nav_contact_us_over.gif");
		nav_links_over = newImage("/images/nav_links_over.gif");
		nav_providers_over = newImage("/images/nav_providers_over.gif");
		nav_families_over = newImage("/images/nav_families_over.gif");
		nav_staff_over = newImage("/images/nav_staff_over.gif");
		nav_volunteers_over = newImage("/images/nav_volunteers_over.gif");
		nav_publications_over = newImage("/images/nav_publications_over.gif");
		nav_videos_over = newImage("/images/nav_videos_over.gif");
		preloadFlag = true;
	}
}

function clickIt(nodeName){
		if(document.getElementById(nodeName).style.display == "none"){
			document.getElementById(nodeName).style.display = "";
			}
		else{
			document.getElementById(nodeName).style.display = "none";
		}
	}

function openEmailFriendWindow(theURL,winName,features) { //v2.0

    var qsParm = new Array();
    qsParm['id'] = null;
    qsParm['title'] = null;
    
    var query = window.location.search.substring(1);
    var parms = query.split('&');
    for (var i=0; i<parms.length; i++) {
       var pos = parms[i].indexOf('=');
       if (pos > 0) {
          var key = parms[i].substring(0,pos);
          var val = parms[i].substring(pos+1);
          qsParm[key] = val;
          }
       }
       //Get the value of ID from the queryString
       var qsJobID = qsParm['jobID'];
       var qsTitle = qsParm['title'];
       
    theURL = "emailFriend.aspx?jobID=" + qsJobID  + "&url=" + window.location.href;
    winName = "Definition";
    features="scrollbars=yes,resizable=yes,width=550,height=627";
    window.open(theURL,winName,features);

}
    
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

    
function setNavigation(){

    //Function that reads the QS & Maintains the down-state for current page!
    
    var qsParm = new Array();
    qsParm['id'] = null;
    
    var query = window.location.search.substring(1);
    var parms = query.split('&');
    for (var i=0; i<parms.length; i++) {
       var pos = parms[i].indexOf('=');
       if (pos > 0) {
          var key = parms[i].substring(0,pos);
          var val = parms[i].substring(pos+1);
          qsParm[key] = val;
          }
       }
       //Get the value of ID from the queryString
       qsVal = qsParm['id'];
       
       if(qsVal==null){qsVal='0.0';  }
       
       //get just the first part of the querystring, before the "."
       qsVal1 = qsVal.substring(0, qsVal.indexOf('.'));
    
    //The below sets the image beside the currently selected page
    if(document.getElementById(qsVal)){
            document.getElementById(qsVal).innerHTML="<img src=\"/images/nav_arrow.gif\" alt=\"\" />";
        }

    //The below shows the correct left nav
    if(document.getElementById(qsVal1)){
        //alert("HERE Left Nav Div " + qsVal1);
            clickIt(qsVal1);
        }        
        
     //This Sets the variable ONCE, each time the page is loaded
    topNavSelected = "nav_" + qsVal1;
    setOverState(topNavSelected);      //Call the setOverState Function
}


function setOverState(){

    //if(topNavSelected) alert("You are defined"); else alert('"a" what?!');

    //The Below sets the over state on the top Nav
    if(document.getElementById(topNavSelected))
    {
        //alert("topNavSelected= " + topNavSelected);
        document.getElementById(topNavSelected).src="/images/nav/" + topNavSelected + "_over.gif";
    }   
}

function validate_frmEmailFriend()
{ 

	var filter=/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/
	
	if (!filter.test(document.frmEmailFriend.txtFromEmail.value)){
	alert("Please input a VALID email address in the form of: YourName@yourDomain.com !")
	document.frmEmailFreind.txtFromEmail.focus();
	return (false);
	}
	
	if (!filter.test(document.frmEmailFriend.txtToEmail.value)){
	alert("Please input a VALID email address in the form of: YourName@yourDomain.com !")
	document.frmEmailFreind.txtToEmail.focus();
	return (false);
	}
}	


function validate_frmAddJob()
{ 
    
 if (document.aspnetForm.title.value.length < 2)
  {
    alert("Please enter a job title.");
    document.aspnetForm.title.focus();
    return (false);
  }

   if (document.aspnetForm.location.selectedIndex==0)
  {
    alert("Please select a location.");
    document.aspnetForm.location.focus();
    return (false);
  }

if (document.aspnetForm.department.selectedIndex==0)
  {
    alert("Please select a department.");
    document.aspnetForm.department.focus();
    return (false);
  }
  
if (document.aspnetForm.category.selectedIndex==0)
  {
    alert("Please select a category.");
    document.aspnetForm.category.focus();
    return (false);
  }

 if (document.aspnetForm.postDate.value.length < 9)
  {
    alert("Please correct the Post date.\nThis field must adhear to the STRICT format: MM/DD/YYYY\nie. 05/05/2005");
    document.aspnetForm.postDate.focus();
    return (false);
  }
  
//ERROR CHECK FOR POST DATE 
	error = 0;
	//alert("document.EditRecord.date.value= " + document.EditRecord.date.value)
	if((document.aspnetForm.postDate.value.charAt(2)!="/" && document.aspnetForm.postDate.value.charAt(5)!="/") || document.aspnetForm.postDate.value.length!=10)
		error = 1;
	else if(isNaN(document.aspnetForm.postDate.value.charAt(0))||isNaN(document.aspnetForm.postDate.value.charAt(1))||isNaN(document.aspnetForm.postDate.value.charAt(3))||isNaN(document.aspnetForm.postDate.value.charAt(4))||isNaN(document.aspnetForm.postDate.value.charAt(6))||isNaN(document.aspnetForm.postDate.value.charAt(7))||isNaN(document.aspnetForm.postDate.value.charAt(8))||isNaN(document.aspnetForm.postDate.value.charAt(9)))
		error = 1;
	else
	{
		var day = eval(document.aspnetForm.postDate.value.charAt(3)+document.aspnetForm.postDate.value.charAt(4));
		var day = parseInt(day);
		mnth = eval(document.aspnetForm.postDate.value.charAt(0)+document.aspnetForm.postDate.value.charAt(1));
		var mnth = parseInt(mnth);
		yr = eval(document.aspnetForm.postDate.value.charAt(6)+document.aspnetForm.postDate.value.charAt(7)+document.aspnetForm.postDate.value.charAt(8)+document.aspnetForm.postDate.value.charAt(9));
		var yr = parseInt(yr);
		
		//Make sure date is NOT in the past!
		var today = new Date();
		//alert("Date= " + today);
		
		var date = new Date();
		var TodayDay  = date.getDate();
		var TodayMonth = date.getMonth() + 1;
		var yy = date.getYear();
		var TodayYear = (yy < 1000) ? yy + 1900 : yy;

		if((yr <= TodayYear) && (mnth < TodayMonth))
			error = 7;			

		if(mnth>12 || mnth<1 || day>31 || day<1 || yr<2006)
			error = 7;

		// mnthArray[0] is january, mnthArray[11] is december
		mnthArray = new Array(31,29,31,30,31,30,31,31,30,31,30,31);

		// netscape/IE number months starting with january = 0
		mnth = mnth-1;
		mydate = new Date(yr,mnth,day);
		if(day > parseInt(mnthArray[parseInt(mnth)]))
			error = 3;	
	}

	switch(error)
	{
		
	case 1: alert("               Please correct the Post date.\nThis field must adhear to the STRICT format: MM/DD/YYYY\nie. 05/05/2005");
			document.aspnetForm.postDate.focus();
			return false;
			break;
	case 2: alert("The month you entered is invalid.");
			return false;
			break;
	case 3: alert("The day you entered is invalid for the month.");
			document.aspnetForm.postDate.focus();
			return false;
			break;
	case 7:	alert("Please enter a VALID date, NOT in the past, in the strict format: MM/DD/YYYY.");
			document.aspnetForm.postDate.focus();
			return false;
			break;														
	}  
  
  
if (document.aspnetForm.deadLine.value.length > 1)
{  
//ERROR CHECK FOR APPLICATION DEADLINE DATE
	error = 0;
	//alert("document.EditRecord.date.value= " + document.EditRecord.date.value)
	if((document.aspnetForm.deadLine.value.charAt(2)!="/" && document.aspnetForm.deadLine.value.charAt(5)!="/") || document.aspnetForm.deadLine.value.length!=10)
		error = 1;
	else if(isNaN(document.aspnetForm.deadLine.value.charAt(0))||isNaN(document.aspnetForm.deadLine.value.charAt(1))||isNaN(document.aspnetForm.deadLine.value.charAt(3))||isNaN(document.aspnetForm.deadLine.value.charAt(4))||isNaN(document.aspnetForm.deadLine.value.charAt(6))||isNaN(document.aspnetForm.deadLine.value.charAt(7))||isNaN(document.aspnetForm.deadLine.value.charAt(8))||isNaN(document.aspnetForm.deadLine.value.charAt(9)))
		error = 1;
	else
	{
		var day = eval(document.aspnetForm.deadLine.value.charAt(3)+document.aspnetForm.deadLine.value.charAt(4));
		var day = parseInt(day);
		mnth = eval(document.aspnetForm.deadLine.value.charAt(0)+document.aspnetForm.deadLine.value.charAt(1));
		var mnth = parseInt(mnth);
		yr = eval(document.aspnetForm.deadLine.value.charAt(6)+document.aspnetForm.deadLine.value.charAt(7)+document.aspnetForm.deadLine.value.charAt(8)+document.aspnetForm.deadLine.value.charAt(9));
		var yr = parseInt(yr);
		
		//Make sure date is NOT in the past!
		var today = new Date();
		//alert("Date= " + today);
		
		var date = new Date();
		var TodayDay  = date.getDate();
		var TodayMonth = date.getMonth() + 1;
		var yy = date.getYear();
		var TodayYear = (yy < 1000) ? yy + 1900 : yy;

		if((yr <= TodayYear) && (mnth < TodayMonth))
			error = 7;			

		if(mnth>12 || mnth<1 || day>31 || day<1 || yr<2006)
			error = 7;

		// mnthArray[0] is january, mnthArray[11] is december
		mnthArray = new Array(31,29,31,30,31,30,31,31,30,31,30,31);

		// netscape/IE number months starting with january = 0
		mnth = mnth-1;
		mydate = new Date(yr,mnth,day);
		if(day > parseInt(mnthArray[parseInt(mnth)]))
			error = 3;	
	}

	switch(error)
	{
		
	case 1: alert("               Please correct the Deadline date.\nThis field must adhear to the STRICT format: MM/DD/YYYY\nie. 05/05/2005");
			document.aspnetForm.deadLine.focus();
			return false;
			break;
	case 2: alert("The month you entered is invalid.");
			return false;
			break;
	case 3: alert("The day you entered is invalid for the month.");
			document.aspnetForm.deadLine.focus();
			return false;
			break;
	case 7:	alert("Please enter a VALID date, NOT in the past, in the strict format: MM/DD/YYYY.");
			document.aspnetForm.deadLine.focus();
			return false;
			break;														
	} 
  
}


  
 if (document.aspnetForm.description.value.length < 2)
  {
    alert("Please enter a description.");
    document.aspnetForm.description.focus();
    return (false);
  }  


   if (document.aspnetForm.qualifications.value.length < 2)
  {
    alert("Please enter qualifications.");
    document.aspnetForm.qualifications.focus();
    return (false);
  }
  
  

if (document.aspnetForm.hour.selectedIndex==0)
  {
    alert("Please select the hours.");
    document.aspnetForm.hour.focus();
    return (false);
  }
  
  if (document.aspnetForm.shift.selectedIndex==0)
  {
    alert("Please select a shift.");
    document.aspnetForm.shift.focus();
    return (false);
  }

/*
 if (document.aspnetForm.NoPositions.value.length < 1)
  {
    alert("Please enter how many positions are available.");
    document.aspnetForm.NoPosition.focus();
    return (false);
  } 


	var activeChecked 
	for (var i=0; i<document.aspnetForm.ActiveJob.length; i++) {
	
		if (document.aspnetForm.ActiveJob[i].checked) {
		activeChecked = document.aspnetForm.ActiveJob[i].value
		}
	}

	if(!activeChecked){ //if passChecked equal null
		alert("Please select wether this position is active.")
	    document.aspnetForm.NoPosition.focus();
		return (false);
	}
*/

 	if (document.aspnetForm.featuredJob.checked){
 		if (document.aspnetForm.ctl00$ContentPlaceHolder1$featuredText.value.length < 1)
		{
		alert("Please enter text for featured item.");
		document.aspnetForm.ctl00$ContentPlaceHolder1$featuredText.focus();
		return (false);
		}
	}

	
 if (document.aspnetForm.contactName.value.length < 2)
  {
    alert("Please enter a contact Name.");
    document.aspnetForm.contactName.focus();
    return (false);
  } 

 if (document.aspnetForm.contactTitle.value.length < 2)
  {
    alert("Please enter a contact Title.");
    document.aspnetForm.contactTitle.focus();
    return (false);
  } 


	var filter=/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/
	if (!filter.test(document.aspnetForm.contactEmail.value)){
	alert("Please input a VALID email address in the form of: YourName@yourDomain.com !")
	document.aspnetForm.contactEmail.focus();
	return (false);
	}

   return true;
}

function rePopulateFields(idNumber, pageName)
{
    window.location.href= pageName + '?id=' + idNumber
}


function submitApplicantData(criteria)
{
    location.href="applications.aspx?l_name=" + criteria;
}
function funSearch(searchType,criteria)
{

//I am completely embarassed I had to resort to this function :(
//This parses the URL, extracts the name of the page (minus the .aspx extension)
//Then redirects the user to the approiate page with the criteria on the QueryString
// ~Sadly yours, Jason J. Hunter  10-21-06
		var where_is_mytool = window.location.href;
		var mytool_array=where_is_mytool.split("/");

		var TheFileName  = null;
		var TheFileName = mytool_array[(mytool_array.length-1)]
		//alert("TheFileName:" + TheFileName);
		
		
		//Get the Index of the '.'
		var TheName = TheFileName.substring(0, TheFileName.lastIndexOf('.'));
		//alert("TheName= " + TheName);		

			switch(TheName.toLowerCase())
			{
			case "jobs":
			case "editjob":
			case "addjob":
			      location.href="jobs.aspx?" + searchType + "=" + criteria;
			      break;
			      
			case "applicants":
			case "applicant":
			case "applications":			
			case "menu":
			      location.href="applications.aspx?" + searchType + "=" + criteria;
			      break;	
			case "staff":
			case "staffedit":
			      location.href="staff.aspx?" + searchType + "=" + criteria;
			      break;				      
			case "admin":
			      location.href="admin.aspx?" + searchType + "=" + criteria;
			      break;			      		      
		    }

}