var $wWidth = window.innerWidth,

	$wHeight = window.innerHeight,

	$audiobreak;

	

$flashMovie = null;

$audioMovie = null;



$(document).ready(function() {

	

	

	var $vLeft = 0,

		$vTop = 0;

		

	$(".nav").removeAttr("href");

		

	$(".containerLeft").mouseenter(function() {

		$(".prev").css({'width':'1220px'}).css({'height':'790px'});

		

		$(this).mousemove(function(e) {

			var $width = 1220,

				$height = 790,

				onePerWidth = 634 / 100,

				onePerHeight = 400 / 100,

				onePerWidthBig = $width / 100,

				onePerHeightBig = $height / 100,

				top = e.pageY - $(this).offset().top,

				left = e.pageX - $(this).offset().left,

				perLeft = left / onePerWidth,

				perTop = top / onePerHeight,

				$marginLeft = perLeft * onePerWidthBig,

				$marginTop = (perTop * onePerHeightBig) - 100;

				

				

				//alert("Left: "+$marginLeft+"\n Top: "+$marginTop);

			$(".prev").css('margin-left','-'+parseInt($marginLeft)+'px').css('margin-top','-'+parseInt($marginTop)+'px');

		});

	});

	

	$(".containerLeft").mouseleave(function() {

		$(".prev").css({'width':'624px'}).css({'height':'404px'}).css('margin-top','-2px').css('margin-left','auto');

	});

	

	$vLeft = ($wWidth - 400) / 2;

	$vTop = ($wHeight - 300) / 2;

	

	$(".videoBackground").css({'left':$vLeft+'px'}).css({'top':$vTop+'px'});

	$(".video").css({'left':($vLeft + 10)+'px'}).css({'top':($vTop + 10)+'px'});

	

});



function test() {alert("TEST");}



function openVideo(video,title) {	

	$(".videoBackground").fadeIn('fast');

	$(".video").fadeIn('fast');

	

	$(".videoTitle").html(title);

	flashMovie = $('#flashInteract .movie');

	flashMovie.flash(

		{

			swf: 'media/video/'+video,

			width: 320,

			height: 240,

			play: false,

			loop: false,

		}

	);

	

	$(".closeImage").mouseenter(function() {

		$(this).css({'margin-top':'2px'}).css({'margin-right':'0px'}).css({'border':'1px solid #CCCCCC'});

	});

	

	$(".closeImage").mouseleave(function() {

		$(this).css({'margin-top':'3px'}).css({'margin-right':'1px'}).css({'border':''});

	});

}



function openAudio(audio,title) {

	var string = "<div class=\"audiopanel\"></div>";

		string += "<div class=\"audioControlle\">";

		string += "		<a onClick=\"audioPlay();\"><img src=\"img/playBig.jpg\" border=\"0\" style=\"cursor: pointer;\"></a><a onClick=\"audioBreak();\" style=\"cursor: pointer;\"><img src=\"img/breakBig.jpg\" border=\"0\"></a>";

		string += "</div>";

		string += "<div class=\"audioTitle\">";

		string += title;

		string += "</div>";

	$(".bottomContainerLeft").html(string);

	$audiobreak = 1;

	

	audioMovie = $(".audiopanel");

	audioMovie.flash(

		{

			swf: 'media/'+audio,

			width: 1,

			height: 1,

			play: false,

			loop: false,

		}

	);

}



function videoBreak() {

	flashMovie.flash(

		function() {

			this.StopPlay();

		}

	);

}



function videoPlay() {

	flashMovie.flash(

		function() {

			this.Play();

		}

	);

}



function closeVideo(video) {

	$(".videoBackground").fadeOut('fast');

	$(".video").fadeOut('fast');	

}



function audioPlay() {

	audioMovie.flash(

		function() {

			this.Play();

		}

	);

}



function audioBreak() {

	audioMovie.flash(

		function() {

			this.StopPlay();

		}

	);

}



function changeNavPage(page)

{

	if(page != 0)

	{

		$(".custNav").animate({'marginLeft':'-'+page*600+'px'},1000);	

	}

	else

	{		

		$(".custNav").animate({'marginLeft':'-40px'},1000);

	}

}	
