// JavaScript Document
function animationStart() {
	//reset main tiles because it is starting from the beginning.
	if (isPlaying == false) {
		$('#nav_banner').find(".large_tile").fadeOut(200);
		isPlaying = true;
		playTimer = setTimeout("cycle();",11000);
	}
}
function animationStop() {
	if (isPlaying == true) {
		isPlaying = false;
		clearTimeout(playTimer);
	}
	
}

function loop() {			
	$('#main_message')
		/*.find('#top_message')
			.fadeIn(600)
			.delay(1500)
			.fadeTo(300,0.2)
			.delay(200)
			.end()*/
		.find('#bottom_message1')
			.delay(2000)
			.fadeIn(500)
			.delay(1500)
			//.fadeOut(500) 
			.end() 
		/*.find('#bottom_message2')
			.delay(4700)
			.fadeIn(500)
			.delay(1500)
			.fadeOut(500)
			.end()*/
		/*.find('#top_message')	
			.delay(5000)
			.fadeTo(300,1.0)	*/
 }
 
	 function walkthrough() {		
		isPlaying = true;	
		loop();
		$('#nav_banner')	
			.find('.small_tile')			
				.fadeIn(700)
				.delay(6000)
				.fadeOut(500, function () {
				//.end()
					$('#nav_banner')			
						.find('#main_message')
						.delay(500)
						.fadeOut(200)
						.delay(500, cycle)								
		});		
	 }
		
		function cycle() {
			if (isPlaying) {			
				playTimer = setTimeout("cycle();",12500);
				var panelHoldTime = 2300;				
				$('#banner_nav').fadeIn(500);
				$('#nav_banner').find('#right_large')
						.delay(200)
						.fadeIn(500,update_nav(1))	
						.delay(panelHoldTime, checkstop(this))
						.fadeOut(300, function () {
							$('#nav_banner').find('#left_large')								
								.fadeIn(500,update_nav(2))
								.delay(panelHoldTime, checkstop(this))
								.fadeOut(300, function () {								
									$('#nav_banner').find('#panel_large')										
										.fadeIn(500,update_nav(3))
										.delay(panelHoldTime, checkstop(this))
										.fadeOut(300, function () {										
											$('#nav_banner').find('#center_large')												
												.fadeIn(500,update_nav(4))
												.delay(panelHoldTime, checkstop(this))
												.fadeOut(300)											
										});
								});
						});	
			} else {	
				clearTimeout(playTimer);
			}
				
		}
		
		function update_nav (i) {
			var index = i;
			// find button with '.nav-on' and remove class
			$("#banner_nav li a").each(function () {
				$(this).removeClass("nav-on");
			});
			// add '.nav-on' class to index
			$("#banner_nav li:nth-child(" + index + ") a").each(function () {
				$(this).addClass("nav-on");
			});
		}
		function checkstop (obj) {
			if (isPlaying == false) {
				$(obj).stop();
			}
		}
		
 $(document).ready(function() {

	 $(".brief img").each(function (){
	var briefImgStyle = $(this).attr("style");

		if(briefImgStyle != '' && briefImgStyle != null){
			if (!window.DOMParser || ($.browser.msie))	{
				$(this).css("margin" ,"10px;");
			}else{
				$(this).attr("style" ," margin:10px; "+briefImgStyle);
			}
		 }
    });
                  
 });




	/* $('a.loadDiv').click(
	 	function(e) {
			e.preventDefault();
			$(this).parent().fadeOut(200); //clear the current highlighted item (div)			
			var obj = $(this).attr("href"); //get the href as the id of the new div
			$(obj).fadeIn(500);  //fade in div with tile content.
			$('.message').fadeOut(200); //clear all divs with class message
		});		*/
		
	
