var position_banner_elems = function() {
	var oSiteBanner = $('#site_banner').position();
	var iSiteBannerWidth = $('#site_banner').width();
	//var iSiteLogoWidth = $('#site_logo').width();
	
	var iSiteLogoLeft = oSiteBanner.left + iSiteBannerWidth;
	
	$('#site_logo').css({ top : oSiteBanner.top + 'px', left : iSiteLogoLeft + 'px' }).show().bind('click', function() {
		location.href = '/';
	});	

	if ($('#fp_spotlight').length == 1) {
		
		
		var contract_html = $('#fp_spotlight_contract').html();
		
		$('#fp_spotlight').html(contract_html).css({ top : (oSiteBanner.top + 1) + 'px', left : (oSiteBanner.left + 2) + 'px' }).show().hover(fp_spotlight_expand, fp_spotlight_contract);	
	}
};


var gmap_side_bar_html = "";
var gmap_gmarkers = [];
var gmap_htmls = [];
var gmap_i = 0;

//google maps
function createMarker(point, name, html, letteredIcon) {
  	var marker = new GMarker(point, { icon:letteredIcon });
    GEvent.addListener(marker, "click", function() {
    	marker.openInfoWindowHtml('<div align="left">' + html + '</div>');
   	});
    marker.icon = 'b';
    // save the info we need to use later for the side_bar
    gmap_gmarkers[gmap_i] = marker;
    gmap_htmls[gmap_i] = html;
    // add a line to the side_bar html
    gmap_side_bar_html += '<a href="javascript:myclick(' + gmap_i + ')">' + name + '</a><br>';
    gmap_i++;
    return marker;
}

/*
| BANNERS
*/

var bannerHandle = function() {
	if($('#site_banner').length > 0)
	{
		var height = $('#site_banner').children(':first').children(':first').height();
		var width = $('#site_banner').children(':first').children(':first').width();
		
		$('#site_banner').height(height - 90);
		
		$('#bannerContainer').height(height);
		$('#bannerContainer').width(width);
		
		//$('#bannerTextContainer').css({opacity: '0.7'});
		//$('#bannerTextContainer').corner("30px");			
		
		setTimeout('bannerShowText()', 600);
		
		$( window ).wresize( position_banner_elems );
		
		position_banner_elems();
	}
}

var bannerShowText = function() {
	$('#bannerTextContainer').animate(
		{
			bottom: "-65px"
		},
		700
	);
}


var bannerHideText = function() {
	$('#bannerTextContainer').animate(
		{
			bottom: "-165px"
		},
		400
	);
}

/*
| END BANNERS
*/


function toggle_menu(el, id)
{
	if($('#'+id).length > 0)
	{
		var image = $(el).attr('src');
		
		if(image.search(/_down/) > -1)
		{
			image = image.replace(/_down/, "_right");
		}
		else
		{
			image = image.replace(/_right/, "_down");
		}
		
		$(el).attr('src', image);
		
		$('#'+id).slideToggle();
	}
}


$(document).ready(
	function() {
		$('#site_spotlights').innerfade({ speed: 1000, timeout: 2000, type: 'sequence', containerheight: '275px' });		
		$('#site_banner').innerfade({ speed: 2000, timeout: 6000, type: 'sequence', containerheight: '362px' });
	 	
	 	if ($.browser.msie && (parseInt($.browser.version) < 8)) {
			var iSiteBannerWidth = $('#site_banner').width();
			var iLiMarginLeft = '-' + Math.floor(iSiteBannerWidth / 2) + 'px';
			
			//$('#site_banner').children('li').css({ marginLeft : iLiMarginLeft });
	 	}
		
		bannerHandle();
	 	
		process_gmaps();
	}
);
