//<![CDATA[
var tabLinks = new Array();
var contentDivs = new Array();

var tabLinks1 = new Array();
var contentDivs1 = new Array();

var tabLinks2 = new Array();
var contentDivs2 = new Array();


function init() {
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////	
//0
// Grab the tab links and content divs from the page
var tabListItems = document.getElementById('tabs').childNodes;
for ( var i = 0; i < tabListItems.length; i++ ) 
{
if ( tabListItems[i].nodeName == "LI" ) {
var tabLink = getFirstChildWithTagName( tabListItems[i], 'A' );
var id = getHash( tabLink.getAttribute('href') );
tabLinks[id] = tabLink;
contentDivs[id] = document.getElementById( id );
}
}

// Assign onclick events to the tab links, and
// highlight the first tab
var i = 0;
for ( var id in tabLinks ) {
tabLinks[id].onclick = showTab;
tabLinks[id].onfocus = function() { this.blur() };
if ( i == 0 ) tabLinks[id].className = 'selected';
i++;
}
// Hide all content divs except the first
var i = 0;
for ( var id in contentDivs ) {
if ( i != 0 ) contentDivs[id].className = 'tabContent hide';
i++;
}


////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//1
// Grab the tab links1 and content divs from the page
var tabListItems1 = document.getElementById('tabs1').childNodes;
for ( var x = 0; x < tabListItems1.length; x++ ) {
if ( tabListItems1[x].nodeName == "LI" ) {
var tabLink1 = getFirstChildWithTagName( tabListItems1[x], 'A' );
var id1 = getHash( tabLink1.getAttribute('href') );
tabLinks1[id1] = tabLink1;
contentDivs1[id1] = document.getElementById( id1 );
}
}


// Assign onclick events to the tab links, and
// highlight the first tab
var i = 0;
for ( var id1 in tabLinks1 ) {
tabLinks1[id1].onclick = showTab1;
tabLinks1[id1].onfocus = function() { this.blur() };
if ( i == 0 ) tabLinks1[id1].className = 'selected1';
i++;
}
// Hide all content divs except the first
var i = 0;
for ( var id1 in contentDivs1 ) {
if ( i != 0 ) contentDivs1[id1].className = 'tabContent1 hide1';
i++;
}



////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//2
// Grab the tab links1 and content divs from the page
var tabListItems2 = document.getElementById('tabs2').childNodes;
for ( var y = 0; y < tabListItems2.length; y++ ) {
if ( tabListItems2[y].nodeName == "LI" ) {
var tabLink2 = getFirstChildWithTagName( tabListItems2[y], 'A' );
var id2 = getHash( tabLink2.getAttribute('href') );
tabLinks2[id2] = tabLink2;
contentDivs2[id2] = document.getElementById( id2 );
}
}
// Assign onclick events to the tab links, and
// highlight the first tab
var i = 0;
for ( var id2 in tabLinks2 ) {
tabLinks2[id2].onclick = showTab2;
tabLinks2[id2].onfocus = function() { this.blur() };
if ( i == 0 ) tabLinks2[id2].className = 'selected2';
i++;
}
// Hide all content divs except the first
var i = 0;
for ( var id2 in contentDivs2 ) {
if ( i != 0 ) contentDivs2[id2].className = 'tabContent2 hide2';
i++;
}
}





//facebookt, twitter and news//

function showTab() {
var selectedId = getHash( this.getAttribute('href') );
// Highlight the selected tab, and dim all others.
// Also show the selected content div, and hide all others.
for ( var id in contentDivs ) {
if ( id == selectedId ) {
tabLinks[id].className = 'selected';

contentDivs[id].className = 'tabContent';
} else {
tabLinks[id].className = '';
contentDivs[id].className = 'tabContent hide';
}
}
// Stop the browser following the link
return false;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

//be a voice & volunteer//


function showTab1() {
var selectedId1 = getHash( this.getAttribute('href') );
// Highlight the selected tab, and dim all others.
// Also show the selected content div, and hide all others.
for ( var id1 in contentDivs1 ) {
if ( id1 == selectedId1 ) {
tabLinks1[id1].className = 'selected1';
contentDivs1[id1].className = 'tabContent1';
} else {
tabLinks1[id1].className = '';
contentDivs1[id1].className = 'tabContent1 hide1';
}
}
// Stop the browser following the link
return false;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

//partners & supporters//

function showTab2() {
var selectedId2 = getHash( this.getAttribute('href') );
// Highlight the selected tab, and dim all others.
// Also show the selected content div, and hide all others.
for ( var id2 in contentDivs2 ) {
if ( id2 == selectedId2 ) {
tabLinks2[id2].className = 'selected2';
contentDivs2[id2].className = 'tabContent2';
} else {
tabLinks2[id2].className = '';
contentDivs2[id2].className = 'tabContent2 hide2';
}
}
// Stop the browser following the link
return false;
}


////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function getFirstChildWithTagName( element, tagName ) {
for ( var i = 0; i < element.childNodes.length; i++ ) {
if ( element.childNodes[i].nodeName == tagName ) return element.childNodes[i];
}
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function getHash( url ) {
var hashPos = url.lastIndexOf ( '#' );
return url.substring( hashPos + 1 );
}
//]]>
