
$(document).ready(function() {
    InitSite();
    
	//alert(navigator.platform);
	
    //remember sIFR will break some jquery locally, but will work fine on the web server
    if ($.browser.msie && parseInt(jQuery.browser.version) < 7) {} 
	else { InitHeadingReplacement(); };
	//$("a.play").live('click', function (e){
			//e.preventDefault();

			//window.location=$(this).attr("href");
			
		//});
   //} 
});

//GENERIC SITE----------------------------------------------------------------------------->
function isiPhone(){
    return (
        (navigator.platform.indexOf("iPhone") != -1) ||
		(navigator.platform.indexOf("iPad") != -1) ||
        (navigator.platform.indexOf("iPod") != -1)
    );
}

var mtimeout    = 1000;
var mclosetimer;
function InitSite(){

if(isiPhone()){
    $("#home-carousel").css("display", "block");
	$("#is-home-object").css("display", "none");
}

/*
    //clear search form onfocus
    $("#searchField").focus(function() {
	    if( this.value == this.defaultValue ) {
		    this.value = "";
	    }
    }).blur(function() {
	    if( !this.value.length ) {
		    this.value = this.defaultValue;
	    }
    });

*/


    //var closetimer = 0;
    var ddmenuitem = 0;
    var currentLink = null;
    var newMenu = null;
    var navState = null;


	
    function jsddm_open()
    {   
       //cancel timer and close
       jsddm_canceltimer();
       jsddm_close();
       
       //test to see if this nav item is selected
       navState = $(this).attr("class");
       
       //set the values of the current menu and link items
       newMenu = '#' + $(this).attr("rel");
       currentLink = '#' + $(this).attr("id");
       
       //set new menu to visible
       ddmenuitem = $(newMenu).css('visibility', 'visible');
       
       //set the main nav item to selected
       if(navState != "selected"){
        $(this).addClass("selected");
       }
       
       
       //bind the mouseover and mouseout events to the sub nav elements
       $('.leveltwo').bind('mouseover',  jsddm_openSub)
      // $('.leveltwo').bind('mouseout',  jsddm_timer)
        $('.leveltwo').bind('mouseout',  endAndStartMenuTimer)
    }
    
    //control mouse over on sub nav
    function jsddm_openSub()
    {   
        //cancel timer and close
       jsddm_canceltimer();
       jsddm_close();
       
       //need to add the selected class to the main nav item again
       if(navState != "selected"){
        $(currentLink).addClass("selected");
       }
       ddmenuitem = $(newMenu).css('visibility', 'visible');
    }

    function jsddm_close()
    {  
        if(ddmenuitem){
            ddmenuitem.css('visibility', 'hidden');
            if(navState != "selected"){
                $(currentLink).removeClass("selected");
               }
        } 
    
    }

    function jsddm_timer()
    {  mclosetimer = window.setTimeout(jsddm_close, mtimeout);}

    function jsddm_canceltimer()
    {  if(mclosetimer)
       {  window.clearTimeout(mclosetimer);
          mclosetimer = null;}}

    /*$(document).ready(function()
							   
    {  
		$('.levelone > li > A:not(:last)').bind('click', jsddm_open)
		$('.levelone > li > A:not(:last)').bind('mouseover', jsddm_open)
       	$('.levelone > li > A:not(:last)').bind('mouseout',  jsddm_timer)
    });
    document.onclick = jsddm_close;*/
	
	var endAndStartMenuTimer = (function () {
 	var mtimer; // variable persisted here
  	return function () {
    window.clearTimeout(mtimer);
    //var millisecBeforeRedirect = 10000; 
    mtimer = window.setTimeout(jsddm_close, mtimeout); 
  };
})();

	 $(document).ready(function()
							   
	{	
	
      	$('.levelone > li > A:not(:last)').bind('mouseover click', jsddm_open);
       	$('.levelone > li > A:not(:last)').bind('mouseout',  jsddm_timer);
		/* $('body').one(function() { 
   			 jsddm_close;// Hide the menus 
		 }); */
	  // event.stopPropagation(); 
    });

	


}


//handle Newsletter sign up form
function InitNewsletter(){
	
	$("#newsletterCountry").change(function() { 
        var curItem = $(this).attr("value");
        if(curItem == "10"){
			$("#stateFieldset").removeClass("hdn");
			$("#provinceFieldset").addClass("hdn");
		}else{
			$("#stateFieldset").addClass("hdn");
			$("#provinceFieldset").removeClass("hdn");
		}
	    return false;
    });
	
	var currentDDSTate = 0;
	$('#dd-friend-emails').click(function(evt) {
		evt.preventDefault();
		if(currentDDSTate == 0){
			$(this).removeClass("toggle-down");
			$(this).addClass("toggle-up");
			currentDDSTate = 1;
		}else{
			$(this).removeClass("toggle-up");
			$(this).addClass("toggle-down");
			currentDDSTate = 0;
		}
		$("#friend-email-list").toggle();
	});
}

