$(document).ready( function() {
	$("#menu_topo dd").hide();
	$("#menu_topo dt a").hover(function(){
		$("#menu_topo dd:visible").hide();
		$(this).parent().next().fadeIn('600');
		return false;
	});
	$("#bt_enquete").click(function(){
			var Jinput = $("input[type=radio][name=u_input]").is(':checked');
			if(Jinput ==false) {
				alert('Selecione umas das opção de enquete!');
				return false;
			}else{
				envia_form();
			}

	});
});
function envia_form() {
	$("#retorno").empty();
	var enviado 	= $("#enviado").attr("value");
	var idenquete 	= $("#id_enquete").attr("value");
	var u_input 	= $("input[type=radio][name=u_input]:checked").val();
	$.ajax({
		type: "POST",
		url: "/enquete/enquete_post.asp",
		dataType: "html",
		data: "enviado=" + enviado + "&id_enquete=" + idenquete + "&u_input=" + u_input,
		// enviado com sucesso
		success: function(response){
			$("#retorno").append(response);
		},
		// quando houver erro
		error: function(){
		alert("Ocorreu um erro durante a requisição");
		}
	});
}		
function mostra_utilidade(prValor){
	$(".utilidade_texto").slideUp("slow");
	$(".fundo_utilidades").slideUp("slow");
	
	if ($("#"+prValor).is(":visible")){
		$("#"+prValor).slideUp("slow");
	}else{
	 	$("#"+prValor).slideToggle("slow");
	}	
}
function mostra_utilidade2(prValor){
	$(".utilidade_texto").slideUp("slow");
	if ($("#"+prValor).is(":visible")){
		$("#"+prValor).slideUp("slow");
	}else{
	 	$("#"+prValor).slideToggle("slow");
	}	
}
function isObject(obj) {
	if (obj == null) {return false}
	if (typeof(obj) == 'object') { return true;	} else { return false; }
}

function zoom(sProduto){
	!busca_portifolio(sProduto)	
}
function mascara(o,f) {
    v_obj=o
    v_fun=f
    setTimeout("execmascara()",1)
}

function execmascara() {
    v_obj.value=v_fun(v_obj.value)
}
function soNumeros(v) {
    return v.replace(/\D/g,"")
}
function soLetras(v) {
    return v.replace(/([0-9])/g,"")
	
}
function Limpa(v) {
   if (v.value == v.defaultValue ){
		if(isObject(document.getElementById(v.name+'s'))) {
			document.getElementById(v.name+'s').innerHTML  = '';	
		}   	
   	 	return v.value ='';
	}
	
}

function escrever(v){  
 if (v.value == ""){  
       v.value = v.defaultValue; 
	   if(isObject(document.getElementById(v.name+'s'))) {
			document.getElementById(v.name+'s').innerHTML  = '<img src="/imagens/botoes/erro_check.gif"> Campo '+ v.name.replace("_"," ") +' é Obrigatório!';
		} 
   }else{
		if(isObject(document.getElementById(v.name+'s'))) {	
	   		if (v.name =='email' ){
				if ((v.value.length != 0) && ((v.value.indexOf("@") < 1) )){
					document.getElementById(v.name+'s').innerHTML  = '<img src="/imagens/botoes/erro_check.gif"> Campo '+ v.name +' é inválido!';
				}else{
					document.getElementById(v.name+'s').innerHTML  = '<img src="/imagens/botoes/check.gif">';
	
				  }
			}		
	   		if (v.name !='ddd' && v.name !='email'){
				document.getElementById(v.name+'s').innerHTML  = '<img src="/imagens/botoes/check.gif">';
			}
		}
   }  
}  

function Preenche(v,c) {
	if (c='login'){
		if (document.getElementById(c).value == '') {
            document.getElementById(c).value = "Digite seu login";
		}
	}
	if (c='senha'){
		if (document.getElementById(c).value == '') {
            document.getElementById(c).value = "Senha";
		}
	}	
}
function validacampo(prcampo,prform) {
 	if(prcampo.value == '') {
			alert('Campo '+ prform +' é Obrigatório!');
			prcampo.focus();
	} 
			return false;	

}
function valida_contato() {
	var objForm = document.forma_fale;
	if (objForm.nome.value == '') {
		document.getElementById('erro').innerHTML = 'Campo nome é Obrigatório!';
		objForm.nome.focus();
		return false;
	}	
	
	if(objForm.email.value == '') {
		document.getElementById('erro').innerHTML = 'Email é Obrigatório!';
        objForm.email.focus();
        return false;
	} 
	
	if ((objForm.email.value.length != 0) && ((objForm.email.value.indexOf("@") < 1) || (objForm.email.value.indexOf('.') < 7))){
		document.getElementById('erro').innerHTML = 'Email é Invalido!';
    	objForm.email.focus();
		return false;		
	  }

	if (objForm.mensagem.value == '') {
		document.getElementById('erro').innerHTML = 'Campo mensagem é Obrigatório!';
		objForm.mensagem.focus();
		return false;
	}
	
}

