$(document).ready(function() { 

	if ($("#home_builds ul li").length > 0){
		$("#home_builds ul li").hover(function() { //On hover...
			
		var thumbOver = $(this).find("img").attr("src"); //Get image url and assign it to 'thumbOver'
		
		//Set a background image(thumbOver) on the &lt;a&gt; tag 
		$(this).find("a.thumb").css({'background' : 'url(' + thumbOver + ') no-repeat center bottom'});
		//Animate the image to 0 opacity (fade it out)
		$(this).find("img").stop().animate({opacity: 0}, 300);
		} , function() { //on hover out...
			//Animate the image back to 100% opacity (fade it back in)
			$(this).find("img").stop().animate({opacity: 1}, 300);
		});
	}
	
	if ($("#home_jq").length > 0){
	$("#home_jq").easySlider({
			auto: true,
			continuous: true 
		});
	}


if ($("a.thumb").length > 0){
	
 $("a#house-build").click(function() {
		$.fancybox([
			
			{
				'href' : '/images/new-builds/white-lodge/1.JPG',
				'title' : 'New Build House - Foundations'
			},
			{
				'href' : '/images/new-builds/white-lodge/2.jpg',
				'title' : 'New Build House - Foundations'
			},
			{
				'href' : '/images/new-builds/white-lodge/3.jpg',
				'title' : 'New Build House - Construction'
			},
			{
				'href' : '/images/new-builds/white-lodge/4.jpg',
				'title' : 'New Build House - Construction'
			},
			{
				'href' : '/images/new-builds/white-lodge/5.JPG',
				'title' : 'New Build House - Construction'
			},
			{
				'href' : '/images/new-builds/white-lodge/6.jpg',
				'title' : 'New Build House - Construction'
			},
			{
				'href' : '/images/new-builds/white-lodge/7.jpg',
				'title' : 'New Build House - Construction'
			},
			{
				'href' : '/images/new-builds/white-lodge/8.jpg',
				'title' : 'New Build House - Construction'
			},
			{
				'href' : '/images/new-builds/white-lodge/9.jpg',
				'title' : 'New Build House - Roofing'
			},
			{
				'href' : '/images/new-builds/white-lodge/11.jpg',
				'title' : 'New Build House - Roofing'
			},
			{
				'href' : '/images/new-builds/white-lodge/12.jpg',
				'title' : 'New Build House - Construction'
			},
			{
				'href' : '/images/new-builds/white-lodge/13.jpg',
				'title' : 'New Build House - Construction'
			},
			{
				'href' : '/images/new-builds/white-lodge/14.jpg',
				'title' : 'New Build House - Construction'
			},
			{
				'href' : '/images/new-builds/white-lodge/15.JPG',
				'title' : 'New Build House - Construction'
			},
			{
				'href' : '/images/new-builds/white-lodge/16.jpg',
				'title' : 'New Build House - Construction'
			},
			{
				'href' : '/images/new-builds/white-lodge/17.jpg',
				'title' : 'New Build House Complete - Interior Rendering'
			},
			{
				'href' : '/images/new-builds/white-lodge/18.JPG',
				'title' : 'New Build House Complete - Front'
			},
			{
				'href' : '/images/new-builds/white-lodge/19.JPG',
				'title' : 'New Build House Complete - Front'
			},
			{
				'href' : '/images/new-builds/white-lodge/20.JPG',
				'title' : 'New Build House Complete - Front'
			},
			{
				'href' : '/images/new-builds/white-lodge/21.JPG',
				'title' : 'Guest House'
			},
			{
				'href' : '/images/new-builds/white-lodge/22.JPG',
				'title' : 'Bedroom'
			},
			{
				'href' : '/images/new-builds/white-lodge/23.JPG',
				'title' : 'Games Room'
			},
			{
				'href' : '/images/new-builds/white-lodge/24.JPG',
				'title' : 'Bedroom'
			},
			{
				'href' : '/images/new-builds/white-lodge/25.JPG',
				'title' : 'Bedroom'
			},
			{
				'href' : '/images/new-builds/white-lodge/26.JPG',
				'title' : 'Bedroom'
			},
			{
				'href' : '/images/new-builds/white-lodge/27.JPG',
				'title' : 'Bathroom'
			},
			{
				'href' : '/images/new-builds/white-lodge/28.JPG',
				'title' : 'Bathroom'
			},
			{
				'href' : '/images/new-builds/white-lodge/29.JPG',
				'title' : 'Bathroom'
			},
			{
				'href' : '/images/new-builds/white-lodge/30.JPG',
				'title' : 'Kitchen'
			},
			{
				'href' : '/images/new-builds/white-lodge/31.JPG',
				'title' : 'Kitchen'
			},
			{
				'href' : '/images/new-builds/white-lodge/32.JPG',
				'title' : 'Kitchen'
			},
			{
				'href' : '/images/new-builds/white-lodge/33.JPG',
				'title' : 'Kitchen'
			},
			{
				'href' : '/images/new-builds/white-lodge/34.JPG',
				'title' : 'Lounge'
			},
			{
				'href' : '/images/new-builds/white-lodge/35.JPG',
				'title' : 'Lounge'
			},
			{
				'href' : '/images/new-builds/white-lodge/36.JPG',
				'title' : 'Office'
			},
			{
				'href' : '/images/new-builds/white-lodge/37.JPG',
				'title' : 'Hallway'
			},
			{
				'href' : '/images/new-builds/white-lodge/38.JPG',
				'title' : 'Lounge'
			},
			{
				'href' : '/images/new-builds/white-lodge/39.JPG',
				'title' : 'Hallway'
			},
			{
				'href' : '/images/new-builds/white-lodge/40.JPG',
				'title' : 'Hallway'
			},
			{
				'href' : '/images/new-builds/white-lodge/41.JPG',
				'title' : 'Bathroom'
			}			
			
			
			], {
			'type' : 'image',
			'titlePosition': 'over',
			'overlayShow': true
			});
		}); 
 
 
 
 
 $("a#refurbishment3").click(function() {
		$.fancybox([

			{
				'href' : '/images/new-builds/white-lodge/22.JPG',
				'title' : 'Bedroom'
			},
			{
				'href' : '/images/new-builds/white-lodge/23.JPG',
				'title' : 'Games Room'
			},
			{
				'href' : '/images/new-builds/white-lodge/24.JPG',
				'title' : 'Bedroom'
			},
			{
				'href' : '/images/new-builds/white-lodge/25.JPG',
				'title' : 'Bedroom'
			},
			{
				'href' : '/images/new-builds/white-lodge/26.JPG',
				'title' : 'Bedroom'
			},
			{
				'href' : '/images/new-builds/white-lodge/27.JPG',
				'title' : 'Bathroom'
			},
			{
				'href' : '/images/new-builds/white-lodge/28.JPG',
				'title' : 'Bathroom'
			},
			{
				'href' : '/images/new-builds/white-lodge/29.JPG',
				'title' : 'Bathroom'
			},
			{
				'href' : '/images/new-builds/white-lodge/30.JPG',
				'title' : 'Kitchen'
			},
			{
				'href' : '/images/new-builds/white-lodge/31.JPG',
				'title' : 'Kitchen'
			},
			{
				'href' : '/images/new-builds/white-lodge/32.JPG',
				'title' : 'Kitchen'
			},
			{
				'href' : '/images/new-builds/white-lodge/33.JPG',
				'title' : 'Kitchen'
			},
			{
				'href' : '/images/new-builds/white-lodge/34.JPG',
				'title' : 'Lounge'
			},
			{
				'href' : '/images/new-builds/white-lodge/35.JPG',
				'title' : 'Lounge'
			},
			{
				'href' : '/images/new-builds/white-lodge/36.JPG',
				'title' : 'Office'
			},
			{
				'href' : '/images/new-builds/white-lodge/37.JPG',
				'title' : 'Hallway'
			},
			{
				'href' : '/images/new-builds/white-lodge/38.JPG',
				'title' : 'Lounge'
			},
			{
				'href' : '/images/new-builds/white-lodge/39.JPG',
				'title' : 'Hallway'
			},
			{
				'href' : '/images/new-builds/white-lodge/40.JPG',
				'title' : 'Hallway'
			},
			{
				'href' : '/images/new-builds/white-lodge/41.JPG',
				'title' : 'Bathroom'
			}			
			
			
			], {
			'type' : 'image',
			'titlePosition': 'over',
			'overlayShow': true
			});
		}); 	
 
 
 $("a#refurbishment1").click(function() {
		$.fancybox([

			{
				'href' : '/images/refurbishment/interior/1.JPG',
				'title' : 'Refurbishment Stairs'
			},
			{
				'href' : '/images/refurbishment/interior/2.JPG',
				'title' : 'Refurbishment Authentic Tiled Floor'
			},
			{
				'href' : '/images/refurbishment/interior/3.JPG',
				'title' : 'Refurbishment Authentic Tiled Floor'
			}			
			
			
			], {
			'type' : 'image',
			'titlePosition': 'over',
			'overlayShow': true
			});
		}); 	
 
 
  $("a#extension-conservatory").click(function() {
		$.fancybox([

			{
				'href' : '/images/extensions/conservatory/1.JPG',
				'title' : 'Extension Conservatory'
			},
			{
				'href' : '/images/extensions/conservatory/2.JPG',
				'title' : 'Extension Conservatory'
			}			
			
			], {
			'type' : 'image',
			'titlePosition': 'over',
			'overlayShow': true
			});
		}); 
  
  
   $("a#extension-sliding").click(function() {
		$.fancybox([

			{
				'href' : '/images/extensions/sliding-folding-doors/1.JPG',
				'title' : 'Extension with Sliding Folding Doors'
			},
			{
				'href' : '/images/extensions/sliding-folding-doors/2.JPG',
				'title' : 'Extension with Sliding Folding Doors'
			},
			{
				'href' : '/images/extensions/sliding-folding-doors/3.JPG',
				'title' : 'Extension with Sliding Folding Doors'
			},
			{
				'href' : '/images/extensions/sliding-folding-doors/4.JPG',
				'title' : 'Extension with Sliding Folding Doors'
			}			
			
			], {
			'type' : 'image',
			'titlePosition': 'over',
			'overlayShow': true
			});
		}); 
   
      $("a#extension-garage").click(function() {
		$.fancybox([

			{
				'href' : '/images/extensions/garage/1.JPG',
				'title' : 'Extension Garage'
			},
			{
				'href' : '/images/extensions/garage/2.JPG',
				'title' : 'Extension Garage'
			}		
			
			], {
			'type' : 'image',
			'titlePosition': 'over',
			'overlayShow': true
			});
		}); 
	  
	  
	     $("a#extension-porch").click(function() {
		$.fancybox([

			{
				'href' : '/images/extensions/porch/1.JPG',
				'title' : 'Extension Porch'
			}	
			
			], {
			'type' : 'image',
			'titlePosition': 'over',
			'overlayShow': true
			});
		}); 
	
	
	
	}


}); 












