﻿/* ROLLOVER EVENT FOR Context Button MENU ITEM */
function mainSectionRollOver()
{

	// the object should send in itself (this)
	var contextItem = (arguments[0]==null) ? "" : arguments[0]
	var contextItemID = (arguments[1]==null) ? "" : arguments[1]
	var className = (arguments[2]==null) ? "" : arguments[2]


	// if user specifying an object by the ID value
	if (contextItemID.length != 0)
	{
		contextItem = getObjectFromID(contextItemID);
	}

	// set default classname
	if (className.length == 0)
	{
		className = 'buttonHover';
	}

	if(contextItem)
	{
	
	
		if (contextItem.className != 'button' )
		{
			contextItem.className='button';
		}
		else
		{
			contextItem.className=className;
		}
		
	}

}

function toggleDashboardForm(checkbox)
{
	if (checkbox.checked == 1)
	{
		getObjectFromID("myFormDashboard").action = "?page=business";
	}
	else
	{
		getObjectFromID("myFormDashboard").action = "?page=business&action=list";
	}
	
}

function popup()
{
	// the object should send in itself (this)
	var page = (arguments[0]==null) ? "" : arguments[0];
	var width = (arguments[1]==null) ? "" : arguments[1];
	var height = (arguments[2]==null) ? "" : arguments[2];
	                                                   
	
	smallWin = window.open(page, 'MA_Popup', 'toolbar=0,location=0,directories=0, status="Maintenance Assistant - Popup Window", menubar=0,scrollbars=1, resizeable=0,width='+width+',height='+height+'');
	smallWin.focus();                                                   
		
}

/* ROLLOVER EVENT FOR Context Button MENU ITEM */
function subMenuSectionRollOver()
{

	// the object should send in itself (this)
	var contextItem = (arguments[0]==null) ? "" : arguments[0]
	var contextItemID = (arguments[1]==null) ? "" : arguments[1]
	var className = (arguments[2]==null) ? "" : arguments[2]



	// if user specifying an object by the ID value
	if (contextItemID.length != 0)
	{
		contextItem = getObjectFromID(contextItemID);
	}

	// set default classname
	if (className.length == 0)
	{
		className = 'buttonHover';
	}

	if(contextItem)
	{
	
	
		if (contextItem.className != 'button' )
		{
			contextItem.className='button';
		}
		else
		{
			contextItem.className=className;
		}
		
	}

}

/* ROLLOVER EVENT FOR SUBMENU ITEM */
function subMenuSectionDDRollOver()
{

	// the object should send in itself (this)
	var contextItem = (arguments[0]==null) ? "" : arguments[0]
	var className = (arguments[1]==null) ? "" : arguments[1]
	
	// make sure we have an object
	if (contextItem)
	{
		if (contextItem.className == 'subMenuButtonNotSelected' && className.length == 0)
		{
			className = 'subMenuButtonOver';
		}
		else if (contextItem.className == 'subMenuButtonOver' && className.length == 0)
		{
			className = 'subMenuButtonNotSelected';
		}
		else if (contextItem.className == 'subMenuDDButtonNotSelected' && className.length == 0 )
		{
			className = 'subMenuDDButtonSelected'
		}
		else if (contextItem.className == 'subMenuDDButtonSelected' && className.length == 0)
		{
			className = 'subMenuDDButtonNotSelected'					
		}
		
		// we only want to show rollover state if it is expected
		if (contextItem.className == 'subMenuButtonNotSelected' || contextItem.className == 'subMenuDDButtonNotSelected' || contextItem.className == 'subMenuButtonOver' || contextItem.className == 'subMenuDDButtonSelected')
		{
			contextItem.className=className;
		}
	}

}

/* ROLLOVER EVENT FOR SUBMENU ITEM */
/*function leftMenuRollOver()
{
	var contextItem
	// the object should send in itself (this)
	var contextItemID = (arguments[0]==null) ? "" : arguments[0]
	var className = (arguments[1]==null) ? "" : arguments[1]
	      
	                                                     
	                                                      
	// if user specifying an object by the ID value
	if (contextItemID.length != 0)
	{
		
		contextItem = getObjectFromID(contextItemID);
	}

	// set default classname
	if (className.length == 0)
	{
		className = 'menuLink hover';
	}

	if(contextItem)
	{
		if (contextItem.className == 'menuLink hover' )
		{
			contextItem.className='menuLink';
		}
		else
		{
			contextItem.className=className;
		}
	}

}*/