function InitHome(){

    //carousel
    $(".home-move").jCarouselLite({
        visible: 1,
        auto: 4000,
		hoverPause: true,
        speed: 1400,
        easing: 'easeInOutCubic',
        btnNext: ".nextBtn",
        btnPrev: ".prevBtn"
    });


    //**home sites list**//
    //set default values for list items
    $("#home-sites li H3").each(
        function() {
            $(this).css('opacity', 0.7);
            $(this).css('top', '-10px');
        }
    );
    
    $("#home-sites li IMG").each(
        function() {
            $(this).css('opacity', 0.6);
        }
    );
    
    $("#home-sites li").each(
        function() {
            //bind mouse over and out functions to links
            $( this ).bind (
                "mouseenter",
                function(){
                    //alert("over");
                    $(this).find('H3').animate({ 
                        marginTop: "-25px"
                      }, 500 );
                    $(this).find('IMG').fadeTo("slow", 1);

                }
            );
            $( this ).bind (
                "mouseleave",
                function(){
                    //alert("out");
                    $(this).find('H3').animate({ 
                        marginTop: "-0px"
                      }, 500 );
                    $(this).find('IMG').fadeTo("slow", 0.6);
                }
            );
        }
        
    );
	//$('#divInsidebox').hide();
}



//company sponsorship
function InitCompany(){


    //**home sites list**//
    //set default values for list items
    $("ul.sponsorship li H3").each(
        function() {
            $(this).css('opacity', 0.7);
        }
    );
    
    $("ul.sponsorship li").each(
        function() {
            //bind mouse over and out functions to links
            $( this ).bind (
                "mouseenter",
                function(){
                    //alert("over");
                    $(this).find('H3').fadeTo("slow", 1);

                }
            );
            $( this ).bind (
                "mouseleave",
                function(){
                    //alert("out");
                    $(this).find('H3').fadeTo("slow", 0.6);
                }
            );
        }
        
    );
}



//preload images
jQuery.preloadImages = function()
{
  for(var i = 0; i<arguments.length; i++)
  {
    jQuery("<img>").attr("src", arguments[i]);
  }
}

//position compare button
function PositionCompare(){
 var currentWidth = $(window).width() / 2 + 490;
 //alert(currentWidth);
 
 $('input.compare').css("left", currentWidth)
}

//product details
function InitProductDetail(){
	$('#divInsidebox').show();
	
    //sub nav
    $('div#product-specs').addClass('hdn');
    $('div#product-manuals').addClass('hdn');
    $('div#product-print').addClass('hdn');

    $('#product-details LI A').click(function(evt) {
        evt.preventDefault();
	  
        var newContent = $(this).attr("rel");

    	switchProductTab(newContent);
      
    });
	
	$('.product-links A.print').click(function(evt) {
			 evt.preventDefault();
			  if($.browser.opera){$('html').animate({scrollTop: $('#product-details').offset().top}, 2000);} else $('html,body').animate({scrollTop: $('#product-details').offset().top}, 2000);
    
        var newContent = $(this).attr("rel");

    	switchProductTab(newContent);
		
			 });
	
	$('.info-links LI A').click(function(evt) {
        evt.preventDefault();
    	 if($.browser.opera){$('html').animate({scrollTop: $('#product-details').offset().top}, 2000);} else $('html,body').animate({scrollTop: $('#product-details').offset().top}, 2000);
    
        var newContent = $(this).attr("rel");

    	switchProductTab(newContent);
      
    });
	$('#btnPrintall').click(function() {
		window.open('/product/print.cfm?productuid='+$("#productuid").val()+'&'+'all=all',"mywindow",
    "location=0,status=1,scrollbars=1,width=700,height=900,toolbar=0");
		return false;
	});
	$("#chkSelectallfeature").click(function() {
		$("input[name='chkFeaturesection']").attr('checked', this.checked);		
	});
	$("#chkSelectallspec").click(function() {
		$("input[name='chkSpecsection']").attr('checked', this.checked);		
	});
	$('#btnPrintSelect').click(function() {
		var s_features=''; var s_specs='';
		$("input[name='chkFeaturesection']:checked").each(
			  function() {
				 
				  s_features= this.value + ';' + s_features ; 
			  
			  }
		);	
		$("input[name='chkSpecsection']:checked").each(
			  function() {
				  s_specs= this.value + ';' + s_specs  ; 
			  
			  }
		);	
		
		if (s_features.length ==0 && s_specs.length == 0){
		 $.prompt('Please select some product information section to print.');
		}else
		window.open('/product/print.cfm?productuid='+$("#productuid").val()+'&'+'specs='+s_specs+'&features='+s_features,"mywindow",
    "location=0,status=1,scrollbars=1,width=700,height=900,toolbar=0");
		return false;
	});

}

