


/***********************************************
* Tab Content script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

//Set tab to intially be selected when page loads:
//[which tab (1=first tab), ID of tab content to display]:
// Function reVal checks for any url parameters passed and sets the variable sc to that value
function retVal(sName)
{
  /*
   get last loc. of ?
   right: find first loc. of sName
   +2
   retrieve value before next &
  */

  var sURL = new String(window.location);
  var iQMark= sURL.lastIndexOf('?');
  var iLensName=sName.length;

  //retrieve loc. of sName
  var iStart = sURL.indexOf('?' + sName +'=') //limitation 1
  if (iStart==-1)
        {//not found at start
        iStart = sURL.indexOf('&' + sName +'=')//limitation 1
		if (iStart==-1)
		   {//not found at end
		    return 0; //not found
		   }
        }

  iStart = iStart + + iLensName + 2;
  var iTemp= sURL.indexOf('&',iStart); //next pair start
  if (iTemp ==-1)
		{//EOF
		iTemp=sURL.length;
		}
  return sURL.slice(iStart,iTemp ) ;
  sURL=null;//destroy String
}


//alert( retVal('new'));
//checking if any URL param were passed or not
var sc=( retVal('new'));
if (sc == "") {
var initialtab=[1, "sc1"];
}
else {
  var initialtab=[1, sc];
}


function cascadedstyle(el, cssproperty, csspropertyNS){
if (el.currentStyle)
return el.currentStyle[cssproperty]
else if (window.getComputedStyle){
var elstyle=window.getComputedStyle(el, "")
return elstyle.getPropertyValue(csspropertyNS)
}
}

var previoustab=""

////////Needs to be editted if more than six tabs are used////////////////
// add more if statements to check for sc values passed


function expandcontent(cid, aobject, isLink){

if (isLink != "") {
	sc = cid;
}

if (sc == "sc1"  || isLink == 1)
{
	var myTab
	myTab = document.getElementById('A')
	if (document.getElementById){
	highlighttab(myTab)
	detectSourceindex(myTab)
	if (previoustab!="")
	document.getElementById(previoustab).style.display="none"
	document.getElementById(cid).style.display="block"
	previoustab=cid
	if (myTab.blur)
	myTab.blur()
	return false
	}
	else{
	return true
	}
}

else if (sc == "sc2"  || isLink == 2)
{

	var myTab
	myTab = document.getElementById('B')
	if (document.getElementById){
	highlighttab(myTab)
	detectSourceindex(myTab)
	if (previoustab !="")
	document.getElementById(previoustab).style.display="none"
	document.getElementById(cid).style.display="block"
	previoustab=cid
	if (myTab.blur)
	myTab.blur()
	return false
	}
	else{
	return true
	}
}
else if (sc == "sc3"  || isLink == 3)
{
	var myTab
	myTab = document.getElementById('C')
	if (document.getElementById){
	highlighttab(myTab)
	detectSourceindex(myTab)
	if (previoustab !="")
	document.getElementById(previoustab).style.display="none"
	document.getElementById(cid).style.display="block"
	previoustab=cid
	if (myTab.blur)
	myTab.blur()
	return false
	}
	else{
	return true
	}
}
else if (sc == "sc4" || isLink == 4)
{
	var myTab
	myTab = document.getElementById('D')
	if (document.getElementById){
	highlighttab(myTab)
	detectSourceindex(myTab)
	if (previoustab !="")
	document.getElementById(previoustab).style.display="none"
	document.getElementById(cid).style.display="block"
	previoustab=cid
	if (myTab.blur)
	myTab.blur()
	return false
	}
	else{
	return true
	}
}
else if (sc == "sc5" || isLink == 5)
{
	var myTab
	myTab = document.getElementById('E')
	if (document.getElementById){
	highlighttab(myTab)
	detectSourceindex(myTab)
	if (previoustab !="")
	document.getElementById(previoustab).style.display="none"
	document.getElementById(cid).style.display="block"
	previoustab=cid
	if (myTab.blur)
	myTab.blur()
	return false
	}
	else{
	return true
	}
}
else if (sc == "sc6" || isLink == 6)
{
	var myTab
	myTab = document.getElementById('F')
	if (document.getElementById){
	highlighttab(myTab)
	detectSourceindex(myTab)
	if (previoustab !="")
	document.getElementById(previoustab).style.display="none"
	document.getElementById(cid).style.display="block"
	previoustab=cid
	if (myTab.blur)
	myTab.blur()
	return false
	}
	else{
	return true
	}
}
else if (sc == "sc7" || isLink == 7)
{
	var myTab
	myTab = document.getElementById('G')
	if (document.getElementById){
	highlighttab(myTab)
	detectSourceindex(myTab)
	if (previoustab !="")
	document.getElementById(previoustab).style.display="none"
	document.getElementById(cid).style.display="block"
	previoustab=cid
	if (myTab.blur)
	myTab.blur()
	return false
	}
	else{
	return true
	}
}
//the if statement bellow is executed if no Url params were passed
else if (sc == "sc8" || isLink == 8)
{
	var myTab
	myTab = document.getElementById('H')
	if (document.getElementById){
	highlighttab(myTab)
	detectSourceindex(myTab)
	if (previoustab !="")
	document.getElementById(previoustab).style.display="none"
	document.getElementById(cid).style.display="block"
	previoustab=cid
	if (myTab.blur)
	myTab.blur()
	return false
	}
	else{
	return true
	}
}
//the if statement bellow is executed if no Url params were passed

else if (sc == "")
{

if (document.getElementById){
highlighttab(aobject)
detectSourceindex(aobject)
if (previoustab !="")
document.getElementById(previoustab).style.display="none"
document.getElementById(cid).style.display="block"
previoustab=cid
if (aobject.blur)
aobject.blur()
return false
}
else
return true
}

}


