
// --------------------------------------------------------------------------
// ADMIN 
// --------------------------------------------------------------------------	


	// --------------------------------------------------------------------------
	// Rotina das mensagens de alerta
	// --------------------------------------------------------------------------
	$(document).ready(function()
	{
		$("#object").fadeIn(100).fadeOut(100).fadeIn(100).fadeOut(100).fadeIn(100).fadeOut(100).fadeIn(100).fadeOut(100).fadeIn(100).fadeOut(100).fadeIn(100).fadeOut(100).fadeIn(100);			
	});
	
	// --------------------------------------------------------------------------
	// Rotina de Empresas - ABAS
	// --------------------------------------------------------------------------
	$(document).ready(function(){
		$('ul.tabNav a').click(function() {
			var curChildIndex = $(this).parent().prevAll().length + 1;
			$(this).parent().parent().children('.current').removeClass('current');
			$(this).parent().addClass('current');
			$(this).parent().parent().next('.tabContainer').children('.current').slideUp('fast',function() {
				$(this).removeClass('current');
				$(this).parent().children('div:nth-child('+curChildIndex+')').slideDown('normal',function() {
					$(this).addClass('current');
				});
			});
			return false;								
		});
	});
	
	
    
	// --------------------------------------------------------------------------
	// Rotina de FancyBox
	// --------------------------------------------------------------------------
	$(document).ready(function() {
		$("a#imgFancy").fancybox({
			'titleShow'		: true,
			'transitionIn'	: 'elastic',
			'transitionOut'	: 'elastic'
		});		
	});
	
	// --------------------------------------------------------------------------
	// Rotina de Mascará Fone Representantes
	// --------------------------------------------------------------------------
	jQuery(function($){
		$("#rep_fone").mask("(99)9999-9999");
	});
		
	jQuery(function($){
		$("#dep_fone").mask("(99)9999-9999");
	});
		
	jQuery(function($){
		$("#qy_fone").mask("(99)9999-9999");
	});
	
	
	// --------------------------------------------------------------------------
	// Rotina de Mascará Fone Representantes
	// --------------------------------------------------------------------------
	jQuery(function($){
		$("#eve_hora").mask("99:99");
	});
		
	jQuery(function($){
		$("#qy_hora").mask("99:99");
	});
	
	// --------------------------------------------------------------------------
	// Rotina de Eventos - Período de datas
	// --------------------------------------------------------------------------
	$(function() {
		$('#eve_data_ini').datepicker({
			changeMonth: true,
			changeYear: true,
			showOn: 'button', buttonImage: 'images/calendar.png', buttonImageOnly: true 
		});
	
		// Datepicker
		$('#eve_data_ini').datepicker({
			inline: true
		});
		
		//hover states on the static widgets
		$('#dialog_link, ul#icons li').hover(
			function() { $(this).addClass('ui-state-hover'); }, 
			function() { $(this).removeClass('ui-state-hover'); }
		);
		
	});
	
	$(function() {
		$('#eve_data_fim').datepicker({
			changeMonth: true,
			changeYear: true,
			showOn: 'button', buttonImage: 'images/calendar.png', buttonImageOnly: true 
		});
	
		// Datepicker
		$('#eve_data_fim').datepicker({
			inline: true
		});
		
		//hover states on the static widgets
		$('#dialog_link, ul#icons li').hover(
			function() { $(this).addClass('ui-state-hover'); }, 
			function() { $(this).removeClass('ui-state-hover'); }
		);
		
	});
	
	
	// --------------------------------------------------------------------------
	// Rotina de Representantes - mapa
	// --------------------------------------------------------------------------
	function getRepresentantes( estado )
	{
		$.post("listaRepresentantes.php",
		      {uf: estado},
		      function(valor){
		         $("div[name=listaRepresentantes]").html(valor);
		      }
		);
	}
	
	
	
	
	
