(function ($) {
	jQuery(function($){		
		/* Caixa Parcelamento Detalhe do Produto */
   		$('#verP').click(function(event){
   			$('#mudarP').show();
		});
   		$('#fecharP').click(function(event){
   			$('#mudarP').hide();
   		});
   				
		var url_site = $('#url_site').val();
        var url_https = window.location.href;
        
        url = url_https.split(':');		
        
        url_http = url_site.split(':');       
        if(url[0] == 'http'){
        	url_site = "http:"+url_http[1];
        }
        else{
                url_site = "https:"+url_http[1];
        }	
	/* Remove box parcelamento de produto Agrupado */
	if($('.catalog-product-view').size()) {
		if($('.price-to').size()){
			$('#bonus').hide();
		}
	}
			
        /* FunÃƒÂ§ÃƒÂ£o para ImpressÃƒÂ£o automatica de boleto */        
		if($('.billet-standard-redirect').size()){
			$('#billet').submit();
		}
		
        /* AlteraÃƒÂ§ÃƒÂµes no carrinho */
        if($('#cart_true').val() == 1){    
        	
        	$('#wrap_cart_botton').height($('#inferior_carrinho').height());
        	if($.browser.msie){
        		$("#busca_sm input.input-texto").css('margin-left','0px');
        		$("#shopping-cart-totals-table strong").last().css('width','118px');
        	}
        	$('.finalizar_pedido').click(function(event) {
        		window.location = $(this).attr('alt')+'checkout/onepage/';
        	});
                 
		    if($.browser.msie){
				$("#shopping-cart-totals-table strong").last().css('float','left');
				$("#shopping-cart-totals-table strong").last().css('width','118px');
				$("#shopping-cart-totals-table strong").last().css('clear','none');	
            }
			
			/** AJAX - MÉTODO DE ENVIO **/ 
		$('#co-shipping-method-form input').click(function(event){
					/* Carrega Div Ajax */
			        carregaDivAjax('loadimg');
                    
                    CarrierLoad = 'vazio';
                    ValorTotal  = $('#shopping-cart-totals-table strong:eq(1)').html().replace('R$',''); 
				    ValorTotal = ValorTotal.replace('.', '').replace(',','.');
				    ValorTotal = parseFloat(ValorTotal);		   
				    method = $(this).val();
                    Carrier = $(this).attr('rel');
                    ValorCarrier = parseFloat($(this).attr('alt'));
                    action = $('#co-shipping-method-form').attr('action');
                    if($('#shopping-cart-totals-table strong:eq(1)').attr('alt')){
                    	CarrierOld = parseFloat($('#shopping-cart-totals-table strong:eq(1)').attr('alt'));
                    }
                    else{
                    	if($('#carrier_valor').size() !=0){
                    		if($.browser.msie){
                    			CarrierLoad = $('#carrier_valor').html().replace('</TD><TD class=a-right>R$','');
                    			regex = "</TD></TR>";
                    			CarrierLoad = CarrierLoad.replace(regex, '');
                    			CarrierLoad = CarrierLoad.replace('R$', '');
                    		}
                    		else{
                    			CarrierLoad = parseFloat($('#carrier_valor').html().replace('R$',''));
                    		}
                    	}	
                    }
                    $.post(action,{estimate_method:method}, function(data){
                    	if($('#carrier_nome').size() == 0){
                    		$('#ref_carrier').html(
                    				"<span id='carrier_nome' class='resume_left'>"+
                    				Carrier+
                    				"</span><span id='carrier_valor' class='resume_right'>"+
                    				ValorCarrier+
                    				"</span>"
                    		);
                    	}
                    	else{
                    		$('#carrier_nome').html(Carrier);
                         	$('#carrier_valor').html('R$'+ValorCarrier);
                    	}
			ValorTotal = (parseFloat(ValorTotal) + parseFloat(ValorCarrier));
			if($('#shopping-cart-totals-table strong:eq(1)').attr('alt')){
                    		if(parseFloat(CarrierOld) != 0){	
                    			ValorTotal = parseFloat(ValorTotal) - parseFloat(CarrierOld);
                    		}
                    	}
                    	else{
                    		if(CarrierLoad != 'vazio'){			
                    			if(parseFloat(CarrierLoad) != 0){	
                    				ValorTotal = parseFloat(ValorTotal) - parseFloat(CarrierLoad);
                    			}
                    		}	
                    	}
                    	
                    	$('#shopping-cart-totals-table strong:eq(1)').attr('alt', parseFloat(ValorCarrier));                        
                    	$('#shopping-cart-totals-table strong:eq(1)').html(''+ValorTotal).formatCurrency({region:'pt-BR'}); 
                    	$('#carrier_valor').formatCurrency({region:'pt-BR'});
                    	
                    	/* Fecha Div Ajax */
                    	fechaDivAjax('loadimg');
                     });
                        
				});
				
				/** AJAX - EMBALAGEM PARA PRESENTE - POR CARRINHO **/
				$('#giftwrap_carrinho_inteiro').click(function(event){
			        /* Carrega Div Ajax */
			        carregaDivAjax('loadimg');
                    
                    utiliza_carrinho_checked = $('#giftwrap_carrinho_inteiro').attr("checked");
                    action = $('#giftwrap_carrinho_inteiro').attr('url');

                    /** Cria Campo Hidden Para Post **/
                    if(utiliza_carrinho_checked){
                    	var checkHidden = document.createElement('input');
                    	checkHidden.setAttribute('name', 'giftwrap_carrinho_inteiro_hidden');
	                    checkHidden.setAttribute('type', 'checkbox');
	                    checkHidden.setAttribute('checked', 'true');
	                    checkHidden.style.display = 'none';
	                    $('#myform').append(checkHidden);
                    }else{
                    	$('[name=giftwrap_carrinho_inteiro_hidden]').remove();
                    }
                    
                    dados  = $('#myform').serialize();
                    
                    $.post(action, dados, function(data){
                    	var giftwrap_amount = parseFloat(data);
                    	
                    	/** Controla a Imagem de Embalagem dos Produtos **/
                    	$('#shopping-cart-table').children('li').each(function(){
				        	if($(this).attr('class') == 'car_list_main_gift'){
				        		$(this).children('div').each(function(){
				        			if($(this).attr('class') == 'mostraImagemPresente'){
						        		if(utiliza_carrinho_checked){
						            		$(this).fadeIn();
						            	}else{
						            		$(this).fadeOut();
						            	}	
						        	}
				        		});
				        		return false;
				        	}
				        });
				        
				        /** Controla o Valor Total **/
				        var complementoValorPresente = new Number();
				        if(utiliza_carrinho_checked){
				        	complementoValorPresente = giftwrap_amount;
	                    }else{
	                    	complementoValorPresente = $('#valor_presente_div').html();
	                    	complementoValorPresente = complementoValorPresente.replace('</TD><TD class=a-right>R$','');
	                    	complementoValorPresente = complementoValorPresente.replace('</TD></TR>', '');
	                    	complementoValorPresente = complementoValorPresente.replace('R$', '');
	                    	complementoValorPresente = complementoValorPresente.replace(',','.');
	                    	complementoValorPresente = - (parseFloat(complementoValorPresente));
	                    }
	                    
	                    var valorTotal = $('#shopping-cart-totals-table strong:eq(1)').html().replace('R$', '').replace(',','.');
	                    valorTotal = (parseFloat(valorTotal) + parseFloat(complementoValorPresente)).toFixed(2).replace('.',',');
	                    $('#shopping-cart-totals-table strong:eq(1)').html('R$' + valorTotal);
	                    
                    	giftwrap_amount = parseFloat(giftwrap_amount).toFixed(2).replace('.',',');
                    	$('#valor_presente_div').html('R$' + giftwrap_amount);
	                    
						/* Fecha Div Ajax */
                    	fechaDivAjax('loadimg');
                    });
				});
				
				/** AJAX - EMBALAGEM PARA PRESENTE - POR PRESENTE **/
				$('.giftwrap_unidade_presente').click(function(event){
			        /* Carrega Div Ajax */
			        carregaDivAjax('loadimg');
                    
                    action = $(this).attr('url');
                    dados  = $('#myform').serialize();
                    
                    $.post(action, dados, function(data){
                    	var giftwrap_amount = parseFloat(data);
                    	
                    	if($('#valor_subtotal_original')[0]){
                    		var valor_subtotal_original_temp = $('#valor_subtotal_original').val();
                    		
	                    	var valorTotal = valor_subtotal_original_temp.replace('R$', '').replace(',','.');
		                    valorTotal = (parseFloat(valorTotal) + parseFloat(giftwrap_amount)).toFixed(2).replace('.',',');
		                    $('#shopping-cart-totals-table strong:eq(1)').html('R$' + valorTotal);
	                    	
					        giftwrap_amount = parseFloat(giftwrap_amount).toFixed(2).replace('.',',');
					        $('#valor_presente_div').html('R$' + giftwrap_amount);
					        
							/* Fecha Div Ajax */
                    		fechaDivAjax('loadimg');
                    	}
                    });
				});
				
				$('[name=estimate_postcode]').blur(function(event){
					$(this).val(
						$(this).val().replace('-', '')
					);	
				});	
        }
        
        /* FunÃƒÂ§ÃƒÂµes para formulario Opine */
		$('.ancora').click(function(){
			$('html,body').animate({
				scrollTop: $('[rel='+$(this).attr("id")+']').offset().top}, 2000);
			$('.opine #show').hide();
			$('.opine #hide').show();
			$('#frmopn').show();
			
		});		

		/* FunÃƒÂ§ÃƒÂ£o menu lateral esquerdo de ocultamento */
		$('.maisDpt').click(function(event){
			$('.menujs ul').hide();
			$('#menu_'+ $(this).attr('rel') + ' ul').show();
		});
		
		var posMenu;
		if($('#home_page').val() != 1){	
			$.post(url_site +"first.php", function(data){
				$('.menujs ul').hide();
				$('.menujs h4 li').show();
				$('#menu_'+ data + ' ul').show();
				$('#menu_'+ data).insertAfter('#menu_first');
	            if($('#menu_'+ data + ' .menu_lateral_box').size() == 0){
	            	$('.menu_lateral_box_base').insertAfter('#menu_'+ data);
					$('.menu_lateral_box_base').removeClass().addClass('menu_lateral_box');
					$('#menu_'+ Number(data - 1) + ' .menu_lateral_box').removeClass().addClass('menu_lateral_box_base');
	            }
				if($('.menu_conteudo .menu_lateral_box_base').size() == 0){
					$('.menu_lateral_box').last().removeClass().addClass('menu_lateral_box_base');
				}
	
			});
		}
		$('.pMenu').click(function(){
			posMenu = $(this).attr('rel');
			local = $(this).attr('href');
			$.post(url_site +"first.php", {posMenu:posMenu}, function(data){				
					if(data){
					}
					else{
						window.location = local; 
					}
			});
		});
		$('[alt=pMenu]').click(function(){
			posMenu = $(this).attr('rel');
			local = $(this).attr('href');
			$.post(url_site +"first.php", {posMenu:posMenu}, function(data){				
					if(data){
					}
					else{
						window.location = local; 
					}
			});
		});
			
		//Mascaras de input
		$("#cpf").mask("999.999.999-99");
		$("#cnpj").mask("99.999.999/9999-99");
		$("#rg").mask("99.999.999-9");
		$(".cep").mask("99999999");	
		$(".cep").blur(function(){
			$(this).val($(this).val().replace('-', ''));
		});
		$("[title=Telefone Comercial]").mask("(99) 9999-9999");
		$("[title=Telefone]").mask("(99) 9999-9999");
		$("#aitreg-aitoc_checkout_126").mask("(99) 9999-9999");
		$("#day").mask("99");
		$("#month").mask("99");
		$("#year").mask("9999");
		
		//Light box da pagina de produtos
		$('.cloud-zoom-gallery').click(function(event){			
			$('#lightb').attr('href', $(this).attr('href'));
		});
		$('#lightb').lightBox();
		/*
		//Pular de campo depois de preenchido data
		  Está apresentando erro no Firefox
		$('#day').keypress(function(event) {
			if($('#day').val().replace('_', '').trim().length == 2){ $('#month').focus(); }
		});
		$('#month').keypress(function(event) {
			if($('#month').val().replace('_', '').trim().length == 2){ $('#year').focus(); }
		});
		*/
		//billing alteraÃ‚ï¿½Ã¢â‚¬Â¹o juridica para fisica
		$('#showPJ').click(function(event){
			$('[title=Sobrenome]:first').val('juridica');
			$('.name-firstname:first label').html('<em>*</em>Raz&atilde;o');
			$('.name-lastname:first').hide();
			$('#input-emissor').hide();
			$('[title=rg]').width('230px');
			$('#input-rg input').css('width', '230px');
			$('#input-rg label').html('I.E');
			$('#cpf_label').html('CNPJ');
			$("#cpf").unmask().mask("99.999.999/9999-99");
			$('#dob').hide();
			$('#gender').hide();
			$('#responsa').show();
			$('#im').show();
		});
		$('#showPF').click(function(event){
			$('[title=Sobrenome]').val('');
			$('.name-firstname:first label').html('<em>*</em>Nome');
			$('.name-lastname:first').show();
			$('#input-emissor').show();
			$('[title=rg]').css('width', '110px');
			$('#input-rg input').css('width', '110px');
			$('#input-rg label').html('<em>*</em>RG');
			$('#cpf_label').html('CPF');
			$("#cpf").unmask().mask("999.999.999-99");
			$('#dob').show();
			$('#gender').show();
			$('#responsa').hide();
			$('#im').hide();
		});

		//funcao para exibir e esconder div
		$('#show').click(function(event){
			div = $(this).attr('class');	
			$('#'+div).show();
			$(this).hide();
		});
		$('#hide').click(function(event){
			div = $(this).attr('class');	
			$('#'+div).hide();
			$("#show").show();
		});
        $('.cep').blur(function(event){
        	var inputPlace = $(this).attr('id').split('_');
			var inputPlace = inputPlace[1];	
            if($.trim($(this).val()) != ""){
            	$.getScript(url_site+"buscacep/?cep="+$(this).val(), function(){
            		if(resultadoCEP["resultado"] && resultadoCEP["bairro"] != ""){
            			$("#rua_"+inputPlace).val(unescape(resultadoCEP["tipo_logradouro"])+": "+unescape(resultadoCEP["logradouro"]));
                        $("#bairro_"+inputPlace).val(unescape(resultadoCEP["bairro"]));
                        $("#cidade_"+inputPlace).val(unescape(resultadoCEP["cidade"]));
                        $("#"+unescape(resultadoCEP["uf"])).attr('selected', 'selected');
                        $("#_"+unescape(resultadoCEP["uf"])).attr('selected', 'selected');
                        $("#_"+unescape(resultadoCEP["uf"])).attr('selected', 'selected');
                        var uf = unescape(resultadoCEP["uf"]);
                        			switch (uf)
                                        {
                                                case 'AC':
                                                        $("#estado_"+inputPlace+" select").children('option[value="320"]').attr({ selected : "selected" });
                                                        break;
                                                case 'AL':
                                                        $("#estado_"+inputPlace+" select").children('option[value="321"]').attr({ selected : "selected" });
                                                        break;
                                                case 'AP':
                                                        $("#estado_"+inputPlace+" select").children('option[value="322"]').attr({ selected : "selected" });
                                                        break;
                                                case 'AM':
                                                        $("#estado_"+inputPlace+" select").children('option[value="323"]').attr({ selected : "selected" });
                                                        break;
                                                case 'BA':
                                                        $("#estado_"+inputPlace+" select").children('option[value="324"]').attr({ selected : "selected" });
                                                        break;
                                                case 'CE':
                                                        $("#estado_"+inputPlace+" select").children('option[value="325"]').attr({ selected : "selected" });
                                                        break;
                                                case 'DF':
                                                        $("#estado_"+inputPlace+" select").children('option[value="326"]').attr({ selected : "selected" });
                                                        break;
                                                case 'ES':
                                                        $("#estado_"+inputPlace+" select").children('option[value="327"]').attr({ selected : "selected" });
                                                        break;
                                                case 'GO':
                                                        $("#estado_"+inputPlace+" select").children('option[value="328"]').attr({ selected : "selected" });
                                                        break;
                                                case 'MA':
                                                        $("#estado_"+inputPlace+" select").children('option[value="329"]').attr({ selected : "selected" });
                                                        break;
                                                case 'MT':
                                                        $("#estado_"+inputPlace+" select").children('option[value="330"]').attr({ selected : "selected" });
                                                        break;
                                                case 'MS':
                                                        $("#estado_"+inputPlace+" select").children('option[value="331"]').attr({ selected : "selected" });
                                                        break;
                                               case 'MG':
                                                        $("#estado_"+inputPlace+" select").children('option[value="332"]').attr({ selected : "selected" });
                                                        break;
                                                case 'PA':
                                                        $("#estado_"+inputPlace+" select").children('option[value="333"]').attr({ selected : "selected" });
                                                        break;
                                                case 'PB':
                                                        $("#estado_"+inputPlace+" select").children('option[value="334"]').attr({ selected : "selected" });
                                                        break;
                                                case 'PR':
                                                        $("#estado_"+inputPlace+" select").children('option[value="335"]').attr({ selected : "selected" });
                                                        break;
                                                case 'PE':
                                                        $("#estado_"+inputPlace+" select").children('option[value="336"]').attr({ selected : "selected" });
                                                        break;
                                                case 'PI':
                                                        $("#estado_"+inputPlace+" select").children('option[value="337"]').attr({ selected : "selected" });
                                                        break;
                                                case 'RJ':
                                                        $("#estado_"+inputPlace+" select").children('option[value="338"]').attr({ selected : "selected" });
                                                        break;
                                                case 'RN':
                                                        $("#estado_"+inputPlace+" select").children('option[value="339"]').attr({ selected : "selected" });
                                                        break;
                                                case 'RS':
                                                        $("#estado_"+inputPlace+" select").children('option[value="340"]').attr({ selected : "selected" });
                                                        break;
                                                case 'RO':
                                                        $("#estado_"+inputPlace+" select").children('option[value="341"]').attr({ selected : "selected" });
                                                        break;
                                                case 'RR':
                                                        $("#estado_"+inputPlace+" select").children('option[value="342"]').attr({ selected : "selected" });
                                                        break;
                                                case 'SC':
                                                        $("#estado_"+inputPlace+" select").children('option[value="343"]').attr({ selected : "selected" });
                                                        break;
                                                case 'SP':
                                                        $("#estado_"+inputPlace+" select").children('option[value="344"]').attr({ selected : "selected" });
                                                        break;
                                                case 'SE':
                                                        $("#estado_"+inputPlace+" select").children('option[value="345"]').attr({ selected : "selected" });
                                                        break;
                                                case 'TO':
                                                        $("#estado_"+inputPlace+" select").children('option[value="346"]').attr({ selected : "selected" });
                                                        break;


                                        }
                                                        $('#numero').focus();
                                }
                                else{
                                        alert("EndereÃƒÆ’Ã‚Â§o nÃƒÆ’Ã‚Â£o encontrado");
                                         return false;
                                }
                        });
                        }
                        else
                        {
                            alert('Antes, preencha o campo CEP!')
                        }
                });
        
     

		//funcao auto preenchimento de CEP
	 	$('.cep_busca').click(function(event){
			var inputPlace = $(this).attr('title');
			if($.trim($("#cep_"+ $(this).attr('title')).val()) != ""){
				$.getScript(url_site+"buscacep/?cep="+$("#cep_"+ $(this).attr('title')).val(), function(){
				if(resultadoCEP["resultado"] && resultadoCEP["bairro"] != ""){
					$("#rua_"+inputPlace).val(unescape(resultadoCEP["tipo_logradouro"])+": "+unescape(resultadoCEP["logradouro"]));
					$("#bairro_"+inputPlace).val(unescape(resultadoCEP["bairro"]));
					$("#cidade_"+inputPlace).val(unescape(resultadoCEP["cidade"]));
					$("#"+unescape(resultadoCEP["uf"])).attr('selected', 'selected');
					$("#_"+unescape(resultadoCEP["uf"])).attr('selected', 'selected');
					$("#_"+unescape(resultadoCEP["uf"])).attr('selected', 'selected');

					var uf = unescape(resultadoCEP["uf"]);
					switch (uf)
					{
						case 'AC':
							$("#estado_"+inputPlace+" select").children('option[value="320"]').attr({ selected : "selected" });
							break;
						case 'AL':
							$("#estado_"+inputPlace+" select").children('option[value="321"]').attr({ selected : "selected" });
							break;
						case 'AP':
							$("#estado_"+inputPlace+" select").children('option[value="322"]').attr({ selected : "selected" });
							break;
						case 'AM':
							$("#estado_"+inputPlace+" select").children('option[value="323"]').attr({ selected : "selected" });
							break;
						case 'BA':
							$("#estado_"+inputPlace+" select").children('option[value="324"]').attr({ selected : "selected" });
							break;
						case 'CE':
							$("#estado_"+inputPlace+" select").children('option[value="325"]').attr({ selected : "selected" });
							break;
						case 'DF':
							$("#estado_"+inputPlace+" select").children('option[value="326"]').attr({ selected : "selected" });
							break;
						case 'ES':
							$("#estado_"+inputPlace+" select").children('option[value="327"]').attr({ selected : "selected" });
							break;
						case 'GO':
							$("#estado_"+inputPlace+" select").children('option[value="328"]').attr({ selected : "selected" });
							break;
						case 'MA':
							$("#estado_"+inputPlace+" select").children('option[value="329"]').attr({ selected : "selected" });
							break;
						case 'MT':
							$("#estado_"+inputPlace+" select").children('option[value="330"]').attr({ selected : "selected" });
							break;
						case 'MS':
							$("#estado_"+inputPlace+" select").children('option[value="331"]').attr({ selected : "selected" });
							break;
						case 'MG':
							$("#estado_"+inputPlace+" select").children('option[value="332"]').attr({ selected : "selected" });
							break;
						case 'PA':
							$("#estado_"+inputPlace+" select").children('option[value="333"]').attr({ selected : "selected" });
							break;
						case 'PB':
							$("#estado_"+inputPlace+" select").children('option[value="334"]').attr({ selected : "selected" });
							break;
						case 'PR':
							$("#estado_"+inputPlace+" select").children('option[value="335"]').attr({ selected : "selected" });
							break;
						case 'PE':
							$("#estado_"+inputPlace+" select").children('option[value="336"]').attr({ selected : "selected" });
							break;
						case 'PI':
							$("#estado_"+inputPlace+" select").children('option[value="337"]').attr({ selected : "selected" });
							break;
						case 'RJ':
							$("#estado_"+inputPlace+" select").children('option[value="338"]').attr({ selected : "selected" });
							break;
						case 'RN':
							$("#estado_"+inputPlace+" select").children('option[value="339"]').attr({ selected : "selected" });
							break;
						case 'RS':
							$("#estado_"+inputPlace+" select").children('option[value="340"]').attr({ selected : "selected" });
							break;
						case 'RO':
							$("#estado_"+inputPlace+" select").children('option[value="341"]').attr({ selected : "selected" });
							break;
						case 'RR':
							$("#estado_"+inputPlace+" select").children('option[value="342"]').attr({ selected : "selected" });
							break;
						case 'SC':
							$("#estado_"+inputPlace+" select").children('option[value="343"]').attr({ selected : "selected" });
							break;
						case 'SP':
							$("#estado_"+inputPlace+" select").children('option[value="344"]').attr({ selected : "selected" });
							break;
						case 'SE':
							$("#estado_"+inputPlace+" select").children('option[value="345"]').attr({ selected : "selected" });
							break;
						case 'TO':
							$("#estado_"+inputPlace+" select").children('option[value="346"]').attr({ selected : "selected" });
							break;
					
					
					}
							$('#numero').focus();
				}
				else{
					alert("EndereÃƒÆ’Ã‚Â§o nÃƒÆ’Ã‚Â£o encontrado");
					return false;
				}
			});
			}
    			else
    			{
    			    alert('Antes, preencha o campo CEP!')
    			}
		});
		
	});
})(jQuery);

