var position_banner_elems = function() {
	var oSiteBanner = $('#site_banner').position();
	var iSiteBannerWidth = $('#site_banner').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();

		if (bannerTexts[0] != "")
			setTimeout('bannerShowText()', 600);
	}
}

var bannerShowText = function() {

	$('#bannerTextContainer').animate(
		{
			opacity: "1"
		},
		600
	);

}


var bannerHideText = function() {

	$('#bannerTextContainer').animate(
		{
			opacity: "0"
		},
		600
	);

}

/*
| 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: 2000, timeout: 4000, type: 'sequence', containerheight: '275px' });		
		$('#site_banner').innerfade({ speed: 2000, timeout: 6000, type: 'sequence', containerheight: '362px' });
		bannerHandle();
		process_gmaps();
		$(".submenu").css({"opacity": 0.94});
		$('.lightbox').lightBox({
				imageLoading: '/media/images/lightbox/lightbox-imageBlank.gif',
				imageLoading: '/media/images/lightbox/lightbox-ico-loading.gif',
				imageBtnClose: '/media/images/lightbox/lightbox-btn-close.gif',
				imageBtnPrev: '/media/images/lightbox/lightbox-btn-prev.gif',
				imageBtnNext: '/media/images/lightbox/lightbox-btn-next.gif'
		});
	}
);
