

jQuery(function($) {

	$(document).ready(function() {

	
		/* ------- ------------ ------- */
		/* ------- CONTACT FORM ------- */
		/* ------- ------------ ------- */
		//get default text values
		var contactFormFirstnameDefault = $("input#Form_ContactForm_firstname").val();
		var contactFormLastnameDefault = $("input#Form_ContactForm_lastname").val();
		var contactFormPhoneDefault = $("input#Form_ContactForm_phone").val();
		var contactFormEmailDefault = $("input#Form_ContactForm_email").val();
		var contactFormMessageDefault = $("textarea#Form_ContactForm_message").val();
		
		//clear/reset field values on focus/blur
		$("input#Form_ContactForm_firstname").focus(function(){	if($(this).val()==contactFormFirstnameDefault) $(this).val(""); });
		//$("input#Form_ContactForm_firstname").blur(function(){	if($(this).val()=="") $(this).val(contactFormFirstnameDefault); });
		
		$("input#Form_ContactForm_lastname").focus(function(){ if($(this).val()==contactFormLastnameDefault) $(this).val(""); });
		//$("input#Form_ContactForm_lastname").blur(function(){	if($(this).val()=="") $(this).val(contactFormLastnameDefault); });
		
		$("input#Form_ContactForm_phone").focus(function(){	if($(this).val()==contactFormPhoneDefault) $(this).val(""); });
		//$("input#Form_ContactForm_phone").blur(function(){	if($(this).val()=="") $(this).val(contactFormPhoneDefault); });
		
		$("input#Form_ContactForm_email").focus(function(){	if($(this).val()==contactFormEmailDefault) $(this).val(""); });
		//$("input#Form_ContactForm_email").blur(function(){	if($(this).val()=="") $(this).val(contactFormEmailDefault); });
		
		$("textarea#Form_ContactForm_message").focus(function(){	if($(this).val()==contactFormMessageDefault) $(this).val(""); });
		//$("textarea#Form_ContactForm_message").blur(function(){	if($(this).val()=="") $(this).val(contactFormMessageDefault); });	
		
		
		
		$("ul#info-links li").click(function() {
			
			var current = $(this).attr('id');
			//console.log('#box-' + current);
			
			//TODO: Hide currently displayed div
			$('.info-container').each( function() { $(this).slideUp() } );
			
			//TODO: Show selected item
			$('#box-' + current).slideDown();
		});
		
		//TODO: Hover over effect on menu items
		/*
		$("ul#tabs li").hover(function() {
			$("ul#tabs li").each(function() { $(this).removeClass('over'); });
			$(this).addClass('over');
		}, function() {
			$(this).removeClass('over');
			$("ul#tabs li.current").addClass('over');
		});
		*/
		
		$('a#submit-contact-form').click(function() {
			$('#Form_ContactForm').submit();
			return false;
		});
		
				
	}); //end document.ready


	function mapAddress(address, el) {
		var geocoder = new google.maps.Geocoder();
		geocoder.geocode( { 'address': address}, function(results, status) {
		  if (status == google.maps.GeocoderStatus.OK) {	
			
			gmap(el, results[0].geometry.location);
			//return results[0].geometry.location.Ba + ',' + results[0].geometry.location.za;
		  } else {
			//console.log("Geocode was not successful for the following reason: " + status);
			return false;
		  }
		});
	}
	
	function gmap(el, latlng) {
		var map;	
		var myOptions = {
		  zoom: 16,
		  center: latlng,
		  mapTypeId: google.maps.MapTypeId.ROADMAP
		}
		map = new google.maps.Map(el, myOptions);
		var marker = new google.maps.Marker({
			position: latlng, 
			map: map, 
			title:"Title required"
		});
	}
});
