$(document).ready(function()
{    
	var pos_image_animate = 0;
    var curr_img=images_animate[pos_image_animate];    
	var slide_show=true;
    var cant_images = $("#slide_show .aux").size();
	
	function reset_styles(){
		$("#slide_show").css("background", "#0A0A0A url(../images/animate/img"+curr_img+".jpg) no-repeat");
		
		pos_image_animate ++;
        if(pos_image_animate >= images_animate.length)
            pos_image_animate = 0;
        curr_img=images_animate[pos_image_animate];  
        //if(curr_img==1) curr_img=2; else curr_img=1;
		
		var vals_1= {'width':'127px',
			'height':'0',
			'opacity': '1',
			'top':'170px'
		};
		
		$("#strip1").hide();
		$("#strip1").css(vals_1);
		$("#strip2").hide();
		$("#strip2").css(vals_1);
		$("#strip3").hide();
		$("#strip3").css(vals_1);
		$("#strip4").hide();
		$("#strip4").css(vals_1);
		$("#strip5").hide();
		$("#strip5").css(vals_1);
		$("#strip6").hide();
		$("#strip6").css(vals_1);
		$("#strip7").hide();
		$("#strip7").css(vals_1);
		
		$(".white").css({
			'opacity': '1'
		});
		
		var vals_2 = {
			'height':'0px',
			'margin-top':'170px'
		};
		$(".strip_left").css(vals_2);
		
		$("#strip11").css("margin-left", '-80px');
		
		var vals_3= {
			'opacity' : '1',
			'top' : '-150px',
			'height' :'600px'
		};
		$(".strip_left").children().css(vals_3);
		
		$("#strip1").css("background-image", "url("+IMAGES_PATH+"animate/img"+curr_img+"_strip1.jpg)");
		$("#strip2").css("background-image", "url("+IMAGES_PATH+"animate/img"+curr_img+"_strip2.jpg)");
		$("#strip3").css("background-image", "url("+IMAGES_PATH+"animate/img"+curr_img+"_strip3.jpg)");
		$("#strip4").css("background-image", "url("+IMAGES_PATH+"animate/img"+curr_img+"_strip4.jpg)");
		$("#strip5").css("background-image", "url("+IMAGES_PATH+"animate/img"+curr_img+"_strip5.jpg)");
		$("#strip6").css("background-image", "url("+IMAGES_PATH+"animate/img"+curr_img+"_strip6.jpg)");
		$("#strip7").css("background-image", "url("+IMAGES_PATH+"animate/img"+curr_img+"_strip7.jpg)");
		
		$("#strip11").children("img").attr("src", ""+IMAGES_PATH+"animate/img"+curr_img+"_strip1.jpg");
		$("#strip12").children("img").attr("src", ""+IMAGES_PATH+"animate/img"+curr_img+"_strip2.jpg");
		$("#strip13").children("img").attr("src", ""+IMAGES_PATH+"animate/img"+curr_img+"_strip3.jpg");
		$("#strip14").children("img").attr("src", ""+IMAGES_PATH+"animate/img"+curr_img+"_strip4.jpg");
		$("#strip15").children("img").attr("src", ""+IMAGES_PATH+"animate/img"+curr_img+"_strip5.jpg");
		$("#strip16").children("img").attr("src", ""+IMAGES_PATH+"animate/img"+curr_img+"_strip6.jpg");
		$("#strip17").children("img").attr("src", ""+IMAGES_PATH+"animate/img"+curr_img+"_strip7.jpg");
		

		
		
	}
	
	
	
	
	
	
	
	
	function animar(){
		if(slide_show){
			$("#main").animate({'left': '0px'}, 2000, function(){
				$("#strip1").show();
				$("#strip1").animate({
					height: '668px',
					top:'0',
					backgroundPosition: "0px 0px"
				}, 750, function(){
					$(this).animate({
						opacity:1
					}, 100);
				});
				$("#strip1").children().animate({
					opacity: '0'
				}, 750);
				$("#strip2").show();
				$("#strip2").animate({
					opacity: '0.9'
				}, 250, function(){
					$("#strip2").animate({
						height: '668px',
						top:'0',
						backgroundPosition: "0px 0px"
					}, 600, function(){
						$(this).animate({
							opacity:'0'
						}, 150, function(){ });
					});
					$(this).children().animate({
						opacity: '0.2'
					}, 600);
				});
				$("#strip3").show();
				$("#strip3").animate({
					opacity: '0.8'
				}, 100, function(){
					$("#strip3").animate({
						height: '668px',
						top:'0',
						backgroundPosition: "0px 0px"
					}, 700, function(){
						$(this).animate({
							opacity:0
						}, 250);
					});
					$("#strip3").children().animate({
						opacity: '0'
					}, 750);
				});
				$("#strip4").show();
				$("#strip4").animate({
					opacity: '0.8'
				}, 100, function(){
					$(this).animate({
						height: '668px',
						top:'0',
						backgroundPosition: "0px 0px"
					}, 850, function(){
						$(this).animate({
							opacity:0
						}, 250);
					});
					$("#strip4").children().animate({
						opacity: '0.2'
					}, 550);
				});
				$("#strip5").show();
				$("#strip5").animate({
					opacity: '0.8'
				}, 200, function(){
					$(this).animate({
						height: '668px',
						top:'0',
						backgroundPosition: "0px 0px"
					}, 850, function(){
						$(this).animate({
							opacity:0
						}, 250, function(){
							reset_styles();
							animar();
						});
					});
					$("#strip5").children().animate({
						opacity: '0'
					}, 550);
				});
				$("#strip6").show();
				$("#strip6").animate({
					height: '668px',
					top:'0',
					backgroundPosition: "0px 0px",
					opacity: '0.4'
				}, 1000, function(){
					$(this).animate({
						opacity:'0'
					}, 250);
				});
				$("#strip6").children().animate({
					opacity: '0.2'
				}, 750);
				$("#strip7").show();
				$("#strip7").animate({
					opacity: '0.9'
				}, 200, function(){
					$("#strip7").animate({
						height: '668px',
						top:'0',
						backgroundPosition: "0px 0px"
					}, 600, function(){
						$(this).animate({
							opacity:0
						}, 250, function(){
							//reset_styles();
						});
					});
					$(this).children().animate({
						opacity: '0'
					}, 750);
				});
				
				
				///////////////////////////////////////////////////////////////////////////////
				
				$("#strip11").show();
				$("#strip11").animate({
					height: '0'
				},400, function(){
					$(this).animate({
						height: '668px',
						marginTop:'0px',
						marginLeft:'0px'
					}, 750, function(){
						$(this).animate({
							opacity:'1'
						}, 100);
					});
					$(this).children().animate({
						opacity: '1',
						top: '0',
						height: '668px'
					}, 750);
				});
				$("#strip12").show();
				$("#strip12").animate({
					height: '0'
				},300, function(){
					$(this).animate({
						height: '668px',
						marginTop:'0px'
					}, 750, function(){
						$(this).animate({
							opacity:'1'
						}, 100);
					});
					$(this).children().animate({
						opacity: '1',
						top: '0',
						height: '668px'
					}, 750);
				});
				$("#strip13").show();
				$("#strip13").animate({
					height: '0'
				},400, function(){
					$(this).animate({
						height: '668px',
						marginTop:'0px'
					}, 750, function(){
						$(this).animate({
							opacity:'1'
						}, 100);
					});
					$(this).children().animate({
						opacity: '1',
						top: '0',
						height: '668px'
					}, 750);
				});
				$("#strip14").show();
				$("#strip14").animate({
					height: '0'
				},450, function(){
					$(this).animate({
						height: '668px',
						marginTop:'0px'
					}, 750, function(){
						$(this).animate({
							opacity:'1'
						}, 100);
					});
					$(this).children().animate({
						opacity: '1',
						height: '668px',
						top: '0'
					}, 750);
				});
				$("#strip16").show();
				$("#strip16").animate({
					height: '0'
				},350, function(){
					$(this).animate({
						height: '668px',
						marginTop:'0px'
					}, 750, function(){
						$(this).animate({
							opacity:'1'
						}, 100);
					});
					$(this).children().animate({
						opacity: '1',
						height: '668px',
						top: '0'
					}, 750);
				});
				$("#strip15").show();
				$("#strip15").animate({
					height: '0'
				},400, function(){
					$(this).animate({
						height: '668px',
						marginTop:'0px'
					}, 750, function(){
						$(this).animate({
							opacity:'1'
						}, 100);
					});
					$(this).children().animate({
						opacity: '1',
						height: '668px',
						top: '0'
					}, 750);
				});
				$("#strip17").show();
				$("#strip17").animate({
					height: '0'
				},350, function(){
					$(this).animate({
						height: '668px',
						marginTop:'0px'
					}, 750, function(){
						$(this).animate({
							opacity:'1'
						}, 100);
					});
					$(this).children().animate({
						opacity: '1',
						height: '668px',
						top: '0'
					}, 750);
				});
				
			});
		}
		
		
		
	}
	
	
	$("#slide_show").click(function(){
		slide_show = !slide_show;
		animar();
	});
    //setTimeout(animar, 4000);
	//animar();
	
	
});
