

var SwitchAnimations= function (){
	this.hidePreloader=function(){
		$("#preloader").stop().animate({opacity:0}, 2000, "linear", function(){
			$(this).css({"display":"none"});
		});
	}
	this.showPreloader=function(){
		$("#preloader").css({"display":"inline"});
		$("#preloader").stop().animate({opacity:1}, 2000);
	}
	
	this.showMain= function(){
		this.hidePreloader();
		$("#switchBox img").hide();
		$("#bottomBackground").stop().animate({
			"top": "325"
		}, "slow", function(){
			$("#switchBox").show();
			$("#foother").show();
			
			$("#logoBox").show("drop",{} , 1000,  function(){
				$("#switchBox img").show("fold",{} , 1000);
				//'blind', 'clip', 'drop', 'explode', 'fold', 'puff', 'slide', 'scale', 'size', 'pulsate'.
			});
			$("#foother").fadeIn();
		});

		
	}

	this.hideMain=function(){
		
		$("#switchBox img").hide("puff",{} , 500, function(){
			$("#switchBox img").css("width", "230px");
			$("#switchBox img").css("height", "288px");
			$("#switchBox").hide();
		});
		$("#logoBox").hide("drop",{} , 1000, function(){
			
		});
		this.showPreloader();
			//'blind', 'clip', 'drop', 'explode', 'fold', 'puff', 'slide', 'scale', 'size', 'pulsate'.
	}

	this.showSubPage= function(page, fcolor, bcolor, image){
		this.hidePreloader();
		$("#foother").show();
		$("#bottomBackground").stop().animate({
			"top": "425"
		}, "slow");
		
		$("#dataBox").css({"display":"inline", "opacity":"0"});
		$("#dataBox").stop().animate({
			opacity: 1
		}, 1600);
		$("#menuBox").stop().animate({top:'-80'},1000 , "easeOutElastic",  function(){
			$("#menuBox a[href!=#"+page+"] img").stop().animate({"margin-top":"0"}, {queue:false, duration:600, easing: 'easeOutBounce'});
			$("#menuBox a[href=#"+page+"] img").stop().animate({"margin-top":"50"}, {queue:false, duration:600, easing: 'easeOutBounce'});
			//'blind', 'clip', 'drop', 'explode', 'fold', 'puff', 'slide', 'scale', 'size', 'pulsate'.
		});

	}
	this.hideContent=function(){
		$("#dataBox").stop().animate({
			opacity: 0
		}, 1600,"linear");
	}
	this.showContent=function(page){
		this.hidePreloader();
		$("#menuBox img").stop().animate({"margin-top":"0"}, 600, "easeOutBounce", function(){
			$("#menuBox a[href=#"+page+"] img").stop().animate({"margin-top":"50"}, {queue:false, duration:600, easing: 'easeOutBounce'});
		});
		
		$("#dataBox").stop().animate({
			opacity: 1
		}, 1600,"linear");
	}
	
	this.hideSubPage= function(){
		$("#menuBox img").stop().animate({"margin-top":"0"}, "slow");
		$("#dataBox").stop().animate({
			opacity: 0
		}, 1600,"linear", function(){
			$("#dataBox").css({"display":"none"});
			
			$("#menuBox").stop().animate({top:'-140'},1000 , "easeInElastic", function(){
				$("#menuBox img").css({"margin-top":"0"});
			});
		});
		this.showPreloader();
	}
}

function hider(){
	var switcher=new SwitchAnimations();
	switch(slide){
		case 0:{
			switcher.hidePreloader();
		}break;
		case 1:{
			switcher.hideMain();
		}break;
		case 2:{
			//switcher.hideSubPage();
		}break;
	}
}


function initAnimations(){
	$('.button img').mouseover(function(){
		if(slide==1)
		slideUp(this);
	}).mouseout(function(){
		if(slide==1)
		slideDown(this);
	});
	
	$('.menuButton img').mouseover(function(){
		littleSlideDown(this);
	}).mouseout(function(){
		littleSlideUp(this);
	});
}

function slideUp (object){
	$(object).parent().parent().attr("style", "z-index:5");
	$(object).stop().animate({
		"width": "340",
		"height" : "420"
	}, "slow", function(){

	});
}

function slideDown(object){
	$(object).parent().parent().attr("style", "z-index:4");
	$(object).stop().animate({
		"width": "230",
		"height" : "288"
	}, "slow", function(){

	});
}

function littleSlideUp (object){
	if("#"+pageName==$(object).parent().attr("href"))
		$(object).stop().animate({"margin-top":"50"}, {queue:false, duration:600, easing: 'easeOutBounce'});
	else
		$(object).stop().animate({"margin-top":"0"}, {queue:false, duration:600, easing: 'easeOutBounce'});
	
}

function littleSlideDown(object){
	$(object).stop().animate({"margin-top":"60"}, {queue:false, duration:600, easing: 'easeOutBounce'});
}
