function check_form(step)
{
	switch(step)
	{
		case 'step_1':
			//check the form
			if (check_step_1() == true)
			{
				$('step_2').show();
				$('progress').src = 'imgs/search_nav/car02.gif';
				$("step_2_image").src = 'imgs/search_nav/step_2_image_over.gif';
				$('step_1').hide();
				enable_button('step_1');
				enable_button('step_2');
				document.location.href = '#form_start';
			}
			else
			{
				//errors will be displayed now from check_step_1()
			}
			break;
		case 'step_2':
			//check the form
			if (check_step_2() == true)
			{
				$('step_3').show();
				$('progress').src = 'imgs/search_nav/car03.gif';
				$("step_3_image").src = 'imgs/search_nav/step_3_image_over.gif';
				$('step_2').hide();
				enable_button('step_2');
				document.location.href = '#form_start';				
				//enable the summary button cos we've filled it all in by now
				enable_button('summary');
				display_summary();
			}
			else
			{
				//errors will be displayed now from check_step_2()
			}				
			break;
		default:
			//alert('erk');
		
	}	
}

function check_step_1()
{
	var errors = 0;
	var str = '<h1>We need a bit more</h1><p>Please enter your:<BR><BR>';
	
	if ($('Forename').value == '') { str += "Forename<BR>"; errors++; }
	if ($('Surname').value == '') { str += "Surname<BR>"; errors++; }
	if ( ($('DoB_day').value == '') && ($('DoB_Month').value == '') && ($('DoB_Year').value == '') ) { str += "Date of Birth<BR>"; errors++; }
	if ($('Marital_status').value == '') { str += "Marital status<BR>"; errors++; }
	if ($('Number_of_dependents').value == '') { str += "Number of dependents<BR>"; errors++; }
	
	if ($('House_name').value == '') { str += "House name<BR>"; errors++; }
	if ($('Street_name').value == '') { str += "Street name<BR>"; errors++; }
	if ($('Town').value == '') { str += "Town<BR>"; errors++; }
	if ($('Post_Code').value == '') { str += "Post Code<BR>"; errors++; }	
	
	if ($('Residence_Status').value == 'Owned - Mortgage')
	{
		if ($('House_Value').value == '') { str += "House name<BR>"; errors++; }
		if ($('Mortgage_Outstanding').value == '') { str += "Mortgage outstanding<BR>"; errors++; }
		if ($('Equity').value == '') { str += "Equity<BR>"; errors++; }
	}
	
	if ( ($('Time_at_address_Years').value == '') || ($('Time_at_address_Months').value == '') ) { str += "Time at current address<BR>"; errors++; }
	
	if ($('Time_at_address_Years').value < 5)
	{
		//check prev address entries
		if ($('Prev_House_name').value == '') { str += "Previous House name<BR>"; errors++; }
		if ($('Prev_Street_name').value == '') { str += "Previous Street name<BR>"; errors++; }
		if ($('Prev_Town').value == '') { str += "Previous Town<BR>"; errors++; }
		if ($('Prev_Post_Code').value == '') { str += "Previous Post Code<BR>"; errors++; }
	}
	
	if ( ($('telephone_home').value == '') && ($('telephone_work').value == '') && ($('telephone_mobile').value == '') && ($('email_address').value == '') )  { str += "A method of contact<BR>"; errors++; }	
		
	if ($('telephone_home').value != '') {
		if (isNaN($('telephone_home').value)) { str += "Home telephone is invalid (numbers only)<BR>"; errors++; } 
	}
	
	if ($('telephone_work').value != '') {
		if (isNaN($('telephone_work').value)) { str += "Work telephone is invalid (numbers only)<BR>"; errors++; }
	}
	
	if ($('telephone_mobile').value != '') {
		if (isNaN($('telephone_mobile').value)) { str += "Mobile telephone is invalid (numbers only)<BR>"; errors++; }
	}
	
	if ($('email_address').value != '') {
		if ($('email_address').value.indexOf("@") == -1) { str += "Email address must be valid<BR>"; errors++; }
	}
	
	
	
	if (document.aspnetForm.contact_prefered[0].checked) { 
		if ( ($('telephone_home').value == '') ) { str += "Home telephone must be entered<BR>"; errors++; }
	}
	
	if (document.aspnetForm.contact_prefered[1].checked) { 
		if ( ($('telephone_work').value == '') ) { str += "Work telephone must be entered<BR>"; errors++; }
	}
	
	if (document.aspnetForm.contact_prefered[2].checked) { 
		if ( ($('telephone_mobile').value == '') ) { str += "Mobile telephone must be entered<BR>"; errors++; }
	}
	
	if (document.aspnetForm.contact_prefered[3].checked) { 
		if ( ($('email_address').value == '') ) { str += "Email address must be entered<BR>"; errors++; }
	}	
	
	if ($('occupation').value == '') { str += "Occupation<BR>"; errors++; }
	
	if ($('Gross_Annual_Income').value == '') { str += "Gross Annual Income<BR>"; errors++; }
	
	if ($('bank_name').value == '') { str += "Bank name<BR>"; errors++; }
	
	if ( ($('Sort_code1').value == '') || ($('Sort_code2').value == '') || ($('Sort_code3').value == '')) 
	{ 
		str += "Sort code<BR>"; errors++; 
	}
	else
	{
		//its been filled in
		if ( ($('Sort_code1').value.length != 2) || ($('Sort_code2').value.length != 2) || ($('Sort_code3').value.length != 2) || 
		isNaN($('Sort_code1').value) || isNaN($('Sort_code2').value) || isNaN($('Sort_code3').value) ) { str += "Sort code must be xx/xx/xx (numbers only)<BR>"; errors++; }		
	}
	
	if ( ($('Account_number').value == '') || ($('Account_number').value.length >8) || ($('Account_number').value.length <7) || isNaN($('Account_number').value) )
	{
			str += "Account number must be valid (numbers only)<BR>"; errors++; 
	}
	
	if ($('Residence_Status').value != 'Owned - No Mortgage')
	{
		if ( ($('Mortgage').value == '') || isNaN($('Mortgage').value) ) { str += "Mortgage/Rent per month<BR>"; errors++; }
	}
	
	if (isNaN($('Existing_car_loan').value)) { str += "Existing car loan must be valid (numbers only)<BR>"; errors++; }
	
	if ( (!document.aspnetForm.replace_car_loan[0].checked) && (!document.aspnetForm.replace_car_loan[1].checked) ) { str += "Replacing car loan?<BR>"; errors++; }
	if (document.aspnetForm.replace_car_loan[0].checked) 
	{ 
		if ($('Existing_car_lender').value == '') { str += "Car finance lender's name<BR>"; errors++; }
	}
	
	if (errors > 0) 
	{ 
		//goto top
		document.location.href = '#top';
		
		//add on the buttons for this box
		str += '</p><span class="buttons"><input name="close" type="button" class="submit" id="close" onclick="close_dialog_box()" value="OK" style="clear:both;font-family:Arial, Verdana, Helvetica, sans-serif;color:#FFFFFF;font-size:100%;border:1px solid #6e0004;background-color:#4176C4;width:128px; margin:5px 0; font-size:11px;" /></span>';
		
		if(BrowserDetect.browser != 'Explorer') { str += '<div style="clear:both">&nbsp;</div>' };
		
		//disable dropdowns so IE6 doesn't display them and ruin our asthetic...
		disable_selects();
		
		//display modal dialog
		messageObj.setHtmlContent(str);		
		messageObj.setCssClassMessageBox(false);
		messageObj.setSource(false);	// no html source since we want to use a static message here.
		messageObj.setShadowDivVisible(true);	// Disable shadow for these boxes	
		messageObj.display();
		
		return false;
				
	}
	else
	{ 
		//we're good to go
		return true; 
	}
}

