// JavaScript Document
//Initialises all scripts and effects
//PsyWeb - October 2009 - info@psy-web.co.uk
jQuery.noConflict();
jQuery(function($) {
$(function(){
	
	//remove the no-js class from the body to prove that javascript has loaded
			$("body").removeClass('no-js');
						//round corners - because IE can't
						$("#content").corner("bottom 20px");
						$("#header").corner("bottom 20px");
						$("#footer .box1").corner("20px");
						$("#mainNav li a:first").corner("tl 20px");
						$("#mainNav li a:last").corner("tr 20px");
						
		    //do the menus
			//cache nav
		var nav = $("#mainNav div");

		//add indicators and hovers to submenu parents
		nav.find("li").each(function() {
			if ($(this).find("ul").length > 0) {

				$("<span>").text(" ").appendTo($(this).children(":first"));

				//show subnav on hover
				$(this).mouseenter(function() {
					$(this).find("ul").stop(true, true).slideDown().parent().addClass('selected');
				});

				//hide submenus on exit
				$(this).mouseleave(function() {
					$(this).find("ul").stop(true, true).slideUp().parent().removeClass('selected');;
				});
			}
		});
						  //TABS
						//hide the tab panes if javascript is enabled
						$("div.panes div.pane").css('display','none');
						//make the tabs
						$("ul.tabs").tabs("div.panes > div",{
										  current: 'current',//class name applied to the current tab
										  //effect: 'fade', //default, fade, slide, horizontal,ajax
										  event: 'click', // click, mouseover, dblclick
										  history: true, // true or false - uses hash in url
										  initialIndex: 0 //index of the inital tab opened
										  //tabs: 'a' //selector for what makes the tabs
										  });
									  
										
						//OVERlAY
						//hide the overlay if javascript is enabled
						$("div.overlay").css('display','none')
						//trigger for overlay
						$("a.trigger").overlay({expose:'#333333',fixed:false});//make a link with id of expose will dark out the background
						
						//make the members stack up nicely by removing margin on the odd ones
						 $("#chapterMembers ul li:odd").css('margin-right','0');
						 
						 //Make the tooltips
						 $("a.tooltipTrigger").tooltip({
													   opacity:1,
													   position:'center left',
													   offset:[-120, 30],
													   relative:true,
													   effect:'slide'
													   
													   });
						 //autofill the professionals wanted form when a link is clicked
						 $("a.tooltipTrigger").click(function(){
															  var jobWanted = $(this).text();
															  $("#overlay h3").remove();
															  $("#overlay form").before("<h3>Yes! I want to apply for "+ jobWanted + " in this chapter</h3>");
															  $("#overlay form #CAT_Custom_67736").val(jobWanted);
															  });
						 
				   	
						
						
						
						//make all a elements with class of .groupHeight the same height as the biggest

 
	
	var max = 0
	$(".groupHeight").each(function(){
        if ($(this).height() > max)
            max = $(this).height();   
    });
    $(".groupHeight").height(max);
	
	$(".fGroupHeight").height(footerMax); 
	
	var footerMax = 0
	$(".fGroupHeight").each(function(){
        if ($(this).height() > footerMax)
            footerMax = $(this).height();   
    });
    $(".fGroupHeight").height(footerMax);
	
	
				  			 });
							 });
