/*
	Tabs functions by Joshua Lieberman
*/

function hideLayer(id){ 
	if (document.getElementById){ obj = document.getElementById(id); }
	obj.style.display = "none"; 
}
function showLayer(id){ 
	if (document.getElementById){ obj = document.getElementById(id); }
	obj.style.display = "block"; 
}
function toggleLayer( whichLayer )
{
  var elem, vis;
  if( document.getElementById ) // this is the way the standards work
    elem = document.getElementById( whichLayer );
  else if( document.all ) // this is the way old msie versions work
      elem = document.all[whichLayer];
  else if( document.layers ) // this is the way nn4 works
    elem = document.layers[whichLayer];
  vis = elem.style;
  // if the style.display value is blank we try to figure it out here
  if(vis.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined)
    vis.display = (elem.offsetWidth!=0&&elem.offsetHeight!=0)?'block':'none';
  vis.display = (vis.display==''||vis.display=='block')?'none':'block';
}
function toggleAllOtherLayersOff(whichLayer,n)
{
	for (i=1;i<=n;i++)
	{
		if (i!=whichLayer) { // Do this too all other tabs then the clicked on tab
			var divBlock="commentForm"+i;
			hideLayer(divBlock); // hide it's comment form
			var tabOnBlock="linkForm"+i+"on";
			hideLayer(tabOnBlock); // hide it's on state tab
			var tabOffBlock="linkForm"+i+"off";
			showLayer(tabOffBlock); // show it's off state tab
		}
	}
}
function tabs(t,n){
	toggleAllOtherLayersOff(t,n);
	var commentBlock="commentForm"+t;
	toggleLayer(commentBlock);
	var tabBlockOn="linkForm"+t+"on";
	var tabBlockOff="linkForm"+t+"off";
	showLayer(tabBlockOn);
	hideLayer(tabBlockOff);
}
function tab(t){
	tabs(t,2);	
}
function modules(m,maintabs){
	toggleAllOtherLayersOff(-1,maintabs);
	showLayer(m);
	var commentBlock = m + "comment";
	toggleLayer(commentBlock);
}
function module(m){
	modules(m,2);	
}
function toggleAllModuleLayersOff( application,amount )
{
	for (i=1;i<=amount;i++)
	{
		var commentBlock=application+i+"comment";
		hideLayer(commentBlock); // hide it's comment form
		var moduleOnBlock=application+i+"";
		hideLayer(moduleOnBlock); // hide it's on state tab
	}
}
function lmsTab( t ){
	tab(t);
	toggleAllModuleLayersOff('lms',9);
}
function mmsTab( t ){
	tab(t);
	toggleAllModuleLayersOff('mms',6);
}
function datamagineTab( t ){
	tab(t);
	toggleAllModuleLayersOff('datamagine',8);
}
function v1pmsTab( t ){
	tab(t);
	toggleAllModuleLayersOff('v1pms',5);
}
function eatecTab( t ){
	tabs(t,3);
	toggleAllModuleLayersOff('eatec',16);
}
// For the Contact Us - Locations
function toggleLocation( loc ){
	var numOfLocations = 7;
	for (i=1;i<=numOfLocations;i++)
	{
		var divBlock="location"+i;
		if (i!=loc) { // Do this too all other locations then the clicked on location
			hideLayer(divBlock); // hide it's comment form
		} else {
			showLayer(divBlock);
		}
	}
}

