	/* GLOBAL VARRIABLES */
var animationSpeed				= 500
var $body		 				= false
var	$window		 				= false
var $mainNavListFirstlevelItem	= false
var $videoOverlay				= false
var $videoContainer				= false
var $leadOverlay				= false
var $leadContainer				= false
	/* GLOBAL VARRIABLES */

;(function($) {
	$(function() {

		$('body').append('<div id="videoOverlay"></div>')// Creat the videoOverlay div
		$('body').append('<div id="leadOverlay"></div>')//Create the lead overlay div

		$body = $('body')
		$window = $(window)
		$videoOverlay = $('#videoOverlay')
		$videoContainer = $('#videoContainer')
		$leadOverlay = $('#leadOverlay')
		$leadContainer = $('#leadContainer')

		/* Begin dropdown function */
		$mainNavListFirstlevelItem = $('#mainNavwithDropNav > ul > li')
		$dropNav = $('.dropdownWrap')
		$dropNav_dropdown = $dropNav.find('div.dropdown')

		//alert (  'DIV.Dropdow:'+ $dropNav_dropdown.height() +'\nUL:'+ $dropNav.find('ul').height() )
		$mainNavListFirstlevelItem.each(function(i) {
			if (($dropNav_dropdown.eq(i).height() - $dropNav.eq(i).find('ul').height()) <= 30) {
				$dropNav_dropdown.eq(i).width(250)
			}
			else {
				$dropNav_dropdown.eq(i).width(498)
			}
		})
		$dropNav.css({ 'visibility': 'visible', 'display': 'none' })

		$mainNavListFirstlevelItem
			.mouseenter(function() {
				$(this).find('div.dropdownWrap').show()
				$(this).addClass('hovered')
			})
			.mouseleave(function() {
				$(this).find('div.dropdownWrap').hide()
				$(this).removeClass('hovered')
			})
		/* End dropdown function */

		/* Begin tab function */
		var $tabiTems = $('#tabiTems > li')
		var $tabDescriptions = $('#tab_Container > div.tabsContents')
		$tabiTems.each(function(i) {
			$(this).click(function() {
				$('#tabiTems > li.active').removeClass('active')
				$(this).addClass('active')
				$tabDescriptions.addClass('displayHide')
				$tabDescriptions.eq(i).removeClass('displayHide')
			})//end click function
		})// End each function

		/* End dropdown function */

		$('#videoThumbs').click(function() {
			showAndHideVideoOverlay('home')
		})// End videoThumbs click function


		/* Begin right nav item click function*/
		var $rightNavListItem = $('#rightNav > li ')
		$('#rightNav > li > div').hide()
		$rightNavListItem.each(function(i) {
			var $rightNavListItemDescription = $('#rightNav > li').eq(i).find('div')
			$(this).click(function() {
				if ($rightNavListItemDescription.is(':hidden')) { // when the div is closed
					$rightNavListItemDescription.animate({ 'height': 'show' })//slideDown(animationSpeed);
					$rightNavListItem.eq(i).siblings('li').find('div').animate({ 'height': 'hide' })//slideUp(animationSpeed);
					$rightNavListItem.css({ 'background': 'url(/images/enterprise/minus.gif) no-repeat 0 15px' })
					$rightNavListItem.eq(i).siblings('li').css({ 'background': 'url(/images/enterprise/plus.gif) no-repeat 0 15px' })
				}
				else { // when the div is open
					$rightNavListItemDescription.animate({ 'height': 'hide' })//slideUp(animationSpeed);
					$rightNavListItem.css({ 'background': 'url(/images/enterprise/plus.gif) no-repeat 0 15px' })
				}
			})// End click function
		})// End each function	

		/* End right nav item click function*/

		// we want to have the meetus open when you hit the site, so we'll take care of that now.

		var $rightNavListItemDescription = $('#rightNav > li').eq(0).find('div')
		$rightNavListItemDescription.animate({ 'height': 'show' })//slideDown(animationSpeed);
		$rightNavListItem.eq(0).siblings('li').find('div').animate({ 'height': 'hide' })//slideUp(animationSpeed);
		$rightNavListItem.css({ 'background': 'url(/images/enterprise/minus.gif) no-repeat 0 15px' })
		$rightNavListItem.eq(0).siblings('li').css({ 'background': 'url(/images/enterprise/plus.gif) no-repeat 0 15px' })


	})// END OF DOCUMENT READY FUNCTION


})(jQuery)

	/* Begin Video Overlay function*/

