// 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);								  
		});
		
		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;

	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();
}

function setTimer() {
	if (displayHero == 0) {
		timer = setTimeout("switchHomeContent()", 5000);
	} else 	if (displayHero == 1) {
		timer = setTimeout("switchHomeContent()", 10000);
	}
}

function switchHomeContent() {
	if (displayHero==0) {
		//Stand Apart.
		$("#saTble").show();
		$("#rmTble").hide();
		displayHero = 3;
	} else if (displayHero==1) {
		//Reach More Buyers.
		$("#saTble").hide();
		$("#rmTble").show();
		displayHero =0;
	}
	
	setTimer();
}