function check_step_2()
{
	var errors = 0;
	var str = '<h1>We need a bit morem</h1><p>Please enter your:<BR><BR>';
	
	if ($('Make').value == '') { str += "Car's make<BR>"; errors++; }
	if ($('Model').value == '') { str += "Car's model<BR>"; errors++; }
	if ($('fuel').value == '') { str += "Car's fuel<BR>"; errors++; }
	if ($('new_or_used').value == '') { str += "Is your car new or used?<BR>"; errors++; }
	
	if ($('new_or_used').value == 'Used') 
	{  
		if ( ($('Current_mileage').value == '') || isNaN($('Current_mileage').value) ) { str += "Current mileage (numbers only)<BR>"; errors++; }
		if ( ($('registration_year').value == '') || ($('registration_month').value == '') ) { str += "Registration month and year<BR>"; errors++; }
	}	
	
	if ( ($('Vehicle_cost_price').value == '') || isNaN($('Vehicle_cost_price').value) ) { str += "Vehicle cost price (numbers only)<BR>"; errors++; }
	if ( ($('Cash_deposit').value == '') || isNaN($('Cash_deposit').value) ) { str += "Cash deposit (numbers only)<BR>"; errors++; }
	if ( ($('Part_exchange').value == '') || isNaN($('Part_exchange').value) ) { str += "Part exchange (numbers only)<BR>"; errors++; }
	if ($('Balance_to_finance').value == '') { str += "Balance to finance<BR>"; errors++; }
	if ($('finance_term').value == '') { str += "Finance term<BR>"; errors++; }
	if ( (!document.aspnetForm.balloon_required[0].checked) && (!document.aspnetForm.balloon_required[1].checked) ) { str += "Balloon required<BR>"; errors++; }
	
	if (errors > 0) 
	{ 
		//goto top
		document.location.href = '#top';
		
		//add on the buttons for this box
		str += '</p><span class="buttons"><input name="close" type="button" class="submit" id="close" onclick="close_dialog_box()" value="OK" style="clear:both;font-family:Arial, Verdana, Helvetica, sans-serif;color:#FFFFFF;font-size:100%;border:1px solid #6e0004;background-color:#4176C4;width:128px; margin:5px 0; font-size:11px;" /></span>';
		
		if(BrowserDetect.browser != 'Explorer') { str += '<div style="clear:both">&nbsp;</div>' };
		
		//disable dropdowns so IE6 doesn't display them and ruin our asthetic...
		disable_selects();
		
		//display modal dialog
		messageObj.setHtmlContent(str);		
		messageObj.setCssClassMessageBox(false);
		messageObj.setSource(false);	// no html source since we want to use a static message here.
		messageObj.setShadowDivVisible(true);	// Disable shadow for these boxes	
		messageObj.display();
		
		return false; 
	}
	else
	{ 
		//we're good to go
		return true; 
	}
}

