﻿//-------------------------------------------------------//
//------------------------ All --------------------------//


//:::::::: Preload Images :::::::://
var imgs = new Array(61);

imgs[0] = "images/compare/bck-header.jpg";
imgs[1] = "images/compare/bck-info.gif";
imgs[2] = "images/compare/menuClosed.gif";
imgs[3] = "images/compare/menuOpen.gif";
imgs[4] = "images/compare/tabOfficeClosed.gif";
imgs[5] = "images/compare/tabOfficeOpen.gif";
imgs[6] = "images/compare/tabWindowsClosed.gif";
imgs[7] = "images/compare/tabWindowsOpen.gif";

imgs[8] = "images/menu/btn-menu-buy-off.gif";
imgs[9] = "images/menu/btn-menu-buy-on.gif";
imgs[10] = "images/menu/btn-menu-buy-over.gif";
imgs[11] = "images/menu/btn-menu-learn-off.gif";
imgs[12] = "images/menu/btn-menu-learn-on.gif";
imgs[13] = "images/menu/btn-menu-learn-over.gif";
imgs[14] = "images/menu/btn-menu-middle-off.gif";
imgs[15] = "images/menu/btn-menu-middle-on.gif";
imgs[16] = "images/menu/btn-menu-middle-over.gif";

imgs[17] = "images/tabsImages/buy/BuyTab3-license1.jpg";
imgs[18] = "images/tabsImages/buy/BuyTab3-license2.jpg";
imgs[19] = "images/tabsImages/buy/BuyTab3-license3.jpg";
imgs[20] = "images/tabsImages/buy/BuyTab4.jpg";

imgs[21] = "images/tabsImages/learn/LearnTab2-menuOver1.jpg";
imgs[22] = "images/tabsImages/learn/LearnTab2-menuOver2.jpg";
imgs[23] = "images/tabsImages/learn/LearnTab3.jpg";
imgs[24] = "images/tabsImages/learn/LearnTab4.jpg";
imgs[25] = "images/tabsImages/learn/LearnTab5.jpg";

imgs[26] = "images/tabsImages/try/TryTab2.jpg";
imgs[27] = "images/tabsImages/try/TryTab3.jpg";

imgs[28] = "images/tabsImages/work/cpa1.jpg";
imgs[29] = "images/tabsImages/work/cpa2.jpg";
imgs[30] = "images/tabsImages/work/cpa3.jpg";
imgs[31] = "images/tabsImages/work/cpa4.jpg";

imgs[32] = "images/tabsImages/work/dentist1.jpg";
imgs[33] = "images/tabsImages/work/dentist2.jpg";
imgs[34] = "images/tabsImages/work/dentist3.jpg";
imgs[35] = "images/tabsImages/work/dentist4.jpg";

imgs[36] = "images/tabsImages/work/investigator1.jpg";
imgs[37] = "images/tabsImages/work/investigator2.jpg";
imgs[38] = "images/tabsImages/work/investigator3.jpg";
imgs[39] = "images/tabsImages/work/investigator4.jpg";

imgs[40] = "images/tabsImages/work/panel5.jpg";

imgs[41] = "images/tabsImages/work/trainer1.jpg";
imgs[42] = "images/tabsImages/work/trainer2.jpg";
imgs[43] = "images/tabsImages/work/trainer3.jpg";
imgs[44] = "images/tabsImages/work/trainer4.jpg";

imgs[45] = "images/tabsImages/top1.jpg";
imgs[46] = "images/tabsImages/top2.jpg";
imgs[47] = "images/tabsImages/top3.jpg";
imgs[48] = "images/tabsImages/top4.jpg";
imgs[49] = "images/tabsImages/top5.jpg";
imgs[50] = "images/tabsImages/top6.jpg";

imgs[51] = "images/tabsImages/btn-next.png";
imgs[52] = "images/tabsImages/btn-off.png";
imgs[53] = "images/tabsImages/btn-on.png";
imgs[54] = "images/tabsImages/btn-previous.png";

