	$.testAttr = function(obj,attr){ 
   blSuportAtribut = false; 
   objTest = document.createElement(obj); 
   if(attr in objTest) blSuportAtribut = true;
	 return blSuportAtribut;
	}
	
jQuery(function($){
		boxInfo.boxIni({imgLoad: "images/loadintronet.gif", top:"20%", backgroundColor:"#4878c7", border:"1px solid #3a317f"});
		
		$("#txtTelefone").mask("(99) 9999-9999");
		$("#txtCelular").mask("(99) 9999-9999");
  	$("#txtCep").mask("99 . 999 - 999");
						
	if(!$.testAttr("input","placeholder")){
		$('input[placeholder],textarea[placeholder]').attr('value',function(){
			return $(this).attr("placeholder");
		}).focus(function(){
			var strBgColor = '#abd6ff';
			var strBorder = '1px solid #3ca1ff';
			if($(this).attr("value")==$(this).attr("placeholder")){
				$(this).val("").css({
					background: strBgColor,
					border:strBorder
				});
			}
			else{
				$(this).css({
					background:strBgColor,
					border:strBorder
				});
			}
		}).blur(function(){
			$(this).attr('value',function(){return $.trim($(this).val())});
			if($.trim($(this).attr("value"))==""){
				$(this).val($(this).attr("placeholder")).removeAttr('style');
			}
			else{
				$(this).removeAttr('style');
			}
		});
	}
	else{
		$('input[placeholder], textarea[placeholder]').focus(function(){
			var strBgColor = '#abd6ff';
			var strBorder = '1px solid #3ca1ff';
			$(this).css({
				background:strBgColor,
				border:strBorder
			});
		}).blur(function(){
			$(this).attr('value',function(){return $.trim($(this).attr('value'))});
			$(this).removeAttr('style');
		});
	}
				
		$('#btContatos').click( function() {
		$(this).attr('disabled', 'disabled');
		if(!boxInfo.validaDados('#formContatos')){$('#btContatos').removeAttr('disabled'); return;}
		boxInfo.boxOpen("Aguarde...", false, true);
		
		$.ajax({
					dataType: "json", 
      		type: "POST",
      		url: "ajax/enviar.contato.php",
	  			data: $('#formContatos').serialize(),
      		success: function(retorno){

						if(retorno.erro==1){
        			boxInfo.boxOpen(retorno.msg, true);
							$('#btContatos').removeAttr('disabled');
						}
						else{
							boxInfo.boxOpen(retorno.msg);
							$("#divRetorno").html("<center><p class='style3' style='padding-top:50px;'>"+retorno.msg+"</p></center>");
							$('#btContatos').removeAttr('disabled');
						}
       		}
    	});
	});
});
