
$(document).ready(function(){
	
	
	
	$('#finalizar').live('click',function() {	
	
	var valor_filial  = $('select[name="escolhe_filial"]').val();
	
	if ( valor_filial == 0  ){
	
	alert("Selecione a unidade que deseja enviar o orçamento!");
	
	} else {
		
		ajax_lista(valor_filial,'#lista_div','envia_lista.php');
		
		}
	
	
	
	})
	
	
$('#bt_fechar').live('click',function() {
$('#entrar').hide();

	})	
	
	
$('tr, button[class=bt_alterar]').live('click',function(event){

var y = event.pageY - 40 + 'px';
var x = event.pageX - 96 + 'px';

/*alert('y= ' + y + '  x= ' + x);*/

$('#retorno_div').show();
$('#retorno_div').css('top',y);
$('#retorno_div').css('left',x );

function some(){
	$('#retorno_div').hide().empty();
}

someb = setTimeout(some,4000);
}) 
	
	
	
	
	$('#minha_lista').live('click',function(){
		
	$('#lista_div_cont table tbody tr:odd').addClass('par');
	
	$('#minha_lista_cont').fadeTo('slow', 1.0);
})

	$('#fechar_lista').click(function(){
	$('#minha_lista_cont').fadeTo('slow', 0);
})
		
	
		jQuery('#cep').mask('99.999-999');
		$('#representantes').hide();
		
		$('#mostrarepre').click(function(){
		$('#representantes').show();
		})
		$('#fechar').click(function(){
		$('#representantes').hide();
		})	
		
$('#menu_pro > li').addClass('li_fora');
$("#menu_pro li ul").hide();
$('#menu_pro > li').bind('mouseenter', openSubMenu); 
$('#menu_pro > li').bind('mouseleave', closeSubMenu); 

function openSubMenu() {
$(this).addClass('li_emcima3 a'); 
$(this).find('ul').fadeIn('fast');
$(this).find('ul ul').hide();
$(this).addClass('li_emcima');
$(this).addClass('li_emcima2');
$(this).removeClass('li_fora');
};

function closeSubMenu() { 
$(this).find('ul').fadeOut('fast');
$(this).removeClass('li_emcima2');
$(this).addClass('li_fora');
$(this).removeClass('li_emcima3 a');
}; 




// INTRANET EXTRANET

$("#intraextra > ul").hide();
$('#intraextra > li').bind('click', openSubMenu2); 
$('#intraextra > li').bind('mouseleave', closeSubMenu2); 

function openSubMenu2() {
$(this).find('ul').fadeIn('fast');
};

function closeSubMenu2() { 
$(this).find('ul').fadeOut('fast');
};

// INTRANET EXTRANET

$('#entrar_mostra').click(function(e) {
	e.preventDefault();
	$('#entrar').load('login.php');
	$('#entrar').fadeIn('fast');

})

  

$('#logout').click(function(e) {
	
	window.location = 'logout.php';
	
})


$('#meus_dados').click(function(e) {
	e.preventDefault();
	$('#entrar').load('altera_cadastro.php');
	$('#entrar').fadeIn('fast');
})
});		
      
	 
function ajax2(v, div, linq){		
var iconCarregando = $('<span class="destaque">Processando Dados ...</span>');
var va = v;
var diva = div;
var linqa = linq;
 
	jQuery.ajax({
		
			url: linqa, 
			dataType: 'html',
			data: {re: va},
			type: 'GET',
			beforeSend: function() {
				$('#retorno_div').html(iconCarregando);
				},
				
			complete: function() {
				$(iconCarregando).remove();
				 },
			success: function(data, textStatus) {
			jQuery(diva).html(data);
			},
			error: function(xhr,er) {
			jQuery('#mensagem_erro').html('<p class="destaque">Error ' + xhr.status + ' - ' + xhr.statusText + '<br />Tipo de erro: ' + er +'</p>')
			}});		
					
}
 