imgs[55] = "images/btn-tab-3-off.jpg";
imgs[56] = "images/btn-tab-3-on.jpg";
imgs[57] = "images/btn-tab-3-over.jpg";
imgs[58] = "images/btn-tab-5-off.jpg";
imgs[59] = "images/btn-tab-5-on.jpg";
imgs[60] = "images/btn-tab-5-over.jpg";
imgs[61] = "images/btn-tab-4-off.jpg";
imgs[62] = "images/btn-tab-4-on.jpg";
imgs[63] = "images/btn-tab-4-over.jpg";


function preload()
{
    var tmp = null;
    
    //Preload images
    for (var i=0;i<imgs.length;i++)
    {
        tmp = imgs[i];
        imgs[i] = new Image();
        imgs[i].src = tmp;
    }        
}

void(preload());


//:::::::: Push footer to the bottom of the screen (bottom of MNP) :::::::://
function pushFooter()
{
    $("footer").style.height = screen.height - 650;
}


//:::::::: Loads the "Top Reasons to Upgrade" for the Learn and Buy pages :::::::://
var nbTops = 6;
var topSelected;
var timerTops;

function showTop(btn)
{    
    //If Previuos
    if(btn==0)
    {
        if(topSelected==1)
        {
            showTop(nbTops);
        }
        else
        {
            showTop(topSelected-1);
        }
    }
    //If Next
    else if (btn==nbTops+1)
    {
        if(topSelected==nbTops)
        {
            showTop(1);
        }
        else
        {
            showTop(topSelected+1);
        }            
    }
    else
    {
        //All content - hide
        //All buttons - off
        for(i=1;i<=nbTops;i++)
        {  
            $("top" + i).hide();
            $("btnTop" + i).className = "btnOff";
        }
        //Show the selected one        
        $("backgroundTops").style.backgroundImage = "url(images/tabsImages/top" + btn + ".jpg)";
        $("btnTop" + btn).className = "btnOn";        
        $("top" + btn).show();           
        topSelected = btn;                                 
    }
}

function autoplayTops()
{        
    timerTops = setTimeout("autoplayTops()", 10000);  
    showTop(topSelected+1); //Always changes to next 
}

function stopPlayTops(btn)
{
    clearTimeout(timerTops);    
    showTop(btn);
} 


//-------------------------------------------------------//
//------------------------ Learn ------------------------//


//:::::::: Shows the content for the Success Stories Menu :::::::://
function showMenu(nbMenu)
{
    $("scrolling").scrollTop=0; 
    //Show the menu list
    if (nbMenu==0)
    {           
        $("menuList").show();
        $("menuContenu").hide();
    }
    //Show the content selected
    else
    {
        $("menuList").hide();
        $("menuContenu").show();        
        for(i=1;i<=6;i++)// 6 is the number of elements on the menu list
        {
            $("contenuMenu"+i).hide();
            $("contenuMenu"+nbMenu).show();
        }        
    }    
}


//:::::::: Print the content for the Success Stories Menu :::::::://
function print(nbMenu)
{
    var printContent = $("contenuMenuBody" + nbMenu);
    var uniqueName = new Date();
    var windowName = 'Print' + uniqueName.getTime();
    var printWindow = window.open('', windowName, "width=740,height=325,top=200,left=250,toolbars=no,scrollbars=yes,status=no,resizable=yes");
    printWindow.document.writeln(printContent.innerHTML);
    printWindow.document.close();
    printWindow.focus();
    printWindow.print();
    printWindow.close();
}


//:::::::: Shows the Compare charts for Windows and Office :::::::://
function Option_Click(nbOption)
{
    if(nbOption==1)
    {
        $("menuWindows").className = "menuBtnOnCompare";
        $("menuOffice").className = "menuBtnCompare";
        
        $("contentCompareOffice").hide();
        $("contentCompareWindows").show();
        $("bottomOffice").hide();
        $("bottomWindows").show();
    }
    else
    {
        $("menuWindows").className = "menuBtnCompare";
        $("menuOffice").className = "menuBtnOnCompare";
        
        $("contentCompareWindows").hide();
        $("contentCompareOffice").show();        
        $("bottomWindows").hide();
        $("bottomOffice").show();
    }
}


