function trim(str){return str.replace(/^\s+|\s+$/g,"");}

var opts =
  // horizontal Dock with images expanding downwards in the vertical axis...
{ align: 'botton'
  // set the maximum minor axis (vertical) image dimension to 48px
, size: 30
  // add labels..
, labels: true
  // swap the GIF extension for PNG extension for the larger image...
, source: function(i){ return this.src.replace(/gif$/,'png'); }
};

function isArray(o){
	return(typeof(o.length)=="undefined")?false:true;
}


	function replaceAll(str, de, para){
	    var pos = str.indexOf(de);
	    while (pos > -1){
			str = str.replace(de, para);
			pos = str.indexOf(de);
		}
	    return (str);
	}
	
function submeterContato(){
	

    $("#contato").ajaxSubmit({
 	   		
        target: '',
        url: './gestor/modulos/contato/?acao=set2', 
        type: 'post', 
        success: function(resposta) {
			res = resposta.split('|');
			resformated = '';
			if(isArray(res)) {
				if(res.length<=1){ document.contato.reset(); }
				for(i=0;i<res.length;i++){
					resformated += res[i]+'\n';
				}
			}else{
				resformated = resposta;
				document.contato.reset();
			}
    		alert(resformated);
        }
    		
    });
	
}


function submeterUsuario(){

    $("#cadastroUsuario").ajaxSubmit({
 	   		
        target: '',
        url: './gestor/modulos/usuario/?acao=set2', 
        type: 'post', 
		success: function(resposta) {
			res = resposta.split('|');
			resformated = '';
			if(isArray(res)) {
				if(res.length<=1){
					location.href="./?p=formularios#conteudo";
				}
				for(i=0;i<res.length;i++){
					resformated += res[i]+'\n';
				}
			}else{
				resformated = resposta;
				document.cadastroUsuario.reset();
			}
			alert(resformated);
		}
    		
    });
	
}


function consultaEmail(){

    $("#consultaemail").ajaxSubmit({
 	   		
        target: '',
        url: './gestor/modulos/usuario/?acao=verificaEmail', 
        type: 'post', 
        success: function(resposta) {
			//alert(resposta);
   			if(resposta==1){
   				location.href="./?p=formcadastrocoleta#conteudo";
   			}else if(resposta==2){
   				location.href="./?p=formcadastrousuario#conteudo";
   			}else if(resposta==3){
   				alert('Coloque se email');
   			}

        }
    		
    });
	
}


function submeterExame(){
    $("#cadastroExame").ajaxSubmit({
        target: '',
        url: './gestor/modulos/agendamento/?acao=set2', 
        type: 'post', 
        success: function(resposta) {
   			if(resposta==1){
   				alert('Agendamento cadastrado com sucesso, logo entraremos em contato para confirmaÃ§Ã£o!');
				document.cadastroExame.reset();
				location.href="./?p=formcadastrocoleta#conteudo";
   			}else if(resposta==0){
				alert('Erro ao cadastrar o agendaento do exame, verifique se os campos estÃ£o preencidos corretamente!');
   			}

        }
    		
    });
	
}

function consultaEmailDuvida(){

    $("#consultaemail").ajaxSubmit({
 	   		
        target: '',
        url: './gestor/modulos/usuario/?acao=verificaEmail', 
        type: 'post', 
        success: function(resposta) {
			//alert(resposta);
   			if(resposta==1){
   				location.href="./?p=formcadastroduvida";
   			}else if(resposta==2){
   				location.href="./?p=formcadastrousuario";
   			}else if(resposta==3){
   				alert('Coloque se email');
   			}

        }
    		
    });
	
}



function submeterCadastroDuvida(){
	//alert('Entrou!');
    $("#formularioCadastroDuvida").ajaxSubmit({
 	   		
        target: '',
        url: './gestor/modulos/duvida/?acao=set2', 
        type: 'post', 
        success: function(resposta) {
			//alert(resposta);
   			if(resposta==1){
   				alert(('Sua dÃºvida foi Cadastrada com Sucesso, Aguarde nossa reposta!'));
				location.href="./?p=duvidas";
   			}else if(resposta==0){
				alert('Erro ao cadastrar sua dÃºvida, verifique se os campos estão preencidos corretamente!');
   			}

        }
    		
    });
	
}



////////Funções do ChatOnline //////////

function replaceAll(str, de, para){
    var pos = str.indexOf(de);
    while (pos > -1){
		str = str.replace(de, para);
		pos = str.indexOf(de);
	}
    return (str);
}