// --------------------------------------------------------------------------
// SITE
// --------------------------------------------------------------------------
	

	// --------------------------------------------------------------------------
	// Rotina da Empresa - Fotos
	// --------------------------------------------------------------------------
	function setDadosFotos(arquivo, caminho)
	{
		document.getElementById('ampliaImg').href = arquivo;
		document.getElementById('imgGrande').src  = caminho;
	}
	
	
	// --------------------------------------------------------------------------
	// Rotina da Produtos - Fotos
	// --------------------------------------------------------------------------
	function setFotoGrande(arquivo)
	{
		document.getElementById('imgGrande').src  = arquivo;
	}
	
	
	    
	// --------------------------------------------------------------------------
	// Rotina de FancyBox
	// --------------------------------------------------------------------------
	$(document).ready(function() {
		$("#ampliaImg").fancybox({
			'width'				: '90%',
			'height'			: '90%',
			'autoScale'			: false,
			'transitionIn'		: 'elastic',
			'transitionOut'		: 'elastic',
			'type'				: 'iframe',
			'padding'			: 0
		});
		
		
		$("a[rel=ampliaImgs]").fancybox({
			'transitionIn'		: 'elastic',
			'transitionOut'		: 'elastic',
			'titlePosition' 	: 'over',
			'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
				return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; <br><br>' + title : '') + '</span>';
			}
		});
		
		
	});
	
	
	// --------------------------------------------------------------------------
	// Rotina do Contato - Seleciona o Tipo
	// --------------------------------------------------------------------------	
	$(document).ready(function() {
		$.viewMap = {
			'Empresa' 		: $('#trEmpresa'),
			'Pessoa Física' : $('#trPessoa')
			};
		
			$('#tipoUser').change(function() {
		
			$.each($.viewMap, function() {  this.hide(); });
		
			$.viewMap[$(this).val()].show();
		});
	});
	
	// --------------------------------------------------------------------------
	// Rotina do Login - aparece a tela
	// --------------------------------------------------------------------------	

	
	$(document).ready(function() {
		$(".topoTopMenuAction").click( function() {
			if ($("#topoOpenCloseIdentifier").is(":hidden")) {
				$("#topoSlider").animate({ 
					marginTop: "-192px"
					}, 500 );
				$("#topoTopMenuImage").html('<img src="./img/open.png" alt="Abrir" align="absmiddle" />&nbsp;&nbsp;Abrir Login');
				$("#topoOpenCloseIdentifier").show();
			} else {
				$("#topoSlider").animate({ 
					marginTop: "-20px"
					}, 500 );
				$("#topoTopMenuImage").html('<img src="./img/close.png" alt="Fechar" align="absmiddle" />&nbsp;&nbsp;Fechar Login');
				$("#topoOpenCloseIdentifier").hide();
			}
		});  
	});

	
	
	
	// --------------------------------------------------------------------------
	// Rotina de Mascará Fones - Cadastros, Contato
	// --------------------------------------------------------------------------
	jQuery(function($){
		$("#con_telefone").mask("(99)9999-9999");
	});
	
	jQuery(function($){
		$("#usu_telefone").mask("(99)9999-9999");
	});
	
	
	
	// --------------------------------------------------------------------------
	// Rotina do Carrocel dos Eventos
	// --------------------------------------------------------------------------
	jQuery.easing['BounceEaseOut'] = function(p, t, b, c, d) {
		if ((t/=d) < (1/2.75)) {
			return c*(7.5625*t*t) + b;
		} else if (t < (2/2.75)) {
			return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
		} else if (t < (2.5/2.75)) {
			return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
		} else {
			return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
		}
	};
	
	
	
	jQuery(document).ready(function() {
	    jQuery('#mycarousel').jcarousel({
	    });
	});
	
	
	
	// --------------------------------------------------------------------------
	// Rotina do Menu de Categorias
	// --------------------------------------------------------------------------
	$(function(){
	$('#categoriaMenu a')
		.css( {backgroundPosition: "0px 40px"} )
		.mouseover(function(){
			$(this).stop().animate({backgroundPosition:"(0px 116px)"}, {duration:250})
		})
		.mouseout(function(){
			$(this).stop().animate({backgroundPosition:"(0px 40px)"}, {duration:250, complete:function(){
				$(this).css({backgroundPosition: "0px 40px"})
			}})
		})
	});
	
	
	
	
	
	// --------------------------------------------------------------------------
	// Rotina só números input
	// --------------------------------------------------------------------------
	function soNumero(root){
	    var reet = root.value;
	    var arr1 = reet.length;
	    var ruut = reet.charAt(arr1-1);
	    if (reet.length > 0){
	        var regex = /[0-9]|\./;
	        if (!ruut.match(regex)){
	            var reet = reet.slice(0, -1);
	            $(root).val(reet);
	        }
	    }
	}
	
	
	// --------------------------------------------------------------------------
	// Rotina de Serviços - Guarda Horários 
	// --------------------------------------------------------------------------
	/*
	var idSelected = new Array();
	function multipleSelect(obj) { 
		while (obj.selectedIndex != -1) { 		
		   idSelected[obj.selectedIndex] = (idSelected[obj.selectedIndex] != 1) ? 1 : 0; 
		   obj.options[obj.selectedIndex].selected = false; 
		}  
		for(var i in idSelected){
			if(idSelected[i] == 1)
				obj.options[i].selected = true; 
		}
	}
	*/
	
