$(document).ready( function()
      {
         PEPS.rollover.init();
		
		$("#overlay #Template_SPApply1_linkApply img").addClass("on");
		
		$("#quick-links dd").hide();
	   
		$("#quick-links dt").click(
			function() {
				$("#quick-links dd").slideDown();
				$("#quick-links dt").addClass("open").animate({ opacity: 0, "easing": "easeout" }, 1000);
				$('html, body').animate({ scrollTop: 60000 }, 'slow'); 
			});
		$("#quick-links dd .close").click(
			function() {
				$("#quick-links dd").slideUp();
				$("#quick-links dt").removeClass("open").animate({opacity: 1, "easing": "easeout"}, 1000);
			});


		$("#flashcontainer").hide();
		$("#post-videoImage").hide();
		
		$("#pre-videoImage a").click(

		function() {
		    $("#pre-videoImage").slideUp('slow');
		    $("#pre-videoImage").hide();
		    $("#flashcontainer").slideDown('slow');
		    $(this).addClass("selected");
			    return false;
			});


		$("#post-videoImage a").click(

		function() {
		    $("#post-videoImage").slideUp('slow');
		    $("#post-videoImage").hide();
		    $("#flashcontainer").slideDown('slow');
		    $(this).addClass("selected");
		    return false;
		});
		


		$("#support-holder").hide();
	   	$("#support a").click(
			function() {
				$("#support-holder").slideDown();
				$(this).addClass("selected");
				return false;
			});
		$("#support-holder .close").click(
			function() {
				$("#support-holder").slideUp();
				$("#support a").removeClass("selected");
			
			});

		$(".slider").hide();

		puffLength = ($('.puff').length - 1);
		for(i=0; i<=puffLength; i++){
			$(".puff:eq("+i+") p.view a").data('myId', i);
			$(".puff:eq("+i+") p.view a").click(
				function() {
					$(".puff .slider").hide();
					$(".puff:eq(" + $(this).data('myId') + ") .slider").fadeIn('slow');
					return false;
				}
			);
		}

		$(".puff p.view").hover(
      function () {
        $(this).toggleClass("on");
      }
    );


		sliderLength = ($('.slider').length - 1);
		for(i=0; i<=sliderLength; i++){
			$(".slider:eq("+i+") h3").data('myId', i);
			$(".slider:eq("+i+") h3").click(
				function() {
					$(".slider:eq(" + $(this).data('myId') + ")").fadeOut('slow');
					return false;
				}
			);
		}

		
//		$("#btn-go, #btn-go2").hide();

//    	$("#section-choose select").change(function() {
//        window.location = $("#section-choose select option:selected").val();
//    	})
		
    	$("#ddl-energy-type").change(function() {
        window.location = $("#ddl-energy-type option:selected").val();
    	})
		
		$(".product-detail").hide();
		$("#product-holder .more a").toggle(function(){
			$(this).addClass("active");
			$(this).parent().siblings('.product-detail').slideDown();
			return false;
			}, function () {
			$(this).removeClass("active");
			$(this).parent().siblings('.product-detail').slideUp();
			return false;
		});
		
		$("#product-holder-full .product-detail").show();
		
		//Full Caption Sliding (Hidden to Visible)
		$('.boxgrid.slidedown').keyup(function(){
			$(".boxcaption", this).stop().animate({top:'1px'},{queue:false,duration:300});
		}, function() {
			$(".boxcaption", this).stop().animate({top:'-185px'},{queue:false,duration:300});
		});
		
		$('.boxgrid.slidedown').hover(function(){
			$(".boxcaption", this).stop().animate({top:'1px'},{queue:false,duration:300});
		}, function() {
			$(".boxcaption", this).stop().animate({top:'-185px'},{queue:false,duration:300});
		});
		
		$('#nav-main .nav-sub li:last').addClass('last');
		
		$("#footer li").append("<span> |</span>");
//		$("#footer li:last-child span").detach();
		$("#footer li:last-child span").remove();
	    $("#breadcrumbs li").append("<span> |</span>");
//		$("#breadcrumbs li:last-child span, #breadcrumbs li:first-child span").detach();
		$("#breadcrumbs li:last-child span, #breadcrumbs li:first-child span").remove();


		
      });

      
      PEPS = {};
      
      PEPS.rollover =
      {
         init: function()
         {
            this.preload();
            
            $(".on").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() {
               $('.on').each( function( key, elm ) { $('<img>').attr( 'src', PEPS.rollover.newimage( $(this).attr('src') ) ); });
            });
         },
         
         newimage: function( src ) { return src.substring( 0, src.search(/(\.[a-z]+)/) ) + '-on' + src.match(/(\.[a-z]+)/)[0]; },
         oldimage: function( src ){ return src.replace(/-on/, ''); }
		 
		 
      };


      function closeFlashArea() {

            $("#flashcontainer").slideUp('slow');
            
            //$("#flashcontainer").removeClass("open").animate({ opacity: 1, "easing": "easeout" }, 1000);
            
		    $("#post-videoImage").slideDown('slow');
		    $(this).addClass("selected");
			    return false;

			};
      
      
      

