
var xmlhttp
var url

function getxmlhttpobject()
{
    var objxmlhttp = null
    if (window.XMLhttpRequest)
    {
        objxmlhttp = new XMLhttpRequest()
    }
    else if (window.ActiveXObject)
    {
        objxmlhttp = new ActiveXObject("microsoft.XMLHTTP")
    }
    return objxmlhttp
} 

//
function httpRequest(url)
{
    if(window.XMLHttpRequest) req = new XMLHttpRequest() 
    else if (window.ActiveXObject) req = new ActiveXObject("microsoft.XMLHTTP") 
    req.open("get",url,false)
    req.send(null)
    return req.responseText  
} 

//
function EnviaCurriculo(Id_Vaga,cod_usuario)
{  
    xmlhttp = getxmlhttpobject()
    var url = "vaga_candidatarse.asp?Id_Vaga="+Id_Vaga+"&cod_usuario="+cod_usuario
    xmlhttp.open("GET", url, true)
	var retorno = httpRequest(url)
	//alert("url" + url )
	//window.open(url)
	switch(retorno)
	{
	case "encontrou":
	  alert ("Seu currículo já foi enviado para esta vaga!")
	  break;    
	case "enviou":
	  alert ("Seu currículo foi enviado com sucesso, aguarde contato!")
	  break;
	case "naologado":
	  window.open("../pessoal/msg.asp?cod=6",target='_parent',"candidatarse","fullscreen=yes,menubar=yes,directories=yes,toolbar=yes")
	  break;
	} 


    xmlhttp.send(null)
}


function UploadGrava(Arquivo)
{  
    xmlhttp = getxmlhttpobject()
    var url = "site/include/upload_grava.asp?Arquivo="+Arquivo
    xmlhttp.open("GET", url, true)
	var retorno = httpRequest(url)
	window.open(url)
	switch(retorno)
	{
	case "enviou":
	  alert ("Upload concluido com sucesso!")
	  break;    
	case "erro":
	  alert ("Ocorreu um erro, o arquivo não foi enviado!")
	  break;
	} 


    xmlhttp.send(null)
}

