// Sitewide scripts using jquery
//requires includes/scripts.php

$(document).ready(function() { 
// initialise Superfish Navigation
	$("ul.sf-menu").superfish({ 
		animation: {height:"show", opacity:"show"},	// slide-down effect with fade-in 
		delay: 600,              					// .5 second delay on mouseout
		dropShadows: true 							//Do not show dropshadows
	});//.find("ul").bgIframe({opacity:false});

// initialise Header Rotating Images using InnerFade
	$("#sub_header #slideshow").innerfade({
		speed: 2000,
		timeout: 5000,
		type: "random",
		containerheight: "312px"
	});

//back in history button
	$("a.btn_back").click(function() {
		history.go(-1);
		return false;
	});
	
// Add target="_blank" to external links
	$("a").filter(function() {
		return this.hostname && this.hostname !== location.hostname;
	}).attr("target", "_blank");

//remove the outline of a link when clicked
	$("a").click(function() {
		this.blur();
	});
	
//Function to hide email addresses
	$("span.mailme").each(function(){
		var spt = "#" + $(this).attr("id");
		var at = / where /; //replaces with @
		var dot = / all /g; //replaces with .
		var addr = $(spt).text().replace(at,"@").replace(dot,".");
		$(spt).after('<a href="mailto:'+addr+'" title="Send an email">'+ addr +'</a>')
		.hover(function(){window.status="Send a letter!";}, function(){window.status="";});
		$(spt).remove();
	});

//lightbox photo gallery
	$(".gallery a").lightBox();

//disable navigation link
	$(".noclick").click(function() {return false;});

//Slideshow Pro Created with SWFObject
	$("#ssp_photos").flash({ 
		swf: "ssp_photos.swf",
		width: 634,
		height: 509,
		allowfullscreen: true,
		expressInstaller: "justThisOnceExpressInstaller.swf"
	});
	


//iSelect Popup
	$("#iselect_design").hover(function() {
		$(this).find("#iselect_promo:hidden").fadeIn(500);
	}, function() {
		$(this).find("#iselect_promo:visible").fadeOut(500);
	});
});