function check_contact_form()
{
	var errors = 0;
	var str = '<h1>We need a bit more</h1><p>Please enter your:<BR><BR>';
	
	if ($('Forename').value == '') { str += "Forename<BR>"; errors++; }
	if ($('Surname').value == '') { str += "Surname<BR>"; errors++; }
	if ($('Telephone').value == '') { str += "Telephone<BR>"; errors++; }
	if ($('Preferred_Time').value == '') { str += "Preferred time<BR>"; errors++; }
	
	if (errors > 0) 
	{ 
		//goto top
		document.location.href = '#top';
		
		//add on the buttons for this box
		str += '</p><span class="buttons"><input name="close" type="button" class="submit" id="close" onclick="close_dialog_box()" value="OK" style="clear:both;font-family:Arial, Verdana, Helvetica, sans-serif;color:#FFFFFF;font-size:100%;border:1px solid #6e0004;background-color:#4176C4;width:128px; margin:5px 0; font-size:11px;" /></span>';
		
		if(BrowserDetect.browser != 'Explorer') { str += '<div style="clear:both">&nbsp;</div>' };
		
		//display modal dialog
		messageObj.setHtmlContent(str);		
		messageObj.setCssClassMessageBox(false);
		messageObj.setSource(false);	// no html source since we want to use a static message here.
		messageObj.setShadowDivVisible(true);	// Disable shadow for these boxes	
		messageObj.display();
		
		return false; 
	}
	else
	{ 
		//we're good to go
		document.form1.submit();
		
		return true; 
	}
}

