jQuery(function() {

	//START box height stuff for the TEFL HOME PAGE
	var divHeight = 0;
	var divHeight2 = 0;
	var tallestDiv = 0;
	var tallestDiv2 = 0;
	
	//find the tallest .fw-panel-store-l-course-inner ...
	jQuery(".fw-panel-store-l-course-inner").each(function (){
		divHeight = jQuery(this).height();
		if(divHeight > tallestDiv ) {
			tallestDiv = divHeight;
		}
	});
	jQuery("#panel-combined-courses .course-panel").each(function (){
		divHeight = jQuery(this).height();
		if(divHeight > tallestDiv ) {
			tallestDiv = divHeight;
		}
	});
	jQuery("#panel-online-courses .course-panel").each(function (){
		divHeight2 = jQuery(this).height();
		if(divHeight2 > tallestDiv2 ) {
			tallestDiv2 = divHeight2;
		}
	});
	jQuery("#panel-combined-courses .course-offer, #panel-combined-courses .panel-courses-promo .promo-inner-panel").each(function (){
		divHeight = jQuery(this).height();
		if(divHeight > tallestDiv ) {
			tallestDiv = divHeight;
		}
	});
	jQuery("#panel-online-courses .course-offer, #panel-online-courses .panel-courses-promo .promo-inner-panel").each(function (){
		divHeight2 = jQuery(this).height();
		if(divHeight2 > tallestDiv2 ) {
			tallestDiv2 = divHeight2;
		}
	});
	//...and then make all .fw-panel-store-l-course-inner elements that height
	jQuery(".fw-panel-store-l-course-inner").css("height", tallestDiv-10);
	jQuery("#panel-combined-courses .panel-courses-inner").css("height", tallestDiv+125);
	jQuery("#panel-combined-courses .course-panel").css("height", tallestDiv);
	jQuery("#panel-combined-courses .course-offer").css("height", tallestDiv+45);
	jQuery("#panel-combined-courses .panel-courses-promo .promo-inner-panel").css("height", tallestDiv+92);
	
	jQuery("#panel-online-courses .panel-courses-inner").css("height", tallestDiv2+125);
	jQuery("#panel-online-courses .course-panel").css("height", tallestDiv2);
	jQuery("#panel-online-courses .course-offer").css("height", tallestDiv2+45);
	jQuery("#panel-online-courses .panel-courses-promo .promo-inner-panel").css("height", tallestDiv2+92);
//	jQuery("#panel-combined-courses .course-offer").css("height", tallestDiv-10);
	//END box height stuff for the TEFL HOME PAGE
	
	
	//make the course panels clickable
	jQuery(".course-panel,.course-panel-wide,.promo-inner-panel").css("cursor","pointer");
	//jQuery(".course-panel,.course-panel-wide,.promo-inner-panel").click(function() {window.location = jQuery(this).find("a:first").attr("href")});
	jQuery(".course-panel,.course-panel-wide,.promo-inner-panel").click(function(event) {
		if (event.target.className != "btn-buycourse pop-venue") {
			window.location = jQuery(this).find("a:first").attr("href");
		}
	});
	
	//make the course panels respond to hover
	jQuery(".course-panel,.course-panel-wide,.promo-inner-panel").css("cursor","pointer");	
	jQuery(".course-panel,.course-panel-wide,.promo-inner-panel").click(function() {window.location = jQuery(this).find("a:first").attr("href")});
	jQuery(".course-panel,.course-panel-wide").hover(
      function () {jQuery(this).addClass("course-panel-hover")}, 
      function () {jQuery(this).removeClass("course-panel-hover")}
    );
	
	  //make the taster banner clickable
	jQuery(".side-tefl-taster-new").css("cursor","pointer");
	jQuery(".side-tefl-taster-new").click(function(event) {
		if (event.target.className != "btn-standard btn-green btn-arrow") {
			/* window.location = jQuery(this).find("a:first").attr("href");*/
		window.open (jQuery(this).find("a:first").attr("href"), "taster");
		}
	});

	//make the fw-panel-store-l-course pods and the fw-panel-store-l-spotlight pod clickable and add a hover event, and hide the link <a> tag
	jQuery(".fw-panel-store-l-course").css("cursor","pointer");	
	jQuery(".fw-panel-store-l-course").click(function() {window.location = jQuery(this).find("a:first").attr("href")});
	jQuery(".fw-panel-store-l-course").find("a:first").css("display","none");	
	jQuery(".fw-panel-store-l-course").hover(
      function () {jQuery(this).addClass("fw-panel-store-l-course-over")}, 
      function () {jQuery(this).removeClass("fw-panel-store-l-course-over")}
    );
	jQuery(".fw-panel-store-l-course-inner").hover(
      function () {jQuery(this).addClass("fw-panel-store-l-course-inner-over")}, 
      function () {jQuery(this).removeClass("fw-panel-store-l-course-inner-over")}
    );
		
	jQuery("#fw-panel-store-l-spotlight").css("cursor","pointer");	
	jQuery("#fw-panel-store-l-spotlight").find("a:first").css("display","none");	
	jQuery("#fw-panel-store-l-spotlight").click(function() {window.location = jQuery(this).find("a:first").attr("href")});	
	jQuery("#fw-panel-store-l-spotlight").hover(
      function () {jQuery(this).addClass("fw-panel-store-l-spotlight-over");jQuery("#fw-panel-store-l-spotlight-inner").addClass("fw-panel-store-l-spotlight-inner-over")}, 
      function () {jQuery(this).removeClass("fw-panel-store-l-spotlight-over");jQuery("#fw-panel-store-l-spotlight-inner").removeClass("fw-panel-store-l-spotlight-inner-over")}
    );


	
	
	//make the fw-panel-tefl-abroad-intern pods clickable and add hover colours
	jQuery(".fw-panel-tefl-abroad-intern").css("cursor","pointer");	
	jQuery(".fw-panel-tefl-abroad-intern").click(function() {window.location = jQuery(this).find("a:first").attr("href")});
	
	jQuery(".tai-china").hover(
		function () {jQuery(this).addClass("tai-china-over")}, 
		function () {jQuery(this).removeClass("tai-china-over")}
	);
		jQuery(".tai-thailand").hover(
		function () {jQuery(this).addClass("tai-thailand-over")}, 
		function () {jQuery(this).removeClass("tai-thailand-over")}
	);
	
	jQuery("#video-wide-1").dialog({
		bgiframe: true,
		autoOpen: false,
		width: 715,
		resizable: false,
		modal: true,
		title: ' '
	});

	// open dialog
	jQuery('a.pop-widevideo').click(function(event){
		jQuery('#video-wide-1').dialog('open');
		event.preventDefault();
		var videoTitle = jQuery('a.pop-widevideo').attr('title');
		jQuery("#ui-dialog-title-video-wide-1").html(videoTitle);
	});
	
	


});


function faq_learn_same_height() {
	
	//alert("Load was performed.");
	
	//make the 'faq-small' and the 'TEFL Learn' panels the same height
	//get both heights...
	var learnHeight = jQuery("#panel-tefl-learn-inner").height();
	var faqHeight = jQuery("#panel-faq-small-inner").height();
	
	//make them both the same size
	if(faqHeight > learnHeight) {jQuery("#panel-tefl-learn-inner").css("height", faqHeight+15)}
	if(learnHeight > faqHeight) {jQuery("#panel-faq-small-inner").css("height", learnHeight)}
	// alert("loaded")

}

//only do this jQuery stuff after everything has loaded, includes images and video etc
$(window).load(function(){


});