function switchProductTab(newContent){
	
	  $("#product-details LI A").removeClass("selected");
      $("#product-details LI A[rel="+newContent+"]").addClass("selected");
        
        switch(newContent){
            case 'product-features':
                $('div#product-features').removeClass('hdn');
                $('div#product-specs').addClass('hdn');
                $('div#product-manuals').addClass('hdn');
                $('div#product-print').addClass('hdn');
                break;
            case 'product-specs':
                $('div#product-features').addClass('hdn');
                $('div#product-specs').removeClass('hdn');
                $('div#product-manuals').addClass('hdn');
                $('div#product-print').addClass('hdn');
                break;
            case 'product-manuals':
                $('div#product-features').addClass('hdn');
                $('div#product-specs').addClass('hdn');
                $('div#product-manuals').removeClass('hdn');
               $('div#product-print').addClass('hdn');
                break;
           case 'product-print':
                $('div#product-features').addClass('hdn');
                $('div#product-specs').addClass('hdn');
                $('div#product-manuals').addClass('hdn');
                $('div#product-print').removeClass('hdn');
                break; 
        }
	
	
}
function InitProductImages(){

    

    //test number of thumbnails

    var count = $('.product-move ul li').length;

    //alert(count);

    

    //hide initial state of pop up next prev links if there is only 1 image

    if(count < 2){

        $("#popupGallery A#prevBtn").css('visibility', 'hidden');

        $("#popupGallery A#nextBtn").css('visibility', 'hidden');   

    }

    

    //if count < 6

    if(count < 6){

        //Hide arrow btns

        $('div#product-carousel a.next').css('visibility', 'hidden');

        $('div#product-carousel a.prev').css('visibility', 'hidden');

    }

    

    

    //set initial values for links

    var prevItem = -1;

    var currentItem = 0;

    var nextItem = 1;

    var totalItems = $('.product-move ul li a').length;

    var galleryImages = new Array();

    

    $(".product-move ul li a").each(

        function() {

            galleryImages.push($(this).attr("href"));

            $( this ).bind (

                "click",

                function(evt){

                    evt.preventDefault();

                    

                    prevItem = Number($(this).attr("class")) - 1;

                    currentItem = Number($(this).attr("class"));

                    nextItem = Number($(this).attr("class")) + 1;

                    

                    populateLinks();

                    

                    var newMainImage = $(this).attr("rel");

                    var newFullImage = $(this).attr("href");

                    

                    $("#large-image").attr("src", newMainImage);

                    $("#gallery-image img").attr("src", newFullImage);

                }

            );

        }

        

    );

    

    //populate prev link

    $("#popupGallery A#prevBtn").attr("href", galleryImages[prevItem]);

    $("#popupGallery A#prevBtn").attr("class", prevItem);

    

    //populate next link

    $("#popupGallery A#nextBtn").attr("href", galleryImages[nextItem]);

    $("#popupGallery A#nextBtn").attr("class", nextItem);

    

    //hide prev link initially

    $("#popupGallery A#prevBtn").css('visibility', 'hidden');

    

    //handle lightbox thumbnail clicks

    $("ul#gallery-thumbs li a").click(function (evt) {

        evt.preventDefault();

    

        prevItem = Number($(this).attr("class")) - 1;

        currentItem = Number($(this).attr("class"));

        nextItem = Number($(this).attr("class")) + 1;

        

        populateLinks();

        

    

        var newFullImage = $(this).attr("href");

        

        //change main image

        $("#gallery-image img").attr("src", newFullImage);

    });

    

    $("#popupGallery A#prevBtn").click(function (evt) {

        evt.preventDefault();

        

        var newFullImage = $(this).attr("href");

        

        //change main image

        $("#gallery-image img").attr("src", newFullImage);

        

        prevItem = Number($(this).attr("class")) - 1;

        currentItem = Number($(this).attr("class"));

        nextItem = Number($(this).attr("class")) + 1;

        

        //alert("Prev = " + prevItem + " Current = " + currentItem + " Next = " + nextItem);

        

        populateLinks();

    });

    

    $("#popupGallery A#nextBtn").click(function (evt) {

        evt.preventDefault();

        

        var newFullImage = $(this).attr("href");

        

        //change main image

        $("#gallery-image img").attr("src", newFullImage);

        

        prevItem = Number($(this).attr("class")) - 1;

        currentItem = Number($(this).attr("class"));

        nextItem = Number($(this).attr("class")) + 1;

        

        //alert("Prev = " + prevItem + " Current = " + currentItem + " Next = " + nextItem);

        

        populateLinks();

    });

    

    function populateLinks(){

        //populate prev link

        $("#popupGallery A#prevBtn").attr("href", galleryImages[prevItem]);

        $("#popupGallery A#prevBtn").attr("class", prevItem);

        

        //populate next link

        $("#popupGallery A#nextBtn").attr("href", galleryImages[nextItem]);

        $("#popupGallery A#nextBtn").attr("class", nextItem);

    

        if(currentItem == 0){

            //hide prev btn

            $("#popupGallery A#prevBtn").css('visibility', 'hidden');

        }else{

            //show prev btn

            $("#popupGallery A#prevBtn").css('visibility', 'visible');

        }

        

        if(currentItem == totalItems - 1){

            //hide next btn

            $("#popupGallery A#nextBtn").css('visibility', 'hidden');

        }else{

            //show next btn

            $("#popupGallery A#nextBtn").css('visibility', 'visible');

        }

    }

    

    

    //product carousel

    $(".product-move").jCarouselLite({

        visible: 5,

        speed: 500,

        easing: 'easeInOutCubic',

        btnNext: ".next",

        btnPrev: ".prev",

        circular: false

    });

    

}

 




