jQuery(function() {	


	//START box height stuff for the TEFL HOME PAGE
	var divHeight = 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 (){
		divHeight = jQuery(this).height();
		if(divHeight > tallestDiv2 ) {
			tallestDiv2 = divHeight;
		}
	});
	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 (){
		divHeight = jQuery(this).height();
		if(divHeight > tallestDiv2 ) {
			tallestDiv2 = divHeight;
		}
	});
	//...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 .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 .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");
		}
	});

	jQuery(".course-panel,.course-panel-wide").hover(
      function () {jQuery(this).addClass("course-panel-hover")},
      function () {jQuery(this).removeClass("course-panel-hover")}
    );


	//make the 'faq-small' and the 'undecided' panels the same height
	//get both heights...
	var undecidedHeight = jQuery("#panel-undecided-inner").height();
	var faqHeight = jQuery("#panel-faq-small-inner").height();
	
	//make them both the same size
	if(faqHeight > undecidedHeight) {jQuery("#panel-undecided-inner").css("height", faqHeight)}
	if(undecidedHeight > faqHeight) {jQuery("#panel-faq-small-inner").css("height", undecidedHeight)}
	
	
	
	//make the 'faq-small' and the 'undecided' panels clickable and add a hover event
	jQuery(".pu-box").css("cursor","pointer");	
	jQuery(".pu-box").click(function() {window.location = jQuery(this).find("a:first").attr("href")});
	jQuery(".pu-box").hover(
      function () {jQuery(this).find("a:first").addClass("hover")}, 
      function () {jQuery(this).find("a:first").removeClass("hover")}
   );
   
	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);
	});
   
 });
