/*==================================================================================================
	TERRAIN
	------------------------------------------------------------------------------------------------
	Custom Functions
	
	Author: JA, WebLinc
	Date Created: 03.31.2008
	
--------------------------------------------------------------------------------------------------*/

/*======================================
	FLASH ON
----------------------------------------
	Replace html content with 
	Flash intro
--------------------------------------*/

$(document).ready(function() { 
	if( (parseInt(jQuery.fn.flash.hasFlash.playerVersion()) >= 8) && !(document.cookie && document.cookie.indexOf("flashLoaded")>-1) ) {

		jQuery("#flash-intro").empty().flash({
			src: "/resources/site1/flash/intro/terrain_intro.swf",
			width: "100%",
			height: "100%",
			menu: "false",
			wmode: "transparent"
		});

	} else {
		flashOff();
		contentOn();
	}
});


/*======================================
	FLASH OFF
----------------------------------------
	Remove flash
--------------------------------------*/
function flashOff() {
	jQuery("#flash-intro").addClass("inactive");
}


/*======================================
	CONTENT ON
----------------------------------------
	Load html content behind Flash, 
	so it is visible when Flash fades
--------------------------------------*/
function contentOn() {
	document.cookie = 'flashLoaded=1; path=/';
	jQuery("body").removeClass("blank");
 	jQuery("#main-container").removeClass("shift").addClass("active");
}

/*======================================
	Modal Window
----------------------------------------
	Jon Bytof - 2009-06-26
--------------------------------------*/
function callEventModal(){
	var $eventContent = $.trim($($(this).attr('href')).html()),
		$modalOverlay = $('#modal-overlay'),
		$modalWindow = $('#modal-window'),
		$modalContent = $('#modal-content');
	
	$modalOverlay.hide();
	$modalWindow
		.hide()
		.find('a.modal-close').click(function(){
			$modalOverlay.hide();
			$modalWindow.hide();
			return false;
		});
		
	$modalContent.html($eventContent);
	
	$modalWindow.css({
		'top': $(window).scrollTop() + ($(window).height() - $modalWindow.height())/2,
		'left': ($(window).width() - $modalWindow.width())/2
	});
	
	if($.browser.msie){
		$modalOverlay.show();
		$modalWindow.show();
	} else {
		$modalOverlay.fadeIn("fast");
		$modalWindow.fadeIn("fast");
	}
	return false;
}

