var idbcurrdivopen = '';
var iddivopen = '';
function ShowHideSection(obj,sec,idseccion){
	var vseccion = document.getElementById(sec);
	var vbuttonsection = document.getElementById('buttonsection_'+idseccion);
	var vtempbdivopen = '';
	var vtempdivopen = '';
	if (vbuttonsection.className=='openseccion'){
		if (idbcurrdivopen!=''){
			vtempbdivopen = document.getElementById(idbcurrdivopen);
			vtempdivopen = document.getElementById(iddivopen);
			vtempbdivopen.className = 'openseccion';
			vtempdivopen.style.display = 'none';
			vtempdivopen.style.visibility = 'hidden';
		}
		vbuttonsection.className = 'closeseccion';
		vseccion.style.display = 'block';
		vseccion.style.visibility = 'visible';
		idbcurrdivopen = 'buttonsection_'+idseccion;
		iddivopen = sec;
	}else{
		if (idbcurrdivopen == ('buttonsection_'+idseccion)){
			idbcurrdivopen = '';
			iddivopen = '';
		}
		vbuttonsection.className = 'openseccion';
		vseccion.style.display = 'none';
		vseccion.style.visibility = 'hidden';
	}

}

function panelPlanesFormativos(id){
	if ($('divcursos_'+id).style.display!='none'){
		$('btncloseopen'+id).removeClassName('closeseccion');
		$('btncloseopen'+id).addClassName('openseccion');
		Effect.SlideUp('divcursos_'+id, { duration: 0.5 });
	}else{
		$('btncloseopen'+id).removeClassName('openseccion');
		$('btncloseopen'+id).addClassName('closeseccion');
		Effect.SlideDown('divcursos_'+id, { duration: 0.5 });
	}

}

function overMe(idobj){
	new Effect.Highlight(idobj, { startcolor: '#F8D353', endcolor:'#ffffff', restorecolor: '#ffffff',afterUpdate: overMeTwo(idobj)});
}
function overMeTwo(idobj){
	$(idobj).setStyle({backgroundColor: '#F8D353'});
}

function outMe(idobj){
	$(idobj).setStyle({backgroundColor: '#FFFFFF'});
	// new Effect.Highlight(idobj, { startcolor: '#ffff99', endcolor: '#fffffff', restorecolor: '#fffffff'});
}
/*
function panelProfileCurso(id){
	alert($('profilecurso'+id).style.display);
	if ($('profilecurso'+id).style.display!='none'){
		$('profilecurso'+id).clonePosition('divbody');
		Effect.Fold('profilecurso'+id);
	}else{
		$('profilecurso'+id).setStyle({zIndex: '1001'});
		$('profilecurso'+id).fade({duration: 3.0,from:1.0,to:0.3});
		$('profilecurso'+id).clonePosition('divbody');
		Effect.Grow('profilecurso'+id);
	}
}

*/


function panelProfileCurso(id){
//	if ($('profilecurso').style.display!='none'){
//		$('profilecurso').clonePosition('divbody');
//		Effect.Fold('profilecurso',{duration: 1.0,queue: 'end'});
//	}else{
//		$('profilecurso').setStyle({zIndex: '1001'});
//		if (id>2){
//			$('profilecursodata'+id).setStyle({marginTop: '-'+((id*20)+93)+'px'});
//		}
//		$('profilecurso').clonePosition('divbody');
//		$('profilecurso').appear({ duration: 1.0, from : 0.0, to : 0.3});
//		Effect.BlindDown('profilecursodata'+id,{duration: 1.0,queue: 'end'});
//	}
}


function hidePanelCurso(id){
		Effect.BlindUp('profilecursodata'+id,{duration: 0.2});
		Effect.BlindUp('profilecurso',{duration: 0.5, queue: 'end'});

}

function runSearch(){
	if ($('searchcurses').value==''){
		$('pmsg').addClassName('pmsgError');
		$('pmsg').innerHTML = 'Teclee lo que desea buscar.';
		$('divmsg').show();
	}else{
		$('divmsg').hide();
		document.frmSearchCurses.submit();
	}

}

function enviar(){
   var mensaje = "Debe rellenar los campos:\n";
   if (document.frmEnvio.NOMBRE.value.length == 0) mensaje+="\n· nombre";
   if (document.frmEnvio.APELLIDOS.value.length == 0) mensaje+="\n· apellidos";
   var pattern = /\d{9,}/;
   if (!pattern.test(document.frmEnvio.TELEFONO.value) || document.frmEnvio.TELEFONO.value.length == 0) mensaje+="\n· tel\éfono";
   if (document.frmEnvio.MOVIL.value.length == 0) mensaje+="\n· m\óvil";
   if (document.frmEnvio.RESIDENCIA.value.length == 0) mensaje+="\n· residencia";

   if (!validar_email(document.frmEnvio.EMAIL.value) || document.frmEnvio.EMAIL.value.length == 0) mensaje+="\n· e-mail";
   if (document.frmEnvio.COMENTARIO.value.length == 0) mensaje+="\n· comentario";
   if (document.frmEnvio.POLITICA.checked == 0) {
   		if(mensaje.length>26)
   		mensaje+="\n\n\ Debe aceptar la Pol\ítica de privacidad\n";
   		else
   		mensaje="\n\ Debe aceptar la Pol\ítica de privacidad\n\n";
   		}
   if (mensaje.length>26) alert(mensaje);
   else {
      document.getElementById('accion').value = 'envio';
      document.frmEnvio.submit();
   }
}
function LimitarTexto(Caracteres){
   var aux = document.frmEnvio.COMENTARIO.value;
   aux = aux.replace(/\n/g,'-.............................................-');
   if (aux.length > Caracteres){
      aux = aux.slice(0,Caracteres);
      alert('No se pueden insertar m\ás de ' + Caracteres + ' caracteres en el comentario');
      document.frmEnvio.COMENTARIO.value = aux.replace(/-.............................................-/g,'\n');;
   }
}

function popup (altura,anchura,pagina){
	var izquierda=(screen.width/2)-(anchura/2);
	var superior=(screen.height/2)-(altura/2);
	 return window.open(pagina,'_blank','toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=yes, width='+anchura+', height='+altura+', left='+izquierda+', top='+superior+'');
}

function buscadorNoticias() {
   if(document.getElementById("tubusqueda").value == '')
      alert("No hay criterio de b&uacute;squeda");
   else
      document.forms.buscador.submit();
      
}
