//BALAO DO POCKET///////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////
$(document).ready(function() {
			$("#bt-mais").bind({
			mouseover: MostrarBalao,
			mouseout : EsconderBalao
			});
			function MostrarBalao(){
			$(".tool").fadeIn();
			$(".tool").css("display", "block");
			}
			function EsconderBalao(){
			$(".tool").css("display", "none");
			}

});

//CHECKBOX/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
$(document).ready(function() {
$("a#checkboxF").click(function(){
			if($('#mailing:checked').is(':checked')){
			$("a#checkboxF").css("background-position", "0 0px");
			$("#mailing").attr('checked', false);
			preventDefault();
			}
			else{
			$("a#checkboxF").css("background-position", "0 -12px");
			$("#mailing").attr('checked', true);
			preventDefault();
			}
								});
			$("#reset").click(function(){
			$("a#checkboxF").css("background-position", "0 0px");
			$("#mailing").attr('checked', false);  
						   				});

//LABEL QUE SOME AO DAR ONCLICK
$("#nome-completo").inputLabel();
$("#email").inputLabel();	
$("#assunto-mensagem").inputLabel();	
$("#mensagem").inputLabel();

});
			
//FANCY-BOX//////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////
$(document).ready(function() {
	 $(".evento-1").fancybox({
		'padding'			: 0,				
		'width'				: 740,
		'height'			: 518,
		'autoScale'			: false,
		'transitionIn'		: 'fade',
		'transitionOut'		: 'fade',
		'type'				: 'iframe'
	});
	$(".box_pequeno").fancybox({
		'padding'			: 0,	
		'border'			: 0,			
		'width'				: 740,
		'height'			: 265,
		'autoScale'			: false,
		'transitionIn'		: 'fade',
		'transitionOut'		: 'fade',
		'type'				: 'iframe'
	});
	$(".evento-2").fancybox({
		'padding'			: 0,				
		'width'				: 740,
		'height'			: 518,
		'autoScale'			: false,
		'transitionIn'		: 'fade',
		'transitionOut'		: 'fade',
		'type'				: 'iframe'
	});
	$("a[rel=galeria01]").fancybox({
		'padding'			: 10,						 
		'overlayColor'		: '#000000',
		'overlayOpacity'	: 0.7,
		'transitionIn'		: 'fade',
		'transitionOut'		: 'fade',
		'titlePosition' 	: 'outside',
		'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
				return '<span id="fancybox-title-inside">' + (title.length ? ' &nbsp; ' + title : '') + ' - Foto ' + (currentIndex + 1) + ' de ' + currentArray.length +  '</span>';
		}
	})

});

// ANIMAÇÃO MENU //////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////
$(function() {               
	$("ul#top-menu span").css("opacity","0");			// Definir a opacidade no carregamento da página
    	$("ul#top-menu span").hover(function () {		// on mouse over
        	$(this).stop().animate({					// animar a opacidade a plena
            	opacity: 1
                        }, '');
                },
                
		function () {								// on mouse out
        	$(this).stop().animate({ 				// animar a opacidade
				opacity: 0
                        }, 'slow');
                });
        });


//DROP DOWN MENU EFFECT ///////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////
$(document).ready(function() {
	//On Hover Over
function megaHoverOver(){
    $(this).find(".submenu").stop().fadeTo('fast', 1).show(); //Find sub and fade it in       
}
//On Hover Out
function megaHoverOut(){
  $(this).find(".submenu").stop().fadeTo('fast', 0, function() { //Fade to 0 opactiy
      $(this).hide();  //after fading, hide it
  });
}
//Set custom configurations
var config = {
     sensitivity: 2, 		// number = sensitivity threshold (must be 1 or higher)
     interval: 100, 		// number = milliseconds for onMouseOver polling interval
     over: megaHoverOver,	// function = onMouseOver callback (REQUIRED)
     timeout: 500, 			// number = milliseconds delay before onMouseOut
     out: megaHoverOut 		// function = onMouseOut callback (REQUIRED)
};

$("ul#top-menu li .submenu").css({'opacity':'0'}); //Fade sub nav to 0 opacity on default
$("ul#top-menu li").hoverIntent(config); //Trigger Hover intent with custom configurations
});

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

	                            



//RELOGIO ///////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////

function checkTime(I){
			 		 if (I<10){
  						 I = "0" + I;
  					 }
					 return I;
			}
		  
    		function dataCompleta(){
				
        	var data = new Date();
			
			var dia		= data.getDay();
			var mes		= data.getMonth();
			var ano		= data.getFullYear();
			
			var ndia	= data.getDate();
			
        	var horas   = checkTime(data.getHours());
        	var minutos = checkTime(data.getMinutes());
			
			if( dia == 0 ){ diaSemana = "Domingo";}
			if( dia == 1 ){ diaSemana = "Segunda-Feira";}
			if( dia == 2 ){ diaSemana = "Terça-Feira";}
			if( dia == 3 ){ diaSemana = "Quarta-Feira";}
			if( dia == 4 ){ diaSemana = "Quinta-Feira";}
			if( dia == 5 ){ diaSemana = "Sexta-Feira";}
			if( dia == 6 ){ diaSemana = "Sábado";}
			
			switch(mes){
				case 0  : mesAno = "Janeiro";
				break;
				case 1  : mesAno = "Fevereiro";
				break;
				case 2  : mesAno = "Março";
				break;
				case 3  : mesAno = "Abril";
				break;
				case 4  : mesAno = "Maio";
				break;
				case 5  : mesAno = "Junho";
				break;
				case 6  : mesAno = "Julho";
				break;
				case 7  : mesAno = "Agosto";
				break;
				case 8  : mesAno = "Setembro";
				break;
				case 9  : mesAno = "Outubro";
				break;
				case 10 : mesAno = "Novembro";
				break;
				case 11 : mesAno = "Dezembro";
				break;
			}
			
			
        	var exibe   = document.getElementById("data-top");
       		exibe.innerHTML = 
			diaSemana + ', ' + ndia + ' de ' + mesAno + ' de ' + ano + ' | ' + horas + ":" + minutos;
			}