//:::::::: Show Windows Comparison :::::::://
function showComWin(nb)
{    
    if(nb==0)
    {
        for(i=1; i<=4; i++)
        {
            $("winComparison" + i).hide();            
            $("linkWin" + i).className = "linkWindowsClosed";
        }
    }
    else
    {
        if($("linkWin" + nb).className == "linkWindowsOpen")
        {
            $("winComparison" + nb).hide();
            $("linkWin" + nb).className = "linkWindowsClosed";
        }
        else
        {
            $("winComparison" + nb).show();        
            $("linkWin" + nb).className = "linkWindowsOpen";
        }
    }
}


//:::::::: Show Office Comparison :::::::://
function showComOff(nb)
{
    if(nb==0)
    {
        for(i=1; i<=4; i++)
        {
            $("offComparison" + i).hide();            
            $("linkOff" + i).className = "linkOfficeClosed";
        }
    }
    else
    {
        if($("linkOff" + nb).className == "linkOfficeOpen")
        {
            $("offComparison" + nb).hide();
            $("linkOff" + nb).className = "linkOfficeClosed";
        }
        else
        {
            $("offComparison" + nb).show();        
            $("linkOff" + nb).className = "linkOfficeOpen";
        }
    }
}


//-------------------------------------------------------//
//------------------------ Buy --------------------------//


//:::::::: Loads the Licenses for "Save When Purchasing 5 or More Copies" :::::::://
var nbLicenses = 2;
var licenseSelected;
var timerLicenses;

function showLicense(btn)
{      
    //If Previuos
    if(btn==0)
    {
        if(licenseSelected==1)
        {
            showLicense(nbLicenses);
        }
        else
        {
            showLicense(licenseSelected-1);
        }
    }
    //If Next
    else if (btn==nbLicenses+1)
    {
        if(licenseSelected==nbLicenses)
        {
            showLicense(1);
        }
        else
        {
            showLicense(licenseSelected+1);
        }            
    }
    else
    {
        //All content display = "none"
        //All buttons - off
        for(i=1;i<=nbLicenses;i++)
        {  
            $("license" + i).hide();
            $("btnLicense" + i).className = "btnOff";
        }
        //Show the selected one        
        $("backgroundLicenses").style.backgroundImage = "url(images/tabsImages/buy/BuyTab3-license" + btn + ".jpg)";
        $("btnLicense" + btn).className = "btnOn";        
        $("license" + btn).show();           
        licenseSelected = btn;                                 
    }
}

function autoplayLicenses()
{   
    timerLicenses = setTimeout("autoplayLicenses()", 10000);    
    showLicense(licenseSelected+1); //Always changes to next 
}

function stopPlayLicenses(btn)
{
    clearTimeout(timerLicenses);    
    showLicense(btn);
} 


//-------------------------------------------------------//
//------------------------ Work --------------------------//


//:::::::: Loads the Trainers for Katie :::::::://
var nbTrainers = 5;
var trainerSelected;
var timerTrainers;

function showTrainer(btn)
{      
    //If Previuos
    if(btn==0)
    {
        if(trainerSelected==1)
        {
            showTrainer(nbTrainers);
        }
        else
        {
            showTrainer(trainerSelected-1);
        }
    }
    //If Next
    else if (btn==nbTrainers+1)
    {
        if(trainerSelected==nbTrainers)
        {
            showTrainer(1);
        }
        else
        {
            showTrainer(trainerSelected+1);
        }            
    }
    else
    {
        //All content display = "none"
        //All buttons - off
        for(i=1;i<=nbTrainers;i++)
        {  
            $("trainer" + i).hide();
            $("btnTrainer" + i).className = "btnOff";
        }
        //Show the selected one        
        if(btn==5)
        {
            $("backgroundTrainers").style.backgroundImage = "url(images/tabsImages/work/panel5.jpg)";
        }
        else
        {
            $("backgroundTrainers").style.backgroundImage = "url(images/tabsImages/work/trainer" + btn + ".jpg)";
        }
        $("btnTrainer" + btn).className = "btnOn";        
        $("trainer" + btn).show();           
        trainerSelected = btn;                                 
    }
}

