///////////////////////////////////////////////////////////////////////////////////////////
// MENU SANFONA
///////////////////////////////////////////////////////////////////////////////////////////
$(document).ready(function(){
     $("dd").hide();
	 $("dd:#aberto").show();
     $("dt a").click(function(){
        $("dd:visible").slideUp("slow");
        $(this).parent().next().slideDown("slow");
        return false;
     });
	 
	// label forms
	/////////////////////////////////////////////////////////////////////////////////////
	$("#nome-completo").inputLabel();
	$("#empresa").inputLabel();	
	$("#email").inputLabel();	
	$("#telefone").inputLabel();
	$("#celular").inputLabel();	
	$("#mensagem").inputLabel();
	
	
	// submenu
	/////////////////////////////////////////////////////////////////////////////////////
	$(".bt-inicial").hover(function() {
       	$(".submenu-produtos").slideUp();
		$(".submenu-institucional").slideUp();
    });
	$(".bt-institucional").hover(function() {
       	$(".submenu-produtos").slideUp();
		$(".submenu-institucional").slideDown();
    });
	$(".bt-produtos").hover(function() {
       	$(".submenu-produtos").slideDown();
		$(".submenu-institucional").slideUp();
    });
	$(".bt-artigos").hover(function() {
       	$(".submenu-produtos").slideUp();
		$(".submenu-institucional").slideUp();
    });
	$("#menu-align").hover(function() {
       	$(".submenu-produtos").slideUp();
		$(".submenu-institucional").slideUp();
    });
	
	// baloes
	/////////////////////////////////////////////////////////////////////////////////////
	////////////balao amostragem
	$(".bt-amostragem").hover(function() {
       	$("#bl-amostragem-cinza").fadeIn();
    });
	$(".bt-amostragem").mouseout(function() {
       	$("#bl-amostragem-cinza").fadeOut();
    });
	////////////balao monitoramento
	$(".bt-monitoramento").hover(function() {
       	$("#bl-monitoramento-cinza").fadeIn();
    });
	$(".bt-monitoramento").mouseout(function() {
       	$("#bl-monitoramento-cinza").fadeOut();
    });
	////////////balao remediacao
	$(".bt-remediacao").hover(function() {
       	$("#bl-remediacao-cinza").fadeIn();
    });
	$(".bt-remediacao").mouseout(function() {
       	$("#bl-remediacao-cinza").fadeOut();
    });
	////////////balao acessorios
	$(".bt-acessorios").hover(function() {
       	$("#bl-acessorios-cinza").fadeIn();
    });
	$(".bt-acessorios").mouseout(function() {
       	$("#bl-acessorios-cinza").fadeOut();
    });
	////////////balao liked
	$(".bt-in").hover(function() {
       	$("#bl-bt-in").fadeIn();
    });
	$(".bt-in").mouseout(function() {
       	$("#bl-bt-in").fadeOut();
    });
	////////////balao skype
	$(".bt-skype").hover(function() {
       	$("#bl-bt-skype").fadeIn();
    });
	$(".bt-skype").mouseout(function() {
       	$("#bl-bt-skype").fadeOut();
    });
	////////////balao twitter
	$(".bt-twitter").hover(function() {
       	$("#bl-bt-twitter").fadeIn();
    });
	$(".bt-twitter").mouseout(function() {
       	$("#bl-bt-twitter").fadeOut();
    });
	////////////balao youtube
	$(".bt-tube").hover(function() {
       	$("#bl-bt-tube").fadeIn();
    });
	$(".bt-tube").mouseout(function() {
       	$("#bl-bt-tube").fadeOut();
    });
	////////////balao facebook
	$(".bt-face").hover(function() {
       	$("#bl-bt-face").fadeIn();
    });
	$(".bt-face").mouseout(function() {
       	$("#bl-bt-face").fadeOut();
    });
	
	$("a[rel=galeria]").fancybox({
		'padding'			: 0,						 
		'overlayColor'		: '#000000',
		'overlayOpacity'	: 0.8,
		'transitionIn'		: 'fade',
		'transitionOut'		: 'fade',
		'titlePosition' 	: 'inside',
		'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
			return '<span id="fancybox-title-inside">' + (title.length ? '' + title : '') + '<span class="cinza11C"></span>';
		}
	});
	$(".popup").fancybox({
		'padding'			: 0,						 
		'overlayColor'		: '#000000',
		'overlayOpacity'	: 0.8,
		'width'				: 1000,
		'height'			: '90%',
		'autoScale'			: false,
		'transitionIn'		: 'fade',
		'transitionOut'		: 'fade',
		'type'				: 'iframe'
	});

});

