
$(document).ready( function () {

	currentImage = -1;
	rotateInterval = setInterval(changeImage, 10000);

	function changeImage(side, dropInterval){
		

		if(arguments[0] == undefined || typeof(arguments[0]) == "number")
		side = "right";

		if(arguments[1] == undefined)
		dropInterval = false;


		clearInterval(rotateInterval);
		
		if(side == "right"){
			currentImage++;
		}else{
			currentImage--;
		}

		if(side == "right"){
		
			if(currentImage+1 == $(".rotating_billboard .overflow .rotate").length){
				currentImage = -1;
			}
			
		}

		if(side == "left"){
		
			if(currentImage == -2){
				currentImage = $(".rotating_billboard .overflow .rotate").length-2;
			}
			
		}

			
		currentPosition = (currentImage+1)*-1000;
	
		$(".overflow").animate({
			left: currentPosition
		}, 1000, 'swing',function(){
			
			if(!dropInterval)
			rotateInterval = setInterval(changeImage, 10000);
			
		});
			

	}



	/*$("#rb").hover(function(){
		
		$("#rb_left_arr").animate({ opacity: 1.00 }, 250);
		$("#rb_right_arr").animate({ opacity: 1.00 }, 250);
		
	},function(){
		
		$("#rb_left_arr").animate({ opacity: 0.00 }, 250);
		$("#rb_right_arr").animate({ opacity: 0.00 }, 250);

	});*/
	
	
	$("#rb_left_arr").click(function(){
	
		changeImage("left", true);
		
	});

	$("#rb_right_arr").click(function(){
	
		changeImage("right", true);
		
	});


	

});



function subscribeProccess () {
	
	var currentEmail = $("#subscribeEmail").val();

	$.ajax({
			type: "POST",
			url: 	"/main/subscribe/",
			data: {usrEmail: currentEmail},
			success: function(msg){
				
				$("#subscribe_txt").animate({ opacity: 0.00 }, 500);
				//$("#subscribe_zag").animate({ opacity: 0.00 }, 500);
				$("#subscribe_fields").animate({
					opacity: 0.00
					}, 500, function() {
					
						$("#subscribe_fields").css("margin-top", "0").html("<font style='color:#cf0103'>Thank you for subscribing to our newsletter.<br>You will the first to be notified about our new releases, features and upcoming events.</font>").animate({ opacity: 1.00 }, 500);
					
					});
				
			}
		});
	
}