function showAndHideVideoOverlay(videosPage){

	/* Begin  Pointers and Varriables */

	var $videoOverlayCloseBtn	= $('#ovelayandVideoCloseBtn')
	var videoContainerHeight	= $videoContainer.height()
	var videoContainerWidth		= $videoContainer.width()
	var bodyHeight				= $body.height()
	var bodyWidth				= $body.width()
	var windowHeight			= $window.height()
	var windowWidth				= $window.width()
	var contentouterWidth		= $('#contentWrapper').outerWidth()
	var overlayHeight			= $videoOverlay.height()
	var overlayWidth			= $videoOverlay.width()
	var verticalPosition		= 0 
	var horizontalPosition		= 0
	/* End Pointers and Varriables */

	overlayHeight = $(document).height()

	overlayWidth = $(document).width()

	if(windowHeight>videoContainerHeight){
		verticalPosition = $window.scrollTop() + Math.round( (windowHeight-videoContainerHeight)/2 )
	}
	else{
		verticalPosition = $window.scrollTop()
	}
	if(windowWidth>videoContainerWidth){
		horizontalPosition = $window.scrollLeft() + Math.round( (windowWidth-videoContainerWidth)/2 )
	}
	else{
		horizontalPosition = $window.scrollLeft()
	}
	$videoOverlay.css({'height': overlayHeight,'width': overlayWidth,'position': 'absolute','left': 0,'top': 0,'z-index': 1000,'opacity': 0.8,'background': '#000'
	})//Set the properties of the overlay div
	
	//show the mask and the contents inside it
	$videoOverlay.animate( {opacity:'show'}, animationSpeed )
	$videoContainer.css({ 'display': 'block','top': verticalPosition,'left': horizontalPosition})
	
	if(videosPage == 'home'){
		$videoOverlay.click(function(){
			$(this).animate( {opacity:'hide'}, animationSpeed )
			$videoContainer.hide()
		})
		$videoOverlayCloseBtn.click(function(){
			$videoOverlay.animate({opacity:'hide'}, animationSpeed )
			$videoContainer.hide()
		})
	}
	else if(videosPage == 'videos'){
		$videoOverlay.click(function(){
			$(this).animate( {opacity:'hide'}, animationSpeed )
			$videoContainer.html('')
			$videoContainer.hide()
		})
		$videoOverlayCloseBtn.click(function(){
			$videoOverlay.animate({opacity:'hide'}, animationSpeed )
			$videoContainer.html('')
			$videoContainer.hide()
		})		
	}
	
} 
	/* End Video Overlay function*/

	
	/* Begin Lead Overlay function*/

function showAndHideLeadOverlay(){

	/* Begin  Pointers and Varriables */

	var $leadOverlayCloseBtn	= $('#ovelayandVideoCloseBtn')
	var leadContainerHeight		= $leadContainer.height()
	var leadContainerWidth		= $leadContainer.width()
	var bodyHeight				= $body.height()
	var bodyWidth				= $body.width()
	var windowHeight			= $window.height()
	var windowWidth				= $window.width()
	var contentouterWidth		= $('#contentWrapper').outerWidth()
	var overlayHeight			= $leadOverlay.height()
	var overlayWidth			= $leadOverlay.width()
	var verticalPosition		= 0 
	var horizontalPosition		= 0
	/* End Pointers and Varriables */

	overlayHeight = $(document).height()

	overlayWidth = $(document).width()

	if(windowHeight>leadContainerHeight){
		verticalPosition = $window.scrollTop() + Math.round( (windowHeight-leadContainerHeight)/2 )
	}
	else{
		verticalPosition = $window.scrollTop()
	}
	if(windowWidth>leadContainerWidth){
		horizontalPosition = $window.scrollLeft() + Math.round( (windowWidth-leadContainerWidth)/2 )
	}
	else{
		horizontalPosition = $window.scrollLeft()
	}
	$leadOverlay.css({'height': overlayHeight,'width': overlayWidth,'position': 'absolute','left': 0,'top': 0,'z-index': 1000,'opacity': 0.8,'background': '#000'
	})//Set the properties of the overlay div
	
	//show the mask and the contents inside it
	$leadOverlay.animate( {opacity:'show'}, animationSpeed )
	$leadContainer.css({ 'display': 'block','top': verticalPosition,'left': horizontalPosition, 'visibility' : 'visible'})
	
} 
	/* End Lead Overlay function*/
