/*Javascript for Qualifications Finder

Lookup Values:

QualTypes

1 - NVQ
2 - Foundation degree
3 - Undergraduate
4 - Postgraduate
5 - IHRIM

AreaTypes

1 - North East
2 - North West
3 - Yorkshire and Humberside
4 - East Midlands
5 - West Midlands
6 - East Anglia
7 - London
8 - South East
9 - South West
10 - UK wide

TimeTypes

1 - Full Time
2 - Part Time
3 - Both

*/

function preloadImages(image_url) {
 if (document.images) {
 //alert("Peloading Images: "+image_url.length);
  for(i=0; i<image_url.length; i++) {
      preload_image_object = new Image();
      // set image url
      preload_image_object.src = image_url[i];
      //alert("Preloading image: "+image_url[i]);
    }
  }
}


function check_HIqualtype( )
{

 valid = true;

 if ( document.HIquals.qualtype.value == '0')  
 {   
  document.HIquals.qualtype.focus();
  document.HIquals.qualtype.value = 0;
  valid = false;
 }

 if ( document.HIquals.qualtype.value == '1' )  
 {
  alert('There are currently no NVQ qualifications in the database. Please choose another type.');
  document.HIquals.qualtype.focus();
  valid = false;
 }

 if ( document.HIquals.qualtype.value == '5' )  
 {
  alert ( 'IHRIM qualifications are UK wide and work-based - the Search criteria will be set to match IHRIM qualifications.' );
  document.HIquals.country.value = '5';
  document.HIquals.areatype.value = '10'; 
  document.HIquals.timetype.value = '3'; 
  document.HIquals.submit.focus();
  valid = false;
 }
return valid;
}


function check_HIcountry() {
	var c = document.HIquals.country.value;
	
	if(c > 1) {
		// Non England
		document.HIquals.areatype.value = 10;
		document.getElementById("sel_areatype").disabled = true;
	}
	else {
		document.HIquals.areatype.value = 0;
		document.getElementById("sel_areatype").disabled = false;
	}
}

function check_HIareatype( )
{

 valid = true;
 
 if ( document.HIquals.areatype.value == '0')  
 {   
  document.HIquals.areatype.focus();
  document.HIquals.areatype.value = 0;
  valid = false;
 }

return valid;
}


function check_HItimetype( )
{
 valid = true;
 
 if ( document.HIquals.timetype.value == '0')  
 {   
  document.HIquals.timetype.focus();
  document.HIquals.timetype.value = 0;
  valid = false;
 }
return valid;
}

function validate_gen_search( ) 
{ 
	valid = true; 

 if (document.general_search.keyword.value == 'Enter keyword...' || document.general_search.keyword.value == '')
 { 
		message = 'Please type a keyword to search for then click Go'; 
		valid = false; 
		document.HIquals.qualtype.focus();
		alert(message);
	}
	return valid; 
} 

function validate_HIqualsform( ) 
{
 valid = true; 
 thisalert = 'Please choose ';

 if ( document.HIquals.qualtype.value == '0' )  
 { 
  thisalert += 'a type of qualification, '; 
  valid = false; 
  document.HIquals.qualtype.focus();
 }
 
 if ( document.HIquals.country.value == '0' )  
 { 
  thisalert += 'a country, ';  
  valid = false; 
  document.HIquals.country.focus();
 } 

 if ( document.HIquals.areatype.value == '0' )  
 { 
  thisalert += 'an area, ';  
  valid = false; 
  document.HIquals.areatype.focus();
 } 

 if ( document.HIquals.timetype.value == '0' )  
 { 
  thisalert += 'Full-time or Part-time or both, ';  
  valid = false; 
  document.HIquals.timetype.focus();
 } 

 if (valid != true) 
 {
  thisalert += 'then click Search.';
  alert(thisalert);
 }

 if ( document.HIquals.qualtype.value == 'IHRIM' )  
 {
  document.HIquals.areatype.value = 'UK wide'; 
  document.HIquals.timetype.value = 'TALL'; 
  valid = true;
 }
return valid; 
} 

function validate_HIcoursesform( ) 
{
 valid = true; 
 thisalert = 'Please choose ';

 if (document.HIcourses.courselist.value == 0) 
 {
  thisalert += 'an ETD course then click Search.';
  valid = false;
  alert(thisalert);
 }
return valid; 
} 


function openResultsWindow(URL)
{
	var WIDTH = 600;
	var HEIGHT = 500;
	var swidth = screen.width;
	var sheight = screen.height;
	var day = new Date();
	var id = day.getTime();
	var lf = (screen.width - WIDTH)/2;
	var tf = (screen.height - HEIGHT)/2;
	var newWin = eval("page" + id + " = window.open(URL,'" + id + "','toolbar=0,scrollbars=1,location=0,status=1,menubar=1,resizable=1,width=" + WIDTH +",height=" + HEIGHT +",top="+ tf + ",left="+ lf +"');");
}
