// Sitewide scripts using jquery
//place this at the bottom of other script includes to activate jquery plugins

$(document).ready(function(){ 
//activate png transparency fix
	$(document).pngFix();

// 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");
	
// initialise Header Rotating Images using InnerFade
	$("#banner #examples").innerfade({
		speed: 2000,
		timeout: 6000,
		type: "sequence",
		containerheight: "284px"
	});

	$("#ads").innerfade({
		speed: 2000,
		timeout: 5000,
		type: "random",
		containerheight: "100px"
	});
	
// Add external link icon to text hyperlinks
	$("a").filter(function() {
		return this.hostname && this.hostname !== location.hostname;
	}).attr("target", "_blank");
	
//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();
	});
	
// validate Youth Newsletter form on keyup and submit
 	$("#Newsletter").validate({
		rules: {
			your_name: "required",
			student_name: "required",
			your_email: {
				required: true,
				email: true
			}
		},
		messages: {
			your_name: "Please enter your full name",
			student_name: "Please enter a student's name",
			your_email: "Please enter your email"
		}
	});

// sifr scripting
/*	$("h2").sifr({
		font: "swf/tahoma.swf",
		version: 3,
		build: "436"
	});*/

//flash videos using SWFObject
	$('#support_clock').flash({ 
		swf: "swf/clock.swf",
		width: 209,
		height: 91
	});
	//showcase of projects
	$('#showcase').flash({ 
		swf: "swf/projects.swf",
		wmode: 'transparent',
		width: 736,
		height: 450
	});

}); 