//Hover INTENT ///////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
* hoverIntent is similar to jQuery's built-in "hover" function except that
* instead of firing the onMouseOver event immediately, hoverIntent checks
* to see if the user's mouse has slowed down (beneath the sensitivity
* threshold) before firing the onMouseOver event.
* 
* hoverIntent r6 // 2011.02.26 // jQuery 1.5.1+
* <http://cherne.net/brian/resources/jquery.hoverIntent.html>
* 
* hoverIntent is currently available for use in all personal or commercial 
* projects under both MIT and GPL licenses. This means that you can choose 
* the license that best suits your project, and use it accordingly.
* 
* // basic usage (just like .hover) receives onMouseOver and onMouseOut functions
* $("ul li").hoverIntent( showNav , hideNav );
* 
* // advanced usage receives configuration object only
* $("ul li").hoverIntent({
*	sensitivity: 7,  // number = sensitivity threshold (must be 1 or higher)
*	interval: 100,   // number = milliseconds of polling interval
*	over: showNav,   // function = onMouseOver callback (required)
*	timeout: 0,      // number = milliseconds delay before onMouseOut function call
*	out: hideNav     // function = onMouseOut callback (required)
* });
* 
* @param  f  onMouseOver function || An object with configuration options
* @param  g  onMouseOut function  || Nothing (use configuration options object)
* @author    Brian Cherne brian(at)cherne(dot)net
*/
(function($) {
	$.fn.hoverIntent = function(f,g) {
		// default configuration options
		var cfg = {
			sensitivity: 7,
			interval: 100,
			timeout: 0
		};
		// override configuration options with user supplied object
		cfg = $.extend(cfg, g ? { over: f, out: g } : f );

		// instantiate variables
		// cX, cY = current X and Y position of mouse, updated by mousemove event
		// pX, pY = previous X and Y position of mouse, set by mouseover and polling interval
		var cX, cY, pX, pY;

		// A private function for getting mouse position
		var track = function(ev) {
			cX = ev.pageX;
			cY = ev.pageY;
		};

		// A private function for comparing current and previous mouse position
		var compare = function(ev,ob) {
			ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t);
			// compare mouse positions to see if they've crossed the threshold
			if ( ( Math.abs(pX-cX) + Math.abs(pY-cY) ) < cfg.sensitivity ) {
				$(ob).unbind("mousemove",track);
				// set hoverIntent state to true (so mouseOut can be called)
				ob.hoverIntent_s = 1;
				return cfg.over.apply(ob,[ev]);
			} else {
				// set previous coordinates for next time
				pX = cX; pY = cY;
				// use self-calling timeout, guarantees intervals are spaced out properly (avoids JavaScript timer bugs)
				ob.hoverIntent_t = setTimeout( function(){compare(ev, ob);} , cfg.interval );
			}
		};

		// A private function for delaying the mouseOut function
		var delay = function(ev,ob) {
			ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t);
			ob.hoverIntent_s = 0;
			return cfg.out.apply(ob,[ev]);
		};

		// A private function for handling mouse 'hovering'
		var handleHover = function(e) {
			// copy objects to be passed into t (required for event object to be passed in IE)
			var ev = jQuery.extend({},e);
			var ob = this;

			// cancel hoverIntent timer if it exists
			if (ob.hoverIntent_t) { ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t); }

			// if e.type == "mouseenter"
			if (e.type == "mouseenter") {
				// set "previous" X and Y position based on initial entry point
				pX = ev.pageX; pY = ev.pageY;
				// update "current" X and Y position based on mousemove
				$(ob).bind("mousemove",track);
				// start polling interval (self-calling timeout) to compare mouse coordinates over time
				if (ob.hoverIntent_s != 1) { ob.hoverIntent_t = setTimeout( function(){compare(ev,ob);} , cfg.interval );}

			// else e.type == "mouseleave"
			} else {
				// unbind expensive mousemove event
				$(ob).unbind("mousemove",track);
				// if hoverIntent state is true, then call the mouseOut function after the specified delay
				if (ob.hoverIntent_s == 1) { ob.hoverIntent_t = setTimeout( function(){delay(ev,ob);} , cfg.timeout );}
			}
		};

		// bind the function to the two event listeners
		return this.bind('mouseenter',handleHover).bind('mouseleave',handleHover);
	};
})(jQuery);



/**
 * 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: "#231f20", 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);


