//vagas
function change_tabs(nv,s){
	if(document.getElementById('div_'+[s]).style.display == 'none'){
		for(i=0;i<nv;i++){
			document.getElementById('div_'+[i]).style.display = 'none';
		}
		document.getElementById('div_'+[s]).style.display = 'block';
	} else {
		document.getElementById('div_'+[s]).style.display = 'none';
	}	
}
function close_vagas(s){
	document.getElementById('span_'+s).style.display = 'none';
	document.getElementById('loff_'+s).style.display = 'none';
}
//////////////////////////////////////////////////////////////////////////


function getCheckedValue(enq_id, radioObj) {
	var radioLength = radioObj.length;
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			var var_Obj = radioObj[i].value;
			return enq_vote(enq_id,var_Obj);
			return true;
		}
	}
	alert('Escolha uma Opção');
	return false;
}

//ajax file
var div_ajax;
var div_id;
var var_val;

function loadXMLDoc_tab(url,value,value1,value2,value3)
{
    req_tab = null;
	iec = null;
	iec = Math.ceil( Math.random() * 100000 );
	if (window.XMLHttpRequest) {
        req_tab = new XMLHttpRequest();
        req_tab.onreadystatechange = processReqChange_tab;
        req_tab.open("GET", url+'?ipage='+value+'&cnt='+value1+'&cv_id='+value2+'&pct='+iec, true);
        req_tab.send(null);

    } else if (window.ActiveXObject) {
        req_tab = new ActiveXObject("Microsoft.XMLHTTP");
        if (req_tab) {
            req_tab.onreadystatechange = processReqChange_tab;
            req_tab.open("GET", url+'?ipage='+value+'&cnt='+value1+'&cv_id='+value2+'&pct='+iec, true);
            req_tab.send();
        }
    }
}

function processReqChange_tab(){	
	if (req_tab.readyState < 4) {
		document.getElementById(div_ajax).style.filter = 'alpha(opacity=55)';
		document.getElementById(div_ajax).style.opacity = '0.55';
		document.getElementById(div_ajax).style.background = 'url(img/ajax-loader.gif) center center no-repeat';
	} else if (req_tab.readyState == 4) {
		document.getElementById(div_ajax).style.opacity = '';
		document.getElementById(div_ajax).style.filter = '';
		if(div_ajax == 'span_'+var_val){
			document.getElementById('loff_'+var_val).style.display = 'block';
			document.getElementById(div_ajax).style.background = 'url(img/vacancy_people_tr.gif) center center no-repeat';
				
		} else {
			document.getElementById(div_ajax).style.background = '';
		}
		document.getElementById(div_ajax).innerHTML = req_tab.responseText;
    }
}

//show tab nav content
function enq_vote(value,value1){
	div_ajax = 'enq_div';
	loadXMLDoc_tab('enquetes/enquetes.php',value,value1);
}

//show cities
function show_city(value){
	div_ajax = 'lcidade';
	loadXMLDoc_tab('../_inc/cidades.php',value);
}

//show cities
function show_city_ext(value,value1){
	div_ajax = 'lcidade';
	loadXMLDoc_tab('_inc/cidades.php',value,value1);
}

//call vacancies
function show_vacancy(value){
	div_ajax = 'lvagas';
	document.getElementById(div_ajax).style.visibility = 'visible';
	document.getElementById('loff').style.visibility = 'visible';
	document.getElementById('gads').style.visibility = 'visible';
	loadXMLDoc_tab('vagas/vagas_show.php',value);
}

//call vacancies
function show_vacancy_2(value,value1,value2){
	div_ajax = 'span_'+value;
	var_val = value;
	var ds = document.getElementById(div_ajax).style;
	if(ds.display == 'none'){
		ds.display = 'block';
		loadXMLDoc_tab('vagas/vagas_show.php',value,value1,value2);
	} else {
		close_vagas(value);
	}
}

//do login inside of the vacancy
function do_login_vaga(value,value1,value2){
	//trata a vaga
	div_ajax = 'span_'+value;
	
		var ds = document.getElementById(div_ajax).style;
	if(ds.display == 'none'){
		ds.display = 'block';
	}
	loadXMLDoc_tab('vagas/vagas_show.php',value,value1,value2);
	setTimeout('change_logon('+value2+')',300);
}

//show login info
function change_logon(value2){
	//trata o login
	div_ajax = 'login';
	loadXMLDoc_tab('login.php','','',value2);
}

//show newsletter fields
function nl_show(value){
	div_ajax = 'nl_div';
	loadXMLDoc_tab('newsletter_hl.php',value);
}

//subscribe newsletter
function nl_subs(value,value1,value2){
	div_ajax = 'nl_div';
	loadXMLDoc_tab('newsletter_hl.php',value,value1,value2);
}

//vagas ticker
function change_vaga(){
	div_ajax = 'vg_ticket';
	loadXMLDoc_tab('vagas_ticker_cdt.php');
}
//vagas ticker
function change_vaga_mnt(){
	div_ajax = 'vg_ticket';
	loadXMLDoc_tab('vagas_ticker.php');
}
