$(document).ready(function() {
	
	// call us image rollovers
	
		// set default region (Yorkshire)
		$("img#mapImage").attr("src", "/images/map/map-yorkshire.gif");
		$("div.areaContact").hide();
		$("div#yorkshire").show();
	
	 	// rollover area
		$("map#callmap area").hover( function() {
			
			// get current href and store region in var
			var currentRegion = $(this).attr("href");
			currentRegion = currentRegion.substring(1);
			
			// update map image
			$("img#mapImage").attr("src", "/images/map/map-" + currentRegion + ".gif");
			
			// hide all contact numbers
			$("div.areaContact").hide();
			
			// show current region numbers
			$("div#" + currentRegion + "").show();
			
		}, function() {
		  	
		});
		
		// disable map clicks
		$("map#callmap area").click( function() {
			return false;
		});
		
	// button hovers
	$("input#sendRight").hover( function() {
		$(this).attr("src", "/images/send-right-hover.gif");
	}, function() {
		$(this).attr("src", "/images/send-right.gif");	
	});
	
	// clear form inputs
		$('input').focus(function() {
  			$(this).val("");
		});
		
	// callback popup
		
		$("body").append("<div id=\"filterBG\"></div>"); // create filter overlay element
		$("div.callBack").append('<a id="callShow" href="#" title="request a call back">Call back</a>'); // create callback link
		
		// show form
		$("a#callShow").click( function() {
			// set the height of overlay
			var docHeight = $(document).height();
			$("div#filterBG").css("height", docHeight);
			
			$("div#callbackPopup").show(); // show the form
			$("div#callbackPopup").center(); // center the form
			$("div#filterBG").show(); // show the bg
			
			// sort the z-index
			$("div#callbackPopup").css("z-index", "99999");
			$("div.topNav").css("z-index", "1");
			$("div.download").css("z-index", "1");

			return false;
		});
		
		// close submit form
		$("a#closeSubmit").click( function() {
			$("div#callbackPopup").hide(); // hide the form
			$("div#filterBG").hide(); // hide the bg
			
			// sort the z-index
			$("div.topNav").css("z-index", "9999");
			$("div.download").css("z-index", "1000");
			
			return false;
		});
	
	// center div function
	jQuery.fn.center = function () {
    	this.css("position","absolute");
    	this.css("top", ( $(window).height() - this.height() ) / 2+$(window).scrollTop() + "px");
    	this.css("left", ( $(window).width() - this.width() ) / 2+$(window).scrollLeft() - 20 + "px");
    	return this;
	}

});

$(window).load(function() {
    $('#homeBanner').nivoSlider({
        effect:'fade', // Specify sets like: 'fold,fade,sliceDown'
        animSpeed:500, // Slide transition speed
        pauseTime:5000, // How long each slide will show
        directionNav:false, // Next & Prev navigation
        directionNavHide:true, // Only show on hover
        controlNav:false, // 1,2,3... navigation
        pauseOnHover:true // Stop animation while hovering
    });
});
