$(document).ready(function() {
	
	//OUTBOUND LINKS
	$("div#content p a").click(function() {
		var href = $(this).attr("href");
		if(href.indexOf('efret.co.uk') == -1) {
			$(this).attr("target","_blank");
		}
	});
	
	//SUB NAV
	$(".sub-nav").hide();
	
	$(".link a").mouseup(function () {
		$(this).css({"background-position":"0 0"});
	}).mousedown(function () {
		$(this).css({"background-position":"0 -70px"});
	});
	
	$(".sub").mouseover(function() {
		$("a:first", this).css({"background-position":"0 -35px"});
		$("ul.sub-nav", this).show();
	}).mouseout(function() {
		if($("body").attr('id') == 'service' && $("a:first", this).attr('class') == 'services') {
			$("a:first", this).css({"background-position":"0 -70px"});
		} else if($("body").attr('id') == 'collaborator' && $("a:first", this).attr('class') == 'collaborators') {
			$("a:first", this).css({"background-position":"0 -70px"});
		} else if($("body").attr('id') == 'administration' && $("a:first", this).attr('class') == 'administration') {
			$("a:first", this).css({"background-position":"0 -70px"});
		} else {
			$("a:first", this).css({"background-position":"0 0"});
		}
		$("ul.sub-nav", this).hide();
	});
	
	//LANGUAGE SELECT
	$("ol#nav li input").hide();
	$("ol#nav li select").css({"width":"100px"}).change(function() {
		var lang = $("option:selected", this).attr("value");
		if(lang != "eng") {
			var href = "http://translate.google.com/translate?u=http%3A%2F%2Fwww.efret.co.uk/%2F&langpair=en%7C"+lang+"&hl=en&ie=UTF-8";
			window.location = href;
		} else if(lang == "eng") {
			var href = "http://www.efret.co.uk/";
			window.location = href;
		}
	});
	
});