// JavaScript Document
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_str(id, element, str1, str2) {



var e = document.getElementById(id);
if(e.style.display == 'none'){
e.style.display = 'block';
//element.innerHTML = 'hide '+postfix;
element.innerHTML = str2;
}
else{
e.style.display = 'none';
//element.innerHTML = 'show '+postfix;
element.innerHTML = str1;
}
}

function toggle_visibility(id, element, str) {

if(str){
	var postfix = str;
}else{
	var postfix = 'details';
}

var e = document.getElementById(id);
if(e.style.display == 'none'){
e.style.display = 'block';
element.innerHTML = 'hide '+postfix;
}
else{
e.style.display = 'none';
element.innerHTML = 'show '+postfix;
}
}

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++;
	}
	
	
}