function InitArticleList(){
    $(".article-list li A").each(
        function() {
            //bind mouse over and out functions to links
            $( this ).bind (
                "mouseenter",
                function(){
                    $(this).parent().find('IMG').css('background-color', '#000000');
                    $(this).parent().find('P').css('color', '#00929f');
                    $(this).parent().find('A.more').css('color', '#00929f');
                    $(this).parent().find('H3 A').css('color', '#00929f');
                }
            );
            $( this ).bind (
                "mouseleave",
                function(){
                    //alert("out");
                    $(this).parent().find('IMG').css('background-color', '#ffffff');
                    $(this).parent().find('P').css('color', '#333333');
                    $(this).parent().find('A.more').css('color', '#333333');
                    $(this).parent().find('H3 A').css('color', '#666666');
                }
            );
        }
        
    );  
    //to handle if there is an h3 heading in the article list
    $(".article-list li H3 A").each(
        function() {
            //bind mouse over and out functions to links
            $( this ).bind (
                "mouseenter",
                function(){
                    $(this).parent().parent().find('IMG').css('background-color', '#000000');
                    $(this).parent().parent().find('P').css('color', '#00929f');
                    $(this).parent().parent().find('A.more').css('color', '#00929f');
                    $(this).parent().parent().find('H3 A').css('color', '#00929f');
                }
            );
            $( this ).bind (
                "mouseleave",
                function(){
                    //alert("out");
                    $(this).parent().parent().find('IMG').css('background-color', '#ffffff');
                    $(this).parent().parent().find('P').css('color', '#333333');
                    $(this).parent().parent().find('A.more').css('color', '#333333');
                    $(this).parent().parent().find('H3 A').css('color', '#666666');
                }
            );
        }
        
    );  
}

function InitArchiveToggle(){
    var toggleState = "hidden";
    
    $('.archive-list').hide();
    
    $("#archive-link").click(function (evt) {
        evt.preventDefault();
        
        if(toggleState == "hidden"){
            $("#archive-link").css("background-image", "url('image/layout/archive-arrow-down.gif')")
            toggleState = "visible";
        }else{
            $("#archive-link").css("background-image", "url('image/layout/archive-arrow-right.gif')")
            toggleState = "hidden";
        }
        
        $('.archive-list').slideToggle()
    });
}

//DID YOU KNOW PAGE
function InitDYK(){
    //show hover arrow on image mouse over
    $("#DYK-main div.content A").mouseenter(function (evt) {
        evt.preventDefault();
        $("A.summary").css("background","url('image/layout/summary-arrow-over.gif') no-repeat 360px -20px")
    });
    
    $("#DYK-main div.content A").mouseleave(function (evt) {
        evt.preventDefault();
        $("A.summary").css("background","url('image/layout/summary-arrow.gif') no-repeat 360px -20px")
    });


    //handle speech bubbles
    $('.q-mark').hide();

    $(".dyk-categories li A").each(
        function() {
            //bind mouse over and out functions to links
            $( this ).bind (
                "mouseenter",
                function(){
                    //alert("in");
                    $(this).parent().find('.q-mark').show();
                }
            );
            $( this ).bind (
                "mouseleave",
                function(){
                    //alert("out");
                    $(this).parent().find('.q-mark').hide();
                }
            );
        }
        
    ); 
}

function changeDYK(currentImage, currentUrl, currentSummary){
    $('#DYK-main IMG').attr("src", currentImage);
    $('#DYK-main A.summary').text(currentSummary);
    $('#DYK-main div.content A').attr("href", currentUrl);
}

function InitAwardsList(){
    $(".awards-list li A").each(
        function() {
            //bind mouse over and out functions to links
            $( this ).bind (
                "mouseenter",
                function(){
                    $(this).parent().find('IMG').css('background-color', '#000000');
                    $(this).parent().find('P').css('color', '#00929f');
                    $(this).parent().find('A.more').css('color', '#00929f');
                }
            );
            $( this ).bind (
                "mouseleave",
                function(){
                    //alert("out");
                    $(this).parent().find('IMG').css('background-color', '#ffffff');
                    $(this).parent().find('P').css('color', '#333333');
                    $(this).parent().find('A.more').css('color', '#333333');
                }
            );
        }
        
    );  
    $(".awards-list li A.more").each(
        function() {
            //bind mouse over and out functions to links
            $( this ).bind (
                "mouseenter",
                function(){
                    $(this).parent().parent().find('IMG').css('background-color', '#000000');
                    $(this).parent().find('P').css('color', '#00929f');
                    $(this).parent().find('A.more').css('color', '#00929f');
                }
            );
            $( this ).bind (
                "mouseleave",
                function(){
                    //alert("out");
                    $(this).parent().parent().find('IMG').css('background-color', '#ffffff');
                    $(this).parent().find('P').css('color', '#333333');
                    $(this).parent().find('A.more').css('color', '#333333');
                }
            );
        }
        
    );
}

