﻿// Relies on JQuery
var prevTab = -1;
var isDark = false;
function initTabs(){                
    $(".tab-list a").each(function(i){
        if ($(this).attr('dynamic')!='false' || $(this).attr('dynamic')==null){        
            this.href = '#';                
            $(this).click(function(){
                showTab(this);
                return false;
            });        
        }
    });
    // shadows
    giveShadow($(".tab-views"));        
}
function showTab(el){    
    
    if (prevTab < 0){
        prevTab = parseInt($("#tab-multiview-prev").val());        
    } 
    
    document.getElementById("tab-view" + prevTab).className = 'hide';
    var liTags = el.parentNode.parentNode.getElementsByTagName("li");
    for (j=0;j<liTags.length;j++){        
        $(liTags[j]).removeClass("sel");
    }
    var i = $(el).attr('tabIndex');
    if (i==undefined){i = 0;}    
    $(el.parentNode).addClass("sel");
    //el.parentNode.className = "sel";
    document.getElementById("tab-view" + i).className = 'tab-view';    
    $("#tab-multiview-prev").val(i);
    
    el.blur();    
    prevTab = i;
}

//This function was created in order for links other than the tabs themselves to switch the tabs
function showTab2(el){    
    
    if (prevTab < 0){
        prevTab = parseInt($("#tab-multiview-prev").val());        
    } 
    
    document.getElementById("tab-view" + prevTab).className = 'hide';
    var liTags = el.parent().parent().children("li");
    for (j=0;j<liTags.length;j++){        
        $(liTags[j]).removeClass("sel");
    }
    var i = el.attr('tabIndex');
    if (i==undefined){i = 0;}    
    $(el.parent()).addClass("sel");
    
    document.getElementById("tab-view" + i).className = 'tab-view';    
    $("#tab-multiview-prev").val(i);
    
    el.blur();    
    $("#tab-view" + i + " .text").focus().val("Enter Search Text Here").select();
    prevTab = i;
}


$(document).ready (function(){
    initTabs();
});