// JavaScript Document

//--- Element Declaration ---//
var HOME_MOVIE = "#homeMovie";
var HOME_MOVIE_IMG = "#homeMovieScroll";
var gbl_scrollCounter=0;
var SCROLL_IMAGES = new Array();
var timer;
var displayHero = 1;

pic1= new Image(); 
pic1.src="/images/home/LandingPage01.jpg";
SCROLL_IMAGES.push(pic1);
pic2= new Image(); 
pic2.src="/images/home/LandingPage02.jpg";
SCROLL_IMAGES.push(pic2);
pic3= new Image(); 
pic3.src="/images/home/LandingPage03.jpg";
SCROLL_IMAGES.push(pic3);



//--- On load execution ---//
$(function() {
		/*** Init Page ***/
		//Check if flash version is up to date.
		MM_CheckFlashVersion('8,0,0,0','Content on this page requires a newer version of Adobe Flash Player. Do you want to download it now?');
		
		/*** Page Events ***/
		//Add click event to the home movie image.
		$(HOME_MOVIE + " img").css({cursor:"pointer"}).click(function() {
			var iframeContent = '<iframe src="/movies/quickTour.jsp" width="480" height="360" scrolling="no" frameborder="0"></iframe>'
			$(HOME_MOVIE).html(iframeContent);								  
		});
		
		$("#heroArea").click(function() {
			clearTimeout(timer);						  
		});
		
		//setTimer();
		
});


//--- Page Functions---//
function changeMainInfo(content) {
	//Stop the auto rotation
	clearTimeout(timer);
	
	if (content=='standApart') {
		$("#saTble").show();
		$("#rmTble").hide();
	} else {
		$("#saTble").hide();
		$("#rmTble").show();
	}
		
}


function viewHomeSample(id) {
	//Stop the auto rotation
	clearTimeout(timer);
	
	var h = $(window).height();
		if (h>=1200) {
			h=1200;	
		}
		hWin = h-150;
		var w= Math.round((h*800)/1200);
		wWin = w -13;
		hPD = hWin-35;
		wPD = w - 10;
		
	//Need to detec if IE. If so pop up windwo rather thickbox.
	//Issue is that IE renders the embed inccrrectly.
	if ($.browser.msie) {
		//Is IE
		//popupWindow('/popMsgs/popSamples.jsp', "_blank", true , 640, 440,);
		
		windowOtherUse = window.open ("/popMsgs/popSamples.jsp?id="+id+"&w="+wPD+"&h="+hPD,name, "menubar=0, resizable=1,status=0, toolbar=0, location=0, directories=0, scrollbars=1, width="+wWin+",height="+hWin); 

	} else {
		//Not IE
		
	
		popupMessage("May not be displayed as actual size.", "popSamples.jsp", hWin, wWin, "id="+id+"&w="+wPD+"&h="+hPD+"&TB_iframe=1&modal=true");
	
		$("#homeMovie").hide();
	}
}

function homepageShowMovie() {
	$("#homeMovie").show();
}


/*
* Hero Area
*/
function setTimer() {
	/*
	if (displayHero == 0) {
		timer = setTimeout("switchHomeContent()", 5000);
	} else 	if (displayHero == 1) {
		timer = setTimeout("switchHomeContent()", 10000);
	}
	*/
	
	timer = setTimeout("switchHomeContent()", 5000);
}

function switchHomeContent() {
	clearTimeout(timer);
	
	var position;
	var elemFadeIn;
	var elemFadeOut;
	if (displayHero==1 || displayHero==3) {
		//First Image
		position = "-900px 0px";
		elemFadeIn = ".hero2";
		elemFadeOut = ".hero1";
		displayHero = 2;

	} else if (displayHero==2) {
		//Second Image
		position = "0px 0px";
		elemFadeIn = ".hero1";
		elemFadeOut = ".hero2";
		displayHero = 3;
	}
	
	$("#heroArea").stop().animate({backgroundPosition: position},500);
	$(elemFadeOut).hide();
	$(elemFadeIn).fadeIn(500);
	
	if (displayHero < 3) {
		setTimer();
	}
}

function heroCirleClicked() {
		
}
