var birminghamOffice = null;
var leicesterOffice = null;
var map = null;

function gMapLoad() {
	  	birminghamOffice = new google.maps.LatLng(52.451372,-1.818193);
	  	leicesterOffice = new google.maps.LatLng(52.5950582,-1.18996739);

		var myOptions = {
			zoom: 13,
			center: birminghamOffice,
			mapTypeId: google.maps.MapTypeId.ROADMAP
		}
		map = new google.maps.Map(document.getElementById("map"), myOptions);
		
		var boMarker = new google.maps.Marker({
			position: birminghamOffice, 
			map: map,
			title:"Birmingham Office"
		});
		var loMarker = new google.maps.Marker({
			position: leicesterOffice, 
			map: map,
			title:"Leicester Office"
		});
		google.maps.event.addListener(map, 'tilesloaded', function() {
    		$("#maploader").fadeOut();
  		});

		
}

$(document).ready(function(){
	var page = $("#page");
	var scope = "general";
	var scopeArray = ["home","commercial","property","financial"];
	for (var scopetype in scopeArray){
		if(page.hasClass(scopeArray[scopetype])){
			scope = scopeArray[scopetype];
			break;
		}
	}
	$("#main-nav li:not(."+scope+")").hover(function(){
										$(this).find(".subnav-pop").show();
										$(this).addClass("topmost");
									},function(){
										$(this).find(".subnav-pop").hide();	
										$(this).removeClass("topmost");
									});
	if($("#map").length>0){
		gMapLoad();	
		$(".map-link").click(function(){
									  var link = $(this);
									  if(link.hasClass("view-birmingham"))
														  {
																$("#contact-map").removeClass("leicester").addClass("birmingham");
																map.setCenter(birminghamOffice);
																//$("#maploader").fadeIn();
														  }
														  else if(link.hasClass("view-leicester")){
															  	$("#contact-map").removeClass("birmingham").addClass("leicester");
																map.setCenter(leicesterOffice);
																//$("#maploader").fadeIn();
														  }
														  return false;
									  });
	}
	
	$(".b-clearform").click(function(){
									 $("#quote-form input").val("");
									 return false;
									 });
	
	//Form Validation
	//$("#send-request").click(function(){
    //    $(".formError").hide();
       /* hide all the error tooltips */
    //});
	var use_ajax=false;
	//$.validationEngine.settings={};
	/* initialize the settings object for the formValidation plugin */
	if($("#quote-form").length>0)
	{
		$("#quote-form").validationEngine({	/* create the form validation */
			inlineValidation: false,
			promptPosition: "centerRight"
		 });
	}
	
	
	//End Form Validation
});
