// JavaScript Document
//####################################################################################################
//####################################################################################################
//FUNÇÕES GLOBAIS COM JQUERY                                                                         #
//####################################################################################################
//####################################################################################################


		//####################################################################################################
		//----------------------------------------------------------------------------------------------------		
		$(document).ready(function(){ 
								   
			$(document).pngFix(); 
			
			$(".aba:first").show();
					
				$("#nav-aba a").click(function(){
				   $(".aba").hide();
				   var div = $(this).attr('href');
				   $(div).show();
				   
				   return false;
				});
				
			/*$('#mycarousel').jcarousel({
				wrap: 'circular'
			});*/
			
			$(".view_picture_full").fancybox({
				'autoScale'     	: true,
				'transitionIn'		: 'elastic',
				'transitionOut'		: 'elastic',
				'easingIn'      	: 'easeOutBack',
				'easingOut'     	: 'easeInBack'
				
			});
			$("a[rel=pic_group]").fancybox({
				'autoScale'     	: true,
				'transitionIn'		: 'elastic',
				'transitionOut'		: 'elastic',
				'easingIn'      	: 'easeOutBack',
				'easingOut'     	: 'easeInBack',
				'titlePosition' 	: 'over',
				'titleFormat'       : function(title, currentArray, currentIndex, currentOpts) {
					return '<span id="fancybox-title-over">Image ' +  (currentIndex + 1) + ' / ' + currentArray.length + ' ' + title + '</span>';
				}
			});
			
			//$("#telefone").mask("(99) 9999 - 9999");
			
			$("#content > div").hide();
			$("#content > div:eq(0)").show();
			$("#tabs > a:eq(0)");
			
			
			$("select[name=cod_estados]").change(function(){
														  
				$("select[name=cod_cidades]").html('<option value="0">Carregando...</option>');				
				$.post("./lib/ajax/ajax.php",{
					   cod_estados:$(this).val(),
					   ParentName:'sortbystate'
					   },
						  function(valor){
							 $("select[name=cod_cidades]").html(valor);
						  }
					  )
				
			 });
			
			$('#gotosearch').click(function(){
											
				$("#load_content_revendas").html('<div style="margin:0 auto; margin-top:30px;"><img src="assets/images/ajax-loader.gif"> Carregando...</div>');				
				$.post("./lib/ajax/ajax.php",{
					   cod_estados:$('#cod_estados').val(),
					   cod_cidades:$('#cod_cidades').val(),
					   ParentName:'sortbyfilter'
					   },
						  function(valor){
							 $("#load_content_revendas").html(valor);
						  }
					  )
				
			 });
			
	
		}); 
		//----------------------------------------------------------------------------------------------------		
		//####################################################################################################

		//####################################################################################################
		//----------------------------------------------------------------------------------------------------		
		function opentab(num) {
				$("#content > div").hide();
				$("#content > div:eq(" + (num-1) + ")").fadeIn();
				$("#tabs > a");
				$("#tabs > a:eq(" + (num-1) + ")");	
			}		
		//----------------------------------------------------------------------------------------------------		
		//####################################################################################################

		function mudaDiv(id_div){
			id = document.getElementById("menu"+id_div);
			var novo_id = id_div;
			if(id_div==1){
				novo_id++;
			} else if(id_div==2) {
				novo_id--;
			}
			novo = document.getElementById("menu"+novo_id);
			id.style.display="block";
			novo.style.display="none";
		}
		function MM_showHideLayers() { //v9.0
		  var i,p,v,obj,args=MM_showHideLayers.arguments;
		  for (i=0; i<(args.length-2); i+=3) 
		  with (document) if (getElementById && ((obj=getElementById(args[i]))!=null)) { v=args[i+2];
			if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
			obj.visibility=v; }
		}