/* This method supports any method that needs to grab the object from the
   * ID Name */
   function getObjectFromID()
   {
		var contextItemName = (arguments[0]==null) ? "" : arguments[0];
		var contextItem = '';

		if (document.getElementById) { // DOM3 = IE5, NS6
			contextItem = (document.getElementById(contextItemName))?document.getElementById(contextItemName):null;
			//contextItem = document.getElementById(contextItemName)
			
		}
		else {
			if (document.layers) { // Netscape 4
				contextItem = document.contextItemName?document.contextItemName:null;
			}
			else { // IE 4
				contextItem = document.all.contextItemName?document.all.contextItemName:null;
			}
		}

		return contextItem

   }

   
   /* ROLLOVER EVENT FOR A HOME TAB ITEM ITEM */
   function homeTabButtonRollOver()
   {
 	// the object should send in itself (this)
 	var contextItem = (arguments[0]==null) ? "" : arguments[0]
 	var className = (arguments[1]==null) ? "" : arguments[1]
 	
 	if (className.length == 0)
 	{
 		className = 'homeTabOver';
 	}

 	

 	if(contextItem)
 	{
 		if (contextItem.className.length > 0)
 		{
 			if (contextItem.className == 'homeTabOff')
 			{
 				contextItem.className='homeTabOver';
 			}
 			else if (contextItem.className == 'homeTabOver')
 			{
 				contextItem.className='homeTabOff';
 			}
 		}
 		else
 		{
 			contextItem.className=className;
 		}
 		
 	}
   }
   
   
   /* ROLLOVER EVENT FOR A TAB ITEM ITEM */
  function tabButtonRollOver()
  {
	// the object should send in itself (this)
	var contextItem = (arguments[0]==null) ? "" : arguments[0]
	var className = (arguments[1]==null) ? "" : arguments[1]
	
	if (className.length == 0)
	{
		className = 'homeTabHover';
	}

	

	if(contextItem)
	{
		if (contextItem.className.length > 0)
		{
			if (contextItem.className != 'homeTabSelected')
			{
				contextItem.className='';
			}
		}
		else
		{
			contextItem.className=className;
		}
		
	}
  }
  
  
  
  /* ROLLOVER EVENT FOR A TAB ITEM ITEM */
  function tabPageButtonRollOver()
  {
	// the object should send in itself (this)
	var contextItem = (arguments[0]==null) ? "" : arguments[0]
	var className = (arguments[1]==null) ? "" : arguments[1]
	
	if (className.length == 0)
	{
		className = 'pageTabHover';
	}

	

	if(contextItem)
	{
		if (contextItem.className.length > 0)
		{
			if (contextItem.className != 'pageTabSelected')
			{
				contextItem.className='';
			}
		}
		else
		{
			contextItem.className=className;
		}
		
	}
  }
  
  
  /* ROLLOVER EVENT FOR A TAB FORM ITEM */
  function tabFormButtonRollOver()
  {
	// the object should send in itself (this)
	var contextItem = (arguments[0]==null) ? "" : arguments[0];
	var className = (arguments[1]==null) ? "" : arguments[1];
	
	if (className.length == 0)
	{
		className = 'formTabHover';
	}

	

	if(contextItem)
	{
		
		if (contextItem.className.length > 0)
		{
			
			if (contextItem.className != 'formTabSelected')
			{
				contextItem.className='';
			}
			
		}
		else
		{
				contextItem.className=className;
		}
		
	}
  }
  
  
 
  
  function tabSectionShow()
  {
	 // the object should send in itself (this)
	var contextTabItem = (arguments[0]==null) ? "" : arguments[0];
	var tabNumber = (arguments[1]==null) ? 0 : arguments[1];
	var totalTabNumber = (arguments[2]==null) ? 0 : arguments[2];
	var isHome = (arguments[3]==null) ? false : arguments[3];
	
	if(contextTabItem)
	{
		/*if (contextTabItem.className.length > 0)
		{*/
			var i = 0;
			if (isHome)
			{
				if (contextTabItem.className != 'homeTabOn')
				{
					// if the tab is selected, then we don't need to change the context
					// user has clicked on the active tab
					
					for (i = 1; i <= totalTabNumber; i++)
					{							
						getObjectFromID('tab'+i).className='homeTabContentHide';
						getObjectFromID('tabButton'+i).className='homeTabOff';
					}
					
					if (tabNumber > 0)
					{
						getObjectFromID('tab'+tabNumber).className = 'homeTabContentShow';
						getObjectFromID('tabButton'+tabNumber).className='homeTabOn';
					}
				}
			}
			else
			{
				
				if (contextTabItem.className != 'formTabSelected')
				{
					// if the tab is selected, then we don't need to change the context
					// user has clicked on the active tab
					
					for (i = 1; i <= totalTabNumber; i++)
					{	
						getObjectFromID('formTab'+i).style.display='none';
						getObjectFromID('formTabButton'+i).className='';
						
					}
					
					if (tabNumber > 0)
					{
						getObjectFromID('formTab'+tabNumber).style.display = '';
						getObjectFromID('formTabButton'+tabNumber).className='formTabSelected';
					}
				}
				
				
			}
		/*}
		else
		{
			//contextItem.className=className;
		}*/
		
	}
	
}
  
