﻿//used for hero rotator - SP 5/18/2011
function theRotator() {
	//Set the opacity of all images to 0
	$('div.rotator ul li').css({opacity: 0.0});
	
	//Get the first image and display it (gets set to full opacity)
	$('div.rotator ul li:first').css({opacity: 1.0});
		
	//Call the rotator function to run the slideshow, 6000 = change to next image after 6 seconds
	
	setInterval('rotate()',3000);
	
}

function rotate() {	
	//Get the first image
	var current = ($('div.rotator ul li.show')?  $('div.rotator ul li.show') : $('div.rotator ul li:first'));

    if ( current.length == 0 ) current = $('div.rotator ul li:first');

	//Get next image, when it reaches the end, rotate it back to the first image
	var next = ((current.next().length) ? ((current.next().hasClass('show')) ? $('div.rotator ul li:first') :current.next()) : $('div.rotator ul li:first'));
	
	//Un-comment the 3 lines below to get the images in random order
	
	//var sibs = current.siblings();
        //var rndNum = Math.floor(Math.random() * sibs.length );
        //var next = $( sibs[ rndNum ] );
			

	//Set the fade in effect for the next image, the show class has higher z-index
	next.css({opacity: 0.0})
	.addClass('show')
	.animate({opacity: 1.0}, 1000);

	//Hide the current image
	current.animate({opacity: 0.0}, 1000)
	.removeClass('show');
	
};

//end of hero rotator functions

//used for right rail expand/colapse charlie added for 2010 updates
$(document).ready(function() {
    $('.rightRailModule.rightRailBooking h4.rightRailExpand').toggleClass('expandSelected').next('div.expandListItemContent').slideToggle(500);
    $('.rightRailModule h4.rightRailExpand').click(function() {
        $(this).toggleClass('expandSelected');
        $(this).next('div.expandListItemContent').slideToggle(500);
    });
    $('.rightRailModule').css({
    // 'margin-bottom': '7px'
	});
	
	
	//Loads the hero rotator - SP 5/18/11
	theRotator();
	$('div.rotator').fadeIn(1000);
    $('div.rotator ul li').fadeIn(1000); // tweek for IE
	//end of hero rotator
	
	 //fancybox - SP 02/01/11
	  $('.videoBox').click(function() {
                $.fancybox({
                'padding'        : 0,
                'autoScale'        : false,
                'transitionIn'    : 'none',
                'transitionOut'    : 'none',
                'title'            : this.title,
                'width'        : 680,
                'height'        : 383,
                'href'            : this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
                'type'            : 'swf',
                'swf'            : {
                     'wmode'        : 'transparent',
                    'allowfullscreen'    : 'true'
                }
        });

    	return false;
		});
		
	//pagePopup displays the contents of a page as a fancybox popup
	//uses the href value from the <a> tag - SP 5/12/11
	$('a.pagePopup').click(function() { 
           $.fancybox({
                'width': 960,
                'height': 720,
                'enableEscapeButton' : false,
                'overlayShow' : true,
                'overlayOpacity' : 0,
                'hideOnOverlayClick' : false,
                'type': 'iframe',
                'href': $(this).attr("href")
            });
    return false;
	});
    //end of pagePopup
	

//International flags in header

$('#flagflash').mouseover(function() {
    $('#fws-intl li:not(:first)').show();
});

$('#flagflash').mouseout(function() {
    $('#fws-intl li:not(:first)').hide();
});
	
	
});
