var preloadFlag = false;

function removeHint(fld) { //removes field hint on focus
  fld.className = "FieldHint"
  fld.value=""
}
function preloadImages() {  
	if (document.images) {

		preloadFlag = true;  
	}
}
function newImage(arg)  
{ if (document.images)
  {	rslt = new Image(); rslt.src = arg; return rslt; } 
}

function MM_swapImgRestore() { //v3.0 
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc; 
} 
 
function MM_findObj(n, d) { //v4.01 
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) { 
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} 
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n]; 
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); 
  if(!x && d.getElementById) x=d.getElementById(n); return x; 
} 
 
function MM_swapImage() { //v3.0 
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3) 
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];} 
}
function ShowPrivacy(){
    popWindow = window.open("../../popups/privacy.html","popWin2","width=740,height=530,toolbar=no,location=no,menubar=no,status=no,scrollbars=yes,resizable=no")
}
function showFeedback(){
    popWindow = window.open("../../popups/feedback.php","popWin2","width=669,height=530,toolbar=no,location=no,menubar=no,status=no,scrollbars=yes,resizable=no")
}
function showTerms(){
    popWindow = window.open("../../popups/terms.html","popWin2","width=740,height=530,toolbar=no,location=no,menubar=no,status=no,scrollbars=yes,resizable=no")
}
function ShowJoin(){
    popWindow = window.open("cafestudyRego.join","popWin2","width=740,height=530,toolbar=no,location=no,menubar=no,status=no,scrollbars=yes,resizable=no")
}


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];}   
  } 
}


/**
 * Sets the "State" and "Postcode" fields to enabled/disabled, depending on the calue of the "Country" field.
 *
 * If the Country drop-down has been set to NZ, set the State drop-down to NZ and disable it. Also disable the Postcode field.
 */
function setIndustry()
{
	// Set student
	if ( document.getElementById('icol_20').selectedIndex == 7 )
	{
  	document.getElementById('icol_23').selectedIndex = 39;
  	document.getElementById('icol_24').selectedIndex = 4;
  	document.getElementById('icol_25').selectedIndex = 1;
	}
	// Set home duties
	if ( document.getElementById('icol_20').selectedIndex == 5 )
	{
  	document.getElementById('icol_23').selectedIndex = 39;
  	document.getElementById('icol_24').selectedIndex = 4;
  	document.getElementById('icol_25').selectedIndex = 17;
	}
	// Set unemployed
	if ( document.getElementById('icol_20').selectedIndex == 8 )
	{
  	document.getElementById('icol_25').selectedIndex = 15;
	}
	// Set retired
	if ( document.getElementById('icol_20').selectedIndex == 6 )
	{
  	document.getElementById('icol_23').selectedIndex = 39;
  	document.getElementById('icol_24').selectedIndex = 4;
  	document.getElementById('icol_25').selectedIndex = 16;
	}	
}
function setStatePostcodeStatus ( )
{
	if ( document.getElementById('country').selectedIndex == 2 )
	{
		// Country has been set to 'New Zealand'
		
		opt = document.createElement('option');
		opt.text = 'New Zealand';
		opt.value = 'New Zealand';		
		
		state = document.getElementById('state');
		
	  try
	  {
	    state.add(opt, null); // standards compliant; doesn't work in IE
	  }
	  catch(ex)
	  {
	    state.add(opt); // IE only
	  }
	  
		document.getElementById('state').selectedIndex = 9;
		document.getElementById('state').disabled = true;
		document.getElementById('postcode').value = '';
		document.getElementById('postcode').disabled = true;
		document.getElementById('postcodeRequiredStar').innerHTML = ' ';
		document.getElementById('stateRequiredStar').innerHTML = ' ';
	}
	else
	{
		// Country has been set to something else
				
		// If the state was previously 'New Zealand', reset it to 'Select'
		if ( document.getElementById('state').selectedIndex == 9 ) document.getElementById('state').selectedIndex = 0;
		
		document.getElementById('state').disabled = false;
		document.getElementById('postcode').disabled = false;
		if ( !document.getElementById('postcode').value )
			document.getElementById('postcodeRequiredStar').innerHTML = '<font color="red">*</font>';		
		if ( !document.getElementById('state').value )
			document.getElementById('stateRequiredStar').innerHTML = '<font color="red">*</font>';		
		
		// Remove 'New Zealand' from the list
		document.getElementById('state').remove(9);
		document.getElementById('state').remove(9);
	}		
}


/**
 * Makes sure that the State and Postcode fields are re-enabled just before the form is submitted,
 * otherwise the field values aren't sent to the server.
 */

function enableStatePostcode ( )
{
	document.getElementById('state').disabled = false;
	document.getElementById('postcode').disabled = false;
}


/**
 * Enables/disables the "Vehicle Make" drop-down list depending on the value of "I currently own or drive a vehicle"
 */

/*function setVehicleMakeStatus ( )
{
  if ( document.getElementById('vehicleYes').checked )
  {
    document.getElementById('vehicleMake').disabled = false;
		if ( !document.getElementById('vehicleMake').value )
		  document.getElementById('vehicleMakeRequiredStar').innerHTML = '<font color="red">*</font>';		
  }
  else
  {
    document.getElementById('vehicleMake').selectedIndex = 0;
    document.getElementById('vehicleMake').disabled = true;
		document.getElementById('vehicleMakeRequiredStar').innerHTML = '';		
  }
}
*/



