current_page="21";
scene_height=1020;
main_height=850;
testimonials_height=1000;
		
var options_testimonials = {
	target: "#div_testimonials_form",
	type: "POST",
	clearForm: true
};
var options_settestimonial = {
	target: "#div_settestimonial_form",
	type: "POST",
	clearForm: true
};
var options_contacts = {
	target: "#div_contacts_form",
	type: "POST",
	clearForm: true
};
var options_library = {
	target: "#div_library_form",
	type: "POST",
	clearForm: true
};


$(document).ready(function(){

	$(".js").css("display","block");
	
	$.positionAll(current_page,0);
	
	$("#testimonials_form").ajaxForm(function() {
		$("#testimonials_form").ajaxSubmit(options_testimonials);
	});
	$("#settestimonial_form").ajaxForm(function() {
		$("#settestimonial_form").ajaxSubmit(options_settestimonial);
	});
	$("#contacts_form").ajaxForm(function() {
		$("#contacts_form").ajaxSubmit(options_contacts);
	});
	$("#library_form").ajaxForm(function() {
		$("#library_form").ajaxSubmit(options_library);
	});
	
	$(".show_library_form").click(function(){
		$.showCloseForm("#library_div",1)
		return false;
	});
	$(".close_library_form").click(function(){
		$.showCloseForm("#library_div",0)
		return false;
	});
	$(".show_contacts_form").click(function(){
		$.showCloseForm("#contacts_div",1)
		return false;
	});
	$(".close_contacts_form").click(function(){
		$.showCloseForm("#contacts_div",0)
		return false;
	});
	$(".show_testimonials_form").click(function(){
		$.showCloseForm("#testimonials_div",1)
		return false;
	});
	$(".close_testimonials_form").click(function(){
		$.showCloseForm("#testimonials_div",0)
		return false;
	});
	$(".show_settestimonial_form").click(function(){
		$.showCloseForm("#settestimonial_div",1)
		return false;
	});
	$(".close_settestimonial_form").click(function(){
		$.showCloseForm("#settestimonial_div",0)
		return false;
	});
	
	
	$(".menu11").click(function(){
		$.closeAllForms();
		$.positionAll("11",1500);
		current_page="11";
		return false;
	});
	
	$(".menu12").click(function(){
		$.closeAllForms();
		$.positionAll("12",1500);
		current_page="12";
		return false;
	});
	
	$(".menu13").click(function(){
		$.closeAllForms();
		$.positionAll("13",2500);
		current_page="13";
		return false;
	});
	
	$(".menu21").click(function(){
		$.closeAllForms();
		$.positionAll("21",1500);
		current_page="21";
		return false;
	});
	
	$(".menu22").click(function(){
		$.closeAllForms();
		$.positionAll("22",1500);
		current_page="22";
		return false;
	});   
	
	$(".menu23").click(function(){
		$.closeAllForms();
		$.positionAll("23",2500);
		current_page="23";
		return false;
	});  
	
	$(".link_training_main").click(function(){
		$.hide_trainings();
		$("#training_main").fadeIn("slow").end()
		return false;
	});
	$(".link_training_0").click(function(){
		$.hide_trainings();
		$("#training_0").fadeIn("slow").end()
		return false;
	});
	$(".link_training_1").click(function(){
		$.hide_trainings();
		$("#training_1").fadeIn("slow").end()
		return false;
	});
	$(".link_training_2").click(function(){
		$.hide_trainings();
		$("#training_2").fadeIn("slow").end()
		return false;
	});
	$(".link_training_3").click(function(){
		$.hide_trainings();
		$("#training_3").fadeIn("slow").end()
		return false;
	});
	$(".link_training_4").click(function(){
		$.hide_trainings();
		$("#training_4").fadeIn("slow").end()
		return false;
	});
	$(".link_training_5").click(function(){
		$.hide_trainings();
		$("#training_5").fadeIn("slow").end()
		return false;
	});
	
	$(window).resize(function(){
		$.positionAll(current_page,50);
	});
	
});