jQuery.preloadImages = function()
{
  for(var i = 0; i<arguments.length; i++)
  {
    jQuery("<img>").attr("src", arguments[i]);
  }
}

//////////////////// MICHELLE'S CODE DONT DELETE ////////////////////////////

function InitSponsorship(){
    $("#sponsorship-list li A").each(
        function() {
            //bind mouse over and out functions to links
            $( this ).bind (
                "mouseenter",
                function(){
                    $(this).parent().find('IMG').css('background-color', '#000000');
                    $(this).parent().find('P').css('color', '#00929f');
                    $(this).parent().find('A.more').css('color', '#00929f');
                }
            );
            $( this ).bind (
                "mouseleave",
                function(){
                    //alert("out");
                    $(this).parent().find('IMG').css('background-color', '#ffffff');
                    $(this).parent().find('P').css('color', '#333333');
                    $(this).parent().find('A.more').css('color', '#333333');
                }
            );
        }
        
    );  
    
    /*$("#sponsorship-list li H2 A").each(
        function() {
            //bind mouse over and out functions to links
            $( this ).bind (
                "mouseenter",
                function(){
                    alert("yes");
                    $(this).parent().parent().find('IMG').css('background-color', '#000000');
                    $(this).parent().parent().find('P').css('color', '#00929f');
                    $(this).parent().parent().find('A.more').css('color', '#00929f');
                }
            );
            $( this ).bind (
                "mouseleave",
                function(){
                    //alert("out");
                    $(this).parent().parent().find('IMG').css('background-color', '#ffffff');
                    $(this).parent().parent().find('P').css('color', '#333333');
                    $(this).parent().parent().find('A.more').css('color', '#333333');
                }
            );
        }
        
    );  */
}

//company sponsorship big panel 
function InitCompanyBig(){
    //**home sites list**//
    //set default values for list items
    $("ul.sponsorship-big li H3").each(
        function() {
            $(this).css('opacity', 0.7);
        }
    );
    
    $("ul.sponsorship-big li").each(
        function() {
            //bind mouse over and out functions to links
            $( this ).bind (
                "mouseenter",
                function(){
                    //alert("over");
                    $(this).find('H3').fadeTo("slow", 1);

                }
            );
            $( this ).bind (
                "mouseleave",
                function(){
                    //alert("out");
                    $(this).find('H3').fadeTo("slow", 0.6);
                }
            );
        }
        
    );
}


function InitPromotions(){
    $("#promotions-list li A").each(
        function() {
            //bind mouse over and out functions to links
            $( this ).bind (
                "mouseenter",
                function(){
                    $(this).parent().find('IMG').css('background-color', '#000000');
                    $(this).parent().find('P').css('color', '#00929f');
                    $(this).parent().find('A.more').css('color', '#00929f');
                }
            );
            $( this ).bind (
                "mouseleave",
                function(){
                    //alert("out");
                    $(this).parent().find('IMG').css('background-color', '#ffffff');
                    $(this).parent().find('P').css('color', '#333333');
                    $(this).parent().find('A.more').css('color', '#333333');
                }
            );
        }
        
    );  

}

/*function checkForm(){
	if (document.product.category.selectedIndex==0) {
		alert ("Please select a manual type");
		return false;
	}
	if (document.product.productType.selectedIndex==0) {
		alert ("Please select a product category");
		return false;
	}
}*/

function checkUserGuide(){
 if (!document.product.fileName.value && !document.product.productType.selectedIndex){
	alert ("Please enter a model number or select a product category from the dropdown menu.");
	return false
	}

}

function InitProductHome(){
    //carousel
    $(".product-home-move").jCarouselLite({
        visible: 1,
        auto: 4000,
		hoverPause: true,
        speed: 1400,
        easing: 'easeInOutCubic',
        btnNext: ".nextBtn",
        btnPrev: ".prevBtn"
        //btnGo: [".hpMove1", ".hpMove2", ".hpMove3"]
    });
    
    $('#product-home-list LI A').mouseenter(function(evt) {
         evt.preventDefault();
        $(this).parent().addClass("selected");
    });
    $('#product-home-list LI A').mouseleave(function(evt) {
         evt.preventDefault();
        $("#product-home-list LI").removeClass("selected");
    });
    
    $('#product-home-list LI H3 A').mouseenter(function(evt) {
         evt.preventDefault();
        $(this).parent().parent().parent().addClass("selected");
    });
    $('#product-home-list LI H3 A').mouseleave(function(evt) {
         evt.preventDefault();
        $("#product-home-list LI").removeClass("selected");
    });
	//$('#divInsidebox').hide();
}