function close_dialog_box()
{
	//close our box
	messageObj.close();		
	//re-enable the selects
	enable_selects();
}

function disable_selects()
{
	var selects = document.getElementsByTagName("select");    
	for (var i=0; i<selects.length; i++) { $(selects[i]).disable(); }
}

function enable_selects()
{
	var selects = document.getElementsByTagName("select");    
	for (var i=0; i<selects.length; i++) { $(selects[i]).enable(); }
}

function enable_button(which_step)
{
	switch(which_step)
	{
	case 'step_1':
	  $("step_1_link").href = "javascript:show('1')";
	  break;    
	case 'step_2':	  
	  $("step_2_link").href = "javascript:show('2')";
	  break;    
	case 'summary':
	  $("step_3_link").href = "javascript:show('3')";
	  break;    
	default:
	  alert('default');
	}	
}

function show(div_name)
{
	//close all divs first
	$('step_1').hide();
	$('step_2').hide();
	$('step_3').hide();	
	
	//now show the one we want
	$('step_'+div_name).show();
	
	//move the car
	$('progress').src = 'imgs/search_nav/car0'+div_name+'.gif';
}

function swap_image(what, image_name)
{
	document.getElementById(what).src = image_name;
}

function display_house_value(val)
{
	if (val == 'Owned - Mortgage')
	{
		$('house_value').show();
		$('mortgage_outstanding').show();
		$('equity').show();	
	}
	else
	{
		$('house_value').hide();
		$('mortgage_outstanding').hide();
		$('equity').hide();	
	}
	
	if (val != 'Owned - No Mortgage')
		$('mortgage_value_star').style.display = "inline";
	else
		$('mortgage_value_star').hide();	
}

function calculate_equity(sum1, sum2)
{
	var sum1 = parseInt(sum1);
	var sum2 = parseInt(sum2);
	
	if ( (isNaN(sum1)) || (isNaN(sum2)) )
	{
		if ( (sum1 > 0) && (sum2 > 0) )
		{
			document.aspnetForm.Equity.value = (sum1 - sum2);
		}
		else
		{
			document.aspnetForm.Equity.value = '';
		}
	}
	else
	{
		document.aspnetForm.Equity.value = (sum1 - sum2);
	}
}

function check_time_at_address(val)
{
	if (val < 5)
	{
		$('prev_address_details_header').show();
		$('prev_address_details').show();
	}
	else
	{
		$('prev_address_details_header').hide();
		$('prev_address_details').hide();
	}
}

function display_prev_employer_name(months, years)
{
	months = parseInt(months);
	years = parseInt(years);
	
	//add up the months and years, less than 18 and display the prev employer input
	if (years > 0)
	{
		var extra_months = years * 12;
		
		months += extra_months;
	}
	
	if (months < 19)
	{
		$('Prev_Employers_Name').show();
		$('Time_at_prev_employer').show();
	}
	else
	{	
		$('Prev_Employers_Name').hide();
		$('Time_at_prev_employer').hide();
	}
}
	
function display_car_lender(val)
{
	if (val == 'yes')
	{
		$('Existing_car_lender').show();
		$('Existing_car_lender_text').show();
	}
	else
	{
		$('Existing_car_lender').hide();
		$('Existing_car_lender_text').hide();
	}
}