function autoplayTrainers()
{   
    timerTrainers = setTimeout("autoplayTrainers()", 10000);    
    showTrainer(trainerSelected+1); //Always changes to next 
}

function stopPlayTrainers(btn)
{
    clearTimeout(timerTrainers);    
    showTrainer(btn);
} 


//:::::::: Loads the Dentists for Carol :::::::://
var nbDentists = 5;
var dentistSelected;
var timerDentist;

function showDentist(btn)
{      
    //If Previuos
    if(btn==0)
    {
        if(dentistSelected==1)
        {
            showDentist(nbDentists);
        }
        else
        {
            showDentist(dentistSelected-1);
        }
    }
    //If Next
    else if (btn==nbDentists+1)
    {
        if(dentistSelected==nbDentists)
        {
            showDentist(1);
        }
        else
        {
            showDentist(dentistSelected+1);
        }            
    }
    else
    {
        //All content display = "none"
        //All buttons - off
        for(i=1;i<=nbDentists;i++)
        {  
            $("dentist" + i).hide();
            $("btnDentist" + i).className = "btnOff";
        }
        //Show the selected one        
        if(btn==5)
        {
            $("backgroundDentists").style.backgroundImage = "url(images/tabsImages/work/panel5.jpg)";
        }
        else
        {
            $("backgroundDentists").style.backgroundImage = "url(images/tabsImages/work/dentist" + btn + ".jpg)";
        }
        $("btnDentist" + btn).className = "btnOn";        
        $("dentist" + btn).show();           
        dentistSelected = btn;                                 
    }
}

function autoplayDentists()
{   
    timerDentist = setTimeout("autoplayDentists()", 10000);    
    showDentist(dentistSelected+1); //Always changes to next 
}

function stopPlayDentists(btn)
{
    clearTimeout(timerDentist);    
    showDentist(btn);
} 

//:::::::: Loads the Investigators for Max :::::::://
var nbInvestigators = 5;
var investigatorSelected;
var timerInvestigator;

function showInvestigator(btn)
{      
    //If Previuos
    if(btn==0)
    {
        if(investigatorSelected==1)
        {
            showInvestigator(nbInvestigators);
        }
        else
        {
            showInvestigator(investigatorSelected-1);
        }
    }
    //If Next
    else if (btn==nbInvestigators+1)
    {
        if(investigatorSelected==nbInvestigators)
        {
            showInvestigator(1);
        }
        else
        {
            showInvestigator(investigatorSelected+1);
        }            
    }
    else
    {
        //All content display = "none"
        //All buttons - off
        for(i=1;i<=nbInvestigators;i++)
        {  
            $("investigator" + i).hide();
            $("btnInvestigator" + i).className = "btnOff";
        }
        //Show the selected one        
        if(btn==5)
        {
            $("backgroundInvestigators").style.backgroundImage = "url(images/tabsImages/work/panel5.jpg)";
        }
        else
        {
            $("backgroundInvestigators").style.backgroundImage = "url(images/tabsImages/work/investigator" + btn + ".jpg)";
        }
        $("btnInvestigator" + btn).className = "btnOn";        
        $("investigator" + btn).show();           
        investigatorSelected = btn;                                 
    }
}

function autoplayInvestigators()
{   
    timerInvestigator = setTimeout("autoplayInvestigators()", 10000);    
    showInvestigator(investigatorSelected+1); //Always changes to next 
}

function stopPlayInvestigators(btn)
{
    clearTimeout(timerInvestigator);    
    showInvestigator(btn);
}


//:::::::: Loads the CPAs for Ted :::::::://
var nbCPAs = 5;
var cpaSelected;
var timerCPA;