/*function InitProductHome(){
    //carousel
    $(".product-home-move").jCarouselLite({
        visible: 1,
        auto: 4000,
        speed: 1400,
        easing: 'easeInOutCubic',
        btnGo: [".hpMove1", ".hpMove2", ".hpMove3"]
    });
}

function InitProductHome(){
    //carousel
    $(".product-home-move").jCarouselLite({
        visible: 1,
        auto: 4000,
        speed: 1400,
        easing: 'easeInOutCubic',
        btnGo: [".hpMove1", ".hpMove2", ".hpMove3"]
    });
	
	$('#product-home-list LI A').click(function(evt) {
         evt.preventDefault();
        $("#product-home-list LI").removeClass("selected");
        $(this).parent().addClass("selected");
    });
    
    $('#product-home-list LI H3 A').click(function(evt) {
         evt.preventDefault();
        $("#product-home-list LI").removeClass("selected");
        $(this).parent().parent().parent().addClass("selected");
    });

}*/




function goTo(obj) {
	if(obj.options[obj.selectedIndex].value != "")
	document.location = obj.options[obj.selectedIndex].value;
}


/* dont need these in here - they are inside sifr-nz.js file 

//sIFR image replacement methods
function InitHeadingReplacement(){
    sIFR.replace(aachen, {
      selector: 'H2.ctb',
      css: ['.sIFR-root { color: #000000; font-size: 22px; }'],
      wmode: 'transparent'
    });
    
    sIFR.replace(aachen, {
      selector: 'H1.ctb',
      css: ['.sIFR-root { color: #000000; font-size: 22px; }'],
      wmode: 'transparent'
    });
    
    sIFR.replace(aachen, {
      selector: 'h2.ctw',
      css: ['.sIFR-root { color: #ffffff; font-size: 22px; }'],
      wmode: 'transparent'
    });
    
    sIFR.replace(aachen, {
      selector: 'h1.ctw',
      css: ['.sIFR-root { color: #ffffff; font-size: 22px; }'],
      wmode: 'transparent'
    });
    
    sIFR.replace(aachen, {
      selector: 'h2.ctccb',
      css: ['.sIFR-root { color: #00adef; font-size: 22px; }'],
      wmode: 'transparent'
    });
    
    sIFR.replace(aachen, {
      selector: 'h2.ctbs',
      css: ['.sIFR-root { color: #000000; font-size: 18px; }'],
      wmode: 'transparent'
    });
    
    sIFR.replace(aachen, {
      selector: 'h2.ctb-nl',
      css: ['.sIFR-root { color: #000000; font-size: 22px;}'],
      wmode: 'transparent'
    });
    
    sIFR.replace(aachen, {
      selector: 'h2.ctbs-nl',
      css: ['.sIFR-root { color: #000000; font-size: 18px;}'],
      wmode: 'transparent'
    });
    
    sIFR.replace(aachen, {
      selector: 'h3.ctb',
      css: ['.sIFR-root { color: #000000; font-size: 18px;}'],
      wmode: 'transparent'
    });
    
    sIFR.replace(aachen, {
      selector: 'h1.ctb-xl',
      css: ['.sIFR-root { color: #000000; font-size: 55px;}'],
      wmode: 'transparent'
    });
}
*/
function InitProductList(){
    var count = 0;
	$("#frmProducts").clearForm();

    $( "input" ).click(
        function( objEvent ){
            if(this.checked == true ){
                //check that there are not already 6 items selected
                if(count != 5){
                    count = count + 1;
                    $(this).parent().find('LABEL').css('display', 'none');
                    $(this).parent().find('a.compare').css('display', 'block');
                }else{
					$.prompt('You cannot compare more than 5 items');                 
                    this.checked = false;
                }
            }else{
                count = count - 1;
                $(this).parent().find('LABEL').css('display', 'block');
                $(this).parent().find('a.compare').css('display', 'none');
            }
  
        }
    );

    $( "a.compare" ).click(
        function( objEvent ){
            if(count < 2){
               $.prompt('Please select at least 2 products to compare');
            }else{
               $('#frmProducts').submit();
            }
  
        }
    );
}

 $.fn.clearForm = function() {

        return this.each(function() {
  
          var type = this.type, tag = this.tagName.toLowerCase();

          if (tag == 'form')

            return $(':input',this).clearForm();
  
          if (type == 'text' || type == 'password' || tag == 'textarea')
  
            this.value = '';

          else if (type == 'checkbox' || type == 'radio')

            this.checked = false;

          else if (tag == 'select')

            this.selectedIndex = -1;
 
        });

      };

function OneLink(sHostname){ 
		document.location.href = document.location.protocol + "//" + sHostname + document.location.pathname + document.location.search;
		}
 
