var clicked = '';
function showMeFaq(num){
	var d = document.getElementById('faq' + num).style.display;
	if(d == 'none'){
	 document.getElementById('faq' + num).style.display = 'block';
	}else{
	document.getElementById('faq' + num).style.display = 'none';
	}
}

function showMeDesc(num){
	var d = document.getElementById('desc' + num).style.display;
	if(d == 'none'){
	 document.getElementById('desc' + num).style.display = 'block';
	}else{
	document.getElementById('desc' + num).style.display = 'none';
	}
}
function showMeTitles(num){
	var myWin = window.open('includes/fnc.conf_titulos.php?id=' + num,'','width=516,height=500,scrollbars=yes');
	myWin.focus();
}
function getVariablesForm(form) {
	
	var myForm = document[form];
	var fields = myForm.length;
	var page = myForm.action;
	var vars = page;
	
	for(var i = 0; i < fields; i++){
		var v;
		switch(myForm[i].type){
			case 'select-one':
				v = myForm[i].options[myForm[i].selectedIndex].value;
			break;
			default:
				v = myForm[i].value;
			break;
		}
		
		if(v != 'undefined' && v != '' && v != 0){		
			vars += '&' + myForm[i].id + "=" + v + "\n";
		}
		
	}
	window.location= vars;
}

function resetForm(form){
	var myForm = document[form];
	var fields = myForm.length;
	
	for(var i = 0; i < fields; i++){
		switch(myForm[i].type){
			case 'select-one':
				myForm[i].options[myForm[i].selectedIndex].value = 0;
			break;
			default:
				myForm[i].value = '';
			break;
		}		
	}
}

function lighted(obj,color){
	obj.style.cursor='pointer';
	obj.style.backgroundColor='#' + color;
}
function unlighted(obj,color){
	obj.style.backgroundColor='#' + color;	
}

function verifica_contratar(){
	document.contratar.submit();	
}

function inputs_array(form,inputName){	
	
	var cantidad = document[form][inputName].length;
	
	var j=0;
	//var myForm = document[form][inputName];
	//alert(cantidad);
	for(var i=0; i < cantidad; i++)
	{
		//alerts += document[form]['temas[]'][1].checked + "\n";
		if(document.apuntate['temas[]'][i].checked)
		{
			j++;	
		}
		//a += field;
		//alert(document.apuntate['temas[]'][1].checked);
	}
	return j;
}

/*function verifica_apuntate(){	
	if(document.apuntate.contacto.value != ""){
		if(emailCheck (document.apuntate.email.value)){
			if(inputs_array('apuntate','temas[]')){
				if(document.apuntate.provincia.options[document.apuntate.provincia.selectedIndex].value){
					document.apuntate.submit();	
				}else{
					alert("Seleccione una Provincia");
				}
			}else{
				alert("Seleccione uno o más temas");
			}
		}else{
			alert('E-mail incorrecto.');
		}
	}else{
		alert('Complete el campo "Persona de contacto".');
	}
}*/
function verifica_apuntate(){
	
	var form = document.apuntate;
	var e = '';
	
	if(document.apuntate.contacto.value == "")
		e += 'Complete el campo "Persona de contacto". \n';
	
	if(!emailCheck(document.apuntate.email.value))
		e += 'E-mail incorrecto. \n';
		
	if(!inputs_array('apuntate','temas[]'))
		e += 'Seleccione uno o más temas \n';
		
	if(!document.apuntate.provincia.options[document.apuntate.provincia.selectedIndex].value)
		e += 'Seleccione una Provincia \n';
	
	if(e == ''){
		document.apuntate.submit();
	}else{
		alert(e);
	}
	
}

function verifica_registros(){
	document.registros.submit();
}
function verifica_bavanzada(form){
	var myForm = document[form];
	var fields = myForm.length - 1;
	var j = 0;
	
	for(var i = 0; i < fields; i++){
		switch(myForm[i].type){
			case 'select-one':
				newValue = myForm[i].options[myForm[i].selectedIndex].value;
			break;
			default:
				newValue = myForm[i].value;
			break;
		}
		if(newValue == '' || newValue == 0 || newValue=='undefined'){
			j++;
		}
	}
	if(j < fields){
		myForm.submit();
	}else{
		alert('Debe completar al menos uno de los campos.');
	}
}
function selectBgOver(obj){
	obj.style.backgroundColor = '#000080';
	obj.style.color = '#fff';
	obj.style.cursor = 'default';
}
function selectBgOut(obj){
	obj.style.backgroundColor = '#fff';
	obj.style.color = '#000';
}

function selectSubMenu(n){
	var  cant = 7;
	for(var i = 1; i <= 9; i++){
		document.getElementById('subSelect' + i).style.display = 'none';	
	}
	document.getElementById('subSelect' + n).style.display = 'block';
}
function $(x) { return document.getElementById(x); } 

function crece(id, w, h, x) {
    var capa = $(id); 
	//alert(capa.style.display);
    var creciendo = setInterval( function() { 
        if(capa.style.display==='none') { 
            capa.style.display = 'block'; 
            capa.style.height = "1px";
        } 
        else { 
            var altoActual = parseInt( capa.style.height ); 
            if( altoActual < h ) 
                capa.style.height = (altoActual+=7) +"px"; 
            if( altoActual>=h ) 
                clearInterval(creciendo); 
        } 
    }, 1);  
}

document.onmouseup = function (){
	var  cant = 7;
	for(var i = 1; i <= 9; i++){
		if(document.getElementById('subSelect' + i)){
			document.getElementById('subSelect' + i).style.display = 'none';
		}
	}
	document.getElementById('selectOptions').style.display = 'none';	
	document.getElementById('selectOptions1').style.display = 'none';	
};


function resetButtons(){
	document.getElementById("sm_0").style.display="none";
}
function ppp(num){
	//resetButtons();
	switch(num){
		case 0:
			document.getElementById("sm_0").style.display="block";
			//document.getElementById("framePDF").style.display="none";
		break;
	}
}

function chgColor(obj,color)
{
	obj.style.cursor = 'pointer';
	obj.style.backgroundColor = color;
	if(obj.style.color != '#fff'){
		obj.style.color = '#fff';
	}else{
		obj.style.color = '#000';
	}
}