function display_credit_history_details(defaults, ccj)
{
	if ( (document.aspnetForm.defaults[0].checked) || (document.aspnetForm.ccj[0].checked) )
	{
		$('credit_history_details').show();
	}
	else
	{	
		$('credit_history_details').hide();
	}
}

function calculate_finance_figure()
{
	var Vehicle_cost_price = parseInt(document.aspnetForm.Vehicle_cost_price.value);
	var Cash_deposit = parseInt(document.aspnetForm.Cash_deposit.value);
	var Part_exchange = parseInt(document.aspnetForm.Part_exchange.value);	
	
	if ( (isNaN(Vehicle_cost_price)) || (isNaN(Cash_deposit)) || (isNaN(Part_exchange)) )
	{
		document.aspnetForm.Balance_to_finance.value = '';
	}
	else
	{
		document.aspnetForm.Balance_to_finance.value = Vehicle_cost_price - (Cash_deposit + Part_exchange);
	}
}
	
	
function display_summary()
{
	var str = "<p>Forename: <strong>"+ $('Forename').value +"</strong> </p>";
	str += "<p>Middle name: <strong>"+ $('Middle_name').value +"</strong> </p>";
	str += "<p>Surname: <strong>"+ $('Surname').value +"</strong> </p>";
	str += "<p>Date of Birth: <strong>"+ $('DoB_day').value +"/"+ $('DoB_Month').value +"/"+ $('DoB_Year').value +"</strong> </p>";
	str += "<p>Nationality: <strong>"+ $('Nationality').value +"</strong> </p>";
	str += "<p>Marital status: <strong>"+ $('Marital_status').value +"</strong> </p>";
	str += "<p>Number of dependents: <strong>"+ $('Number_of_dependents').value +"</strong> </p>";
	
	str += "<div class=\"largeboxSearchSubTitle\">Your Address</div>";
	str += "<p>House name/number: <strong>"+ $('House_name').value +"</strong></p>";
	str += "<p>Street name: <strong>"+ $('Street_name').value +"</strong></p>";
	str += "<p>Town/City: <strong>"+ $('Town').value +"</strong></p>";
	str += "<p>Post Code: <strong>"+ $('Post_Code').value +"</strong></p>";
	str += "<p>Residential status: <strong>"+ $('Residence_Status').value +"</strong></p>";
	str += "<p>House Value: <strong>"+ $('House_Value').value +"</strong></p>";
	str += "<p>Mortgage Outstanding: <strong>"+ $('Mortgage_Outstanding').value +"</strong></p>";
	str += "<p>Time at address: <strong>"+ $('Time_at_address_Years').value +" years, "+ $('Time_at_address_Months').value +" months</strong> </p>";
	
	if ($('Time_at_address_Years').value < 5)
	{	
		str += "<div class=\"largeboxSearchSubTitle\">Your Previous Address (if required)</div>";
		str += "<p>House name/number: <strong>"+ $('Prev_House_name').value +"</strong></p>";
		str += "<p>Street name: <strong>"+ $('Prev_Street_name').value +"</strong></p>";
		str += "<p>Town/City: <strong>"+ $('Prev_Town').value +"</strong></p>";
		str += "<p>Post Code: <strong>"+ $('Prev_Post_Code').value +"</strong></p>";
		str += "<p>Time at address: <strong>"+ $('Prev_Time_at_address_Years').value +" years, "+ $('Prev_Time_at_address_Months').value +" months</strong> </p>";
	}
	
	str += "<div class=\"largeboxSearchSubTitle\">Your Contact Details</div>";
	str += "<p>Home telephone: <strong>"+ $('telephone_home').value +"</strong></p>";
	str += "<p>Work telephone: <strong>"+ $('telephone_work').value +"</strong> </p>";
	str += "<p>Mobile telephone: <strong>"+ $('telephone_mobile').value +"</strong></p>";
	str += "<p>Email address: <strong>"+ $('email_address').value +"</strong></p>";
	str += "<p>Contact preferred: <strong>"+ $('contact_prefered').value +"</strong></p>";
	
	str += "<div class=\"largeboxSearchSubTitle\">Your Employment Details</div>";
	str += "<p>Occupation: <strong>"+ $('occupation').value +"</strong></p>";
	str += "<p>Employers Name: <strong>"+ $('Employers_Name').value +"</strong></p>";
	str += "<p>Time at current employer (if required): <strong>"+ $('time_with_employer_years').value +" year(s), "+ $('time_with_employer_months').value +" months</strong> </p>";
	str += "<p>Address: <strong>"+ $('Employment_Address').value +"</strong> </p>";
	str += "<p>Prev employer (if required): <strong>"+ $('prev_employers_name').value +"</strong> </p>";
	str += "<p>Time at previous employer (if required): <strong>"+ $('Time_at_prev_employer_Years').value +" year(s), "+ $('Time_at_prev_employer_months').value +" months</strong> </p>";
	
	str += "<div class=\"largeboxSearchSubTitle\">Your Bank Details</div>";
	str += "<p>Bank name: <strong>"+ $('bank_name').value +"</strong></p>";
	str += "<p>Sort code: <strong>"+ $('Sort_code1').value +"-"+ $('Sort_code2').value +"-"+ $('Sort_code3').value +"</strong> </p>";
	str += "<p>Account number: <strong>"+ $('Account_number').value +"</strong> </p>";
	
	str += "<div class=\"largeboxSearchSubTitle\">Your Monthly Outgoings</div>";
	str += "<p>Mortgage/Rent£: <strong>"+ $('Mortgage').value +"</strong> </p>";
	str += "<p>Existing car loan £: <strong>"+ $('Existing_car_loan').value +"</strong> </p>";
	str += "<p>Does this application replace your existing car loan: <strong>"+ $('replace_car_loan').value +"</strong> </p>";
	str += "<p>Existing lender (if required): <strong>"+ $('Existing_car_lender').value +"</strong> </p>";
	
	str += "<div class=\"largeboxSearchSubTitle\">Your Car Details</div>";
	str += "<p>Make: <strong>"+ $('Make').value +"</strong></p>";
	str += "<p>Model: <strong>"+ $('Model').value +"</strong> </p>";
	str += "<p>Fuel: <strong>"+ $('fuel').value +"</strong> </p>";
	str += "<p>New or Used: <strong>"+ $('new_or_used').value +"</strong> </p>";
	
	if ( ($('registration_month').value == '') || ($('registration_year').value == '') )
	{
		str += "<p>Month and year of registration if used: <strong>n/a</strong></p>";
	}
	else
	{
		str += "<p>Month and year of registration if used: <strong>"+ $('registration_month').value +"/"+ $('registration_year').value +"</strong> </p>";
	}
	
	str += "<p>Reg number (if known): <strong>"+ $('reg_number').value +"</strong></p>";
	str += "<p>Current mileage if used (in 000's): <strong>"+ $('Current_mileage').value +"</strong></p>";
	str += "<p>Suppliers name: <strong>"+ $('Suppliers_name').value +"</strong> </p>";
	str += "<p>Suppliers website or telephone number: <strong>"+ $('Suppliers_website').value +"</strong> </p>";
	
	str += "<div class=\"largeboxSearchSubTitle\">Your Finance Details</div>";
	str += "<p>Vehicle cost price: <strong>&pound;"+ $('Vehicle_cost_price').value +"</strong> </p>";
	str += "<p>Cash deposit: <strong>&pound;"+ $('Cash_deposit').value +"</strong> </p>";
	str += "<p>Part exchange: <strong>&pound;"+ $('Part_exchange').value +"</strong> </p>";
	str += "<p>Balance to finance: <strong>&pound;"+ $('Balance_to_finance').value +"</strong> </p>";
	str += "<p>Finance term: <strong>"+ $('finance_term').value +"</strong> </p>";
	str += "<p>Balloon required: <strong>"+ $('balloon_required').value +"</strong> </p>";
	
	str += "<div class=\"largeboxSearchSubTitle\">Data Protection</div>";
	str += "<p>Fast Car Finance is unable to process your application unless you expressly accept our Website <a href=\"terms.htm\" target=\"_blank\">Terms and Conditions</a> and <a href=\"privacy.htm\" target=\"_blank\">Privacy Statement</a>. Please tick the box below to confirm your acceptance of those terms</p>";
	str += "<p>I agree: <strong>Yes:</strong><input name=\"agree_to_terms\" type=\"radio\" class=\"check\" id=\"agree_to_terms\" style=\"position:relative; top:6px\" value=\"yes\" />|<strong> No:</strong><input name=\"agree_to_terms\" type=\"radio\" class=\"check\" id=\"agree_to_terms\" style=\"position:relative; top:6px\" value=\"no\" /></p>";
	
	str += "<div class=\"largeboxSearchSubTitle\">Marketing</div>";
	str += "<p style=\"position:relative; top:-4px\">Please tick the following box if you wish to receive information on our products and services in the future: <input name=\"agree_to_marketing\" type=\"checkbox\" class=\"check\" id=\"agree_to_marketing\" style=\"position:relative; top:6px\" value=\"yes\" /></p>";
	
	//write it - not using prototype cos it errors for innerhtml
	document.getElementById('summary_holder').innerHTML = str;
}