function ValidaEmail(campoemail) {
 var obj = eval(campoemail);
 var txt = obj.value;
  if ((txt.length != 0) && ((txt.indexOf("@") < 1) || (txt.indexOf('.') < 7)))
  {
  	alert('oi')
	//document.getElementById('erro').innerHTML = 'E-mail Invalido!';
//	obj.focus();
  }
}
function counterUpdate(opt_countedTextBox, opt_countBody, opt_maxSize) {
        var countedTextBox = opt_countedTextBox ? opt_countedTextBox : "counttxt";
        var countBody = opt_countBody ? opt_countBody : "countBody";
        var maxSize = opt_maxSize ? opt_maxSize : 1024;

        var field = document.getElementById(countedTextBox);

        if (field && field.value.length >= maxSize) {
                field.value = field.value.substring(0, maxSize);
        }
        var txtField = document.getElementById(countBody);
                txtField.innerHTML = maxSize-field.value.length;
}
var dicionarioSaltaCampo;
function SaltaCampo(campo, prox, tammax, teclapres)
{
    var tecla = teclapres.keyCode;
    var vr = campo.value;
    var tam = vr.length;

    // Desconsidera o [tab] e o [shift+tab]
    if  ((tecla != 9) && (tecla != 16))    
        if (campo.value.length >= tammax)
        {
            // Trunca o conteudo para o tamanho m?ximo, no caso de CTRL+V
            campo.value = campo.value.substring(0, tammax );
            
            // Muda o foco para o pr?ximo componente
            prox.focus();
        }
}

function CtrlEnd(){
	if (window.event.keyCode==13) window.event.keyCode=9;   //ENTER vai para TAB
	if (window.event.keyCode==120) !About();				//F9
	if (window.event.keyCode==121) window.parent.valida(); //F10
	if (window.event.keyCode==27) window.parent.Aboutout(); //ESC
}
function excluir(sValor) {
	var sConfirm = confirm('Tem certeza?');

	if(sConfirm) {
		location.href='?acao=exc&id=' + sValor;
	}
}
function mostra(prValor)
	{
		c = document.getElementById(prValor)
		c.style.display = 'block';
	}
function esconde(prValor)
	{
		c = document.getElementById(prValor)
		c.style.display = 'none';
	}
function SrvAba(menu,conteudo)
	{
		this.menu = menu;
		this.conteudo = conteudo;
	}

function AlternarAbasSrv(menu,conteudo)
{
//	$('#'+ conteudo +'').fadeOut();	
	for (i=0;i<arSrv.length;i++)
	{
		$('#'+ conteudo +'').fadeIn(600);

		m = document.getElementById(arSrv[i].menu);
		m.className = 'SrvOff';
		c = document.getElementById(arSrv[i].conteudo)
		c.style.display = 'none';
	}
	m = document.getElementById(menu)
	m.className = 'ativa';
	c = document.getElementById(conteudo)
	c.style.display = 'block';

	
}


//Specify affected tags. Add or remove from list:
var tgs = new Array( 'div','p' ,'li');
//Specify spectrum of different font sizes:
var szs = new Array( 'xx-small','x-small','small','medium','large','x-large','xx-large' );
var startSz = 2;

function AumentaFonte(trgt,inc ) {
	if (!document.getElementById) return
	var d = document,cEl = null,sz = startSz,i,j,cTags;
	sz += inc;
	if ( sz < 0 ) sz = 0;
	if ( sz > 6 ) sz = 6;
	startSz = sz;
	if ( !( cEl = d.getElementById( trgt ) ) ) cEl = d.getElementsByTagName( trgt )[ 0 ];

	cEl.style.fontSize = szs[ sz ];

	for ( i = 0; i < tgs.length; i++ ) {
		cTags = cEl.getElementsByTagName( tgs[ i ] );
		for ( j = 0; j < cTags.length; j++ ) cTags[ j ].style.fontSize = szs[ sz ];
	}
}
function AbrePopUp(sUrl,sW,sH) {
	window.open(sUrl, 'Janela','scrollbars=yes,resizable=yes,width='+ sW +',height='+ sH +'');
}