function toggleLayer(whichLayer)
{
  if (document.getElementById)
  {
	  // this is the way the standards work
	  var style2 = document.getElementById(whichLayer).style;
	  style2.display = style2.display? "":"none";
  }
  else if (document.all)
  {
	  // this is the way old msie versions work
	  var style2 = document.all[whichLayer].style;
	  style2.display = style2.display? "":"none";
  }
  else if (document.layers)
  {
	  // this is the way nn4 works
	  var style2 = document.layers[whichLayer].style;
	  style2.display = style2.display? "":"none";
  }

}

function toggleLayerAdvanced(whichLayer, expand)
{
  if (document.getElementById)
  {
	  // this is the way the standards work
	  var style2 = document.getElementById(whichLayer).style;
	  if (expand)
		  style2.display = "";
	  else
		  style2.display = "none";
		  
  }
  else if (document.all)
  {
	  // this is the way old msie versions work
	  var style2 = document.all[whichLayer].style;
	  if (expand)
		  style2.display = "";
	  else
		  style2.display = "none";
  }
  else if (document.layers)
  {
	  // this is the way nn4 works
	  var style2 = document.layers[whichLayer].style;
	  if (expand)
		  style2.display = "";
	  else
		  style2.display = "none";
  }

}


/* GENERAL FORM SUBMIT */
function savePageForm(formName)
{
	saveHTML ( );
	getObjectFromID('myForm').submit();
}



/*_______________ THREAD JAVASCRIPT ITEMS ___________________*/
function toggleThread(threadID)
{
	
	//var renderedThread = getObjectFromID('renderThreadMessage_'+threadID);
	var editThread = getObjectFromID('editThreadMessage_'+threadID);
	
	if (!editThread)
		return;

	toggleLayer('renderThreadMessage_'+threadID);
	toggleLayer('renderThreadButtons_'+threadID);
	toggleLayer('editThreadMessage_'+threadID);
	
}


function forumExpandCollapse(thisForum)
{
	
	forumButton = getObjectFromID('buttons_collapseForum_'+thisForum);
	if (forumButton.className == 'buttons_collapseForum')
		forumCollapse(thisForum);
	else
		forumExpand(thisForum);
	
}

function forumExpand()
{
	var forumContainer = (arguments[0]==null) ? "" : arguments[0];
	
	var forumCategory = null;
	var forumButton = null;
	
	if (forumContainer.length > 0)
	{
		forumCategory = getObjectFromID('forumCategory_'+forumContainer);
		forumButton = getObjectFromID('buttons_collapseForum_'+forumContainer);
		if (forumCategory.style.display == 'none')
			toggleLayerAdvanced('forumCategory_'+forumContainer,true);
		forumButton.className = 'buttons_collapseForum';

	}
	else
	{
		var i = 1;
		forumCategory = getObjectFromID('forumCategory_'+i);
		forumButton = getObjectFromID('buttons_collapseForum_'+i);
		while(forumCategory)
		{
			if (forumCategory.style.display == 'none')
				toggleLayerAdvanced('forumCategory_'+i,true);
			forumButton.className = 'buttons_collapseForum';
			i++;
			forumCategory = getObjectFromID('forumCategory_'+i);
			forumButton = getObjectFromID('buttons_collapseForum_'+i);
		}
	}
}

