	 function popup(url) {
		window.open(url,'newWin','width=700,height=400, scrollbars=yes');
	 }

	 function display(id, visibility) {

	   if (document.all) {
		 if (visibility) {
		   document.all[id].style.display='block';
		 } else {
		   document.all[id].style.display='none';
		 }
	   } else {
		 var p = document.getElementById(id);
		 if (visibility) {
		   p.style.display='block';
		 } else {
		   p.style.display='none';
		 }
	   }
	 }

	 function validateForm() {
	  retVal = true;

	  // first name
	  if (retVal == true) {
	   retVal = individualValidate('first_name');
	  } else {
	   individualValidate('first_name');
	  }

	  // last name
	  if (retVal == true) {
	   retVal = individualValidate('surname');
	  } else {
	   individualValidate('surname');
	  }

	  // dob year
	  if (retVal == true) {
	   retVal = individualValidate('dob_year');
	  } else {
	   individualValidate('dob_year');
	  }

	  // dob year 4digit
	  if(!document.forms['home'].elements['dob_year'].value.match(/^\d{4}$/)) {
	   retVal = false;
	   document.forms['home'].elements['dob_year'].className = 'input-err';
	  }

	  // email address
	  if (retVal == true) {
	   retVal = individualValidate('email');
	  } else {
	   individualValidate('email');
	  }

	  // phone
	  if (retVal == true) {
	   retVal = individualValidate('phone');
	  } else {
	   individualValidate('phone');
	  }

	  // only if valid, check About your home part
	  // street
	  if (retVal == true) {
	   retVal = individualValidate('street');
	  } else {
	   individualValidate('street');
	  }

	  // town
	  if (retVal == true) {
	   retVal = individualValidate('town');
	  } else {
	   individualValidate('town');
	  }

	  // zip
	  if (retVal == true) {
	   retVal = individualValidate('zip');
	  } else {
	   individualValidate('zip');
	  }

	  // Pulldowns
	  // Marital Status

	  if (retVal == true) {
	   retVal = individualValidatePulldown('married');
	  } else {
	   individualValidatePulldown('married');
	  }

	  // income
	  if (retVal == true) {
	   retVal = individualValidatePulldown('income');
	  } else {
	   individualValidatePulldown('income');
	  }

	  // amount
	  if (retVal == true) {
	   retVal = individualValidatePulldown('amount');
	  } else {
	   individualValidatePulldown('amount');
	  }

	  // residential
	  if (retVal == true) {
	   retVal = individualValidatePulldown('residential');
	  } else {
	   individualValidatePulldown('residential');
	  }
	  
	 // residential
	  if (retVal == true) {
	   retVal = individualValidatePulldown('purpose');
	  } else {
	   individualValidatePulldown('purpose');
	  }
	  
	  // home value
	  if (retVal == true) {
	   retVal = individualValidatePulldown('home_value');
	  } else {
	   individualValidatePulldown('home_value');
	  }

	  // I accept checkbox
	  if (retVal == true) {
	   if (document.forms['home'].elements['accept'].checked == false) {
		retVal = false;
//		document.forms['home'].elements['accept'].className = 'input-errcheckbox';
	   document.getElementById("c").style.backgroundColor="orange";
	  
	  } else {
//		document.forms['home'].elements['accept'].className = '';
	   document.getElementById("c").style.backgroundColor="#C9DFE2";
	   }
	  } else {
	   if (document.forms['home'].elements['accept'].checked == false) {
		//document.forms['home'].elements['accept'].className = 'input-errcheckbox';
	  document.getElementById("c").style.backgroundColor="orange";
	  } else {
//		document.forms['home'].elements['accept'].className = '';
	 document.getElementById("c").style.backgroundColor="#C9DFE2";
	 }

	  }



	  // Partner details (if applicable)
	  if (document.forms['home'].elements['married'].value == 'Married' ||
		  document.forms['home'].elements['married'].value == 'Living Together') {

		  // dob year
		  if (retVal == true) {
		   retVal = individualValidate('part_dob_year');
		  } else {
		   individualValidate('part_dob_year');
		  }

		  // dob year 4digit
		  if(!document.forms['home'].elements['part_dob_year'].value.match(/^\d{4}$/)) {
		   retVal = false;
		   document.forms['home'].elements['part_dob_year'].className = 'input-err';
		  }

		  // firstname
		  if (retVal == true) {
		   retVal = individualValidate('part_name1');
		  } else {
		   individualValidate('part_name1');
		  }

		  // surname
		  if (retVal == true) {
		   retVal = individualValidate('part_name2');
		  } else {
		   individualValidate('part_name2');
		  }

		  // pulldowns

		  // p_income
		  if (retVal == true) {
		   retVal = individualValidatePulldown('p_income');
		  } else {
		   individualValidatePulldown('p_income');
		  }

		  // job_len
		  if (retVal == true) {
		   retVal = individualValidatePulldown('job_len');
		  } else {
		   individualValidatePulldown('job_len');
		  }
	  }

//document.forms['home'].action = 'processForm.php';


//##############################################################################
//The case anaylysis will be done in processForm.php
/*

//##############################################################################
//Case APS
	  // residential and purpose
	  if (document.forms['home'].elements['residential'].value == 'Own Home Outright') {
	   	document.forms['home'].action = 'http://www.e-financialaffiliates.com/track.aspx?cid=19&efid=2334';
	  }
	  
	  else if (document.forms['home'].elements['purpose'].value == 'Mortgage' || 
	      document.forms['home'].elements['purpose'].value == 'Remortgage') {
			document.forms['home'].action = 'http://www.e-financialaffiliates.com/track.aspx?cid=19&efid=2334';
			//document.forms['home'].action = 'http://';
	  }

//##############################################################################
// Case EuroCredit
	  // residential
	  else if (document.forms['home'].elements['residential'].value == 'Student Accomodation' ||
	      document.forms['home'].elements['residential'].value == 'Tenant (Furnished)' ||
	      document.forms['home'].elements['residential'].value == 'Tenant (UnFurnished)' ||
	      document.forms['home'].elements['residential'].value == 'Living with Parent/s') {
			document.forms['home'].action = 'http://www.e-financialaffiliates.com/track.aspx?cid=3&efid=2334';
	  }
	  
//##############################################################################
// Case 6
	  // title and residential
	  else if (document.forms['home'].elements['title'].value == 'Mrs' && document.forms['home'].elements['residential'].value == 'Mortgaged Home') {
			document.forms['home'].action = 'case6.php';
	  }
	  
//##############################################################################
// Case 5
	  else if ((document.forms['home'].elements['title'].value == 'Miss' || document.forms['home'].elements['title'].value == 'Mr')
	  	  && document.forms['home'].elements['residential'].value == 'Mortgaged Home') {
			document.forms['home'].action = 'case5.php';
	  }
	  
//##############################################################################

*/
	  
	  
	  return retVal;
	 }

	 function individualValidate(elementName) {
	  if (document.forms['home'].elements[elementName].value == '') {
	   document.forms['home'].elements[elementName].className = 'input-err';
	   return false;
	  } else {
	   document.forms['home'].elements[elementName].className = 'input';
	   return true;
	  }
	 }

	 function individualValidatePulldown(elementName) {
	  if (document.forms['home'].elements[elementName].options[document.forms['home'].elements[elementName].selectedIndex].value == '') {
	   document.forms['home'].elements[elementName].className = 'input-errpulldown';
	   return false;
	  } else {
	   document.forms['home'].elements[elementName].className = 'input';
	   return true;
	  }

	 }

	 function populateForm() {
	  // populate(document.forms[0].elements['dob_day'], make_range(1, 5, 1, 2, '', ''));
	  // populate(document.forms[0].elements['dob_month'], make_range(1, 10, 1, 0, ',000', '&pound;'));
	 }

