//jquery functions
$(document).ready(function() {

	//menu initialiser
	$('#main-navigation-Level-1 > li').bind('mouseover', mmul_open);
	$('#main-navigation-Level-1 > li').bind('mouseout',  mmul_timer);

	//cyle latest properties
	lastest_property();

	if (( $("#minprice").length > 0 ) && ( $("#maxprice").length > 0 )){
		rental_or_sale_select( $("#rentalorsale").attr("value"),0,0);
	}


	//if div map exists load the MS Map
	if ( $("#main-map").length > 0 ) {
		loadHomePage();
	}

	//if div map exists load the MS Map
	if ( $("#map-search-map").length > 0 ) {
		loadPage();
	}


	if ( $("#contact-us-map").length > 0 ) {
		GetMillsoppsOfficesMap('contact-us-map');
	}

	if ( $("#individual-propertymap").length > 0 ) {
		GetIndividualMap($("#lat").attr("value"),$("#lng").attr("value"),'m','individual-propertymap');
	}

	if ( $("#individual-aerialview").length > 0 ) {
		GetIndividualMap($("#lat").attr("value"),$("#lng").attr("value"),'a','individual-aerialview');
	}

	$(".main-navigation-Level-2 li .current").each( function() {
		$this = $(this);
		$this.parent().parent().parent().addClass("current-li");
	});


});


function check_register_form()
{
	var errorList = '';
	var areaSelected = false;
	if(document.registerForm.first_name.value=='') errorList += '\n - First Name';
	if(document.registerForm.last_name.value=='') errorList += '\n - Last Name';
	if(document.registerForm.address1.value=='') errorList += '\n - Address Line 1';
	if(document.registerForm.town.value=='') errorList += '\n - Town';
	if(document.registerForm.county.value=='') errorList += '\n - County';
	if(document.registerForm.postcode.value=='') errorList += ' \n - Postcode';
	if((document.registerForm.mobile_phone.value=='') && (document.registerForm.home_phone.value=='') && (document.registerForm.work_phone.value=='')) errorList += '\n - A contact number';
	if(document.registerForm.email.value=='') errorList += '\n - Email Address';
//	if((document.registerForm.mortgage_advice.checked=='') && (document.registerForm.finance.checked=='') && (document.registerForm.executive.checked=='') && (document.registerForm.emailproperties.checked=='') && (form.textproperties.checked=='')) errorList += '\n - What services would you like information on';

/*
	for(i=0; i<registerForm.millsoppsareas.length; i++){
		if (registerForm.millsoppsareas[i].checked==true)
		{
			areaSelected = true;
		}
	}

	if (areaSelected==false)  errorList += '\n - An area of interest';
*/

	if (errorList!='')
	{
		errorList = 'Please complete the following information' + errorList;
		alert(errorList);
		return false;
	} else {
		return true;
	}
}


function updateCheckBox(checkBoxId)
{
	if (document.getElementById(checkBoxId).checked==true)
	{
		document.getElementById(checkBoxId).checked=false;
	} else {
		document.getElementById(checkBoxId).checked=true;
		document.getElementById('allareas').checked=false;
	}
	
}

function checkAllAreas(checkBoxId)
{
	if ((document.getElementById(checkBoxId).checked==true) && (document.getElementById('allareas').checked==true))
	{
		document.getElementById('allareas').checked=false;
	}
}