﻿var prevTab;
var prevBox;

window.onload = function(){
    attachFlashMovie();
    attachFlashVideo();
    
    //tracking
    var productVar = document.getElementById('products');

    if(productVar.className == "productsOn"){
        pageTrack('/whySlimFast/products');
    }
}

function clickTab(tab){
    var obj = document.getElementById(tab);
    var oldclass = obj.className.toString();
    
    if(!obj.className.toString().match('On')){  
        obj.className = oldclass + "On";
        
        var lastTabClass;
        var index;
        
        if(!prevTab){  
            prevTab = document.getElementById("products");
            prevBox = document.getElementById("productsBox");
        }
        
        /* hide previous content box */
        prevBox.style.display = "none";
        
        prevTabClass = prevTab.className.toString();
        index = prevTabClass.lastIndexOf('On');
        prevTab.className = prevTabClass.substr(0, index);
        prevTab = obj;
        
         /* display current content box */
        prevBox = document.getElementById(oldclass + "Box");
        prevBox.style.display = "block";
    }

    if(tab=="products"){
        pageTrack('/whySlimFast/products');
    }else if(tab=="tools"){
        pageTrack('/whySlimFast/tools');
    }else if(tab=="buddies"){
        pageTrack('/whySlimFast/buddies');
    }else if(tab=="dietitians"){
        pageTrack('/whySlimFast/dietitians');
    }
}

function attachFlashMovie(){
    var so = new SWFObject("images/promo/Main_728.swf", "mymovie", "602", "110", "8", "null");
	so.addParam("wmode", "transparent");
    so.write("flashcontent");
}

function attachFlashVideo(){
    var so = new SWFObject("images/promo/fitnessvideo/lib/fPlayer/fPlayerIn.swf", "mymovie2", "193", "110", "8", "null"); 
    so.addParam("base", "images/promo/fitnessvideo/lib/fPlayer/");
    so.write("fitnessFlashVideo"); 
}

function hideDropdowns(){
	
    var ddl1 = $get('event1');
    var ddl2 = $get('height_ft');
    var ddl3 = $get('height_in');

    ddl1.style.visibility="hidden";
    ddl2.style.visibility="hidden";
    ddl3.style.visibility="hidden";
}


function showDropdowns(){

    var ddl1 = $get('event1');
    var ddl2 = $get('height_ft');
    var ddl3 = $get('height_in');

    ddl1.style.visibility="visible";
    ddl2.style.visibility="visible";
    ddl3.style.visibility="visible";

}