// show-hide components

function toggleLayer(whichLayer){
   if (document.getElementById){
       // this is the way the standards work
      var style2 = document.getElementById(whichLayer).style;
      style2.display = style2.display? "":"block";
   }
   else if (document.all){
      // this is the way old msie versions work
      var style2 = document.all[whichLayer].style;
      style2.display = style2.display? "":"block";
   }
   else if (document.layers){
      // this is the way nn4 works
      var style2 = document.layers[whichLayer].style;
      style2.display = style2.display? "":"block";
   }
}

function hideLayer(whichLayer){
   if (document.getElementById){
       // this is the way the standards work
      var style2 = document.getElementById(whichLayer).style;
      style2.display = "none";
   }
   else if (document.all){
      // this is the way old msie versions work
      var style2 = document.all[whichLayer].style;
      style2.display = "none";
   }
   else if (document.layers){
      // this is the way nn4 works
      var style2 = document.layers[whichLayer].style;
      style2.display = "none";
   }
}

function showLayer(whichLayer){
   if (document.getElementById){
       // this is the way the standards work
      var style2 = document.getElementById(whichLayer).style;
      style2.display = "block";
   }
   else if (document.all){
      // this is the way old msie versions work
      var style2 = document.all[whichLayer].style;
      style2.display = "block";
   }
   else if (document.layers){
      // this is the way nn4 works
      var style2 = document.layers[whichLayer].style;
      style2.display = "block";
   }
}

function showContent(id, num){
	for(i=1;i<=num;i++)
	   hideLayer('option'+i);
	showLayer('option'+id);
}

// open special windows


function flaWin(url,x,y){
	if (document.all)
        var xMax = screen.width, yMax = screen.height;
    else
        if (document.layers)
            var xMax = window.outerWidth, yMax = window.outerHeight;
        else
            var xMax = 800, yMax=600;

    var xOffset = (xMax - x)/2, yOffset = (yMax - y)/2;
	window.open(url,'futureWin','width='+x+',height='+y+',screenX='+xOffset+',screenY='+yOffset+',top='+yOffset+',left='+xOffset+', menubar=no, resizable=no, scrollbar=no, status=no, toolbar=no, titlebar=no');
}


function openWin2(url,x,y){
	if (document.all)
        var xMax = screen.width, yMax = screen.height;
    else
        if (document.layers)
            var xMax = window.outerWidth, yMax = window.outerHeight;
        else
            var xMax = 800, yMax=600;

    var xOffset = (xMax - x)/2, yOffset = (yMax - y)/2;
	window.open(url,'futureWin','width='+x+',height='+y+',screenX='+xOffset+',screenY='+yOffset+',top='+yOffset+',left='+xOffset+',resizable=no,status=no,scrollbars=yes,toolbar=no');
}


function openWin3(url,x,y){
	if (document.all)
        var xMax = screen.width, yMax = screen.height;
    else
        if (document.layers)
            var xMax = window.outerWidth, yMax = window.outerHeight;
        else
            var xMax = 800, yMax=600;

    var xOffset = (xMax - x)/2, yOffset = (yMax - y)/2;
	window.open(url,'futureWin','width='+x+',height='+y+',screenX='+xOffset+',screenY='+yOffset+',top='+yOffset+',left='+xOffset+',resizable=yes,status=yes,scrollbars=yes,toolbar=yes');
	}


// show mail components

function showMailTo(prefix, domain, br){
	if(!br)
       document.write('<a href="mailto:'+prefix+'@'+domain+'">'+prefix+'@'+domain+'</a>');	
	else
	   document.write('<a href="mailto:'+prefix+'@'+domain+'">'+prefix+'<br/>@'+domain+'</a>');
}


// auto-menu selection


function setCurrentLink(){
   var subnavHolder = document.getElementById('mainnav');
   var a = subnavHolder.getElementsByTagName("a");
   for(var i=0;i<a.length;i++){
	    a[i].onmouseover = function(){ clearTimeout(tabTimeout); };
		a[i].onmouseout = function(){ resetTheTimer(); };
        if(a[i].href.split("#")[0] == window.location.href.split("#")[0]){
			a[i].className = 'current';
        }
    }
}

function resetTab(){
	expandcontent(initialtab[1], tabobjlinks[initialtab[0]-1]);
}

function clearTabTimeout(){
	clearTimeout(tabTimeout);
}

