// JavaScript Document

	// Spotlight Tagline link functions:
	
	function BrokerageLink () {
		document.location.href = "/brokerage/";
	}
	function ConsultingLink () {
	    document.location.href = "/consulting/";
	}
	function InvestmentLink () {
	    document.location.href = "/investment/";
	}
	function DevelopmentLink () {
	    document.location.href = "/development/";
	}
	
	function IntegrityLink () {
	    document.location.href = "/about_us/";
	}
	function ExperienceLink () {
	    document.location.href = "/clients/";
	}
	function ResultsLink () {
	    document.location.href = "/featured_projects/";
	}
	
/***Simple jQuery Slideshow Script (SPOTLIGHT SLIDESHOW)
	Released by Jon Raasch (jonraasch.com) under FreeBSD license. */
	
	function slideSwitch() {
		var $active = $('#slideshow IMG.active');
	
		if ( $active.length == 0 ) $active = $('#slideshow IMG:last');
	
		// use this to pull the images in the order they appear in the markup
		var $next =  $active.next().length ? $active.next()
			: $('#slideshow IMG:first');
	
		// uncomment the 3 lines below to pull the images in random order
		
		// var $sibs  = $active.siblings();
		// var rndNum = Math.floor(Math.random() * $sibs.length );
		// var $next  = $( $sibs[ rndNum ] );
	
	
		$active.addClass('last-active');
	
		$next.css({opacity: 0.0})
			.addClass('active')
			.animate({opacity: 1.0}, 1000, function() {
				$active.removeClass('active last-active');
			});
	}
	
	$(function() {
		setInterval( "slideSwitch()", 6000 );
	});

 //  BEGIN News ticker function: 
 $(function() {
                $("#news_bar_content").webwidget_slideshow_common({
                    slideshow_transition_effect: 'fade_in',//slide_left slide_down fade_in
                    slideshow_time_interval: '6000',
                    slideshow_window_width: '620',
                    slideshow_window_height: '22',
                    slideshow_border_style: 'none',//dashed dotted double groove hidden inset none outset ridge solid
                    soldeshow_background_color: 'none'
                });
            });
  // END Newsticker Function

// jQuery Document Ready Start:
$(document).ready(function() {

    // Show the news_bar_content and three_panels after the page load is complete, to avoid FOUC (Flash Of Unstyled Content)...
    $('#news_bar_content').show();
    $('#three_panels').show();
    
	// Build and display Date:
	function ShowDate(){
		var d=new Date();
		var strDateString;
		var month=new Array(12);
		month[0]="January";
		month[1]="February";
		month[2]="March";
		month[3]="April";
		month[4]="May";
		month[5]="June";
		month[6]="July";
		month[7]="August";
		month[8]="September";
		month[9]="October";
		month[10]="November";
		month[11]="December";
	
		strDateString = String(month[d.getMonth()] + " " + d.getDate() + ", " + d.getFullYear());
		$("#service_spotlight").html(strDateString);
	}  ShowDate();  // Call the function ShowDate to update the Date field.	
	

/********************** Top Nav Menu Functions:*********************/

	function megaHoverOver(){
		$(this).find(".sub").stop().fadeTo('fast', 1).show();
			
		//Calculate width of all ul's
		(function($) { 
			jQuery.fn.calcSubWidth = function() {
				rowWidth = 0;
				//Calculate row
				$(this).find("ul").each(function() {					
					rowWidth += $(this).width(); 
				});	
			};
		})(jQuery); 
		
		if ( $(this).find(".row").length > 0 ) { //If row exists...
			var biggestRow = 0;	
			//Calculate each row
			$(this).find(".row").each(function() {							   
				$(this).calcSubWidth();
				//Find biggest row
				if(rowWidth > biggestRow) {
					biggestRow = rowWidth;
				}
			});
			//Set width
			$(this).find(".sub").css({'width' :biggestRow});
			$(this).find(".row:last").css({'margin':'0'});
			
		} else { //If row does not exist...
			
			$(this).calcSubWidth();
			//Set Width
			$(this).find(".sub").css({'width' : rowWidth});
			
		}
	}
	
	function megaHoverOut(){ 
	  $(this).find(".sub").stop().fadeTo('fast', 0, function() {
		  $(this).hide(); 
	  });
	}

	var config = {    
		 sensitivity: 2, // number = sensitivity threshold (must be 1 or higher)    
		 interval: 0, // number = milliseconds for onMouseOver polling interval    
		 over: megaHoverOver, // function = onMouseOver callback (REQUIRED)    
		 timeout: 200, // number = milliseconds delay before onMouseOut    
		 out: megaHoverOut // function = onMouseOut callback (REQUIRED)    
	};
 
	$("ul#topnav li .sub").css({'opacity':'0'});
	$("ul#topnav li").hoverIntent(config);

	// End Top Nav Menu Functions	
});  // End jQuery Document Ready Function
