﻿var rotator;
window.onload = GetRandomDest;
function PauseRotator()
{
    if(!rotator)
    {
        rotator = $find("featuredAnimation").get_OnLoadBehavior().get_animation();
    }
    rotator.pause();
}

function PlayRotator()
{
    if(rotator)
    {
        rotator = $find("featuredAnimation").get_OnLoadBehavior().get_animation();
    }
    rotator.play();
}

function SetBubbles(curBubble)
{
    bubbleNames = new Array();
    bubbleNames[0] = 'ctl00_phBanner_FeaturedDestinations_Rating1';
    bubbleNames[1] = 'ctl00_phBanner_FeaturedDestinations_Rating2';
    bubbleNames[2] = 'ctl00_phBanner_FeaturedDestinations_Rating3';
    bubbleNames[3] = 'ctl00_phBanner_FeaturedDestinations_Rating4';

   for (bub in bubbleNames)
   {    
       if(bubbleNames[bub].match(curBubble) != null)
       {
            document.getElementById(bubbleNames[bub]).className = 'on';
       }
       else
       {
            document.getElementById(bubbleNames[bub]).className = 'off';
       }
   }
}

function updateBubble(num)
{
     bubbleNames = new Array();
    bubbleNames[0] = 'ctl00_phBanner_FeaturedDestinations_Rating1';
    bubbleNames[1] = 'ctl00_phBanner_FeaturedDestinations_Rating2';
    bubbleNames[2] = 'ctl00_phBanner_FeaturedDestinations_Rating3';
    bubbleNames[3] = 'ctl00_phBanner_FeaturedDestinations_Rating4';

   for (bub in bubbleNames)
   {    
       if(bub == num)
       {
            document.getElementById(bubbleNames[bub]).className = 'on';
       }
       else
       {
            document.getElementById(bubbleNames[bub]).className = 'off';
       }
   }
}

function GetRandomDest()
{
    ChangeDest(GetRandomNum());
}

function GetRandomNum()
{
    return Math.floor((8-4)*Math.random());

}

function ChangeDest(num)
{
    bubbleNames = new Array();
    bubbleNames[0] = 'ctl00_phBanner_FeaturedDestinations_FeaturedDestination1';
    bubbleNames[1] = 'ctl00_phBanner_FeaturedDestinations_FeaturedDestination2';
    bubbleNames[2] = 'ctl00_phBanner_FeaturedDestinations_FeaturedDestination3';
    bubbleNames[3] = 'ctl00_phBanner_FeaturedDestinations_FeaturedDestination4';

   for (bub in bubbleNames)
   {    
       if(bub == num)
       {
            document.getElementById(bubbleNames[bub]).style.display = 'block';
       }
       else
       {
            document.getElementById(bubbleNames[bub]).style.display = 'none';
       }
   }
   updateBubble(num);
}