
//**********************************************************************************************************/
//
// Author: Keith Krecicki
// Website: http://www.kk-design.com
// Date: November 12, 2010
// License: Creative Commons Attribution 3.0 License (http://creativecommons.org/licenses/by/3.0/)
// Browsers: Tested successfully on Win7 with the following browsers (using DOCTYPE XHTML Strict):
// * Firefox: 2.0.0.7, 1.5.0.12
// * Internet Explorer: 7.0, 6.0 SP2, 5.5 SP2
// * Opera: 9.23
//
//**********************************************************************************************************/


/* isShowing
   Determines whether a specified element is showing or not.
   @environment ALL
   @param element - The specified element.
   @return True if showing, false otherwise.
*/
function isShowing( element ) {
   return ( ! isHidden( element ) );
} // isShowing


/* isHidden
   Determines whether a specified element is hidden or not.
   @environment ALL
   @param element - The specified element.
   @return True if hidden, false otherwise.
*/
function isHidden( element ) {
   // Checks the element's class name for 'hidden'.
   // element.className.indexOf( 'hidden' ) will be -1 if 'hidden' is not found.
   return ( element.className.indexOf( "hidden" ) != -1 );
} // isHidden

/* show
   Shows a specified element.
   @environment ALL
   @param element - The specified element.
   @return True if successful, false otherwise.
*/
function show( element ) {
   if( ! element ) { return false; }

   if( isHidden( element ) ) {
       // Remove 'hidden' from the class name of the element.
       return ( element.className = element.className.slice( 0, element.className.indexOf( "hidden" ) ) + element.className.slice( element.className.indexOf( "hidden" )+6 ) );
   }

   return false;
} // show

/* hide
   Hides a specified element.
   @environment ALL
   @param element - The specified element.
   @return True if successful, false otherwise.
*/
function hide( element ) {
   if( ! element ) { return false; }

   if( isShowing( element ) ) {
       // Add 'hidden' to the class name of the element.
       // This places hidden as the last class in the class name attribute.
       if( element.className == "" ) { return ( element.className = "hidden" ); }
       else { return ( element.className = element.className + " hidden" ); }
   }

   return false;
} // hide 


/* setDivHeight
   Sets the height of a DIV based on the height of a PARENT DIV.
   @environment ALL
   @param parentContainer - ID of parent container.
   @param containerToSize - ID of container you want to set height to.
   @return height in number format plus [px].
*/
function setDivHeight(parentContainer, containerToSize) {
	var heightOfParentContainer = document.getElementById( parentContainer ).offsetHeight;
	if (heightOfParentContainer != null) {
		document.getElementById( containerToSize ).style.height = heightOfParentContainer + "px";
	}
} // setDivHeight

/* rand
   Generates a random number between 0 and a specified max value.
   @environment ALL
   @param  max - The specified max value.
   @return The randomly generated number between 0 and max.
*/
function rand( max ) {
   return Math.floor(Math.random()*max);
} // rand


function rotateHomepageOfferings( num ) {
   var random = rand( num );
   random = random + 1; // Shift random number 1 to the right, we do not use Offerings0.
	if (random == 1) {
		show(document.getElementById( "highlightsBusiness" ));
		show(document.getElementById( "otherCompanyHighlightsRightBusiness" ));
		hide(document.getElementById( "highlightsPersonal" ));
		hide(document.getElementById( "otherCompanyHighlightsRightPersonal" ));
		hide(document.getElementById( "highlightsFinancial" ));
		hide(document.getElementById( "otherCompanyHighlightsRightFinancial" ));
		hide(document.getElementById( "highlightsEmployee" ));
		hide(document.getElementById( "otherCompanyHighlightsRightEmployee" ));
	} else if (random == 2) {
		hide(document.getElementById( "highlightsBusiness" ));
		hide(document.getElementById( "otherCompanyHighlightsRightBusiness" ));
		show(document.getElementById( "highlightsPersonal" ));
		show(document.getElementById( "otherCompanyHighlightsRightPersonal" ));
		hide(document.getElementById( "highlightsFinancial" ));
		hide(document.getElementById( "otherCompanyHighlightsRightFinancial" ));
		hide(document.getElementById( "highlightsEmployee" ));
		hide(document.getElementById( "otherCompanyHighlightsRightEmployee" ));
	} else if (random == 3) {
		hide(document.getElementById( "highlightsBusiness" ));
		hide(document.getElementById( "otherCompanyHighlightsRightBusiness" ));
		hide(document.getElementById( "highlightsPersonal" ));
		hide(document.getElementById( "otherCompanyHighlightsRightPersonal" ));
		show(document.getElementById( "highlightsFinancial" ));
		show(document.getElementById( "otherCompanyHighlightsRightFinancial" ));
		hide(document.getElementById( "highlightsEmployee" ));
		hide(document.getElementById( "otherCompanyHighlightsRightEmployee" ));
	} else if (random == 4) {
		hide(document.getElementById( "highlightsBusiness" ));
		hide(document.getElementById( "otherCompanyHighlightsRightBusiness" ));
		hide(document.getElementById( "highlightsPersonal" ));
		hide(document.getElementById( "otherCompanyHighlightsRightPersonal" ));
		hide(document.getElementById( "highlightsFinancial" ));
		hide(document.getElementById( "otherCompanyHighlightsRightFinancial" ));
		show(document.getElementById( "highlightsEmployee" ));
		show(document.getElementById( "otherCompanyHighlightsRightEmployee" ));
	}
}

sfHover = function() {
	var sfEls = document.getElementById("sidebarNav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}


