var storeId = 1;

var numRegions=0;

function CountRegions (select)

{

  numRegions=0;

  for (var i = 0; i < select.options.length; i++)

    if (select.options[i].selected)

      numRegions++;



  if (select.options[0].selected && numRegions > 1 )

  {

    select.options[0].selected = false;

    alert("Either select \"Select all \" alone, or select other Locations");

  }

}



var numIndustries=0;

function CountSelection(select)

{

  numIndustries=0;

  for (var i = 0; i < select.options.length; i++)

    if (select.options[i].selected)

      numIndustries++;



  if (select.options[0].selected && numIndustries > 1)

  {

    select.options[0].selected = false;

    alert("Either select \"Select all \" alone, or select other industries");

  }

}





function FilterKeywords()

{

  if( document.search_form.state.value.length != 0 )

  {

    {

	return true;

    }

  }

  else

    return true;

}







function displayAllJobsForRecruiter_OLDDDDDDDDDDDDDDDDD()

{

    

    document.search_form.action = "/smejobsearch/jsponly/SearchResultPage.jsp?applySearchCriteria=false&storeId=1&time_interval_id=ALL&job_type_id=ANY";

    document.search_form.submit();

}



function displayAllJobsForRecruiter1()

{

  //this is the new JSP with the encoding URL stuffl

  

		var url = "/jobsearch.php?division=ANY&keyWords=ANY&state=";

		window.location = url;

		return;



  popupTheNewSearchWindow("/smejobsearch/jsponly/SearchResultPage.jsp?newSearch=true&applySearchCriteria=false&storeId=1&time_interval_id=ALL&job_type_id=ANY");

}











function NothingIsSelected()

{



  var noIndustries = false;

  if( document.search_form.division.value == "ANY" )

    noIndustries = true;



  var noRegions = false;

  if( document.search_form.keyWords.value == "ANY" )

    noRegions = true;



  var noKeyWords = false;

  if( document.search_form.state.value.length == 0 )

    noKeyWords = true;



  if( noIndustries && noRegions && noKeyWords )

      return true;

    else

      return false;



}



function PostTheForm()

{

  



  var isSubmitForm = false;



  if( document.search_form.state.value.length == 0 )

  {

    if( numIndustries <= 1 && document.search_form.division.value != "ANY" )

    {

      isSubmitForm = true;

    }

    else

    {

     isSubmitForm = true;

    }

  }

  else

  {

    isSubmitForm = true;

  }



	if( isSubmitForm )

	{

		/* Studio Emotion Mod... redirect the user to a a aust corp page which will then display the results. 
		old one
 		var division = document.search_form.division.value;
 		var keyWords = document.search_form.keyWords.value;
 		var state = document.search_form.state.value;
 		var url = "/jobsearch.php?division=" + division + "&keyWords=" + keyWords + "&state=" + escape(state);*/
 		
		/*  new system 29/09/10  HNC  */
		
		var division = document.search_form.division.value;
 		var keyWords = document.search_form.keyWords.value;
 		var state = document.search_form.state.value;
		//var url = "http://austcorpexecutive.force.com/jobs/jobsearchresult?division=" + division + "&keyWords=" + keyWords + "&state= " + state;
 		var url = "jobsearch_v2.php?division=" + division + "&keyWords=" + keyWords + "&state=" + state;
 
 		window.location = url;

		return;

	  
 



    //alert("The JS_URL is:  " + JS_URL);

    popupTheNewSearchWindow(JS_URL);

    return;

  }

  else

    return;

}



function popupTheNewSearchWindow(url)

{

    var popupWindow = window.open(url, "popupwin",

    "width=700, height=600, top=0, left=0, toolbar=yes, scrollbars=yes, resizable=yes");



    popupWindow.focus();

}



//function SubmitTheForm() old script



function SubmitTheForm()

{

  if( NothingIsSelected() )

  {

	isSubmitForm = true;

  }



  if( !FilterKeywords() )

    return;

  else

    return PostTheForm();

}



function setInitialFocus()

{

  document.search_form.state.focus();

}