function initialize1() {
      if (GBrowserIsCompatible()) {
        var map = new GMap2(document.getElementById("map_canvas"));
		map.addControl(new GSmallMapControl());
        map.addControl(new GMapTypeControl());
		map.removeMapType(G_SATELLITE_MAP);
        map.setCenter(new GLatLng(51.432334, -0.814958), 13);
		map.setMapType(G_NORMAL_MAP);
		
		window.setTimeout(function() {
          map.setMapType(G_NORMAL_MAP);
        }, 1000);

		var center = new GLatLng(51.432484, -0.814788);
		var marker = new GMarker(center, {draggable: true});
        map.addOverlay(marker);
		//(51.432484, -0.814788) http://maps.google.co.uk/maps?f=q&source=s_q&hl=en&geocode=&q=Cadley+Forest+Road+Wokingham+Berkshire+RG40+5SA&sll=53.800651,-4.064941&sspn=21.383044,41.176758&ie=UTF8&t=h&z=16&iwloc=A
		//marker.openInfoWindowHtml("<div style='line-height:14px;'><strong><a href=\"http://maps.google.co.uk/maps?f=q&source=s_q&hl=en&geocode=&q=Cadley+Forest+Road+Wokingham+Berkshire+RG40+5SA&sll=53.800651,-4.064941&sspn=21.383044,41.176758&ie=UTF8&t=h&z=16&iwloc=A\" style=\"text-decoration:underline;\" >Ian Lee Builder Ltd</a><br />Cadley<br />Forest Road<br />Wokingham<br />Berkshire<br />RG40 5SA</div>");
      }
}



