// 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\./, '.');
   }
};




$(document).ready(function(){
					
$(".price_box").children("p:last").addClass("last");
								   
/*  locations map tabbed state navigation  */
$(".states #sa").show();
$(".states #nt").hide();
	
$("#sa_tab").click(function(){
	$("#sa").show();
	$("#nt").hide();
});

$("#nt_tab").click(function(){
	$("#sa").hide();
	$("#nt").show();
});

//$("#locations .list ul li:eq(10)").addClass("test");


/* colorbox (aka lightbox) functions. All pages that need to come up in a popup need to include the href:url.aspx parameter */

$(".content_oc").hide();
$(".open_close").click(function(){
	$(this).next(".content_oc").slideToggle();
});

$(".open_close").hover(function(){
	$(this).addClass("hover1");
}, function(){
	$(this).removeClass("hover1");
	});

$("a.img").colorbox({opacity:0.5});

$("a.vid1").colorbox({iframe:true, width:'279px', height:'430px', opacity:0.5});
$("a.vid2").colorbox({iframe:true, width:'420px', height:'380px', opacity:0.5});

$("a.box").colorbox({iframe:true, width:'680px', height:'700px', opacity:0.5});

$("a.box2").colorbox({iframe:true, width:'625px', height:'545px', opacity:0.5});

$("a.media").colorbox({iframe:true, width:'830px', height:'583px', opacity:0.5});

$("a.box_subscribe").colorbox({iframe:true, width:'600px', height:'420px', opacity:0.5});

$("#solutions .solution").hide();


$("#one_t").click(function(){
		$(this).addClass("active");
		$(this).siblings().removeClass("active");
		$(this).parent().siblings("#solutions").children(".solution").hide();
		$(this).parent().siblings("#solutions").children("#dnn_one_s").show();
		sIFR.replace(helvetica, {
		selector: '#right_items #solutions .title h3',
		css: '.sIFR-root {color: #9CED74; }',
		wmode: 'transparent'
		});
		
		sIFR.replace(helvetica, {
		selector: '#right_items #solutions .info h4',
		css: '.sIFR-root {color: #70837e; }',
		wmode: 'transparent'
		});
	});

$("#two_t").click(function(){
		$(this).addClass("active");
		$(this).siblings().removeClass("active");
		$(this).parent().siblings("#solutions").children(".solution").hide();
		$(this).parent().siblings("#solutions").children("#dnn_two_s").show();
		sIFR.replace(helvetica, {
		selector: '#right_items #solutions .title h3',
		css: '.sIFR-root {color: #9CED74; }',
		wmode: 'transparent'
		});
		
		sIFR.replace(helvetica, {
		selector: '#right_items #solutions .info h4',
		css: '.sIFR-root {color: #70837e; }',
		wmode: 'transparent'
		});
	});

$("#three_t").click(function(){
		$(this).addClass("active");
		$(this).siblings().removeClass("active");
		$(this).parent().siblings("#solutions").children(".solution").hide();
		$(this).parent().siblings("#solutions").children("#dnn_three_s").show();
		sIFR.replace(helvetica, {
		selector: '#right_items #solutions .title h3',
		css: '.sIFR-root {color: #9CED74; }',
		wmode: 'transparent'
		});
		
		sIFR.replace(helvetica, {
		selector: '#right_items #solutions .info h4',
		css: '.sIFR-root {color: #70837e; }',
		wmode: 'transparent'
		});
	});

$("#four_t").click(function(){
		$(this).addClass("active");
		$(this).siblings().removeClass("active");
		$(this).parent().siblings("#solutions").children(".solution").hide();
		$(this).parent().siblings("#solutions").children("#dnn_four_s").show();
		sIFR.replace(helvetica, {
		selector: '#right_items #solutions .title h3',
		css: '.sIFR-root {color: #9CED74; }',
		wmode: 'transparent'
		});
		
		sIFR.replace(helvetica, {
		selector: '#right_items #solutions .info h4',
		css: '.sIFR-root {color: #70837e; }',
		wmode: 'transparent'
		});
	});

$("#solutions .info tr").children("td:last-child").addClass("no_line");


// sifr intialising (hopefully)

});