function date_focus(local, foco){	
	valor = document.getElementById(local).value; alert(local);
	
	if (valor.length == 2){ alert(foco); document.getElementById(foco).focus();  }		
}

function carregaDivAjax(idDiv){
	jQuery(function($){
       	$('#loadg').css("width", $(window).width());
	    $('#loadg').css("height", $(window).height() + 330);
	    $('#loadg').slideDown('slow');
	    
    	/* Centraliza Div na Tela */
    	controlaPosicaoDivTela(idDiv);
	});
}

function fechaDivAjax(idDiv){
	jQuery(function($){	
		$('#loadg').slideUp('slow');
	    $('#'+idDiv).fadeOut('slow');
	});
}

/* ======= INICIO FUNÇÕES - CENTRALIZAR OBJETOS EM TELA ======= */ 
function controlaPosicaoDivTela(idDiv){
	jQuery(function($){
		var distanciaTop   = f_scrollTop();
		var distanciaLeft  = f_scrollLeft();
		var areaUtilWidth  = f_clientWidth();
		var areaUtilHeight = f_clientHeight();
		var divWidth	   = document.getElementById(idDiv).style.width.replace('px','');  //offsetWidth;
		var divHeight	   = document.getElementById(idDiv).style.height.replace('px',''); //offsetHeight;
		
		/* Calculando Posição */
		var posicaoXDiv = ((areaUtilWidth  / 2) - (divHeight  / 2)) + distanciaLeft;
		var posicaoYDiv = ((areaUtilHeight / 2) - (divWidth / 2))   + distanciaTop;
		
		$('#'+idDiv).css('position', 'absolute');
		$('#'+idDiv).css('top',  posicaoYDiv);
		$('#'+idDiv).css('left', posicaoXDiv);
		$('#'+idDiv).show();
	});
}

function f_clientWidth() {
	return f_filterResults (
		window.innerWidth ? window.innerWidth : 0,
		document.documentElement ? document.documentElement.clientWidth : 0,
		document.body ? document.body.clientWidth : 0
	);
}

function f_clientHeight() {
	return f_filterResults (
		window.innerHeight ? window.innerHeight : 0,
		document.documentElement ? document.documentElement.clientHeight : 0,
		document.body ? document.body.clientHeight : 0
	);
}

function f_scrollTop() {
	return f_filterResults (
		window.pageYOffset ? window.pageYOffset : 0,
		document.documentElement ? document.documentElement.scrollTop : 0,
		document.body ? document.body.scrollTop : 0
	);
}

function f_scrollLeft() {
	return f_filterResults (
		window.pageXOffset ? window.pageXOffset : 0,
		document.documentElement ? document.documentElement.scrollLeft : 0,
		document.body ? document.body.scrollLeft : 0
	);
}

function f_filterResults(n_win, n_docel, n_body) {
	var n_result = n_win ? n_win : 0;
	if (n_docel && (!n_result || (n_result > n_docel)))
		n_result = n_docel;
	return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
}
/* ======= FIM FUNÇÕES - CENTRALIZAR OBJETOS EM TELA ======= */


