$(document).ready(function(){

$(".home-bubbles div img").animate({"left":"0px", "top":"0px"},400);
	// Bouncer animation (by Leo Xavier)
	// BASE SPEED OF BOUNCING. WILL ADD RAINDOM 0-100 TO UNSYNC BOUNCING
	var bouncespeed = 1300;
	
	// SELECT ALL A'S EXCEPT... RESET BG-POSITION TO AVOID INITIAL POSITION BUG AND CALL BOUNCER
	$('img.float').each(
		function () {
			$(this).css({'marginLeft': '5px', 'marginTop':'5px'});
			bounce(this);
		}
	);
	
	// ACTUAL BOUNCER. CALLBACK OF ANIMATION IS THE BOUNCER ITSELF, TO LOOP ALL NIGHT LONG
	function bounce(currentA) {
		newx = Math.floor(80*Math.random());
		newy = Math.floor(70*Math.random());
		newspeed = bouncespeed + Math.floor(10*Math.random());
		$(currentA).animate({'marginLeft': newx+'px', 'marginTop': newy+'px'}, newspeed, 'linear', function() { bounce(currentA);});
	}
	
////////
///////////////////////////////
$(".sub-navigation a, .crew-polaroid img, .extras-polaroid img").click(function(){
var id = $(this).attr("id");
$(".sub-navigation a").removeClass("current");
$(".sub-navigation a#"+id).addClass("current");
$(".sub-pages span").hide();
$(".sub-pages span."+id).show();

if(ie==1)
{
$(".crew-polaroid-persons img").css({"top":"30px"});
}
else
{
$(".crew-polaroid-persons img").css({"top":"-600px"});
$(".crew-polaroid-persons img, .crew-polaroid div img, .extras-polaroid div img").rotate(0);
$(".crew-polaroid-persons img").animate({"top":"30px"},500, function(){$(this).rotate({animateTo:10});});
}
$(".crew-polaroid div img").fadeIn("fast", function(){$(this).animate({"left":"0px", "top":"0px"},400, function(){$(".crew-polaroid div img:first").rotate({animateTo:-10});$(this).rotate({animateTo:20});$(".crew-polaroid div img:last").rotate({animateTo:-20});})});

$(".extras-polaroid div img").animate({"left":"0px", "top":"0px"},300, function(){
$(".extras-polaroid div img:first").rotate({animateTo:10});
$(".extras-polaroid div img:eq(2)").rotate({animateTo:8});
$(".extras-polaroid div img:eq(3)").rotate({animateTo:16});
//$(".extras-polaroid div img:eq(4)").rotate({animateTo:-11});
$(".extras-polaroid div img:last").rotate({animateTo:-10});
});




});


////////////////////////////

$(".backlot-photos img").animate({"top":"0px"}, function(){$(".backlot-photos img:first").rotate({animateTo:-7});$(".backlot-photos img:last").rotate({animateTo:7});});
/////////
$(".locga-images img.car").animate({"left":"-50px", "top":"25px"},1200, function(){$(this).rotate({animateTo:2});});
/////////////////
load_next();
function load_next()
{
$(".credits-holder img[class!='loaded']:first").addClass("loaded").fadeIn("slow", function(){
													   
													   $(this).animate({"left":"0px", "top":"0px", "bottom":"0px"},100);

													   });

setTimeout(function(){
					   load_next();
					},20);
}











});











function enter_website()
{
$(".movie-container").fadeOut("fast", function(){$(this).remove();
$(".navigation").fadeIn("slow", function(){$(".container, .facebook-like, .footer").fadeIn("slow")});
$.ajax({
type: "POST",
url: "start_session.php",
cache: false,
success: function(html){
	
}
});

});	
}


function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