function ajax_lista(v, div, linq){		
var iconCarregando = $('<span class="destaque">Processando Dados ...</span>');
var va = v;
var diva = div;
var linqa = linq;
 
	jQuery.ajax({
		
			url: linqa, 
			dataType: 'html',
			data: {id: va},
			type: 'GET',
			beforeSend: function() {
				$('#retorno_div').html(iconCarregando);
				},
				
			complete: function() {
				$(iconCarregando).remove();
				 },
			success: function(data, textStatus) {
			jQuery(diva).html(data);
			},
			error: function(xhr,er) {
			jQuery('#mensagem_erro').html('<p class="destaque">Error ' + xhr.status + ' - ' + xhr.statusText + '<br />Tipo de erro: ' + er +'</p>')
			}});		
					
		}
 
 
  function ajax_lista_altera(v, v2, div, linq){		
var iconCarregando = $('<span class="destaque">Processando Dados ...</span>');
var va = v2;
var vb = v;
var diva = div;
var linqa = linq;
 
 
/* alert(va + ' ' + vb + ' ' +  diva  + ' ' +  linqa);*/

	jQuery.ajax({
		
			url: linqa, 
			dataType: 'html',
			data: {qtd:vb,id: va },
			type: 'GET',
			beforeSend: function() {
				$('#retorno_div').html(iconCarregando);
				},
				
			complete: function() {
				$(iconCarregando).remove();
				 },
			success: function(data, textStatus) {
			jQuery(diva).html(data);
			},
			error: function(xhr,er) {
			jQuery('#mensagem_erro').html('<p class="destaque">Error ' + xhr.status + ' - ' + xhr.statusText + '<br />Tipo de erro: ' + er +'</p>')
			}});		
					
		}
 
 
   function ajax4(v, div, linq){		
var iconCarregando = $('<span class="destaque">Processando Dados ...</span>');
var va4 = v;
var diva4 = div;
var linqa4 = linq;
 
	jQuery.ajax({
		
			url: linqa4, 
			dataType: 'html',
			data: {p: va4},
			type: 'GET',
			beforeSend: function() {
				$('#retorno_div').html(iconCarregando);
				},
				
			complete: function() {
				$(iconCarregando).remove();
				 },
			success: function(data, textStatus) {
			jQuery(diva4).html(data);
			
			},
			error: function(xhr,er) {
			jQuery('#mensagem_erro').html('<p class="destaque">Error ' + xhr.status + ' - ' + xhr.statusText + '<br />Tipo de erro: ' + er +'</p>')
			}});					
		}      
		 
function ajax3(v1, v2, div, linq){		
var iconCarregando = $('<span class="destaque">Processando Dados ...</span>');
var va1 = v1;
var va2 = v2;
var diva = div;
var linqa = linq;
 
	jQuery.ajax({
		
			url: linqa, 
			dataType: 'html',
			data: {re1: va1, re2:va2},
			type: 'POST',
			
			beforeSend: function() {
				$('#retorno_div').html(iconCarregando);
				},
				
			complete: function() {
				$(iconCarregando).remove();
				 },
			
			success: function(data, textStatus) {
			jQuery(diva).html(data);
			},
			error: function(xhr,er) {
			jQuery('#mensagem_erro').html('<p class="destaque">Error ' + xhr.status + ' - ' + xhr.statusText + '<br />Tipo de erro: ' + er +'</p>')
			}});		
					
}	
// FECHA JANELA	

$('#centro_fechar').live('click', function() {
		$('#fundo').fadeTo('slow', 0.5).css({opacity:0.0,}).hide();
		$('#central').empty().hide();
});
$('#fundo').live('click', function() {
		$(this).fadeTo('slow', 0.5).css({opacity:0.0,}).hide();
		$('#central').hide();
		$('#central').empty().hide();
});

$('#imagem_menor_gal img').live('mouseenter',function(event) {
	event.preventDefault();		
	  $('#imagem_maior_gal img').remove();
	  $('<img height="480" />').attr('src', $(this).attr('src')).appendTo('#imagem_maior_gal').fadeTo('slow', 1.0);								
});

// centraliza div
$.fn.center = function (absolute) {
	return this.each(function () {
		var t = $(this);

		t.css({
			position:	absolute ? 'absolute' : 'fixed', 
			left:		'50%', 
			top:		'50%', 
			zIndex:		'99'
		}).css({
			marginLeft:	'-' + (t.outerWidth() / 2) + 'px', 
			marginTop:	'-' + (t.outerHeight() / 2) + 'px'
		});

		if (absolute) {
			t.css({
				marginTop:	parseInt(t.css('marginTop'), 10) + $(window).scrollTop(), 
				marginLeft:	parseInt(t.css('marginLeft'), 10) + $(window).scrollLeft()
			});
		}
	});
};
<!--SLIDE IMAGENS-->
function centraliza(div){
     $(div).show();
	 $(div).center(true);
	 $('#fundo').css({opacity:0.5,width:$(document).width(),height:$(document).height()}).fadeTo('slow', 0.5).show();
   }
 
  $(document).ready(function(){
	  
	  var inicia = 0;
		 
    function swapImages(){
			
      var $active = $('#imagens img.active');
      var $next = ($('#imagens img.active').next().length > 0) ? $('#imagens img.active').next() : $('#imagens img:first');
      $active.fadeOut(function(){
      $active.removeClass('active');
      $next.fadeIn().addClass('active');
      
      });
    }
		
	if($('#imagens img').length <= 1){
		$('#imagens img').addClass('active');
		}else{
	$('#imagens img:first').addClass('active');
      // Run our swapImages() function every 5secs
     inicia = setInterval(swapImages, 8000); 
	 }  	  
    });
<!--SLIDE IMAGENS-->



function nao_autenticado(){
$('#retorno_div').empty().html("<div class='pro_atencao'>Você só poderá adicionar um produto na lista após ter efetuado autenticação, Obrigado!.</div>");
}




