// JavaScript Document


$(document).ready(function(){
PEPS.rollover.init();
});


//Image Rollover
PEPS = {};
PEPS.rollover =
{
   init: function()
   {
      this.preload();
      $(".rollover").hover(
         function () { $(this).attr( 'src', PEPS.rollover.newimage($(this).attr('src')) ); },
         function () { $(this).attr( 'src', PEPS.rollover.oldimage($(this).attr('src')) ); }
      );
   },
   preload: function()
   {
      $(window).bind('load', function() {
         $('.rollover').each( function( key, elm ) { $('<img>').attr( 'src', PEPS.rollover.newimage( $(this).attr('src') ) ); });
      });
   },   
   newimage: function( src )
   {
      return src.substring( 0, src.search(/(\.[a-z]+)$/) ) + '_r' + src.match(/(\.[a-z]+)$/)[0];
   },
   oldimage: function( src )
   {
      return src.replace(/_r\./, '.');
   }
};













/*  custom jquery actions */ 

$(document).ready(function(){
	
	
	$(".question").click(function(){
		$(this).toggleClass("question_active").next(".answer").slideToggle();
	});
	
	$(".feed_item:first").addClass("first");
	
	$("#birthday_tabs .tab a").click(function(){
		$(this).toggleClass("active");
		$(this).parent().siblings().children().removeClass("active");
	});
	
	$("#birthday_tabs #age1 a").click(function(){
		$("#birthday_content #dnn_age1").toggle().siblings().hide();
	});
	
	$("#birthday_tabs #age2 a").click(function(){
		$("#birthday_content #dnn_age2").toggle().siblings().hide();
	});
	
	$("#birthday_tabs #age3 a").click(function(){
		$("#birthday_content #dnn_age3").toggle().siblings().hide();
	});
	
	$("#birthday_tabs #faq a").click(function(){
		$("#birthday_content #dnn_faq").toggle().siblings().hide();
	});
	

	$("#lessons_tabs .tab a").click(function(){
		$(this).toggleClass("active");
		$(this).parent().siblings().children().removeClass("active");
	});
	
	$("#lessons_tabs #age1 a").click(function(){
		$("#lessons_content #dnn_age1").toggle().siblings().hide();
	});
	
	$("#lessons_tabs #age2 a").click(function(){
		$("#lessons_content #dnn_age2").toggle().siblings().hide();
	});
	
	$("#lessons_tabs #age3 a").click(function(){
		$("#lessons_content #dnn_age3").toggle().siblings().hide();
	});
	
	$("#lessons_tabs #icehockey a").click(function(){
		$("#lessons_content #dnn_icehockey").toggle().siblings().hide();
	});
	
	$("#lessons_tabs #figureskating a").click(function(){
		$("#lessons_content #dnn_figureskating").toggle().siblings().hide();
	});
	
	$(".form_trigger").hover(
		function(){
			$(this).addClass("active");
			$("#forms").show();
		},
		function(){
			$(this).removeClass("active");
			$("#forms").hide();
	});

	$("#forms li a").colorbox({iframe:true, initialWidth:'400px', initialHeight:'320px', width:'570px', height:'770px',opacity:0.5});
	
	$("#HouseMenuNavLink60").colorbox({iframe:true, initialWidth:'400px', initialHeight:'320px', width:'570px', height:'770px', opacity:0.5});
	
	$(".birthday_enquiry").colorbox({iframe:true, initialWidth:'400px', initialHeight:'320px', width:'570px', height:'770px', opacity:0.5});
		$(".inline_enquiry").colorbox({iframe:true, initialWidth:'400px', initialHeight:'320px', width:'570px', height:'770px', opacity:0.5});
	
	$(".contact_enquiry").colorbox({iframe:true, initialWidth:'400px', initialHeight:'320px', width:'570px', height:'500px', opacity:0.5});
	
	$("a#HouseMenuNavLink69").click(function(){
		window.open(this.href);
		return false;
	});
	
	/*$("#ext a.evtLinks").click(function(){
		window.open(this.href);
		return false;
	});*/
	
});