///////////////////////////////////////////////////////////////////////////////////////////
// ANIMACAO BANNER
///////////////////////////////////////////////////////////////////////////////////////////
$(document).ready(function() {
	$('#slideshow').cycle({
		timeout: 8000, //Tempo da transição
		speed:   700,  //Velocidade da transição
		fx:      'scrollHorz', //Tipo
		pager:   '#nav', //A div que vai aprensetar os números do slides
		prev:    '#prev', //Link para voltar ao slide anterior
		next:    '#next' //Link para próximo slide
	});
});

$(document).ready(function() {
	$('#slider-destaque').cycle({
		timeout: 20000, //Tempo da transição
		speed:   700,  //Velocidade da transição
		fx:      'scrollHorz', //Tipo
		prev:    '#prev-destaque', //Link para voltar ao slide anterior
		next:    '#next-destaque' //Link para próximo slide
	});
});

$(document).ready(function() {
	$('#slider-ultimas-noticias').cycle({
		timeout: 3000, //Tempo da transição
		speed:   1000,  //Velocidade da transição
		fx:      'scrollUp', //Tipo
	});
});

$(document).ready(function() {
	$('#slider-produto-modelo').cycle({
		timeout: 3000, //Tempo da transição
		speed:   1000,  //Velocidade da transição
		fx:      'fade', //Tipo
	});
});



///////////////////////////////////////////////////////////////////////////////////////////
// JQUERY ANCORA
///////////////////////////////////////////////////////////////////////////////////////////
var animate = {
	'time': 800,
	'randMin': 1000,
	'randMax': 1200
};


///////////////////////////////////////////////////////////////////////////////////////////
// LABEL FORMULARIO
///////////////////////////////////////////////////////////////////////////////////////////
/**
 * jQuery Initial input value replacer
 * 
 * Sets input value attribute to a starting value  
 * @author Marco "DWJ" Solazzi - hello@dwightjack.com
 * @license  Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
 * @copyright Copyright (c) 2008 Marco Solazzi
 * @version 0.1
 * @requires jQuery 1.2.x
 */
(function (jQuery) {
	/**
	 * Setting input initialization
	 *  
	 * @param {String|Object|Bool} text Initial value of the field. Can be either a string, a jQuery reference (example: $("#element")), or boolean false (default) to search for related label
	 * @param {Object} [opts] An object containing options: 
	 * 							color (initial text color, default : "#666"), 
	 * 							e (event which triggers initial text clearing, default: "focus"), 
	 * 							force (execute this script even if input value is not empty, default: false)
	 * 							keep (if value of field is empty on blur, re-apply initial text, default: true)  
	 */
	jQuery.fn.inputLabel = function(text,opts) {
		o = jQuery.extend({ color: "#858585", e:"focus", force : false, keep : true}, opts || {});
		var clearInput = function (e) {
			var target = jQuery(e.target);
			var value = jQuery.trim(target.val());
			if (e.type == e.data.obj.e && value == e.data.obj.innerText) {
				jQuery(target).css("color", "").val("");
				if (!e.data.obj.keep) {
					jQuery(target).unbind(e.data.obj.e+" blur",clearInput);
				}
			} else if (e.type == "blur" && value == "" && e.data.obj.keep) {
				jQuery(this).css("color", e.data.obj.color).val(e.data.obj.innerText);
			}
		};
		return this.each(function () {
					o.innerText = (text || false);
					if (!o.innerText) {
						var id = jQuery(this).attr("id");
						o.innerText = jQuery(this).parents("form").find("label[for=" + id + "]").hide().text();
					}
					else 
						if (typeof o.innerText != "string") {
							o.innerText = jQuery(o.innerText).text();
						}
			o.innerText = jQuery.trim(o.innerText);
			if (o.force || jQuery(this).val() == "") {
				jQuery(this).css("color", o.color).val(o.innerText);
			}
				jQuery(this).bind(o.e+" blur",{obj:o},clearInput);
			
		});
	};
})(jQuery);

