// 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\./, '.');
   }
};


/*  sliding open close nav  */

$(document).ready(function(){
						   
				   

$(".inside_nav ul li ul").hide();

$(".inside_nav ul li").click(function(){
      $(this).children("ul").slideDown(500);
	  $(this).siblings("li").children("ul").slideUp(500);
	  $(this).addClass("tabopen");
	  $(this).siblings("li").removeClass("tabopen");
	});

$(".inside_nav ul li ul li ul li a").hide();//.click(function(){
	//$(this).children("ul").slideUp(500);

//});


$("#HouseMenuNavItem108 ul").addClass("test");
$("#HouseMenuNavItem80 ul ul").hide();

$("#HouseMenuNavCurrentItem").parent("ul").show().parent("li").addClass("tabopenb");

$(".inside_nav ul ul ul").children("#HouseMenuNavCurrentItem").parent("ul").parent("li").removeClass("tabopenb").addClass("tabopen").parent("ul").show().parent("li").addClass("tabopenb");;

});

/* FAQ accordian script  */

$(document).ready(function(){

$(".answer").hide();
$(".question").click(function(){
	  $(this).next(".answer").slideToggle(500)
	  .siblings(".answer").slideUp(500);
	  $(this).toggleClass("qopen");
	  $(this).siblings(".question").removeClass("qopen");
	});

});





/* tabs script  */

jQuery(document).ready(function(){
	
	jQuery(".htabs li a").click(function(){
		jQuery(this).toggleClass("htabopen");
		jQuery(this).parents("li").siblings("li").children("a").removeClass("htabopen");
	});
	
	jQuery(".htabs li a:first").toggleClass("htabopen");
	
	jQuery(".tab:not(:first)").hide();

	//to fix u know who
	jQuery(".tab:first").show();
	
	jQuery(".htabs a").click(function(){
		stringref = jQuery(this).attr("href").split('#')[1];

		jQuery('.tab:not(#'+stringref+')').hide();

		
			jQuery('.tab#' + stringref).slideDown("slow");
		
		return false;
	});
	
});


/*  hide png's in ie 5, 6  */

var blank = new Image();
 blank.src = 'images/blank.gif';
 
 $(document).ready(function() {
   var badBrowser = (/MSIE ((5\.5)|6)/.test(navigator.userAgent) && navigator.platform == "Win32");
   if (badBrowser) {
     // get all pngs on page
     $('img[src$=.png]').each(function() {
       if (!this.complete) {
         this.onload = function() { fixPng(this) };
       } else {
         fixPng(this);
       }
     });
   }
 });
 
 function fixPng(png) {
   // get src
   var src = png.src;
   // set width and height
   if (!png.style.width) { png.style.width = 0; }
   if (!png.style.height) { png.style.height = 0; }
   // replace by blank image
   png.onload = function() { };
   png.src = blank.src;
   // set filter (display original image)
   //png.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "',sizingMethod='scale')";
 }
 
 
 