
$(document).ready(function(){
		//colorbox
		$("a[rel=colorbox]").colorbox({
				iframe:true,
				width:770,
				height:720
			})
		$("a[href='#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.triggers").click(function(){
		//	var chapterToVisit = $(this).text();
		//	chapterVisitText = "I would like to visit " + chapterToVisit;
		//	$("textarea#CAT_Custom_105172").val(chapterVisitText);
		//	});		
				
		//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'	
													}
													});
		//Tooltip
		$('#cycle li a').tooltip({
			position: 'center top', // top,right,left,bottom,center 
													//offset: [-20,-5], //offset in pixels from [top, left] of tooltip
													relative:true,
													effect: 'slide'
			});											
		$('div.toggler-c').toggleElements({fxAnimation:'fade'}); 												
		
		//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
		$("li.zoneName a:contains('Members')").each(function(){
		
			$("li.leadersLink").remove();
															 });
									 
		$("li.zoneName 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')
		
		//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); 
     					     
	
	
  

  
	
 });

