//** Tab Content script- © Dynamic Drive DHTML code library (http://www.dynamicdrive.com)
//** Last updated: June 29th, 06

var enabletabpersistence=1 //enable tab persistence via session only cookies, so selected tab is remembered?

////NO NEED TO EDIT BELOW////////////////////////
var tabcontentIDs=new Object()
function expandcontent(linkobj)
{
        var ulid=linkobj.parentNode.parentNode.id //id of UL element
        var ullist;
        if(document.getElementById(ulid))
        {
            var ullist=document.getElementById(ulid).getElementsByTagName("li") //get list of LIs corresponding to the tab contents
        
             for (var i=0; i<ullist.length; i++)
             {     
                ullist[i].className=""  //deselect all tabs
                if (typeof tabcontentIDs[ulid][i]!="undefined") //if tab content within this array index exists (exception: More tabs than there are tab contents)                                              
                document.getElementById(tabcontentIDs[ulid][i]).style.display="none"; //hide all tab contents      
             }  
            linkobj.parentNode.className="on";  //highlight currently clicked on tab 
            document.getElementById(linkobj.getAttribute("title")).style.display="block" //expand corresponding tab content
            
         }
}

function savetabcontentids(ulid, relattribute){// save ids of tab content divs
if (typeof tabcontentIDs[ulid]=="undefined") //if this array doesn't exist yet
tabcontentIDs[ulid]=new Array()
tabcontentIDs[ulid][tabcontentIDs[ulid].length]=relattribute

}


function getullistlinkbyId(ulid, tabcontentid){ //returns a tab link based on the ID of the associated tab content
var ullist=document.getElementById(ulid).getElementsByTagName("li")
for (var i=0; i<ullist.length; i++){
if (ullist[i].getElementsByTagName("a")[0].getAttribute("title")==tabcontentid){
return ullist[i].getElementsByTagName("a")[0]
break
}
}
}

function initializetabcontent(N, tab)
{
    var selTabId=0;
    //request cannot read past ampersand
    if(tab == "Network ") tab = "Network & Coverage";
    if(tab == "Specs ") tab = "Specs & Warranty";
 
    var ulobj=document.getElementById(N)
    if(ulobj) 
    {
        var ulist=ulobj.getElementsByTagName("li") //array containing the LI elements within UL   
        if( ulist.length < 1) return;
        for (var x=0; x<ulist.length; x++)
        { //loop through each LI element
            var ulistlink=ulist[x].getElementsByTagName("a")[0]
            if (null != ulistlink)
            {
                savetabcontentids(N, ulistlink.getAttribute("title")) //save id of each tab content as loop runs
            }
        }
        for (var x=0; x<ulist.length; x++)
        {
            //loop through each LI element
            var ulistlink=ulist[x].getElementsByTagName("a")[0]
            if (null != ulistlink)
            {
                var loadedTabName = ulistlink.getAttribute("title");
                if(loadedTabName == tab) selTabId = x;
            }
        } //end inner for loop
        if(ulist[selTabId])
        {
            if (null != ulist[selTabId].getElementsByTagName("a")[0])
            {
                if(ulist[selTabId]) expandcontent(ulist[selTabId].getElementsByTagName("a")[0])   
            }
        }
    }     
}
