$(document).ready(function () {

	$("select").sexyCombo({autoFill:0, emptyText:'Select from the dropdown'});

	running = new Array();
	$(".primary-navi-home > h2").each(function(i) {
		$(this).mouseenter(function () {
		//alert("frog")
			if(running[i] != 1) {
				running[i] = 1;
				$(this).animate({ marginTop:"-10px" }, { duration:300, easing:'easeOutQuint' } ).animate({ marginTop:"0px" }, { duration:300, easing:'easeOutQuint', complete: function(event) {
					running[i] = 0;
				}} );
			}
		});
	});
	
	
	// get the height of the primary menu
	var highest = 0;
	$('.primary-options').each(function (i) {
		highest = (highest < $(this).height()) ? $(this).height() : highest;
	});
	// end
	// open close menu
	var menutoggle = 0;
	var menuchosen = "";
	var closemenu = $(".primary-navi-home").position().top;
	var openmenu = closemenu - highest;
	$(".primary-navi-home > h2").click(function (event) {
		event.preventDefault();
		if (menuchosen != $(this).attr('class')) {
			$(".primary-navi-home").animate({ top:openmenu + 'px' }, { queue:false, duration:1000, easing:'easeOutQuint' } );
			$('.primary-options').hide();
			$('.primary-navi-home > h2').animate({ height:'100px' }, { queue:true, duration:0, easing:'easeOutQuint' } );
			$(this).animate({ height:'125px' }, { queue:true, duration:300, easing:'easeOutQuint' } );
			$('div.'+$(this).attr('class')).fadeIn("slow");
			menuchosen = $(this).attr('class');
		} else {
			$(".primary-navi-home").animate({ top:closemenu + 'px' }, { queue:false, duration:1000, easing:'easeOutQuint' } );
			$(this).animate({ height:'100px' }, { queue:true, duration:300, easing:'easeOutQuint' } );
			menuchosen = "";
		}
	});

	$('#i-am-a-box').change(function(event) {
			loadInterested($(this).val());
		}
	);
	
	$('#jumpSearch').click(function(event) {
		event.preventDefault();
		loadInterestedLink($('#interested-in-box').val());
	});		
	
	var jumpListInterested = new Array();

jumpListInterested[15] = new Array()
jumpListInterested[7] = new Array()
jumpListInterested[9] = new Array()
jumpListInterested[18] = new Array()
jumpListInterested[16] = new Array()
jumpListInterested[21] = new Array()
jumpListInterested[15][28] = new Array('Happold Trust Scholarship','/the-opportunities/he-students/happold-scholarship.php');
jumpListInterested[15][29] = new Array('Bath University Happold Travel Scholarship','/the-opportunities/he-students/bath-university-happold-travel-scholarship.php');
jumpListInterested[15][30] = new Array('Bath University Mike Barnes\' Prize','/the-opportunities/he-students/bath-university-mike-barnes-prize.php');
jumpListInterested[15][31] = new Array('Loughborough Scholarship','/the-opportunities/he-students/loughborough-student-scholarship.php');
jumpListInterested[15][32] = new Array('Learning about other scholars experiences','/the-experience/');
jumpListInterested[15][35] = new Array('Scholarship Opportunities','/the-opportunities/');
jumpListInterested[15][36] = new Array('Past Scholars Case studies','/the-experience/');
jumpListInterested[15][43] = new Array('The IDBE Masters Programme','/the-opportunities/the-opportunities/idbe-course-cambridge-univesrity.php');
jumpListInterested[15][45] = new Array('Happold Trust Lectures','/the-achievements/education/lectures.php');
jumpListInterested[7][26] = new Array('telling my students about engineering','/the-opportunities/education-establishments/the-smallpeice-trust.php');
jumpListInterested[7][38] = new Array('teacher training in engineering','/the-opportunities/education-establishments/the-smallpeice-trust.php');
jumpListInterested[9][25] = new Array('The Arkwright Foundation','/the-opportunities/fe-students/arkwright-foundation.php');
jumpListInterested[18][34] = new Array('Other organisations experience','/the-experience/');
jumpListInterested[18][44] = new Array('Current Happold Trust Patonage','/the-opportunities/charities-projects/patronage.php');
jumpListInterested[16][37] = new Array('Loughborough Scholarship','/the-opportunities/he-students/loughborough-student-scholarship.php');
jumpListInterested[16][46] = new Array('Happold Trust Lectures','/the-achievements/education/lectures.php');
jumpListInterested[21][40] = new Array('The Brilliant Award','/the-opportunities/education-establishments/brilliant-award.php');
jumpListInterested[21][41] = new Array('Research Support','/the-opportunities/education-establishments/research-support.php');
jumpListInterested[21][42] = new Array('The Creative Design Course','/the-opportunities/education-establishments/creative-design-course.php');
jumpListInterested[21][47] = new Array('Lectures','/the-achievements/education/lectures.php');

	function loadInterested(interestedId) {
		$('#interested-in-div').empty();
		$('#interested-in-div').append("<select id=\"interested-in-box\"></select>");
		thisJumpList = jumpListInterested[interestedId];
		for(fish in thisJumpList) {
			linkText = thisJumpList[fish][1];
			displayText = thisJumpList[fish][0];
			$('#interested-in-box').append("<option value=\""+linkText+"\">"+displayText+"</option>");
		}
		$("#interested-in-box").sexyCombo({autoFill:0, emptyText:'Select from the dropdown'});
				
	}
	
	function loadInterestedLink(linkText) {
		if (linkText != "" && linkText != null) {
			location.href = linkText;
		}
		else {
			alert("Please ensure that you have made a selection");
		}
	}	

});
