﻿$(document).ready(function() {
    //Load the slideshow
    theRotator();
});


/* ------------ for Rotator Animation -----------------*/
function theRotator() {
    //Set the opacity of all divs to 0
    hideAll();
    // ini first div show
    firstDivShow();
    // timer                      
    setInterval('rotate()', 7600);
}

function firstDivShow() {
    $('div#Rotator').show();
    $('div#RotaLft').fadeIn(10, function() { $(this).delay(6100).fadeOut(1800); });
    $('div#RotaRgt').show();
    $('#ctl00_ctl00_cphContentOneCol_sub2ColContPlaceHolder1_lblRotateAuthor').show();
    $('#ctl00_ctl00_cphContentOneCol_sub2ColContPlaceHolder1_lblRotateTitle').show();
    $('div.RotaLftDesc').fadeIn(10, function() { $(this).delay(6100).fadeOut(1800); });
    $('div.RotaLftWatch').show();
}

function hideAll() {
    for (i = 1; i < 5; i++) {
        if (i == 1) {
            $('div#Rotator').hide();
            $('div#RotaLft').hide();
            $('div#RotaRgt').hide();
            // Rota1
            $('#ctl00_ctl00_cphContentOneCol_sub2ColContPlaceHolder1_lblRotateAuthor').hide();
            $('#ctl00_ctl00_cphContentOneCol_sub2ColContPlaceHolder1_lblRotateTitle').hide();
            $('div.RotaLftDesc').hide();
            $('div.RotaLftWatch').hide();
        }
        else {
            $('div#Rotator' + i).hide();
            $('div#RotaLft' + i).hide();
            $('div#RotaRgt' + i).hide();
            // Rota2,3,4
            $('#ctl00_ctl00_cphContentOneCol_sub2ColContPlaceHolder1_lblRotateAuthor' + i).hide();
            $('#ctl00_ctl00_cphContentOneCol_sub2ColContPlaceHolder1_lblRotateTitle' + i).hide();
            $('div.RotaLftDesc' + i).hide();
            $('div.RotaLftWatch' + i).hide();
        }
    }
}

function rotate() {
    var numb;
    for (i = 1; i < 5; i++) {
        if (i == 1) { numb = ''; } else { numb = i; }
        if ($('div#RotaRgt' + numb).is(":visible")) {
            $('div#Rotator' + numb).hide();
            $('div#RotaLft' + numb).hide();
            $('div#RotaRgt' + numb).hide();

            if (i == 4) { numb = ''; } else { numb = i + 1; }

            $('div#Rotator' + numb).show();
            $('div#RotaLft' + numb).fadeIn(1000, function() { $(this).delay(5100).fadeOut(1800); });
            $('div#RotaRgt' + numb).show();

            $('#ctl00_ctl00_cphContentOneCol_sub2ColContPlaceHolder1_lblRotateAuthor' + numb).show();
            //$('#ctl00_ctl00_cphContentOneCol_sub2ColContPlaceHolder1_lblRotateTitle').fadeIn(3000, function() {$(this).delay(1000).fadeOut(1000);});
            $('#ctl00_ctl00_cphContentOneCol_sub2ColContPlaceHolder1_lblRotateTitle' + numb).show();
            $('div.RotaLftDesc' + numb).fadeIn(1000, function() { $(this).delay(5100).fadeOut(1800); });
            //$('div.RotaLftWatch').fadeIn(3000, function() {$(this).delay(1000).fadeOut(1000);});
            $('div.RotaLftWatch' + numb).show();
            break;
        }
    }
}

/* ------------ for Rotator Animation -----------------*/


