var requiredFields = new Array ();

function e_friend() {
	var e_add= prompt('Enter your friend\'s email address:',' ');
	if ((e_add==" ") || (e_add==null)) {
		alert("You didn't enter an e-mail address");
	} else {
	    var subj= prompt('Enter the subject of your message:',' ');
	    if ((subj==" ") || (subj==null)) subj="Hi!";
	    var mess= prompt('Enter your message:',' ');
	    var title = document.title
	    var url = document.location.href;
	    window.location="mailto:" + e_add + "?subject=" + subj + "&body=" + mess + "%0A%0A" + title + "%0A" + url;
	}
}

function resetAllSelects () {
	var selects = new Array ("adm_status", "adm_province", "adm_country", "adm_level", "adm_institution", "adm_program", "adm_other");

	for (var y = 0; y < selects.length; y++) {
		var admInputs = document.getElementById (selects[y]).getElementsByTagName("select");

		for (var x = 0; x < admInputs.length; x++) {
			admInputs[x].selectedIndex = 0;
		}
	}
}

// initialise plugins
$(document).ready(function(){
	$('#sitemenu ul').superfish({delay: 1000,animation:{height:'show'},speed:'fast',autoArrows:false,dropShadows:false});
	$('#printthis').click(function(){window.print();});

	$(".hinticon").hover(function() {
    	$(this).next(".hint").animate({opacity: "show", top: "8"}, "slow");},
		function() {$(this).next(".hint").animate({opacity: "hide", top: "8"}, "fast");
	});

	$("#image-switch dt").hover(function () {
		var content_show = $(this).attr("title");
		$("dt.active").removeClass("active");
		$(this).addClass("active");
		$("#switch-image li").fadeOut('fast');
		$("#switch-image #"+content_show).fadeIn('fast');
	});

	$('span.share_links').fadeOut();

	url = $.jqURL.url();

	fburl = 'http://www.facebook.com/share.php?u=' + url;
	twiturl = 'http://twitthis.com/twit?url=' + url;

	$("#share_links").hover(function(){$('span.share_links').fadeIn('fast')},function() {$('span.share_links').fadeOut('fast')});
	$("#facebookus").click(function() {$.jqURL.loc(fburl,{w:640,h:480,wintype:'_blank'})});
	$("#twitterus").click(function() {$.jqURL.loc(twiturl,{w:640,h:480,wintype:'_blank'})});

	$("#who1").click(function (event) {
                resetAllSelects ();
		$("#adm_status").show("slow");
		$("#adm_country").hide("slow");
		$("#adm_province").hide("slow");
		$("#adm_level").hide("slow");
		$("#adm_institution").hide("slow");
		$("#adm_program").show("slow");
		$("#adm_other").hide("slow");
                $("#adm_who_required").hide("slow");
		requiredFields = new Array();
                requiredFields.push ('adm_status');
                requiredFields.push ('adm_program');
	});

	$("#who2").click(function (event) {
                resetAllSelects ();
		$("#adm_status").hide("slow");
		$("#adm_country").hide("slow");
		$("#adm_province").show("slow");
		$("#adm_level").hide("slow");
		$("#adm_institution").hide("slow");
		$("#adm_program").show("slow");
		$("#adm_other").hide("slow");
                $("#adm_who_required").hide("slow");
		requiredFields = new Array();
		requiredFields.push ('adm_province');
		requiredFields.push ('adm_program');
	});

	$("#who3").click(function (event) {
                resetAllSelects ();
		$("#adm_status").hide("slow");
		$("#adm_country").hide("slow");
		$("#adm_province").hide("slow");
		$("#adm_level").hide("slow");
		$("#adm_institution").show("slow");
		$("#adm_program").show("slow");
		$("#adm_other").hide("slow");
                $("#adm_who_required").hide("slow");
		requiredFields = new Array();
		requiredFields.push ('adm_institution');
		requiredFields.push ('adm_program');
	});

	$("#who4").click(function (event) {
                resetAllSelects ();
		$("#adm_status").hide("slow");
		$("#adm_country").show("slow");
		$("#adm_province").hide("slow");
		$("#adm_level").show("slow");
		$("#adm_institution").hide("slow");
		$("#adm_program").show("slow");
		$("#adm_other").hide("slow");
                $("#adm_who_required").hide("slow");
		requiredFields = new Array();
                requiredFields.push ('adm_country');
                requiredFields.push ('adm_level');
                requiredFields.push ('adm_program');
	});

	$("#who5").click(function (event) {
                resetAllSelects ();
		$("#adm_status").hide("slow");
		$("#adm_country").hide("slow");
		$("#adm_province").hide("slow");
		$("#adm_level").hide("slow");
		$("#adm_institution").hide("slow");
		$("#adm_program").hide("slow");
		$("#adm_other").hide("slow");
                $("#adm_who_required").hide("slow");
		requiredFields = new Array();
	});
	
	$("#who6").click(function (event) {
                resetAllSelects ();
		$("#adm_status").hide("slow");
		$("#adm_country").hide("slow");
		$("#adm_province").hide("slow");
		$("#adm_level").hide("slow");
		$("#adm_institution").hide("slow");
		$("#adm_program").hide("slow");
		$("#adm_other").show("slow");
                $("#adm_who_required").hide("slow");
		requiredFields = new Array();
		requiredFields.push ('adm_other');
	});

	$("#financ1").click(function (event) {
		$("#financ_canadian").show("slow");
	});

	$("#financ2").click(function (event) {
		$("#financ_canadian").hide("slow");
	});

	$("#financ3").click(function (event) {
		$("#financ_canadian").hide("slow");
	});
});