function showCPA(btn)
{      
    //If Previuos
    if(btn==0)
    {
        if(cpaSelected==1)
        {
            showCPA(nbCPAs);
        }
        else
        {
            showCPA(cpaSelected-1);
        }
    }
    //If Next
    else if (btn==nbCPAs+1)
    {
        if(cpaSelected==nbCPAs)
        {
            showCPA(1);
        }
        else
        {
            showCPA(cpaSelected+1);
        }            
    }
    else
    {
        //All content display = "none"
        //All buttons - off
        for(i=1;i<=nbCPAs;i++)
        {  
            $("cpa" + i).hide();
            $("btnCPA" + i).className = "btnOff";
        }
        //Show the selected one        
        if(btn==5)
        {
            $("backgroundCPAs").style.backgroundImage = "url(images/tabsImages/work/panel5.jpg)";
        }
        else
        {
            $("backgroundCPAs").style.backgroundImage = "url(images/tabsImages/work/cpa" + btn + ".jpg)";
        }
        $("btnCPA" + btn).className = "btnOn";        
        $("cpa" + btn).show();           
        cpaSelected = btn;                                 
    }
}

function autoplayCPAs()
{   
    timerCPA = setTimeout("autoplayCPAs()", 10000);    
    showCPA(cpaSelected+1); //Always changes to next 
}

function stopPlayCPAs(btn)
{
    clearTimeout(timerCPA);    
    showCPA(btn);
} 


//-------------------------------------------------------//
//------------------------ All --------------------------//

var page;//To know which page we are at


//:::::::: Loads the correct selected menu button :::::::://
function loadMenuSelected()
{
    switch(page)
    {
        case "learn": $("menuLearn").className = "menuSelected";
        break;
        
        case "work": $("menuWork").className = "menuSelected";
        break;
        
        case "try": $("menuTry").className = "menuSelected";
        break;
        
        case "buy": $("menuBuy").className = "menuSelected";
        break;
    }
}


//:::::::: Click on Tabs (left) :::::::://
function Tab_Click(nbTab,nbTotal)
{
    //-------Update Tab Button style-------//
    //All Tabs style as unselected
    for(i=1; i<=nbTotal; i++)
    {        
        $("Tab"+i).className = "tabButton";
    }
    //Only the selected Tab style is selected    
    $("Tab" + nbTab).className = "tabSelected";
    
    //-------Update Div content-------//
    //All Divs don't show up
    for(i=1; i<=nbTotal; i++)
    {             
        $("tabContent" + i).hide();
    }            
    //Only the selected Panel shows up        
    $("tabContent" + nbTab).show(); 
    
    //If Learn page
    if(page=="learn")
    {
        $('linkSuccessStories').hide();
        
        switch(nbTab)
        {
            case 1:
                stopPlayTops(6); 
                autoplayTops();
            break;
            
            case 2:
                showMenu(0);
                $('linkSuccessStories').show();
            break;
        }
    }  
    //If buy page
    else if(page=="buy")
    {
        switch(nbTab)
        {
            case 3:
                stopPlayLicenses(2); 
                autoplayLicenses();
            break;
            
            case 5:
                stopPlayTops(6); 
                autoplayTops();
            break;
        }        
    }    
    //If work page
    else if(page=="work")
    {
        switch(nbTab)
        {
            case 2:
                stopPlayCPAs(5);
                autoplayCPAs();    
            break;
            
            case 3:
                stopPlayInvestigators(5);
                autoplayInvestigators();    
            break;
            
            case 4:
                stopPlayTrainers(5);
                autoplayTrainers();    
            break;
            
            case 5:
                stopPlayDentists(5);
                autoplayDentists();    
            break;         
        }        
    }  
}   

function loadTabs(nbTab,nbTotal)
{   
    if(nbTab>=1 && tab<=nbTotal)
    {
        Tab_Click(nbTab,nbTotal);    
    }
    else
    {
        Tab_Click(1,nbTotal);
    } 
}


function toggleOfferDetailsDesc() {
    if (document.getElementById("offerDetailsLink").style.display == "none" ) {
        document.getElementById("offerDetailsLink").style.display = "block"; 
        document.getElementById("offerDetailsDesc").style.display = "none";
    }
    else {
        document.getElementById("offerDetailsLink").style.display = "none"; 
        document.getElementById("offerDetailsDesc").style.display = "block";
    }
}