function forumCollapse()
{
	
	var forumContainer = (arguments[0]==null) ? "" : arguments[0];
	
	var forumCategory = null;
	var forumButton = null;
	
	if (forumContainer.length > 0)
	{
		forumButton = getObjectFromID('buttons_collapseForum_'+forumContainer);
		forumCategory = getObjectFromID('forumCategory_'+forumContainer);
		if (forumCategory.style.display == '')
			toggleLayerAdvanced('forumCategory_'+forumContainer,false);
		forumButton.className = 'buttons_expandForum';
	}
	else
	{
		var i = 1;
		forumCategory = getObjectFromID('forumCategory_'+i);
		forumButton = getObjectFromID('buttons_collapseForum_'+i);
		while(forumCategory)
		{
			if (forumCategory.style.display == '')
				toggleLayerAdvanced('forumCategory_'+i,false);
			forumButton.className = 'buttons_expandForum';
			i++;
			forumCategory = getObjectFromID('forumCategory_'+i);
			forumButton = getObjectFromID('buttons_collapseForum_'+i);
		}	
	}
}



/* ################### ROTATE INDEX LAYERS ###################### */
var currentIndexTab = 1;
var opacityIn = 0;
var opacityOut = 0;
var howOften = 1;
var stillRotate = true;

function killRotate()
{
	var i = 1;
	while (i < 4)
	{
		if (document.all && document.getElementById) getObjectFromID("tab"+i).filters.alpha.opacity = 100;
		if (!document.all && document.getElementById) getObjectFromID("tab"+i).style.MozOpacity = 1;
		i++;
	}

	stillRotate = false;
}

function rotateIndexFloatingTabs()
{
	if (!stillRotate)
		return;
	
	if (currentIndexTab.length == 0)
		currentIndexTab = 0
	currentIndexTab = (currentIndexTab>=3) ? 1 : currentIndexTab + 1;

	var i = 1;
	while (i < 4)
	{
		if (i == currentIndexTab)
		{
			getObjectFromID("tabButton"+i).className="homeTabOn";
			getObjectFromID("tab"+i).className="homeTabContentShow";

			fadeInLayer("tab"+i, 0);
		}
		else
		{
			fadeOutLayer("tab"+i, 100);
			getObjectFromID("tabButton"+i).className="homeTabOff";				
		}
		i++;
		
	}

	setTimeout("rotateIndexFloatingTabs()",howOften*5000);
			
}

function fadeInLayer(layerName, opacityIn)
{
	
	var thisLayer = getObjectFromID(layerName);
	
	if(opacityIn!= 100){
		opacityIn+=1;
		if(typeof(thisLayer.style.filter)!='undefined'){ // IE5.5+
			thisLayer.style.zoom = 1;
			thisLayer.style.filter = 'alpha(opacity:'+opacityIn+')';
	    } else {
	    	thisLayer.style.opacity = thisLayer.style.MozOpacity = opacityIn/100;
	    }
		/*if (document.all && document.getElementById) setIEOpacity(layerName,opacityIn);
		if (!document.all && document.getElementById) thisLayer.style.MozOpacity = opacityIn/100;*/
		setTimeout('fadeInLayer("'+layerName+'",'+opacityIn+')', 10);
	}
}

function fadeOutLayer(layerName, opacityIn)
{
	var thisLayer = getObjectFromID(layerName);
	
	if(opacityIn!= 0){
		opacityIn-=1;
		if(typeof(thisLayer.style.filter)!='undefined'){ // IE5.5+
			thisLayer.style.zoom = 1;
			thisLayer.style.filter = 'alpha(opacity:'+opacityIn+')';
	    } else {
	    	thisLayer.style.opacity = thisLayer.style.MozOpacity = opacityIn/100;
	    }
		/*if (document.all && document.getElementById) setIEOpacity(layerName,opacityIn);
		if (!document.all && document.getElementById) getObjectFromID(layerName).style.MozOpacity = opacityIn/100;*/
		setTimeout('fadeOutLayer("'+layerName+'",'+opacityIn+')', 10);
	}
	else
	{
		
		getObjectFromID(layerName).className="homeTabContentHide";
	}
}

function setIEOpacity(layerName, opacityVal)
{
	//if (getObjectFromID(layerName).filters.alpha.opacity != null) 
		getObjectFromID(layerName).filters.alpha.opacity = opacityVal;
	//else if (document.all && document.getElementById)
	//	getObjectFromID(layerName).filters = 'alpha(opacity='+opacityVal+')';
}



