//--------------------------------------------------------------------------------
//UTILIDADES
//--------------------------------------------------------------------------------
//Mostamos una alerta
function showMessage(texto, titulo, icon, _alto){
	var jobAlertEmail;
	var ancho = 300;
	var alto = 70;
	var __x = Math.round((anchoDocument - ancho) / 2);
	var __y = 250;
	
	if(titulo == null){
		titulo = "Cátenon";
	}
	
	if(_alto != null){
		alto = _alto;
	}
	
	var JAWindow = dhtmlwindow.open('alertbox', 'inline', '<img src="/images/icons/icon_' + icon + '.gif" style="float:left; padding: 10px;"/><br>' + texto + '', titulo, 'width='+ ancho +'px,height='+ alto +'px,left='+ __x +'px,top='+ __y +'px,resize=0,scrolling=0');
	
	if(document.getElementById(jobAlertEmail)){
		jobAlertEmail = new Spry.Widget.ValidationTextField("jobAlertEmail", "email", {validateOn:["blur"]});
	}
	
	return false;
}

function hideDiv(capa) {
	var divToHide = document.getElementById(capa);
	divToHide.style.display = "none";
}

function showDiv(capa) {
	var divToShow = document.getElementById(capa);
	divToShow.style.display = "block";
}

function checkCBox(CBox){
	if(CBox.value){
		switch(CBox.name){
			case "countryCBox":
				document.searchForm.idpais.value = CBox.value;
			break;
			case "areaCBox":
				document.searchForm.idareaCrm.value = CBox.value;
			break;
			case "teamCBox":
				document.searchForm.idpuestoCrm.value = CBox.value;
			break;
		}
		return 1;
	} else {
		switch(CBox.name){
			case "countryCBox":
				document.searchForm.idpais.value = -1;
			break;
			case "areaCBox":
				document.searchForm.idareaCrm.value = -1;
			break;
			case "teamCBox":
				document.searchForm.idpuestoCrm.value = -1;
			break;
		}
		return 0;
	}
}

function checkTextfield(campo){
	var keywords = trim(campo.value);
	if(keywords.length > 0){
		return 1
	} else {
		campo.value = " ";
		return 0;
	}
}
	
function add_combos(disponibles,seleccionados){
     i=0;
     while(disponibles.options[i]){
         if (disponibles.options[i].selected == true){
             var option = new Option(disponibles.options[i].text,disponibles.options[i].value);
             eval ("seleccionados.options[seleccionados.length] = option");
             disponibles.options[i]=null;
             i=-1;
         }
         i++;
     }   
     
     updateSelectedCountries(seleccionados);   
}

function updateSelectedCountries(seleccionados) {
	var listapaises = '';
	
	i=0;
     while(seleccionados.options[i]){
        listapaises += seleccionados.options[i].value + "|";
         i++;
     }
	
	document.forms[0].cvCountriesList.value = listapaises;
}

function quitar_combos(disponibles,seleccionados){
   
     i=0;
     while(seleccionados.options[i]){
         if (seleccionados.options[i].selected == true){
             var option = new Option(seleccionados.options[i].text,seleccionados.options[i].value);
             eval ("disponibles.options[disponibles.length] = option");
             seleccionados.options[i]=null;
             i=-1;
         }
         i++;
     }       
}