$(function(){
		//get url for redirect
		var host = jQuery.url.attr("host");
		var path = jQuery.url.attr("path");
		//alert(host + path);
		//TABS
		//hide the tab panes if javascript is enabled
						$("div.panes > div:first-child").css('display','none');
						//make the tabs
						$("ul.tabs").tabs("div.panes > div",{
										  
										  });
		//Overlay					
      //$("a.trigger").overlay({expose:'#4F0000'});//makes any link with a class of trigger call an overlay
	  
	   //Image Cycle
	   //id of container for images to be cycled
						$("#cycle").cycle({
										  timeout: 4500, //4 and a half seconds delay until it changes to next image
										  speed: 1000 // 1 second to change to the next image in the cycle 
										  });
						$("#cycle li").hover(
						
						function(){
							$("#cycle").cycle('pause');
							},
						function(){
							$("#cycle").cycle('resume');
							});
						$("#cycle li a").click(function(){
														var chapter = $(this).text()
														var chapterText = "I would like to visit " + chapter + ", please!";
														$.colorbox({
														inline:true,
														href:"#overlay",
														scrolling: false,
														width:700,
														height:544,
														rel: 'nofollow',
														onOpen: function(){
																		$("div.overlay").show();
																		$("#CAT_Custom_105172").val(chapterText);
																		},
														onClosed: function(){
																		$("div.overlay").hide();
																		$("#CAT_Custom_105172").val('');
																		},
			});
							});					  
		//Tooltip
		$('#chapterMembers li a').tooltip({
													
													position: 'center right', // top,right,left,bottom,center 
													offset: [-50,-50], //offset in pixels from [top, left] of tooltip
													relative:true,
													effect: 'slide',//fade or slide up
													events: {
													def: 'click,mouseout'	
													}
													});
		$('#cycle li a').tooltip({
													
													position: 'center right', // top,right,left,bottom,center 
													//offset: [-20,-5], //offset in pixels from [top, left] of tooltip
													relative:true,
													effect: 'slide'
													});											
		
		//make the directors webapp atack up nicely
		$("div#directors div.span-9:odd").addClass('last');
		
		//login zone
		$("#leaders, #members").css('display','none');
		$("select#zone").change(function(){
								selectedVal = $(this).val();
								
								if (selectedVal == 'members'){
								$("#members").show('fast');
								$("#leaders").hide();
								}
								if (selectedVal == 'leaders'){
								$("#leaders").show('fast');
								$("#members").hide();
								}
								else
								$("#leaders, #members").hide();
								
								});
		//remove the relevant buttons in the members area
		$(".zoneSubscriptions li a:contains('Members')").each(function(){
		
										$("li.leadersLink").remove();
															 });
									 
		$(".zoneSubscriptions li a:contains('Leadership')").each(function(){
									
										$("li.membersLink").remove();	 
									 });
		$("li.price:contains('&pound;0.00')").each(function(){
													  $(this).html('<p><strong style="color:#FF0000; background:#FFEFEF; border:1px dotted #B22B2B; padding:0.3em; display:block; text-align:center;">FREE</strong></p>')
													  });
		$("li.bniPrice:contains('&pound;0.00')").each(function(){
													  $(this).css('visibility','hidden')
													  });
		//change the cart link to work with logged in users
		
		cartLink = $("td.cartSummaryItem a").attr('href');
		
		//alert(cartLink);
		$("div#addedToCart a.buttonRight").css('background','#ff9900').attr('href',cartLink);
		
		//make successnet divs stack up nicley
		$("div.successNet:odd").addClass('last')
		//make colorbox links
		$("a[rel=colorbox]").colorbox({
								 iframe: true,
								 width:780,
								 height:720
								 });
		$("a[rel='#overlay']").colorbox({
								 inline:true,
								href:"#overlay",
								scrolling: false,
								width:700,
								height:544,
								rel: 'nofollow',
								onOpen: function(){
												$("div.overlay").show();
												},
								onClosed: function(){
									$("div.overlay").hide();
									}
								 });	
		//prefill the form for the customers when they click arrange a visit
		$("ul#map a").click(function(){
			var chapterToVisit = $(this).text();
			chapterVisitText = "I would like to visit " + chapterToVisit;
			$("textarea#CAT_Custom_105172").val(chapterVisitText);
			});						 					 
		//add class of groupHeight to elements if they need to be the same size
		//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);
		//make the training items big targets

$(".bigTarget a").bigTarget({
							hoverClass: 'over',
							clickZone: 'div:eq(0)'
							});
	
	
 });
