$(document).ready(function(){
	
	SFL.vars={
		imgArray:[
			$("#homeQuoteCopy cite").text(),
			"Max"
		],
		quoteArray:[
			$("#homeQuoteCopy blockquote").text(),
			"The free DVD busted the block I had about doing a maths course."
		]
	};
	
	SFL.initialise();
	
});


SFL = {
	initialise:function(){
		$("a[rel='external']").attr("target", "_blank").addClass("externalLink").each(function(){
			this.title = ((this.title == "") ? "" : "External link to "+this.title+", opens in new window");
		});
		
		$("a[rel='external'] img").each(function(){
			this.alt = this.parentNode.title;
		});
		
		$("div#pageContent a[rel='external'], #footerLinks2 a[rel='external']").append('<img src="img/external-link.gif" alt="" class="externalLinkIcon" />');
		
		$("a[rel='popup']").click(function(){
			window.open(this.href, "dvdWin", "width=600,height=600");
			return false;
		});
		
		$("select#hearAbout").change(function(){
			SFL.checkOtherBox(this.value);
		});
		if(document.getElementById("hearAbout")) {
			SFL.checkOtherBox(document.getElementById("hearAbout").value);
		}
		
		SFL.switchImage(0);
	},
	checkOtherBox: function(wVal){
		if(wVal === "Other"){
			$("label#otherLabel").show();
			$("input#hearAboutOther").show();
		} else {
			$("label#otherLabel").hide();
			$("input#hearAboutOther").hide().attr("value","");
		}
	},
	switchImage: function(wImg){
		var maxImg = SFL.vars.imgArray.length;
		$("div#animFloat img").attr("src","img/"+SFL.vars.imgArray[wImg].toLowerCase()+".gif").attr("alt",SFL.vars.imgArray[wImg]);
		$("div#homeQuoteCopy blockquote").text(SFL.vars.quoteArray[wImg]);
		$("div#homeQuoteCopy cite").text(SFL.vars.imgArray[wImg]);
		
		var nextImg = (wImg >= maxImg-1) ? 0 : wImg+1;
		setTimeout("SFL.switchImage("+nextImg+")", 10000);
	}
};



function watchdvd() { 
 var a = Math.random() * 10000000000000; 
 var dcpix = new Image(); 
 dcpix.src = 'http://ad.uk.doubleclick.net/activity;src=867864;type=getahead;cat=watchdvd;ord=1;num='+ a;
}

