

// Timer Code
var timerID = 0;
var timerTimeout = 0;
var timerInterruptTimeout = 0;
var tabArray = new Array('tab2', 'tab3', 'tab4', 'tab5', 'tab6');
var tabArrayIndex = 0;

function UpdateTimer()
{
	var i;
	
   if(timerID)
      clearTimeout(timerID);

	expandcontent(tabArray[tabArrayIndex], document.getElementById(tabArray[tabArrayIndex] + '_label'));
	
	if (++tabArrayIndex == tabArray.length)
		tabArrayIndex = 0;
                                      
   timerID = setTimeout("UpdateTimer()", timerTimeout);
}

function OnTab(tabObj)
{
	var tabname = tabObj.id.substr(0, tabObj.id.indexOf('_'));
	
	// see if there is a flash movie for this tab
	if (document.getElementById('flash_'+tabname))
		switchFlash('flash_'+tabname);
	
	// update the index accordingly
	for (i in tabArray)
	{
		if (tabArray[i] == tabname)
			tabArrayIndex = i;
	}
	
	expandcontent(tabname, tabObj);
   	//TimerStop();
   	//TimerStart(timerTimeout, timerInterruptTimeout, true)
   	
   	return;
}

function TimerStart(timeout, interruptTimeout, isInterrupted)
{
	timerTimeout = timeout;
	timerInterruptTimeout = interruptTimeout;
	
	
	timerID = setTimeout("UpdateTimer()", ( isInterrupted ? timerInterruptTimeout : timerTimeout ));
}


function TimerStop()
{
   if(timerID) {
      clearTimeout(timerID);
      timerID  = 0;
   }
}


function bookmarksite(title, url){
	if (document.all)
		window.external.AddFavorite(url, title);
	else if (window.sidebar)
		window.sidebar.addPanel(title, url, "")
}

function custom_print() {
    if (document.all) {
        if (navigator.appVersion.indexOf("5.0") == -1) {
            var OLECMDID_PRINT = 6;
            var OLECMDEXECOPT_DONTPROMPTUSER = 2;
            var OLECMDEXECOPT_PROMPTUSER = 1;
            var WebBrowser = "<OBJECT ID=\"WebBrowser1\" WIDTH=0 HEIGHT=0 CLASSID=\"CLSID:8856F961-340A-11D0-A96B-00C04FD705A2\"></OBJECT>";
            document.body.insertAdjacentHTML("beforeEnd", WebBrowser);
            WebBrowser1.ExecWB(6, 2);
            WebBrowser1.outerHTML = "";
        } else {
            self.print();
        }
    } else {
        self.print();
    }
}

/***********************************************
* 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]:
var initialtab=[1, "tab2"]

////////Stop editting////////////////

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 = "";

function expandcontent_fadeout(id, aobject_id)
{
	opacity(previoustab, 100, 0, 300);
	
	setTimeout('expandcontent_fadein("'+id+'", "'+aobject_id+'")', 400);

	return;
}

function expandcontent_fadein(id, aobject_id)
{
	var aobject = document.getElementById(aobject_id);
	
	if (previoustab != "")
		document.getElementById(previoustab).style.display="none";
	
	highlighttab(aobject)
	detectSourceindex(aobject)
	
	opacity(id, 0, 100, 500);
	document.getElementById(id).style.display="block";
	previoustab = id;

	if (aobject.blur)
		aobject.blur();

	return;
}

function expandcontent(cid, aobject)
{
	if (!(document.getElementById))
		return true;
	
	if (previoustab != "")
	{
		expandcontent_fadeout(cid, aobject.id);
		return false;
	}
		
	expandcontent_fadein(cid, aobject.id)
	
	return false;
}


function highlighttab(aobject)
{
	var tabname = aobject.id.substr(0, aobject.id.indexOf('_'));

	if (typeof tabobjlinks == "undefined")
		collecttablinks();

	for (i=0; i<tabobjlinks.length; i++) {
		tabobjlinks[i].style.color = 'white';
		tabobjlinks[i].style.backgroundImage = 'url(../../images/home/tab_bg.gif)';
	}
		
		aobject.style.color = '#85761A';
		aobject.style.backgroundImage = 'url(../../images/home/tab_bg_selected.gif)';

	return;
}

function opacity(id, opacStart, opacEnd, millisec) { 
    //speed for each frame 
    var speed = Math.round(millisec / 100); 
    var timer = 0; 

    changeOpac(opacStart, id);
    
    //determine the direction for the blending, if start and end are the same nothing happens 
    if(opacStart > opacEnd) { 
        for(i = opacStart; i >= opacEnd; i--) { 
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
            timer++; 
        } 
    } else if(opacStart < opacEnd) { 
        for(i = opacStart; i <= opacEnd; i++) 
            { 
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
            timer++; 
        } 
    } 
} 

//change the opacity for different browsers 
function changeOpac(opacity, id)
{ 
    var object = document.getElementById(id).style; 
    object.opacity = (opacity / 100); 
    object.MozOpacity = (opacity / 100); 
    object.KhtmlOpacity = (opacity / 100); 
    object.filter = "alpha(opacity=" + opacity + ")"; 
} 


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=(typeof persisttype!="undefined" && 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];
	var flashid=cookieparse[2];
	expandcontent(tabcontentid, tabobjlinks[whichtab]);
	
	switchFlash(flashid);
	
	}
	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;


var enablepersistence=true //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 exdate=new Date();
exdate.setDate(exdate.getDate()+ 30);
var cookiename=(persisttype=="sitewide")? "tabcontent" : window.location.pathname;
var cookievalue=(persisttype=="sitewide")? tabsourceindex+"|"+previoustab+"|"+cur_flash_id+";path=/" : tabsourceindex+"|"+previoustab+"|"+cur_flash_id;
document.cookie=cookiename+"="+cookievalue + ";expires="+exdate.toGMTString();
}

window.onunload=savetabstate

//TimerStart(5000, 10000, false);

var cur_flash_id='flash_tab2';
function switchFlash(id) {
	if (id != cur_flash_id) {
		var cur = document.getElementById(cur_flash_id);
		var newDiv = document.getElementById(id);
		if (cur && newDiv) {
			cur.style.display = 'none';
			newDiv.style.display = '';
			
			cur_flash_id = id;
		}
	}
}