function initInsideStory(){

   
	$("#tvInsider").hide();
	 $("#shadow").css("height", $(document).height()).hide();
	 var listMv = $('#divInside .move ul li');

	$("#divInside .move ul li a").hover(
	  function () {
		$(this).parent().find('span.play').css("visibility", "visible");
	  }, 
	  function () {
		$(this).parent().find('span.play').css("visibility", "hidden");
	  }
	);	
	
		
	
	$("#divInside .move ul li a").click(function(event){
					var oCm=$(this);
					var nxMid=$("#divInside .move ul li a").index(oCm)+1;
					
					
					event.preventDefault();
					$("#tvInsider").center();
					
					 $("#shadow").toggle();
					 $("#shadow").css("width", $(document).width());
					$("#tvInsider").slideDown("slow");
					$("#tvInsider").append('<div id="tvPlayer"></div>');
					//alert(oCm.attr('href'));
					playInsideVideo(oCm.attr('href'));
					$('#tvInsider').append('<a href="##" class="closeInside">X</a>');
					$("a.closeInside").click(function(event){
					$("#tvInsider").slideUp("slow");
					$('#tvInsider').empty();
					$("#shadow").toggle();
					});		
					$('#tvInsider').append('<a class="nextInside"></a>');
					$("a.nextInside").click(function(event){
						nxMid++;
						if (nxMid >($("#divInside .move ul li a").length-1)) nxMid=0;
						playInsideVideo($("#divInside .move ul li a").eq(nxMid).attr("href"));
							
						});	
					$('#tvInsider').append('<a class="moreInside" href="/inside-stories/"></a>');
					
		});
			

		
	}
	
	function InitPlayer(vidPath){
		var oCm=$(this);
		var nxMid=$("#divInside .move ul li a").index(oCm)+1;
		
		
		//event.preventDefault();
		$("#tvInsider").center();
		
		 $("#shadow").toggle();
		 $("#shadow").css("width", $(document).width());
		$("#tvInsider").slideDown("slow");
		$("#tvInsider").append('<div id="tvPlayer"></div>');
		//alert(oCm.attr('href'));
		playInsideVideo(vidPath);
		$('#tvInsider').append('<a href="##" class="closeInside">X</a>');
		$("a.closeInside").click(function(){
		$("#tvInsider").slideUp("slow");
		$('#tvInsider').empty();
		$("#shadow").toggle();
		});		
		$('#tvInsider').append('<a class="nextInside"></a>');
		$("a.nextInside").click(function(){
			nxMid++;
			if (nxMid >($("#divInside .move ul li a").length-1)) nxMid=0;
			playInsideVideo($("#divInside .move ul li a").eq(nxMid).attr("href"));
			
			});	
		$('#tvInsider').append('<a class="moreInside" href="/inside-stories/"></a>');
	}
	
	function playInsideVideo(vd){
					//alert(vd);
					
					$('#tvPlayer').flash().remove();
					
					$('#tvPlayer').flash(
						{
						swf: '/common/flash/player.swf',
						params: {
							play: true
						},
						flashvars: {
							curMovie:vd
						},
							height: 402,
							width: 640,
							wmode: "transparent"
						}
					)
		}
		

jQuery.fn.center = function () { 
    this.css("position","absolute"); 
    this.css("top", ( $(window).height() - this.height() ) / 2+$(window).scrollTop() / 2 + "px");
    this.css("left", ( $(window).width() - this.width() ) / 2+$(window).scrollLeft() + "px"); 
    return this; 
} 

$("#divInsidebox").ready(function() {         
	initInsideStory();				
});    

function InitISWall(){
	$('#is-subnav LI A').click(function(evt) {
			//alert($(this).attr("href"));
			var pagePos = $(this).attr("href").toString();
			evt.preventDefault();
			if($.browser.opera){$('html').animate({scrollTop: $(pagePos).offset().top}, 2000);} else $('html,body').animate({scrollTop: $(pagePos).offset().top}, 2000);
	});
	ISThumbHover();
	
}

function ISThumbHover(){
	$(".is-list li A").hover(
	  function () {
		$(this).parent().find('span.play').css("visibility", "visible");
	  }, 
	  function () {
		$(this).parent().find('span.play').css("visibility", "hidden");
	  }
	);	
}
/*function hiPlay(ob) {
	ob.hover(
	  function () {
		$(this).parent().find('span.play').css("visibility", "visible");
	  }, 
	  function () {
		$(this).parent().find('span.play').css("visibility", "hidden");
	  }
	);	
	
	$('a.play').remove(); 
		//evt.stopPropagation();
  		ob.prepend('<a class="play" href="'+ob.attr("href")+'"></a>');
		
	

		
		$('a.play').mouseout(function(e) { 
			e.stopPropagation();
  			$(this).remove(); 
		});
}*/
jQuery.clean.convert = function(html) {
	var n = document.createElement('div');
	n.innerHTML = html;
	return n;
};

//MUSION EXPERIENCE

function InitMusion(){
	//$(".state").hide();
}

function setState(curMap){
	$(".state").hide();
	$("#" + curMap).show();
	//alert(curMap);	
}

