/* abas produtos */
$(document).ready(function(){
	$( "#tabs" ).tabs();
});

$(function(){
  
  // The "tab widgets" to handle.
  var tabs = $('.tabs'),
    
    // This selector will be reused when selecting actual tab widget A elements.
    tab_a_selector = 'ul.ui-tabs-nav a';
  
  // Enable tabs on all tab widgets. The `event` property must be overridden so
  // that the tabs aren't changed on click, and any custom event name can be
  // specified. Note that if you define a callback for the 'select' event, it
  // will be executed for the selected tab whenever the hash changes.
  tabs.tabs({ event: 'change' });
  
  // Define our own click handler for the tabs, overriding the default.
  tabs.find( tab_a_selector ).click(function(){
    var state = {},
      
      // Get the id of this tab widget.
      id = $(this).closest( '.tabs' ).attr( 'id' ),
      
      // Get the index of this tab.
      idx = $(this).parent().prevAll().length;
    
    // Set the state!
    state[ id ] = idx;
    $.bbq.pushState( state );
  });
  
  // Bind an event to window.onhashchange that, when the history state changes,
  // iterates over all tab widgets, changing the current tab as necessary.
  $(window).bind( 'hashchange', function(e) {
    
    // Iterate over all tab widgets.
    tabs.each(function(){
      
      // Get the index for this tab widget from the hash, based on the
      // appropriate id property. In jQuery 1.4, you should use e.getState()
      // instead of $.bbq.getState(). The second, 'true' argument coerces the
      // string value to a number.
      var idx = $.bbq.getState( this.id, true ) || 0;
      
      // Select the appropriate tab for this tab widget by triggering the custom
      // event specified in the .tabs() init above (you could keep track of what
      // tab each widget is on using .data, and only select a tab if it has
      // changed).
      $(this).find( tab_a_selector ).eq( idx ).triggerHandler( 'change' );
    });
  })
  
  // Since the event is only triggered when the hash changes, we need to trigger
  // the event now, to handle the hash the page may have loaded with.
  $(window).trigger( 'hashchange' );
  
});

//navega pela fotos dos produtos
$(document).ready(function(){
	$('#s1').cycle({
	    fx:     'none',
	    prev:   '#prev1',
	    next:   '#next1',
	    timeout: 0
	});
	
	$('#s2').cycle({
	    fx:     'none',
	    prev:   '#prev2',
	    next:   '#next2',
	    timeout: 0
	});
});


// alterar quando publicar o site
	$(document).ready(function(){
        $('#s1 a').lightBox({
		    imageLoading: 'http://alutal.com.br/img/lightbox-ico-loading.gif',
			imageBtnClose: 'http://alutal.com.br/img/lightbox-btn-close.gif',
			imageBtnPrev: 'http://alutal.com.br/img/lightbox-btn-prev.gif',
			imageBtnNext: 'http://alutal.com.br/img/lightbox-btn-next.gif'
        });
    });


// alterar quando publicar o site

	$(document).ready(function(){
        $('#tabelas a').lightBox({
		    imageLoading: 'http://alutal.com.br/img/lightbox-ico-loading.gif',
			imageBtnClose: 'http://alutal.com.br/img/lightbox-btn-close.gif'
        });
    });


//menu lateral produtoDetalhe
$(document).ready(function(){
	
	// estado inicial
	$('.acc_container').hide(); // oculta todos os containers
	$('.acc_trigger1').addClass('active').next().show(); // adiciona a class "active" no item com a classe "acc.trigger1" e abre o container imediatamente seguinte
	
	// no clique
	$('.acc_trigger').click(function(){
		if( $(this).next().is(':hidden') ) { 
			$('.acc_trigger').removeClass('active').next().slideUp(); 
			$('.acc_trigger1').removeClass('active').next().slideUp(); 
			$(this).toggleClass('active').next().slideDown(); 
		}
		return false; 
	});
	
	$('.acc_trigger1').click(function(){
		if( $(this).next().is(':hidden') ) { 
			$('.acc_trigger1').removeClass('active').next().slideUp(); 
			$('.acc_trigger').removeClass('active').next().slideUp(); 
			$(this).toggleClass('active').next().slideDown();
		}
		return false; 
	});
});

$(document).ready(function(){
	$("#termo:input").labelify({text: "label"});
	$("#mailNews:input").labelify({text: "label"});	
	$("#login1:input").labelify({text: "label"});
	$("#senha1:input").labelify({text: "label"});
	$("#login2:input").labelify({text: "label"});
	$("#senha2:input").labelify({text: "label"});	
	$("#senha:input").labelify({text: "label"});
	$("#login:input").labelify({text: "label"});	
	$("#nome1:input").labelify({text: "label"});
	$("#empresa1:input").labelify({text: "label"});
	$("#telefone1:input").labelify({text: "label"});
	$("#usuario1:input").labelify({text: "label"});
	$("#senha4:input").labelify({text: "label"});
});


//modal rec senha
$(document).ready(function() {	

	$('a[name=modal]').click(function(e) {
		e.preventDefault();
		
		var id = $(this).attr('href');
	
		var maskHeight = $(document).height();
		var maskWidth = $(window).width();
	
		$('#mask').css({'width':maskWidth,'height':maskHeight});

		$('#mask').fadeIn(500);	
		$('#mask').fadeTo("fast",0.9);	
	
		//Get the window height and width
		var winH = $(window).height();
		var winW = $(window).width();
              
		$(id).css('top',  winH/2-$(id).height()/2);
		$(id).css('left', winW/2-$(id).width()/2);
	
		$(id).fadeIn(1000); 	
	});
	
	$('.window .close').click(function (e) {
		e.preventDefault();
		
		$('#mask').hide();
		$('.window').hide();
	});		
	
	$('#mask').click(function () {
		$(this).hide();
		$('.window').hide();
	});			
	
});


$(document).ready(function() {
    $('.efeito_fade').append('<span class="hover"></span>').each(function () {
        var $span = $('> span.hover', this).css('opacity', 0);
        $(this).hover(function () {
            $span.stop().fadeTo(500, 1);
        }, function () {
            $span.stop().fadeTo(500, 0);
        });
    });
});

	
	$(document).ready(function(){
	     $("#a_fone").mask("99-9999-9999");
	     $("#c_telefone").mask("99-9999-9999");	   
	     $("#or_telefone").mask("99-9999-9999");		     
	     $("#telefone").mask("99-9999-9999");		       
	});
	
//pop up novo endereço e fone

$(document).ready(function() {
	$('#popup').click(function () {
		$(this).hide();
	});	
});
