﻿/* -------------------------------------------------------------------------------- */
/*  Powerco 2010 - In Page JS Code  								                */
/*  Ver          : 1.1                                                              */
/*  Created      : 23 November 2010                                                 */
/*  Last Updated : 28 July 2011                                                     */
/* -------------------------------------------------------------------------------- */

/*--------------------------*/		
/* Document Ready Functions */
/*--------------------------*/	

$(document).ready(function () {
	
	// Add JS idicator class
	if ($("body.home").length) {
		$("body").addClass("js");
	}
	
	
	// Font Size Options
	var $fontSizeOptCol = $("td.font-size"),
		$smallFontLink  = $fontSizeOptCol.find("a.small"),
		$mediumFontLink = $fontSizeOptCol.find("a.medium"),
		$largeFontLink  = $fontSizeOptCol.find("a.large"),
		$contentArea    = $("div.content");

	
    $('td.font-size a').click(function () {

        if ($(this).is('.small')) {
            $mediumFontLink.removeClass('selected');
            $largeFontLink.removeClass('selected');			
			$contentArea.removeClass('medium-font').removeClass('large-font').addClass('small-font');			                        
            $(this).addClass('selected');			
            $.cookie('font-size', 'small', { path: '/' });
        }
        else if ($(this).is('.medium')) {
            $smallFontLink.removeClass('selected');
            $largeFontLink.removeClass('selected');			
			$contentArea.removeClass('small-font').removeClass('large-font').addClass('medium-font');				
            $(this).addClass('selected');
            $.cookie('font-size', 'medium', { path: '/' });
        }
        else if ($(this).is('.large')) {
            $smallFontLink.removeClass('selected');
            $mediumFontLink.removeClass('selected');			
			$contentArea.removeClass('small-font').removeClass('medium-font').addClass('large-font');				
            $(this).addClass('selected');
            $.cookie('font-size', 'large', { path: '/' });
        }

        return false;
    });
	
    // Load the font size cookie
    switch ($.cookie('font-size')) {
        case 'large':
            $largeFontLink.trigger('click');
            break;
        case 'medium':
            $mediumFontLink.trigger('click');
            break;
        case 'small':
            $smallFontLink.trigger('click');
            break;
    }
	
    //bail if this is not the homepage!
    if (!$("body.home").length) { 		
		return false; 
	}

	// Bubble Tip Trigger - Home Page Top Nav
	
	$('#a1_1').bubbletip($('#holder1_1'), {
				deltaDirection: 'down',
				deltaPosition: 0,
				offsetTop: -10
				//,
				//delayShow: 0,
				//delayHide: 0,
				//animationDuration: 0
			});
			
	$('#a1_2').bubbletip($('#holder1_2'), {
				deltaDirection: 'down',
				deltaPosition: 0,
				offsetTop: -10
				//,
				//delayShow: 0,
				//delayHide: 0,
				//animationDuration: 0
			});
			
	$('#a1_3').bubbletip($('#holder1_3'), {
				deltaDirection: 'down',
				deltaPosition: 0,
				offsetTop: -10
				//,
				//delayShow: 0,
				//delayHide: 0,
				//animationDuration: 0
			});
			
	$('#a1_4').bubbletip($('#holder1_4'), {
				deltaDirection: 'down',
				deltaPosition: 0,
				offsetTop: -10
				//,
				//delayShow: 0,
				//delayHide: 0,
				//animationDuration: 0
			});
	
	
	$('#a1_5').bubbletip($('#holder1_5'), {
				deltaDirection: 'down',
				deltaPosition: 0,
				offsetTop: -10
				//,
				//delayShow: 0,
				//delayHide: 0,
				//animationDuration: 0
			});
	
	$('#a1_6').bubbletip($('#holder1_6'), {
				deltaDirection: 'down',
				deltaPosition: 0,
				offsetTop: -10
				//,
				//delayShow: 0,
				//delayHide: 0,
				//animationDuration: 0
			});
			
	$('#a1_7').bubbletip($('#holder1_7'), {
				deltaDirection: 'down',
				deltaPosition: 0,
				offsetTop: -10
				//,
				//delayShow: 0,
				//delayHide: 0,
				//animationDuration: 0
			});
	
	var $listItems = $(".home #main-navigation ul").children();
	
	$($listItems).each(function () 
	{
		var $hoveredLink = $(this).find("a");
		
		if ($hoveredLink.attr("id") == "a1_1")
		{												
			$hoveredLink.mouseover(function() 
			{
				$("table.bubbletip:eq(0)").css('display', 'block');
				$("table.bubbletip:eq(1)").css('display', 'none'); 
				$("table.bubbletip:eq(2)").css('display', 'none'); 
				$("table.bubbletip:eq(3)").css('display', 'none'); 
				$("table.bubbletip:eq(4)").css('display', 'none'); 
				$("table.bubbletip:eq(5)").css('display', 'none'); 
				$("table.bubbletip:eq(6)").css('display', 'none'); 
				$($listItems).removeClass("selected");
			});
		}
		
		if ($hoveredLink.attr("id") == "a1_2")
		{												
			$hoveredLink.mouseover(function() 
			{					
				$("table.bubbletip:eq(0)").css('display', 'none'); 
				$("table.bubbletip:eq(1)").css('display', 'block');
				$("table.bubbletip:eq(2)").css('display', 'none'); 
				$("table.bubbletip:eq(3)").css('display', 'none'); 
				$("table.bubbletip:eq(4)").css('display', 'none'); 
				$("table.bubbletip:eq(5)").css('display', 'none'); 
				$("table.bubbletip:eq(6)").css('display', 'none'); 
				$($listItems).removeClass("selected");
			});
		}
		
		if ($hoveredLink.attr("id") == "a1_3")
		{												
			$hoveredLink.mouseover(function() 
			{					
				$("table.bubbletip:eq(0)").css('display', 'none'); 
				$("table.bubbletip:eq(1)").css('display', 'none');
				$("table.bubbletip:eq(2)").css('display', 'block'); 
				$("table.bubbletip:eq(3)").css('display', 'none'); 
				$("table.bubbletip:eq(4)").css('display', 'none'); 
				$("table.bubbletip:eq(5)").css('display', 'none'); 
				$("table.bubbletip:eq(6)").css('display', 'none'); 
				$($listItems).removeClass("selected");
			});
		}
		
		if ($hoveredLink.attr("id") == "a1_4")
		{												
			$hoveredLink.mouseover(function() 
			{					
				$("table.bubbletip:eq(0)").css('display', 'none'); 
				$("table.bubbletip:eq(1)").css('display', 'none');
				$("table.bubbletip:eq(2)").css('display', 'none'); 
				$("table.bubbletip:eq(3)").css('display', 'block'); 
				$("table.bubbletip:eq(4)").css('display', 'none'); 
				$("table.bubbletip:eq(5)").css('display', 'none'); 
				$("table.bubbletip:eq(6)").css('display', 'none'); 
				$($listItems).removeClass("selected");
			});
		}
		
		if ($hoveredLink.attr("id") == "a1_5")
		{												
			$hoveredLink.mouseover(function() 
			{					
				$("table.bubbletip:eq(0)").css('display', 'none'); 
				$("table.bubbletip:eq(1)").css('display', 'none');
				$("table.bubbletip:eq(2)").css('display', 'none'); 
				$("table.bubbletip:eq(3)").css('display', 'none'); 
				$("table.bubbletip:eq(4)").css('display', 'block'); 
				$("table.bubbletip:eq(5)").css('display', 'none'); 
				$("table.bubbletip:eq(6)").css('display', 'none'); 
				$($listItems).removeClass("selected");
			});
		}
		
		if ($hoveredLink.attr("id") == "a1_6")
		{												
			$hoveredLink.mouseover(function() 
			{					
				$("table.bubbletip:eq(0)").css('display', 'none'); 
				$("table.bubbletip:eq(1)").css('display', 'none');
				$("table.bubbletip:eq(2)").css('display', 'none'); 
				$("table.bubbletip:eq(3)").css('display', 'none'); 
				$("table.bubbletip:eq(4)").css('display', 'none'); 
				$("table.bubbletip:eq(5)").css('display', 'block'); 
				$("table.bubbletip:eq(6)").css('display', 'none'); 
				$($listItems).removeClass("selected");
			});
		}
		
		if ($hoveredLink.attr("id") == "a1_7")
		{												
			$hoveredLink.mouseover(function() 
			{					
				$("table.bubbletip:eq(0)").css('display', 'none'); 
				$("table.bubbletip:eq(1)").css('display', 'none');
				$("table.bubbletip:eq(2)").css('display', 'none'); 
				$("table.bubbletip:eq(3)").css('display', 'none'); 
				$("table.bubbletip:eq(4)").css('display', 'none'); 
				$("table.bubbletip:eq(5)").css('display', 'none'); 
				$("table.bubbletip:eq(6)").css('display', 'block'); 
				$($listItems).removeClass("selected");
			});
		}		
	});		
});

/*-----------------------*/		
/* Window Load Functions */
/*-----------------------*/

$(window).load(function(){

	// Setup the width of slider navigation for centering purpose
	
	var $sliderNavContainer = $("#slider-nav-container");
	
	if ($("body.home").length) {
		
		switch ($("#slider-nav>a").size()) {				
        case 1:
            $sliderNavContainer.addClass("slider-nav-1");
            break;
        case 2:
            $sliderNavContainer.addClass("slider-nav-2");
            break;
        case 3:
            $sliderNavContainer.addClass("slider-nav-3");
            break;			
		case 4:
            $sliderNavContainer.addClass("slider-nav-4");
            break;					
		case 5:
            $sliderNavContainer.addClass("slider-nav-5");			
            break;
		}		
    }					    	
});