function resetTheTimer(){ 
   clearTimeout(tabTimeout);
   tabTimeout = setTimeout(resetTab,2000);
}

function setTabTimeout(){
   var tabHolder = document.getElementById('main_menu');
   var a = tabHolder.getElementsByTagName("a");
   for(var i=0;i<a.length;i++){
         a[i].onmouseout = function(){ resetTheTimer();};
    }
}


window.onload = setCurrentLink;




// tabs

function showSection(set, section){
	var container = document.getElementById(set);
	for(i=0;i<container.childNodes.length;i++){
		if(container.childNodes[i].nodeName == 'DIV'){
			//alert(container.childNodes[i].id);
			container.childNodes[i].className = 'inactive';
		}
	}
	var targetBlock = document.getElementById(section);
	targetBlock.className = 'active';
}


function toggleLayer(whichLayer){
   alert(document.getElementById(whichLayer).style);
   if (document.getElementById){
       // this is the way the standards work
      var style2 = document.getElementById(whichLayer).style;
      style2.display = style2.display? "none":"block";
   }
   else if (document.all){
      // this is the way old msie versions work
      var style2 = document.all[whichLayer].style;
      style2.display = style2.display? "none":"block";
   }
   else if (document.layers){
      // this is the way nn4 works
      var style2 = document.layers[whichLayer].style;
      style2.display = style2.display? "none":"block";
   }
}

function toggle_visibility(id, element) {

var e = document.getElementById(id);
if(e.style.display == 'none'){
e.style.display = 'block';
}
else{
e.style.display = 'none';
}
}

function hideLayer(whichLayer){
   if (document.getElementById){
       // this is the way the standards work
      var style2 = document.getElementById(whichLayer).style;
      style2.display = "none";
   }
   else if (document.all){
      // this is the way old msie versions work
      var style2 = document.all[whichLayer].style;
      style2.display = "none";
   }
   else if (document.layers){
      // this is the way nn4 works
      var style2 = document.layers[whichLayer].style;
      style2.display = "none";
   }
}

function showLayer(whichLayer){
   if (document.getElementById){
       // this is the way the standards work
      var style2 = document.getElementById(whichLayer).style;
      style2.display = "block";
   }
   else if (document.all){
      // this is the way old msie versions work
      var style2 = document.all[whichLayer].style;
      style2.display = "block";
   }
   else if (document.layers){
      // this is the way nn4 works
      var style2 = document.layers[whichLayer].style;
      style2.display = "block";
   }
}

function showInline(whichLayer){
   if (document.getElementById){
       // this is the way the standards work
      var style2 = document.getElementById(whichLayer).style;
      style2.display = "";
   }
   else if (document.all){
      // this is the way old msie versions work
      var style2 = document.all[whichLayer].style;
      style2.display = "";
   }
   else if (document.layers){
      // this is the way nn4 works
      var style2 = document.layers[whichLayer].style;
      style2.display = "";
   }
}

function showContent(id, num){
	for(i=1;i<=num;i++)
	   hideLayer('option'+i);
	showLayer('option'+id);
}

function showMediaControls(num){
	showLayer('media_control_'+num);
	for(i=1;i<=3;i++){
		if(i!=num)
		   hideLayer('media_control_'+i);
	}
}

function changeClass(element, myClass) {
	var elem;
	if(document.getElementById) {
		elem = document.getElementById(element);
	} else if (document.all){
		elem = document.all[element];
	}
	elem.className = myClass;
	if(myClass == 'none')
	   elem.className = null;
}



function showTab(id){
	//alert(id);
	var elem;
	
	changeClass('tab_'+id,'current');
	showLayer('tabContent_'+id);
    
	//Try to set Tab Variable
	var getCurrentTabVar = document.getElementById('currentTabNum');
	if(getCurrentTabVar){
		getCurrentTabVar.value = id;
	}
	
	i = 1;
	while(1==1){
	   if(document.getElementById) {
	    	elem = document.getElementById('tab_'+i);
	   } else if (document.all){
		    elem = document.all['tab_'+i];
	   }		

		//if(!document.getElementById('tab_'+id) && !document.all['tab_'+id]){
		  // break;
		//}
		if(!elem){
		   break;
		}
		else if(i != id){
		   //alert(i);
		   changeClass('tab_'+i, 'none');
		   hideLayer('tabContent_'+i);
		}
		i++;
	}
	
	
}