function highlighttab(aobject){
if (typeof tabobjlinks == "undefined")
collecttablinks()
for (i=0; i<tabobjlinks.length; i++)
tabobjlinks[i].className=""
aobject.className="current"
}

//*function highlighttab(aobject){
//if (typeof tabobjlinks=="undefined")
//collecttablinks()
//for (i=0; i<tabobjlinks.length; i++)
//tabobjlinks[i].style.backgroundColor=initTabcolor
//var themecolor=aobject.getAttribute("theme")? aobject.getAttribute("theme") : initTabpostcolor
//aobject.style.backgroundColor=document.getElementById("tabcontentcontainer").style.backgroundColor=themecolor
//}

function collecttablinks(){
var tabobj=document.getElementById("tablist")
tabobjlinks=tabobj.getElementsByTagName("A")
}

function detectSourceindex(aobject){
for (i=0; i<tabobjlinks.length; i++){
if (aobject==tabobjlinks[i]){
tabsourceindex=i //source index of tab bar relative to other tabs
break
}
}
}

function do_onload(){
var cookiename=(persisttype=="sitewide")? "tabcontent" : window.location.pathname
var cookiecheck=window.get_cookie && get_cookie(cookiename).indexOf("|")!=-1
collecttablinks()
initTabcolor=cascadedstyle(tabobjlinks[1], "backgroundColor", "background-color")
initTabpostcolor=cascadedstyle(tabobjlinks[0], "backgroundColor", "background-color")
if (typeof enablepersistence!="undefined" && enablepersistence && cookiecheck){
var cookieparse=get_cookie(cookiename).split("|")
var whichtab=cookieparse[0]
var tabcontentid=cookieparse[1]
expandcontent(tabcontentid, tabobjlinks[whichtab])
}
else
expandcontent(initialtab[1], tabobjlinks[initialtab[0]-1])
}

if (window.addEventListener)
window.addEventListener("load", do_onload, false)
else if (window.attachEvent)
window.attachEvent("onload", do_onload)
else if (document.getElementById)
window.onload=do_onload




//Dynamicdrive.com persistence feature add-on http://www.dynamicdrive.com/dynamicindex17/tabcontent.htm

if
(sc == "")
{
	var enablepersistence=true //true to enable persistence, false to turn off (or simply remove this entire script block).
}
else
{
	var enablepersistence=false //true to enable persistence, false to turn off (or simply remove this entire script block).
}
var persisttype="local" //enter "sitewide" for Tab content order to persist across site, "local" for this page only

function get_cookie(Name) {
var search = Name + "="
var returnvalue = "";
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search)
if (offset != -1) {
offset += search.length
end = document.cookie.indexOf(";", offset);
if (end == -1) end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(offset, end))
}
}
return returnvalue;
}

function savetabstate(){
var cookiename=(persisttype=="sitewide")? "tabcontent" : window.location.pathname
var cookievalue=(persisttype=="sitewide")? tabsourceindex+"|"+previoustab+";path=/" : tabsourceindex+"|"+previoustab
document.cookie=cookiename+"="+cookievalue
}

window.onunload=savetabstate


