var MsgToID;
var FlashReady = false;
var PlayFlash = false;

$(document).ready(function(){
	MsgToID = window.setTimeout("NextMessage()",GetDelayFromClass($(".homesplashquote:visible")));
	window.setTimeout("NextCaseStudy()",7000);
	$("a[href='#vid']").click(function(event){
		$("#homesplash").fadeOut("slow");
		//alert($("#homevidmovie"));
		//var mov = getFlashMovieObject("homevidmovie");
		//alert(mov.Play());
		PlayHomeVid();
	});
});

function NextMessage(){
	if ($(".homesplashquote").length > 1) {
		$(".homesplashquote:visible").fadeOut("slow");
		nxt = ($(".homesplashquote:visible + .homesplashquote").length > 0) ? $(".homesplashquote:visible + .homesplashquote") : $(".homesplashquote:first");
		nxt.fadeIn("slow");
		MsgToID = window.setTimeout("NextMessage()",GetDelayFromClass(nxt));
	}
}

function NextCaseStudy(){
	if ($(".homecasestudy").length > 1) {
		$(".homecasestudy:visible").fadeOut("slow");
		nxt = ($(".homecasestudy:visible + .homecasestudy").length > 0) ? $(".homecasestudy:visible + .homecasestudy") : $(".homecasestudy:first");
		nxt.fadeIn("slow");
		window.setTimeout("NextCaseStudy()",7000);
	}
}

function GetDelayFromClass(el) {
	delay = parseInt(el.attr("class").replace('homesplashquote delay',''));
	return (isNaN(delay)) ? 5000 : parseInt(el.attr("class").replace('homesplashquote delay',''));
}

function getFlashMovieObject(movieName)
{
  if (navigator.appName.indexOf("Microsoft Internet")==-1)
  {
    if (document.embeds && document.embeds[movieName])
      return document.embeds[movieName]; 
  }
  if (window.document[movieName]) 
  {
      return window.document[movieName];
  }
  else
  {
    return document.getElementById(movieName);
  }
}
 
function movieReady(value) {
	//alert("ready");
	FlashReady = true;
	if (PlayFlash)
		getFlashMovieObject("homevidmovie").playVideoFlash();
}

function PlayHomeVid() {
	PlayFlash = true;
	if (FlashReady)
		getFlashMovieObject("homevidmovie").playVideoFlash();
}