/*
********************************
**	(c)2008 R3 WEBMOTION	  **
**	contact: info@r3.com.br	  **
********************************
*/
jQuery.fn.extend({
	changeImgAnim: function(){
		if($(this)){
			$(this).animate({ marginLeft: "-120px" }, 6000, "linear", function(){
				$(this).fadeOut(1500,function(){
					$(this).css("marginLeft","0").removeClass("view");
					if($(this).is(":last-child")){
						$(this).parent().children().filter(":first-child").addClass("view").fadeIn().changeImgAnim();
					} else {
						$(this).next().addClass("view").fadeIn().changeImgAnim();
					}
				});
			});
		}
	},
	changeImgAnimTwoDir: function(dir){
		if($(this)){
			if(dir=="right"){
				$(this).animate({ marginLeft: "-120px" }, 6000, "linear", function(){
					$(this).fadeOut(1500,function(){
						$(this).css("marginLeft","0").removeClass("view");
						if($(this).is(":last-child")){
							$(this).parent().children().filter(":first-child").addClass("view").fadeIn().changeImgAnimTwoDir("left");
						} else {
							$(this).next().addClass("view").fadeIn().changeImgAnimTwoDir("left");
						}
					});
				});
			} else if(dir=="left"){
				$(this).css("marginLeft","-120px").animate({ marginLeft: "0px" }, 6000, "linear", function(){
					$(this).fadeOut(1500,function(){
						$(this).removeClass("view");
						if($(this).is(":last-child")){
							$(this).parent().children().filter(":first-child").addClass("view").fadeIn().changeImgAnimTwoDir("right");
						} else {
							$(this).next().addClass("view").fadeIn().changeImgAnimTwoDir("right");
						}
					});
				});
			}
		}
	},
	changeImg: function(){
		if($(this)){
			$(this).not(":only-child").each(function(){
				$(this).animate({ opacity: 1 },3000).fadeOut(function(){
					if($(this).is(":last-child")){
						$(this).removeClass("view");
						$(this).parent().children().filter(":first-child").addClass("view").fadeIn().changeImg();
					} else {
						$(this).removeClass("view").next().addClass("view").fadeIn().changeImg();
					}
				});
			});
		}
	},
	changeTxt: function(){
		if($(this)){
			$(this).not(":only-child").each(function(){
				$(this).animate({ marginLeft:"0px" },13000).slideUp("normal",function(){
					if($(this).is(":last-child")){
						$(this).removeClass("view");
						$(this).parent().children().filter(":first-child").addClass("view").slideDown().changeTxt();
					} else {
						$(this).removeClass("view").next().addClass("view").slideDown().changeTxt();
					}
				});
			});
		}
	}
});

$(document).ready(function () {
	
	$("#client_rot img:not(.view)").hide();
	$("#client_rot img.view").changeImg();
	
	$("#home_top div:not(.view)").hide();
	$("#home_top div.view").changeTxt();
	
	$.superbox.settings = {
		boxId: "superbox", // Id attribute of the "superbox" element
		boxClasses: "", // Class of the "superbox" element
		overlayOpacity: .8, // Background opaqueness
		boxWidth: "600", // Default width of the box
		boxHeight: "400", // Default height of the box
		loadTxt: "Carregando...", // Loading text
		closeTxt: "Fechar", // "Close" button text
		prevTxt: "Anterior", // "Previous" button text
		nextTxt: "Proximo" // "Next" button text
	};
	
	$.superbox();

});
