﻿// (C) 2000 www.CodeLifter.com
// http://www.codelifter.com
// Free for all users, but leave in this  header

// =======================================
// set the following variables
// =======================================

// Set speed (milliseconds)
var defaultSlideSpeed = 7000;
var campaignSpeed = 11000;

// =======================================
// do not edit anything below this line
// =======================================

//enable click on 2nd image
//alert("isHomePageSlideImageClickable:" + isHomePageSlideImageClickable);
var isClick = true;

var t;
var j = 0;
var p = Pic.length;

var preLoad = new Array();

for (i = 0; i < p; i++) {

    preLoad[i] = new Image();
    preLoad[i].src = Pic[i];

    preLoad[i].id = "pic_" + i;

    //pageLanguage  - language of the page ,  defined in default.master
    //old- if (i == 1 && isClick == true && pageLanguage == "en") {

    if (i == 1 && isClick == true) {
        preLoad[i].click = "clickMe";
    }
}


function GoTo_ooVooVsSkypeLandPage() {
    //document.location.href="Valentine/SanValentine.htm";    
    document.location.href = "study/oovoopreference?utm_source=web&utm_medium=homepage&utm_campaign=skype&utm_content=HERO";
}

function runSlideShow() {

    var speed;
    //on fade out compleete - do callback function
    $("#SlideShow").fadeTo("slow", 0, function() {

        if (preLoad[j].click == "clickMe") {

            //$("#SlideShow").bind("click", GoTo_ooVooVsSkypeLandPage);
            //$("#SlideShow").css("cursor", "pointer");
            //$("#ooVooVsSkype").css("cursor", "pointer");

            //add click event to ooVoo vs Skype
            $("#ooVooVsSkype").bind("click", GoTo_ooVooVsSkypeLandPage);
            $("#SlideShow").bind("click", GoTo_ooVooVsSkypeLandPage);

            //add mouse cursor- hand to the slide
            $("#ooVooVsSkype").css("cursor", "pointer");
            $("#SlideShow").css("cursor", "pointer");

        }
        else {

            //$("#SlideShow").unbind("click", GoTo_ooVooVsSkypeLandPage);
            //$("#SlideShow").css("cursor", "");
            //$("#ooVooVsSkype").css("cursor", "");

            $("#ooVooVsSkype").unbind("click", GoTo_ooVooVsSkypeLandPage);
            $("#SlideShow").unbind("click", GoTo_ooVooVsSkypeLandPage);

            $("#ooVooVsSkype").css("cursor", "");
            $("#SlideShow").css("cursor", "");
        }

        //TEXT -ON IMAGES
        ShowTextOnImages(j);

        $("#SlideShow").attr("src", preLoad[j].src);
        $("#SlideShow").fadeTo("slow", 1);

        $("#ooVooVsSkype").fadeTo("slow", 1);

        $("#general_1").fadeTo("slow", 1);
        $("#general_2").fadeTo("slow", 1);

    });

    $("#ooVooVsSkype").fadeTo("slow", 0);

    $("#general_1").fadeTo("slow", 0);
    $("#general_2").fadeTo("slow", 0);

    ClearTextFrom_ooVooVsSkype();

    j = j + 1;

    if (j > (p - 1)) {
        j = 0;
    }

    //1- image is skype campaing , delay is set to 20 sec
    if (j == 1) {
        speed = campaignSpeed;
    }
    else {
        //otherwise delay set to default
        speed = defaultSlideSpeed;
    }

    t = setTimeout('runSlideShow()', speed);
}

function ClearTextFrom_ooVooVsSkype() {

    $("#line1").html("");
    $("#line2").html("");
    $("#line3").html("");
    $("#line4").html("");
    $("#line5").html("");

}

function DisplayNewsPopup() {
    //dinamicly show maintanance popup ,  
    //get the text for the message on homepage from web.config
    $('#divMoreNews').css('display', moreNewsDisplay);
    $('#divMaintenancePopup').css('display', popupDisplay);

    // $('#divMessage').html(maintMessage);

    //pach for maint' notification , when press learn more it go to forum
    var linkToForum = 'http://forum.oovoo.com/forums/p/2830/7725.aspx#7725';
    maintMessage = maintMessage + "&nbsp;<a href='" + linkToForum + "' target='_blank' style='font-style: italic; text-decoration: underline; cursor: pointer;white-space: nowrap'>Learn More</a>";
    $('#divMaintenancePopup').html(maintMessage);
}

//TEXT -ON IMAGES
function ShowTextOnImages(id) {

    var imageId = id;

    $("#general_1").html("");
    $("#general_2").html("");


    $("#line1").html("");
    $("#line2").html("");
    $("#line3").html("");
    $("#line4").html("");
    $("#line5").html("");

    try {
        //numOfValuesInContainer - from homepage.aspx , get number of items(key value) is the imageTextContainer
        if (ImagesTextJsonContainer.length != 'undefined' && numOfValuesInContainer >= 1) {

            switch (imageId) {

                case 0:

                    $("#general_1").html(ImagesTextJsonContainer[4][0]);

                    break;

                case 1:

                    $("#line1").html(ImagesTextJsonContainer[1][0]);
                    $("#line2").html(ImagesTextJsonContainer[1][1]);
                    $("#line3").html(ImagesTextJsonContainer[1][2]);
                    $("#line4").html(ImagesTextJsonContainer[1][3]);
                    $("#line5").html(ImagesTextJsonContainer[1][4]);

                    break;

                case 2:

                    $("#general_1").html(ImagesTextJsonContainer[2][0]);

                    break;

                case 3:

                    $("#general_1").html(ImagesTextJsonContainer[3][0]);
                    $("#general_2").html(ImagesTextJsonContainer[3][1]);

                    break;

                default:

                    break;
            }
        }
        else {

            //if the imageTextContainer empty    
            UseDefaultTextOnImagesWhenError(imageId);
        }
    }
    catch (e) {

        //if the imageTextContainer - crashed for some reason
        UseDefaultTextOnImagesWhenError(imageId);

    }

    function UseDefaultTextOnImagesWhenError(imageId) {

        //use default(english text)
        switch (imageId) {

            case 0:

                $("#general_1").html("LET THEM SEE WHO THEY'VE BEEN MISSING");

                break;

            case 1:

                $("#line1").html("Results are in!");
                $("#line2").html("8 out of 10 Skype users prefer ooVoo*");
                $("#line3").html("More Info &gt;&gt;");
                $("#line4").html("* Based on third party research conducted among Skype users.");
                $("#line5").html("Skype, associated trademarks and logos and the \"S\" symbol are trademarks of Skype Limited.");

                break;

            case 2:

                $("#general_1").html("BE THERE -- FROM ANYWHERE");

                break;

            case 3:

                $("#general_1").html("MASTER THE ART OF ENGAGEMENT");
                $("#general_2").html("FULL SCREEN MODE NOW AVAILABLE!");

                break;

            default:

                break;
        }
    }

}