function InitHVT(){
	$("#hvt-print .thumb IMG ,#hvt-tv .thumb IMG").css({ opacity: 0.7 });
						
	 $("#hvt-print .thumb, #hvt-tv .thumb").each(
		function() {
			//bind mouse over and out functions to links
			$( this ).bind (
				"mouseenter",
				function(){
					$(this).find('IMG').fadeTo("slow", 1);
				}
			);
			$( this ).bind (
				"mouseleave",
				function(){
					$(this).find('IMG').fadeTo("slow", 0.7);
				}
			);
		}
	);
	
	var setStatus = 1;
	$('A.btn').click(function(evt) {
		if(setStatus == 1){
			$(".set1").css("display", "none");
			$(".set2").css("display", "block");
			setStatus = 2;
			$("span.set").text("Set 2");
		}else{
			$(".set1").css("display", "block");
			$(".set2").css("display", "none");
			setStatus = 1;
			$("span.set").text("Set 1");
		}
		evt.preventDefault();
	});
}

/* LAUNDRY REFRESH */
function InitLaundry(){
	/*$(".laundry-move").jCarouselLite({
		visible: 1,
		auto: 5000,
		hoverPause: true,
		speed: 1400,
		easing: 'easeInOutCubic',
		btnNext: ".slide-next",
		btnPrev: ".slide-prev"
	});*/
	
	var featureItems = $('.laundry-features, .refrigeration-features, .dishwashing-features').children().length;
	var currentFeature = 1;

	$("#laundry-feature-move,#refrigeration-feature-move,#dishwashing-feature-move").jCarouselLite({
		visible: 1,
		//auto: 10000,
		hoverPause: true,
		speed: 1400,
		easing: 'easeInOutCubic',
		//btnNext: ".feature-next",
		//btnPrev: ".feature-prev",
		btnGo: [".go1", ".go2", ".go3", ".go4", ".go5", ".go6", ".go7", ".go8"],
		beforeStart: function(a) {
			if(currentFeature != featureItems){
				currentFeature = currentFeature + 1;	
			}else{
				currentFeature = 1;	
			}
			$('.laundry-features-nav li a, .refrigeration-features-nav li a, .dishwashing-features-nav li a').removeClass("selected");
			$('.laundry-features-nav li:nth-child(' + currentFeature + ') a, .refrigeration-features-nav li:nth-child(' + currentFeature + ') a, .dishwashing-features-nav li:nth-child(' + currentFeature + ') a').addClass("selected");
		}
	});	
	
	$('.laundry-features-nav li a, .refrigeration-features-nav li a, .dishwashing-features-nav li a').click(function(evt) {
		evt.preventDefault();
		currentFeature = parseInt($(this).attr("rel"));
		//alert(currentFeature);
		
		$('.laundry-features-nav li a, .refrigeration-features-nav li a, .dishwashing-features-nav li a').removeClass("selected");
		$(this).addClass("selected");
	});
	
	$('.laundry-header ul li a, .refrigeration-header ul li a, .dishwashing-header ul li a').click(function(evt) {
        evt.preventDefault();
		var current = $(this).attr("href");
		//alert(current);
    	 if($.browser.opera){$('html').animate({scrollTop: $(current).offset().top}, 2000);} else $('html,body').animate({scrollTop: $(current).offset().top}, 2000); 
      
    });
	
	$('#technology-description').click(function(evt) {
        evt.preventDefault();
		$("#sd-description").slideToggle();
		$("#as-description").slideToggle();
    });
	
	$('#energy-efficiency-link').click(function(evt) {
		
        evt.preventDefault();
		var current = $(this).attr("href");
		if($.browser.opera){$('html').animate({scrollTop: $(current).offset().top}, 2000);} else $('html,body').animate({scrollTop: $(current).offset().top}, 2000);
		$('#energy-compare').slideDown();
		$('#energy-compare-toggle').text('close');
		$('#energy-compare-toggle').removeClass("laundry-toggle-down");
		$('#energy-compare-toggle').addClass("laundry-toggle-up");	
    });
	
	//compare tables
	$('#energy-compare').hide();
	
	$('.laundry-toggle-down, .laundry-toggle-up').click(function(evt) {
        evt.preventDefault();
		var current = $(this).attr("rel");
		//alert($(this).text());
		if($(this).text() == 'open'){
			$(this).text('close');
			$(this).removeClass("laundry-toggle-down");
			$(this).addClass("laundry-toggle-up");
		}else{
			$(this).text('open');
			$(this).removeClass("laundry-toggle-up");
			$(this).addClass("laundry-toggle-down");
		}
    	$(current).slideToggle();
      
    });
	
	$('#thumblink').mouseenter(function(evt) {
        evt.preventDefault();
		$('#thumbimg').hide();
		$('#hoverimg').show();
		$('#french-door #thumblink').find('IMG').fadeTo("med", 0);
      
    });
	$('#thumblink').mouseleave(function(evt) {
        evt.preventDefault();
		$('#thumbimg').show();
		$('#hoverimg').hide();
		$('#french-door #thumblink').find('IMG').fadeTo("med", 1);
      
    });
	$('#hoverimg').hide();
}
