// 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\./, '.');
   }
};


/*  Denhams awesome simple tabs system (cos there are only 2 tabs) */

$(document).ready(function(){
						   
	$("#orange_box .tabs_content:last").hide();
	$("#orange_box .tabs_content:first").show();
	
	$("#orange_box .tabs .tab:first").addClass("up");

	$("#orange_box .tabs .tab:first").click(function(){
		$("#orange_box .tabs_content:last").hide();
		$("#orange_box .tabs_content:first").show();
		$(this).removeClass("down").addClass("up");
		$("#orange_box .tabs .tab:last").removeClass("up").addClass("down");
	});	
	
	$("#orange_box .tabs .tab:last").addClass("down");

	$("#orange_box .tabs .tab:last").click(function(){
		$("#orange_box .tabs_content:last").show();
		$("#orange_box .tabs_content:first").hide();
		$(this).removeClass("down").addClass("up");
		$("#orange_box .tabs .tab:first").removeClass("up").addClass("down");
	});
	
	
	$("#green_box .tabs_content:last").hide();
	$("#green_box .tabs_content:first").show();
	
	$("#green_box .tabs .tab:first").addClass("up");

	$("#green_box .tabs .tab:first").click(function(){
		$("#green_box .tabs_content:last").hide();
		$("#green_box .tabs_content:first").show();
		$(this).removeClass("down").addClass("up");
		$("#green_box .tabs .tab:last").removeClass("up").addClass("down");
	});	
	
	$("#green_box .tabs .tab:last").addClass("down");

	$("#green_box .tabs .tab:last").click(function(){
		$("#green_box .tabs_content:last").show();
		$("#green_box .tabs_content:first").hide();
		$(this).removeClass("down").addClass("up");
		$("#green_box .tabs .tab:first").removeClass("up").addClass("down");
	});	
	
	
	$("#gray_box .tabs_content:last").hide();
	$("#gray_box .tabs_content:first").show();
	
	$("#gray_box .tabs .tab:first").addClass("up");

	$("#gray_box .tabs .tab:first").click(function(){
		$("#gray_box .tabs_content:last").hide();
		$("#gray_box .tabs_content:first").show();
		$(this).removeClass("down").addClass("up");
		$("#gray_box .tabs .tab:last").removeClass("up").addClass("down");
	});	
	
	$("#gray_box .tabs .tab:last").addClass("down");

	$("#gray_box .tabs .tab:last").click(function(){
		$("#gray_box .tabs_content:last").show();
		$("#gray_box .tabs_content:first").hide();
		$(this).removeClass("down").addClass("up");
		$("#gray_box .tabs .tab:first").removeClass("up").addClass("down");
	});	



//hopefully this roll-over dialog box thing works properly

	$(function(){
		$("#pet_list .pet").hover(
			function(){$(this).children().next(".info").fadeIn("fast");},
			function(){$(this).children().next(".info").fadeOut("fast");}
		);
	});	
	
	$(function(){
		$("#dnn_onlineshop .browse").hover(
			function(){$(this).children().next(".info").fadeIn("fast");},
			function(){$(this).children().next(".info").fadeOut("fast");}
		);
	});


});
