var jumingStopper = 0;
var QueryLoader = {
	/*
	 * QueryLoader		Preload your site before displaying it!
	 * Author:			Gaya Kessler
	 * Date:			23-09-09
	 * URL:				http://www.gayadesign.com
	 * Version:			1.0
	 * 
	 * A simple jQuery powered preloader to load every image on the page and in the CSS
	 * before displaying the page to the user.
	 */
	
	overlay: "",
	loadBar: "",
	preloader: "",
	items: new Array(),
	doneStatus: 0,
	doneNow: 0,
	selectorPreload: "body",
	ieLoadFixTime: 2000,
	ieTimeout: "",
	
	init: function() {
		if (navigator.userAgent.match(/MSIE (\d+(?:\.\d+)+(?:b\d*)?)/) == "MSIE 6.0,6.0") {
			//break if IE6			
			return false;
		}
		if (QueryLoader.selectorPreload == "body") {
			QueryLoader.spawnLoader();
			QueryLoader.getImages(QueryLoader.selectorPreload);
			QueryLoader.createPreloading();
		} else {
			$(document).ready(function() {
				QueryLoader.spawnLoader();
				QueryLoader.getImages(QueryLoader.selectorPreload);
				QueryLoader.createPreloading();
			});
		}
		
		//help IE drown if it is trying to die :)
		QueryLoader.ieTimeout = setTimeout("QueryLoader.ieLoadFix()", QueryLoader.ieLoadFixTime);
	},
	
	ieLoadFix: function() {
		var ie = navigator.userAgent.match(/MSIE (\d+(?:\.\d+)+(?:b\d*)?)/);
		if (ie[0].match("MSIE")) {
			while ((100 / QueryLoader.doneStatus) * QueryLoader.doneNow < 100) {
				QueryLoader.imgCallback();
			}
		}
	},
	
	imgCallback: function() {
		QueryLoader.doneNow ++;
		QueryLoader.animateLoader();
	},
	
	getImages: function(selector) {
		var everything = $(selector).find("*:not(script)").each(function() {
			var url = "";
			
			if ($(this).css("background-image") != "none") {
				var url = $(this).css("background-image");
			} else if (typeof($(this).attr("src")) != "undefined" && $(this).attr("tagName").toLowerCase() == "img") {
				var url = $(this).attr("src");
			}
			
			url = url.replace("url(\"", "");
			url = url.replace("url(", "");
			url = url.replace("\")", "");
			url = url.replace(")", "");
			
			if (url.length > 0) {
				QueryLoader.items.push(url);
			}
		});
	},
	
	createPreloading: function() {
		QueryLoader.preloader = $("<div></div>").appendTo(QueryLoader.selectorPreload);
		$(QueryLoader.preloader).css({
			height: 	"0px",
			width:		"0px",
			overflow:	"hidden"
		});
		
		var length = QueryLoader.items.length; 
		QueryLoader.doneStatus = length;
		
		for (var i = 0; i < length; i++) {
			var imgLoad = $("<img></img>");
			$(imgLoad).attr("src", QueryLoader.items[i]);
			$(imgLoad).unbind("load");
			$(imgLoad).bind("load", function() {
				QueryLoader.imgCallback();
			});
			$(imgLoad).appendTo($(QueryLoader.preloader));
		}
	},

	spawnLoader: function() {
		if (QueryLoader.selectorPreload == "body") {
			var height = $(window).height();
			var width = $(window).width();
			var position = "fixed";
		} else {
			var height = $(QueryLoader.selectorPreload).outerHeight();
			var width = $(QueryLoader.selectorPreload).outerWidth();
			var position = "absolute";
		}
		var left = $(QueryLoader.selectorPreload).offset()['left'];
		var top = $(QueryLoader.selectorPreload).offset()['top'];
		
		QueryLoader.overlay = $("<div></div>").appendTo($(QueryLoader.selectorPreload));
		$(QueryLoader.overlay).addClass("QOverlay");
		$(QueryLoader.overlay).css({
			position: position,
			top: top,
			left: left,
			width: width + "px",
			height: height + "px"
		});
		
		QueryLoader.loadBar = $("<div></div>").appendTo($(QueryLoader.overlay));
		$(QueryLoader.loadBar).addClass("QLoader");
		
		$(QueryLoader.loadBar).css({
			position: "relative",
			top: "50%",
			width: "0%"
		});
		
		QueryLoader.loadAmt = $("<div>0%</div>").appendTo($(QueryLoader.overlay));
		$(QueryLoader.loadAmt).addClass("QAmt");
		
		$(QueryLoader.loadAmt).css({
			position: "relative",
			top: "50%",
			left: "50%"
		});
	},
	
	animateLoader: function() {
		
		var perc = (100 / QueryLoader.doneStatus) * QueryLoader.doneNow;
		if (perc > 99) {
			$(QueryLoader.loadAmt).html("100%");
			$(QueryLoader.loadBar).stop().animate({
				width: perc + "%"
			}, 500, "linear", function() { 
				QueryLoader.doneLoad();
			});
			//Here goes raja's animation 
			//its jumping tooo much in IE , more then once ..so lets stop
			//alert(jumingStopper);
			if(jumingStopper!=1){
				$("#gt_logo").animate({"top": "+=10px"}, 1000,"easeInElastic"); 
				$("#gt_logo").animate({"top": "-=10px"}, 1000,"easeInElastic"); 
			
				$("#cut_paper").animate({"top": "+=100px"}, 1000,"easeOutElastic"); 
				$("#cut_paper").animate({"top": "-=100px"}, 1000,"easeOutElastic"); 
				jumingStopper=1;
			}
		} else {
			
			$(QueryLoader.loadBar).stop().animate({
				width: perc + "%"
			}, 500, "linear", function() { });
			$(QueryLoader.loadAmt).html(Math.floor(perc)+"%");
		}
	},

	doneLoad: function() {
		//prevent IE from calling the fix
		clearTimeout(QueryLoader.ieTimeout);
		
		//determine the height of the preloader for the effect
		if (QueryLoader.selectorPreload == "body") {
			var height = $(window).height();
		} else {
			var height = $(QueryLoader.selectorPreload).outerHeight();
		}
		
		//The end animation, adjust to your likings
		$(QueryLoader.loadAmt).hide();
		$(QueryLoader.loadBar).animate({
			height: height + "px",
			top: 0
		}, 0, "linear", function() {
			$(QueryLoader.overlay).fadeOut(800);
			$(QueryLoader.preloader).remove();
		});

var speed5= 300;
var speed8= 350;
var jumingStopper	 = 0;
if(page =="home"){
//lets animate homey 
$('#hand2').css('display','inline');	
$("#bandaid").animate({"top": "-=700px"},speed5);
$("#hand2").animate({"top": "-=700px"},speed5 , function () { 
$("#hand2").animate({"top": "+=700px"},speed5,function (){

$("#quote").animate({"top": "-=575px"},speed5);												
$("#hand2").animate({"top": "-=575px"},speed5,function(){
$("#hand2").animate({"top": "+=575px"},speed5,function(){

$('#hand2').css('left','750px');	

//$('#hand2').css('display','none');
//$("#home_news").animate({"top": "-=741px"},speed5);

//$("#hand2").animate({"top": "-=741px"},speed5,function(){
//$("#hand2").animate({"top": "+=741px"},speed5,function(){
													
//$("#fb_likes").animate({"top": "-=425px"},speed5);

//$("#hand2").animate({"top": "-=425px"},speed5,function(){
//$("#hand2").animate({"top": "+=425px"},speed5,function(){
$('#hand2').css('display','inline');
$("#coin").animate({"top": "-=738px"},speed5);													

$('#hand2').css('left','920px');	

$("#hand2").animate({"top": "-=738px"},speed5,function(){
$("#hand2").animate({"top": "+=738px"},speed5,function(){												
$('#hand2').css('left','330px');

$("#home_center").animate({"top": "-=751px"},speed5);
$("#hand2").animate({"top": "-=751px"},speed5,function(){
													
$("#hand2").animate({"top": "+=729px"},speed5,function(){
$("#home_download_porfile").animate({"top": "-=240px"},speed5);
$("#hand2").animate({"top": "-=240px"},speed5,function(){
$("#hand2").animate({"top": "+=240px"},speed5,function(){

$('#hand2').css('left','475px');

$("#join-our-team").animate({"top": "-=226px"},speed5);
$("#hand2").animate({"top": "-=226px"},speed5,function(){



$('#hand2').css('top','900px');
$('#hand2').css('left','25px');

$("#home_weather").animate({"top": "-=364px"},speed5);


$("#hand2").animate({"top": "-=364px"},speed5,function(){
$("#hand2").animate({"top": "+=364px"},speed5,function(){

$('#hand2').css('left','0px');

$("#social_home_links").animate({"top": "-=226px"},speed5);
$("#hand2").animate({"top": "-=250px"},speed8,function(){


$('#hand2').css('left','100px');
$('#hand2').css('top','900px');

$("#the_alone_pen").animate({"top": "-=131px"},speed5);

$("#hand2").animate({"top": "-=156px"},speed5);

$("#hand2").animate({"top": "+=100px"},speed5,function(){


$('#hand2').css('display','none');

//lets unfreez the main hand , and go go 
$('#hand').css('display','inline');	
activeCheck=true;	
									
//lets start side animation


//if(browserWidth > 1360) { 

$("#pins").animate({"left": "+=418px"},speed5);
$('#hand6').css('display','inline');	  
	  $("#hand6").animate({"left": "+=300px"},speed5, function (){
		  $("#hand6").animate({"left": "-=300px"},speed5, function (){ 
			  $("#clock").animate({"left": "+=305px"},speed5);
			  		$('#hand6').css('display','none');
					$('#hand7').css('display','inline');
					$("#hand7").animate({"left": "+=250px"},speed5, function (){	
					  $("#hand7").animate({"left": "-=250px"},speed5, function (){	
						  $("#money").animate({"left": "+=400px"},speed5);																			   								$('#hand7').css('display','none');
						  		$('#hand8').css('display','inline');
								$("#hand8").animate({"left": "+=338px"},speed5, function (){
								  $("#hand8").animate({"left": "-=418px"},speed5, function (){
									  $("#car").animate({"left": "+=290px"},speed5);
										  $("#hand8").animate({"left": "+=290px"},speed5, function (){
$("#hand8").animate({"left": "-=250px"},speed5, function (){ 
$("#hard_gt_sticky").animate({"left": "+=300px"},speed5);
$('#hand8').css('display','none');
$('#hand9').css('display','inline');
	$("#hand9").animate({"left": "+=250px"},speed5, function (){ }); 
		$("#hand9").animate({"left": "-=250px"},speed5, function (){ 
			$("#car_key").animate({"right": "+=450px"},speed5);
				$('#hand9').css('display','none');
				$('#hand10').css('display','inline');
				$("#hand10").animate({"right": "+=160px"},speed5, function (){ 
					$("#hand10").animate({"right": "-=160px"},speed5, function (){ 
						$("#zippo").animate({"right": "+=490px"},speed5);
							$('#hand10').css('display','none');
							$('#hand11').css('display','inline');
							$("#hand11").animate({"right": "+=160px"},speed5, function (){ 
								$("#hand11").animate({"right": "-=160px"},speed5, function (){
											$('#hand11').css('display','none');
																						});
																					 
});	
						



});
																																				});	
															   
															   
															   
}); 													   
});																								});
});																																																		});
});																																																			});
});
});
//																				  }






});
});
});
});
});
//lets end side animation
});



});




});

});
										 
});


});


//});


//});



});													




//});
//});																																						

});


});	


});
//animation finish of the homey
}else{ // this is not good for home , so we write extra for home animation
$("#home_sticky").animate({"top": "-=594px"},speed5);

/*if(page!="portfolio" && page!="fun"){ //coz there is no IPhone on these pages .*/
	$('#hand2').css('display','inline');
	$("#hand2").animate({"top": "-=594px"},speed5);
/*}*/

if(page=="home"){
	$('#hand3').css('display','none');	
}
$('#hand2').css('display','inline');
$("#hand2").animate({"top": "+=594px"},speed5 , function () {
			$("#bandaid").animate({"top": "-=418px"},speed5);													   			
			$("#hand2").animate({"top": "-=418px"},speed5);
			$("#hand2").animate({"top": "+=418px"},speed5, function (){
				$("#quote").animate({"top": "-=390px"},speed5);	
				$("#hand2").animate({"top": "-=390px"},speed5, function (){
				$("#hand2").animate({"top": "+=390px"},speed5, function (){
				$("#social_home_links").animate({"top": "-=187px"},speed5);	
							$("#hand2").animate({"top": "-=187px"},speed5, function (){
							$("#hand2").animate({"top": "+=187px"},speed5, function (){	
									
									
									
									
									$('#hand2').css('left','100px');
									$('#hand2').css('top','900px');
	
									$("#the_alone_pen").animate({"top": "-=131px"},speed5);

									$("#hand2").animate({"top": "-=156px"},speed5,function(){

									$("#hand2").animate({"top": "+=100px"},speed5,function(){



									
									
									
							
				$('#hand2').css('display','none');

				$('#hand3').css('display','inline');

				$("#hand3").animate({"top": "-=520px"},speed5);
				
				$("#pink_note").animate({"top": "-=720px"},speed5, function (){ 
					$("#hand3").animate({"top": "+=720px"},speed5, function (){ 
						$("#hand3").animate({"top": "-=450px"},speed5);
						$("#note3").animate({"top": "-=450px"},speed5, function (){
							$("#hand3").animate({"top": "+=450px"},speed5, function (){
									
									$('#hand3').css('display','none');
									
									$('#hand4').css('display','inline');

									$("#hand4").animate({"top": "-=550px"},speed5);
									$("#note1").animate({"top": "-=650px"},speed5, function (){
										$("#hand4").animate({"top": "+=550px"},speed5, function (){
												
												$('#hand4').css('display','none');
												
												$('#hand3').css('display','inline');

												$("#hand3").animate({"top": "-=450px"},speed5);
												$("#notepad").animate({"top": "-=738px"},speed5);
												if(pageToAnimate==""){ pageToAnimate = "#page_text1"; }
												$(pageToAnimate).animate({"top": "-=738px"},speed5, function (){											//alert(activeDiv);
													$("#hand3").animate({"top": "+=550px"},speed5 , function (){
													$('#hand3').css('display','none');
			
													$('#hand').css('display','inline');	
													activeCheck=true;											   
});
});
});																						  										
});
});
});
});

});
});
});
});
});
});
});													   		
});




//$("#cards").animate({"top": "-=660px"},speed5);
$('#hand5').css('display','inline');
//$("#hand5").animate({"top": "-=660px"},speed5, function () {
//	$("#hand5").animate({"top": "+=660px"},speed5, function(){
		if(page=="portfolio"){
		$('#hand5').css('display','none');
		}
		if(page=="fun"){
		$('#hand5').css('display','none');
		}
		
		$("#home_download_porfile").animate({"top": "-=733px"},speed5);
			$("#hand5").animate({"top": "-=720px"},speed5, function (){
			$("#hand5").animate({"top": "+=720px"},speed5, function(){
				$("#iphone4").animate({"top": "-=594px"},speed5);
				if(page!="portfolio" && page!="fun")
				$('#iphoone_hand').css('display','inline');
				$("#iphoone_hand").animate({"top": "-=594px"},speed5, function (){
					$("#iphoone_hand").animate({"top": "+=594px"},speed5 , function (){
						$("#coin").animate({"top": "-=704px"},speed8);
						$('#iphoone_hand').css('display','none');
						$('#hand5').css('display','inline');
						$('#hand5').css('left','940px');
						$("#hand5").animate({"top": "-=704px"},speed8, function (){
							$("#hand5").animate({"top": "+=704px"},speed5, function (){
								$('#hand5').css('display','none');

									
//lets animate sides .
//simle animatioon 
/*
$("#pins").animate({"left": "+=418px"},speed5);
$("#car").animate({"left": "+=352px"},speed5);
$("#car_key").animate({"right": "+=450px"},speed5);
$("#zippo").animate({"right": "+=490px"},speed5);
$("#hard_gt_sticky").animate({"left": "+=300px"},speed5);
$("#money").animate({"left": "+=481px"},speed5);
$("#clock").animate({"left": "+=305px"},speed5);
*/
//if(browserWidth > 1360) { 

$("#pins").animate({"left": "+=418px"},speed5);
$('#hand6').css('display','inline');	  
	  $("#hand6").animate({"left": "+=300px"},speed5, function (){
		  $("#hand6").animate({"left": "-=300px"},speed5, function (){ 
			  $("#clock").animate({"left": "+=305px"},speed5);
			  		$('#hand6').css('display','none');
					$('#hand7').css('display','inline');
					$("#hand7").animate({"left": "+=250px"},speed5, function (){	
					  $("#hand7").animate({"left": "-=250px"},speed5, function (){	
						  $("#money").animate({"left": "+=400px"},speed5);																			   								$('#hand7').css('display','none');
						  		$('#hand8').css('display','inline');
								$("#hand8").animate({"left": "+=338px"},speed5, function (){
								  $("#hand8").animate({"left": "-=418px"},speed5, function (){
									  $("#car").animate({"left": "+=290px"},speed5);
										  $("#hand8").animate({"left": "+=290px"},speed5, function (){
$("#hand8").animate({"left": "-=250px"},speed5, function (){ 
$("#hard_gt_sticky").animate({"left": "+=300px"},speed5);
$('#hand8').css('display','none');
$('#hand9').css('display','inline');
	$("#hand9").animate({"left": "+=250px"},speed5, function (){ }); 
		$("#hand9").animate({"left": "-=250px"},speed5, function (){ 
			$("#car_key").animate({"right": "+=450px"},speed5);
				$('#hand9').css('display','none');
				$('#hand10').css('display','inline');
				$("#hand10").animate({"right": "+=160px"},speed5, function (){ 
					$("#hand10").animate({"right": "-=160px"},speed5, function (){ 
						$("#zippo").animate({"right": "+=490px"},speed5);
							$('#hand10').css('display','none');
							$('#hand11').css('display','inline');
							$("#hand11").animate({"right": "+=160px"},speed5, function (){ 
								$("#hand11").animate({"right": "-=160px"},speed5, function (){
											$('#hand11').css('display','none');
																						});
																					 
});	
						



});
																																				});	
															   
															   
															   
}); 													   
});																								});
});																																																		});
});																																																			});
});
});
//																				  }
});																			  
});
});																	  
});
//});
//});
});													  
});
})};
}
}
