var activeslide;

function slideSwitch() {
	//alert(activeslide);
	
	images = $('#slideshow img');
	images.each(function(i) {
		
		if(i == activeslide) {			
			
			alert(i);
			
		} else if (i == (activeslide+1)%images.length) {
			
			
			
		}
	});
	
    activeslide = (activeslide+1)%images.length;
    
    alert(activeslide);
}

function mySlider(){
	
	$('#slideshow img').css("z-index",1);
	
	
	$("#slide_text_box").fadeIn(500);
	$('.first_slide').css("opacity", 0.0).css("z-index",2).css("margin-top", "-150px")
	.animate({opacity: 5.0, marginTop: -420}, 5500, "linear",
		function() {
			
					
						
							setTimeout(function(){
								$("#slide_text_box").fadeOut(500,
									function() {
										$('.second_slide').css("opacity", 0.0).css("z-index",2).css("margin-top", "-100px")
										.animate({opacity: 5.0,marginTop: -250}, 5500, "linear",
											
											function() {
												$('.third_slide').css("opacity", 0.0).css("z-index",2).css("margin-top", "-100px")
												.animate({opacity: 5.0, marginTop: -250}, 5500, "linear",
													
													function() {
														$('.fourth_slide').css("opacity", 0.0).css("z-index",2).css("margin-top", "0")
														.animate({opacity: 5.0, marginTop: -200}, 5500, "linear");
													}
													
													);
											}
											
											);
									}
									);
							}, 5000 );
						
			
		}
	);
}



$(function() {
	activeslide=0;
	
	$('#slideshow img').each(function(i) {
		if(i == activeslide) {
			$(this).css("z-index",2).css("opacity",1.0);
		}
		else {
			$(this).css("z-index",1).css("opacity",0.0);
		}
	});
	
	
	mySlider();
	
	setInterval(function() {
			mySlider();
	},27800);
	
});