$.hide_trainings=function()
{
	$("#training_main, #training_0, #training_1, #training_2, #training_3, #training_4, #training_5").css({display:"none"}).end()
};

$.positionAll=function(current_frame, animation_time)
{
	var win_height=$(window).height();
	var win_width=$(window).width();
	/*var max_content_width=920;*/
	var win_side_padding=(win_width-920)/2;
	var win_scene_side_padding=(win_width-839)/2;
	
	switch (current_frame) 
	{
		case "11": 
		{
			tmpHeight = (win_height>900?win_height:900);
		
			tmpTop = 0;
			tmpLeft = 0;
			
			/*
			tmpX1 = win_width-$.getScrollbarWidth();
			tmpX2 = 0;
			tmpY1 = 0;
			tmpY2 = tmpHeight;
			tmpClip = 'rect(' + tmpY1 + 'px, ' + tmpX1 + 'px, ' + tmpY2 + 'px, ' + tmpX2 + 'px)';
			*/
			
			$(".wrap").height(tmpHeight+'px');
			
			$(".contentdiv").stop()
				.animate({top: tmpTop, left:tmpLeft}, animation_time).end();
				/*.animate({top: tmpTop, left:tmpLeft, clip: tmpClip}, animation_time).end();*/
				
			$("#c11").css({top: "0px", left:"0px"})
					 .width(win_width).end();
			break;
		}
		case "12": 
		{
			tmpHeight = (win_height>900?win_height:900);
			
			tmpTop = 0;
			tmpLeft = -1920;
			
			/*
			tmpX1 = win_width-$.getScrollbarWidth();
			tmpX2 = 0;
			tmpY1 = 0;
			tmpY2 = tmpHeight ;
			tmpClip = 'rect(' + tmpY1 + 'px, ' + tmpX1 + 'px, ' + tmpY2 + 'px, ' + tmpX2 + 'px)';
			*/
			
			$(".wrap").height(tmpHeight+'px');
			
			$(".contentdiv").animate({top: tmpTop, left:tmpLeft}, animation_time).end();
									
			$("#c12").css({top: "25px", left: (win_side_padding+1920)+"px"})
					 .height(((win_height-100)>650)?(win_height-100):650).end();
			
			$("#pic_ufo").css({left:(win_width-500 + 1920)+"px"}).end()
			break;
		}
		case "13": 
		{
			tmpHeight = (win_height>900?win_height:900);
			
			tmpTop = 0;
			tmpLeft = -3840;
			
			 
			/*
			tmpX1 = win_width-$.getScrollbarWidth();
			tmpX2 = 0;
			tmpY1 = 0;
			tmpY2 = tmpHeight ;
			tmpClip = 'rect(' + tmpY1 + 'px, ' + tmpX1 + 'px, ' + tmpY2 + 'px, ' + tmpX2 + 'px)'; 
			*/
			
			$(".wrap").height(tmpHeight+'px');
			
			$(".contentdiv").stop()
				.animate({top: tmpTop, left:tmpLeft}, animation_time).end();
				/*.animate({top: tmpTop, left:tmpLeft, clip: tmpClip}, animation_time).end();*/
								
			$("#c13").css({top: "25px", left: (win_side_padding+3840)+"px"}).end();
			
			$("#pic_moon").css({left:(win_width-500 + 3840)+"px"}).end();
			
			break;
		}
		case "21": 
		{
			tmpTop = 150 - 2635 + (win_height>main_height?(win_height):main_height);
			tmpLeft = 0;
			
			/*
			tmpX1 = win_width-$.getScrollbarWidth();
			tmpX2 = 0;
			tmpY1 = -tmpTop;
			tmpY2 = 2635;
			tmpClip = 'rect(' + tmpY1 + 'px, ' + tmpX1 + 'px, ' + tmpY2 + 'px, ' + tmpX2 + 'px)';
			*/
			
			tmpHeight = 2635 + tmpTop;
			
			$(".wrap").height(tmpHeight+'px');
			
			$(".contentdiv").stop()
				.animate({top: tmpTop, left:tmpLeft}, animation_time).end();
				/*.animate({top: tmpTop, left:tmpLeft, clip: tmpClip}, animation_time).end();*/
			
			$("#c21").css({top: (25 - tmpTop), left: (win_side_padding+"px")})
			
			$("#pic_streetclock").css({left:(win_side_padding +920-150)+"px"}).end()
			$("#pic_bilboard").css({left:(win_side_padding/2 +300)+"px"}).end()
			$("#pic_people").css({left: (win_side_padding/2+"px")}).end()
			break;
		}
		case "22": 
		{
			tmpTop = -2635 + (win_height>scene_height?(win_height):scene_height);
			tmpLeft = -1920;
			
			/*
			tmpX1 = win_width-$.getScrollbarWidth();
			tmpX2 = 0;
			tmpY1 = -tmpTop;
			tmpY2 = 2635;
			tmpClip = 'rect(' + tmpY1 + 'px, ' + tmpX1 + 'px, ' + tmpY2 + 'px, ' + tmpX2 + 'px)';
			*/
			
			tmpHeight = 2635 + tmpTop;
			
			$(".wrap").height(tmpHeight+'px');
			
			$(".contentdiv").stop()
				.animate({top: tmpTop, left:tmpLeft}, animation_time).end();
				/*.animate({top: tmpTop, left:tmpLeft, clip: tmpClip}, animation_time).end();*/
			
			$("#c22").css({left:(win_scene_side_padding+1920)+"px"}).end()
			$("#trainings_content").css({left:(win_scene_side_padding +1942)+"px"}).end()
			$("#pic_scene").css({left:(win_scene_side_padding +1910)+"px"}).end()
			
			break;
		}
		case "23": 
		{
			tmpTop = 150 - 2635 + (win_height>testimonials_height?(win_height):testimonials_height);
			tmpLeft = -3840;
			
			/*
			tmpX1 = win_width-$.getScrollbarWidth();
			tmpX2 = 0;
			tmpY1 = -tmpTop;
			tmpY2 = 2635;
			tmpClip = 'rect(' + tmpY1 + 'px, ' + tmpX1 + 'px, ' + tmpY2 + 'px, ' + tmpX2 + 'px)';
			*/
			
			tmpHeight = 2635 + tmpTop;
			
			$(".wrap").height(tmpHeight+'px');
			
			$(".contentdiv").stop()
				.animate({top: tmpTop, left:tmpLeft}, animation_time).end();
				/*.animate({top: tmpTop, left:tmpLeft, clip: tmpClip}, animation_time).end();*/
				
			$("#c23").css({top: (25-tmpTop), left:(win_side_padding+3840+"px"), height: (((win_height-250)>700)?(win_height-250+"px"):"700px") }).end()
			break;
		}
		default:
			break;
	}
	$("#library_div, #contacts_div, #testimonials_div, #settestimonial_div").animate({top:(win_height/2-200 +"px"), left: (win_width/2-240) +"px"},{ queue:false, duration:500}).end()
};

$.showCloseForm=function(myFormName, toShow)
{
	if (toShow==1){
		$(myFormName).css({top: ($(window).height()/2-200), left: ($(window).width()/2-240)}).fadeIn("fast");
	}
	else{
		$(myFormName).fadeOut("fast").end();
	}
};

$.closeAllForms=function()
{
	$("#library_div").css({display:"none"}).end();
	$("#contacts_div").css({display:"none"}).end();
	$("#testimonials_div").css({display:"none"}).end();
	$("#settestimonial_div").css({display:"none"}).end();
};

