/*-----------------------------------------------------------
    Toggles element's display value
    Input: any number of element id's
    Output: none 
    ---------------------------------------------------------*/
function toggleDisp() {
    for (var i=0;i<arguments.length;i++){
        var d = $(arguments[i]);
        if (d.style.display == 'none')
            d.style.display = 'block';
        else
            d.style.display = 'none';
    }
    
  	
		document.getElementById('tabContent1').style.display	= '' ;

		// This is a hack for Gecko... it stops editing when the editor is hidden.
		if ( !document.all )
		{
			var oEditor = FCKeditorAPI.GetInstance( 'FCKeditor3' ) ;
		
			if (  oEditor.EditMode == FCK_EDITMODE_WYSIWYG )
			oEditor.MakeEditable() ;
		}

}
/*-----------------------------------------------------------
    Toggles tabs - Closes any open tabs, and then opens current tab
    Input:     1.The number of the current tab
                    2.The number of tabs
                    3.(optional)The number of the tab to leave open
                    4.(optional)Pass in true or false whether or not to animate the open/close of the tabs
    Output: none 
    ---------------------------------------------------------*/
function toggleTab(layerID,FCKinstance,num,numelems,opennum,animate) {
    
    if ($('tabContent'+num).style.display == 'none'){
        for (var i=1;i<=numelems;i++){
            if ((opennum == null) || (opennum != i)){
                var temph = 'tabHeader'+i;
                var h = $(temph);
                if (!h){
                    var h = $('tabHeaderActive');
                    h.id = temph;
                }
                var tempc = 'tabContent'+i;
                var c = $(tempc);
                if(c.style.display != 'none'){
                    if (animate || typeof animate == 'undefined')
                        Effect.toggle(tempc,'appear',{duration:0.0, queue:{scope:'menus', limit: 3}});
                    else
                        toggleDisp(tempc);
                }
            }
        }
        var h = $('tabHeader'+num);
        if (h)
            h.id = 'tabHeaderActive';
        h.blur();
        var c = $('tabContent'+num);
        c.style.marginTop = '2px';
        if (animate || typeof animate == 'undefined'){
            Effect.toggle('tabContent'+num,'appear',{duration:0.0, queue:{scope:'menus', position:'end', limit: 3}});
        }else{
            toggleDisp('tabContent'+num);
        }
    }
    
   if(FCKinstance != '') {
    enableFCK(layerID, FCKinstance);
   }

}

/*-----------------------------------------------------------
Toggles Layers (Verticle)
---------------------------------------------------------*/

function enableFCK(layerID, FCKinstance) {

		document.getElementById(layerID).style.display	= '' ;

		// This is a hack for Gecko... it stops editing when the editor is hidden.
		if ( !document.all )
		{
			var oEditor = FCKeditorAPI.GetInstance( FCKinstance ) ;
		
			if (  oEditor.EditMode == FCK_EDITMODE_WYSIWYG )
			oEditor.MakeEditable() ;
		}
		
}

function toggleLayer(tabID, layerID, FCKinstance){    
  //scriptaculous call
  Effect.toggle(layerID,'blind',{duration:0.5});  
  
  if(document.getElementById(tabID).className == 'tab_vert') {  
    document.getElementById(tabID).className	= 'tab_vert_open';
  }else{
    document.getElementById(tabID).className	= 'tab_vert';
  }
  
  if(FCKinstance != '') {
  	enableFCK(layerID, FCKinstance);  	
  }
}