if (document.images){	
	//home
	btn_home_on= new Image();
	btn_home_on.src="/images/bg.gif";  
	
	
   }


function turnoff(imgName){
   if (document.images){
      imgOff=eval(imgName + ".src");
      document[imgName].src= imgOff;
    }
 }


function turnon(imgName){
   if (document.images){
      imgOn=eval(imgName + "_on.src");
      document[imgName].src= imgOn;
    }
 }
 
 



$(function(){
	
	//Do what we need to when form is submitted.	
	$('#form_submit').click(function(){
	
	//Setup any needed variables.
	var input_name = $('#contact_name').val(),
		input_email = $('#contact_email').val(),
		input_number = $('#contact_number').val(),
		input_subject = $('#contact_enquiry').val(),
		input_message = $('#contact_message').val(),
		response_text = $('#response');
		//Hide any previous response text 
		response_text.hide();
		
		//Change response text to 'loading...'
		response_text.html('Sending...').show();
		
		//Make AJAX request 
		$.post('/sendmail.php', {name: input_name, email: input_email, number: input_number, enquiry: input_subject, message: input_message}, 
			   function(data){
				   response_text.removeClass();
				response_text.addClass(data.error);
				response_text.html(data.name);
		}, "json");
		
		//Cancel default action
		return false;
	});

});



