/*
	Helper functions for SVC Flash are accessed via ExternalInterface
*/

// Initialise pretty photo
$( document).ready( function()
{
//	var hideFlashForThisBrowser = !( $.browser.safari || $.browser.mozilla)
	
	$("").prettyPhoto(
		{
			animation_speed: 'fast', /* fast/slow/normal */
			opacity: 0.80,
			show_title: false,
			allow_resize: false,
			default_width: 640,
			default_height: 390,
			theme: 'light_rounded',
			hideflash: false,
			autoplay: true,
			modal: false,
			deeplinking: false,
			keyboard_shortcuts: false,
			callback: closeVideo,
			social_tools: false
		}
	);
});

var bannerAnimation;

function expandBanner( newHeight)
{
	// Default height for expansion
	newHeight = newHeight ? newHeight : 400;
	
	
	
	if(!document.getElementById("homeBanner").style.height){
		document.getElementById("homeBanner").style.height = "150px";
	}
	
	clearInterval( bannerAnimation );
	bannerAnimation = setInterval ( "windowTravel(\"homeBanner\",400,5)", 15 );
	
	//$("#homeBanner").css( "height", newHeight);
}

function shrinkBanner( newHeight)
{
	// Default height for shrinking
	newHeight = newHeight ? newHeight : 150;
	
	if(!document.getElementById("homeBanner").style.height){
		document.getElementById("homeBanner").style.height = "400px";
	}
	clearInterval( bannerAnimation )
	bannerAnimation = setInterval ( "windowTravel(\"homeBanner\",150,-5)", 15 );
	
	//$("#homeBanner").css( "height", newHeight);
}

function openImage( url, title, comment)
{
	$.prettyPhoto.open( url, title, comment);
}

function openVideo( url, title, comment)
{
	$.prettyPhoto.open( url, title, comment);
}

function closeVideo()
{
	if(document.getElementById("flashBanner")){
		$("#flashBanner")[0].closeVideo();
	}
}

function windowTravel(id,newheight,direction){
	var obj = document.getElementById(id);
	var currentHeight = parseInt(obj.style.height);
	
	currentHeight += direction;
	
	if((direction > 0 && currentHeight >= newheight) || (direction < 0 && currentHeight <= newheight)){
		currentHeight = newheight;
		clearInterval( bannerAnimation );
	}
	obj.style.height = currentHeight+"px";
	//alert(currentHeight);
}