function submit_form()
{
	if (!$('agree_to_terms').checked) 
	{ 
		var str = '<h1>We need a bit more</h1><p>Please accept our Data Protection policy to continue.';
		
		//goto top
		document.location.href = '#top';
		
		//add on the buttons for this box
		str += '</p><span class="buttons"><input name="close" type="button" class="submit" id="close" onclick="close_dialog_box()" value="OK" style="clear:both;font-family:Arial, Verdana, Helvetica, sans-serif;color:#FFFFFF;font-size:100%;border:1px solid #6e0004;background-color:#4176C4;width:128px; margin:5px 0; font-size:11px;" /></span>';
		
		if(BrowserDetect.browser != 'Explorer') { str += '<div style="clear:both">&nbsp;</div>' };
		
		//disable dropdowns so IE6 doesn't display them and ruin our asthetic...
		disable_selects();
		
		//display modal dialog
		messageObj.setHtmlContent(str);		
		//height is dependant on whats in it so we need to multiply errors by something useful
		messageObj.setSize(500,120);		
		messageObj.setCssClassMessageBox(false);
		messageObj.setSource(false);	// no html source since we want to use a static message here.
		messageObj.setShadowDivVisible(true);	// Disable shadow for these boxes	
		messageObj.display();
		
		return false; 
	}
	else
	{ 
		//we're good to go
		document.aspnetForm.submit();
	}
	
}

function update_employment_questions()
{
	if ($('Employment_status').value != 'Retired')
	{
		//show the stars
		$('Employers_Name_star').style.display = "inline";
		$('time_with_employer_star').style.display = "inline";
	}
	else
	{
		//disappear the stars
		$('Employers_Name_star').hide();
		$('time_with_employer_star').hide();
	}
}

function update_mileage_question()
{
	if ($('new_or_used').value == 'Used')
	{
		//show the stars
		$('registration_star').style.display = "inline";
		$('mileage_star').style.display = "inline";
	}
	else
	{
		//disappear the stars
		$('registration_star').style.display = "none";
		$('mileage_star').style.display = "none";
	}
}

//broswer detection script
var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{
			string: navigator.userAgent,
			subString: "Chrome",
			identity: "Chrome"
		},
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};
BrowserDetect.init();