
/*
<head></head>
*/
 id_user=GetCookie('IDC');
 id_centro=GetCookie('IDC');
 nombre_user=GetCookie('NOMBRE_USER');
 mail_user=GetCookie('MAIL_USER');
 if(!nombre_user){nombre_user=mail_user}
 pwuser=GetCookie('PASSWORD_USER');
 nombre_centro=GetCookie('nombre_centro');
 pwcentro=GetCookie('password_centro');

urlb='/widget/';
urlbl='/lao/';
pim='http://images.emagister.com/';
hola='Hola';
ir='Ir a Mi Emagister';
desco='Desconexi&oacute;n';
recibe='<B>Recibe gratis cursos por email</B>';
accesou='Acceso para usuarios';
anade='Publica tus cursos';
anade2='Acceso para centros de formaci&oacute;n';
btn_buscando='Buscando';
elcampo='El campo';
nopuedeestarvacio='no puede estar vac&iacute;o';
debesmarcarcasilla='Debes marcar una casilla';
debesalmenos='Debes escribir al menos';
caracteres='caracteres';
foros_web='Foros Web';
cursos_gratis='Cursos gratis';
portales=new Array("");
pdm=location.host.indexOf(".")+1;
function SetCookieSession (name, value) {  
	document.cookie = name + "=" + escape (value) + 
	"; path=/" +  
	"; domain="+location.host.substring(pdm);
}
function SetCookie (name, value) {  
	var expires= new Date(); 
	expires.setYear(2032);
	document.cookie = name + "=" + escape (value) + 
	"; expires=" + expires.toGMTString() +
	"; path=/" +  
	"; domain="+location.host.substring(pdm);
}
function GetCookie (name) {  
	var arg = name + "=";  
	var alen = arg.length;  
	var clen = document.cookie.length;  
	var i = 0;  
	while (i < clen) {    
		var j = i + alen;    
		if (document.cookie.substring(i, j) == arg)      
			return getCookieVal (j);    
		i = document.cookie.indexOf(" ", i) + 1;    
		if (!i) break;   
	}  
	return null;
}
function getCookieVal (offset) {  
	var endstr = document.cookie.indexOf (";", offset);  
	if (endstr == -1)    
	endstr = document.cookie.length;  
	return unescape(document.cookie.substring(offset, endstr));
}
function deleteCookie(name,value){
	var expires= new Date();
	document.cookie = name + "=" + escape (value) + 
	"; expires=" + expires.toGMTString() +
	"; path=/" +  
	"; domain="+location.host.substring(pdm);
}
if(!GetCookie("user_portalf")||(document.referrer.indexOf('emagister.com'))==-1)
{
   if(document.referrer.length>0 && typeof portales != 'undefined'){
	    if(document.referrer) {
			referencia=document.referrer;
			for(i=1;i<portales.length;i++){
				if(referencia.indexOf(portales[i][1])!=-1){
					SetCookieSession('user_portalf',portales[i][0]);
				}
			}
		 }
		else {
		    for(i=1;i<portales.length;i++){
				if(window.location.href.indexOf(portales[i][1])!=-1){
				    SetCookieSession('user_portalf',portales[i][0]);
				}
			}
		}
	}
}
if(!GetCookie('user_portalf')) { SetCookieSession('user_portalf','1'); }
var tlhp=top.location.href;
/*Funcion ya definida en WIDGET/COMMONS/JS/widget-rec_vpfichas.js*/
function recCooPFvalor(PFdato){
	dpfichas=unescape(GetCookie('PFICHASG'));
	posdrec=dpfichas.indexOf(PFdato);
	newstringPF=dpfichas.substring(posdrec);
	valorRecu=newstringPF.substring(newstringPF.indexOf('=')+1,newstringPF.indexOf(','));
	return valorRecu;
}
function cS(metrica,ref,idcen,idcur,tipo,palBusq){
	a=location.host;
	ini=a.lastIndexOf('.');
	project=a.substring(ini+1,ini+1+3);
	id_project=1;	
	if (project=='net'){
		id_project=2;
	}
	var cont="";
	var items=new Array ('txtPalClave','cboCateg','cbotipocurso','cboprovincia','cboprecio');
	var pb="";
	if (palBusq){pb="&BUSQUEDA="+palBusq;}
	T="";
	if (tipo){T="&REFINA="+tipo;}
	if (!ref || ref==''){
		var a=top.location.href;
	
		if (a.indexOf('menu_sup')!=-1){a=a.substring(0,a.lastIndexOf('/')+1)+'index.cfm';}
		if (a.indexOf('?bclient')!=-1){a=a.substring(0,a.lastIndexOf('/')+1)+'index.cfm';}
		dom='http://'+location.host;domb=dom+'/';domi=domb+'index.cfm';
		arrloc=new Array("mas_","masp_","lmbuscados","-pclave-","-cursos-","-bcateg-","cursos_gratis","-centros-","users","/centros/","quienes","centrodetalles","advanced_search","widget-end_process","-bcateg","/cursos-","view_emp.cfm","widget-center_info_request","-programacursos-","-opinionescursos-","-fechascursos-","view_cursos.cfm","novedades_cursos.cfm");
		arrref=new Array("LO MAS BUSCADO","LO MAS BUSCADO","LO MAS BUSCADO","HOME","PCURSO","HOME","HOME","HOME","MENU_DE_USUARIO","MENU_DE_CENTRO","QUIENES_SOMOS","PCENTRO","BUSCADOR AVANZADO","VENTA_CRUZADA","HOME","HOME","HOME","PCENTRO","PCURSO","PCURSO","PCURSO","PCURSO","PCURSO");
		var enco=false;
		var z=0;
		while(z<arrloc.length && !enco){
			cadbus=tlhp.indexOf(arrloc[z]);
			if(cadbus!=-1){ref=arrref[z];enco=true;}
			z++;
		}
		if (tlhp==dom || tlhp==domb || tlhp==domi){ref='HOME';}
	}
	var b=recCooPFvalor('PFICHAID');
	var stcon="";
	if (idcen){stcon="&ID_CENTRO="+idcen;}
	if (idcur){stcon=stcon+"&id_curso="+idcur;}
	if (ref=="OUT") { ref="EXTERNO";}
	aa= new Image(1,1); 
	aa.src='http://estadwt.emagister.com/insert_user_url_action.cfm?id_project='+id_project+'&REF='+ref+'&action='+metrica+T+'&pfichas='+b+stcon+escape(pb)+'&id_user='+GetCookie("IDC")+'&TOP_AB='+escape(location.href)+'&REFERER_AB='+escape(document.referrer.replace(new RegExp(' ','gi'), '?'));
	aa.lowsrc='http://estadwt.emagister.com/insert_user_url_action.cfm?id_project='+id_project+'&REF='+ref+'&action='+metrica+T+'&pfichas='+b+stcon+escape(pb)+'&id_user='+GetCookie("IDC")+'&TOP_AB='+escape(location.href)+'&REFERER_AB='+escape(document.referrer.replace(new RegExp(' ','gi'), '?'));
	return true;
}
arrloc=new Array("users","/centros/","quienes","centrodetalles");
arrcs=new Array("MENU_DE_USUARIO","MENU_DE_CENTRO","QUIENES_SOMOS","PCENTRO");
var enco=false;
var z=0;
while(z<arrloc.length && !enco){
	cadbusRef=document.referrer.indexOf(arrloc[z]);
	cadbus=tlhp.indexOf(arrloc[z]);
	if(cadbusRef!=-1 && cadbus!=-1){cS(arrcs[z]);enco=true;}
	z++;
}

function chto(url,lugar){
	window.location=url;
}

function linki(objeto){
	sitio=objeto.getElementsByTagName('a')[0].href;
	window.location=sitio;
}

function cargarpuente(puente){
	SetCookie('C_ID_PUENTE',puente);
}

function creaXML(){
	var xmlhttp=false;
	/*@cc_on @*/
	/*@if (@_jscript_version >= 5)
	  try {
	  xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
	 } catch (e) {
	  try {
	    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	  } catch (E) {
	   xmlhttp=false;
	  }
	 }
	@else
	 xmlhttp=false
	 @end @*/
	
	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
		try {
			xmlhttp = new XMLHttpRequest();
		} catch (e) {
			xmlhttp=false;
		}
	}
	if (!xmlhttp && window.createRequest) {
		try {
			xmlhttp = window.createRequest();
		} catch (e) {
			xmlhttp=false;
		}
	}
	return xmlhttp;
}
var objanterior;
function showNavigatorLayerOpos(objeto,idLayer,masancho){
	sumancho=masancho?100:0;
	presion(objeto);
	document.getElementById(idLayer).style.left = (izq+25)+'px';
	document.getElementById(idLayer).style.top  = (arr+document.body.scrollTop)+'px';
	totcint=document.getElementById(idLayer).getElementsByTagName("div");
	resta=(totcint[totcint.length-1].childNodes.length>1)?2:3;
	totcinto=totcint.length-parseInt(resta);
	multiplo=(document.all?185:175)+sumancho;
	document.getElementById(idLayer).style.width  = (totcinto*multiplo)+"px";
	document.getElementById(idLayer).style.display=(document.getElementById(idLayer).style.display =='none')?'':'none';
	objactual=document.getElementById(idLayer)
	if(objanterior && objanterior!=objactual){objanterior.style.display='none';}
	objanterior=objactual;
}
function ocnavigs_opos(){
	if(document.getElementById('hnavig'))
		document.getElementById('hnavig').style.display='none';
	if(document.getElementById('lcsos')){
		document.getElementById('lcsos').style.marginLeft='0px';
		document.getElementById('lcsos').style.width='100%';
	}
}

function ocnavigs_sch_opos(){
	if(document.getElementById('hnavig')){
	  document.getElementById('hnavig').parentNode.style.display='none';
	  document.getElementById('lcsos').style.marginLeft='30px';
	  document.getElementById('lcsos').style.width='90%';
	}
}
function ftr_opos(filtro,valor){
	urlbase=unescape(urlbase).replace(new RegExp('%','gi'),'%25');
	if(valor || valor == 0){
		urlir=urlbase+'&'+filtro+'='+valor;
	}
	else{
		// En el caso de categorias descartamos siempre las de nivel superior
		if (filtro.indexOf("frmIdCategNiv") != -1){
			filtro = "frmIdCateg";
		}
		urlir=urlbase.replace(new RegExp('&'+filtro+'=[^&]*','gi'), '');
	}
	
	window.location=urlir;
}
function ircat(objeto){
	hobj=objeto.parentNode.getElementsByTagName('b')[0].getElementsByTagName('a')[0];
	enlace=hobj.href;
	window.location=enlace;
}

function showAlertsToggle(){

	imgElem = document.getElementById('alerts_arrow');
	divElem = document.getElementById('cjaAlertasC');
	divElemTop = document.getElementById('cjaAlertasTop');
	
	if(divElem.style.display == 'none'){
		divElem.style.display = '';
		imgElem.src='/oposiciones_content/alertas/images/darrow.gif';
		divElemTop.style.borderTop = '1px solid #CCCCCC';	
		divElemTop.style.background = '#FCF4D5';		

	}else{
		divElem.style.display = 'none';
		imgElem.src = '/oposiciones_content/alertas/images/larrow.gif';		
		divElemTop.style.border = '0px';		
		divElemTop.style.background = 'none';				
	}
}

function showAlertsToggle2(){

	imgElem = document.getElementById('alerts_arrow');
	divElem = document.getElementById('cjaAlertasC');
	
	if(divElem.style.display == 'none'){
		divElem.style.display = '';
		imgElem.src='/oposiciones_content/alertas/images/uarrow.gif';	

	}else{
		divElem.style.display = 'none';
		imgElem.src = '/oposiciones_content/alertas/images/darrow.gif';							
	}
}

function ocumail(){
	divvmas = document.getElementById('alertVMas');
	divfrmmail = document.getElementById('frmAlertasEmail');	
	tdtitlemail = document.getElementById('frmtitlemail');
	if(GetCookie('EM_SESSIONINFO')){
		divvmas.style.display='none';
		divfrmmail.style.display='none';
		divfrmmail.value = -1;
		tdtitlemail.style.display='none';						
	}
}

function sCOpos(evt,seg,lPuentes,idCateg,pos,totalResults,urlMetrix,idSite,x,y,z){	  
	var imgName = "spy"+Math.round(Math.random()*1000);
	window[imgName]=new Image(1,1);
	var cPuente = GetCookie("C_ID_PUENTE");
	var p=(cPuente && (lPuentes == '' || lPuentes == '-1'))?cPuente:lPuentes;
	var q =( (typeof(luceneQueryString)!= "undefined") ?luceneQueryString:'');
	if (typeof(totalResults)== "undefined") totalResults = '';
	if (typeof(urlMetrix)== "undefined") urlMetrix = 'http://metrix.emagister.com/';
	if (typeof(idSite)== "undefined") idSite = '1';
	if (typeof(x)== "undefined") x = '1';
	if (typeof(y)== "undefined") y = '';
	if (typeof(y)== "undefined") z = '';	
	window[imgName].src=urlMetrix+'EmagStatsWebApp/stats?site='+idSite+'&evt='+evt+'&seg='+seg+'&x='+x+'&y='+y+'&z='+z+'&org='+recCooPFvalor('PFICHAORIGEN')+'&id='+p+'&q='+q+'&cat='+idCateg+"&pos="+pos+"&tr="+totalResults+"&sid="+GetCookie("CFID")+"_"+GetCookie("CFTOKEN");
	return true;
}

function compar(llista){
	aPuentes = llista.split(',');
	if((aPuentes.length-1) >= 7){
		alert('Debes seleccionar un m'+String.fromCharCode(225)+'ximo de 6 cursos para comparar.');
	}else if((aPuentes.length-1) <= 1){
		alert('Debes seleccionar al menos dos cursos para poder comparar.');
	}else{
		llista = llista.substring(1,llista.length);
		comprendos(llista);
	}
}
function comp(llista){    
	aPuentes = llista.split(',');
	if((aPuentes.length-1) >= 7){
		alert('Debes seleccionar un m'+String.fromCharCode(225)+'ximo de 6 cursos para comparar.');
	}else if((aPuentes.length-1) <= 1){
		alert('Debes seleccionar al menos dos cursos para poder comparar.');
	}else{
		llista = llista.substring(1,llista.length);
		comparaCurso(llista);
	}
}



function tgl_get_ttip_show(obj){
	ele = document.getElementById(obj);
	ele.style.visibility='visible';
}

function tgl_get_ttip_hid(obj){
	ele = document.getElementById(obj);
	ele.style.visibility='hidden';
}

function refreshChart(id_categ,id_provincia,id_tipo_admin,tipo_search, obj){

	var xmlhttpa=creaXML();
	urlchart='/oposiciones_content/pconvo/charts/index.cfm?id_categ='+id_categ+'&id_provincia='+id_provincia+'&id_tipo_admin='+id_tipo_admin+'&tipo_search='+tipo_search;
	xmlhttpa.open("GET", urlchart, true);
		
	xmlhttpa.onreadystatechange=function() {		
		if(xmlhttpa.readyState == 4)
		{	
			if(xmlhttpa.status == 200)
			{		
				var xmlObj = xmlhttpa.responseText;
				var ifr = document.getElementById('cjagraficas');
				ifr.innerHTML = xmlObj;

				oldObj.className = '';
				oldObj.onclick=function(){refreshChart(id_categ,id_provincia,id_tipo_admin,(tipo_search?0:1), this)}
				obj.className = 'lnkact';
				obj.onclick= null;
				oldObj = obj;
			}
			else
			{
				alert("Ha ocurrido un error durante la petici"+String.fromCharCode(243)+"n: "  + xmlhttpa.status);
			}	
		}
				
	};

	xmlhttpa.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	xmlhttpa.send(null);
}

function recoconvo(idbusqcurso){
	window.open('/oposiciones_content/pconvo/recomendar_convo/index.cfm?id_busqueda='+idbusqcurso,'','width=470,height=500');
}

function recotemario(idbusqcurso){
	window.open('/oposiciones_content/ptemario/recomendar_temario/index.cfm?id_busqueda='+idbusqcurso,'','width=470,height=500');
}
function validarText(obj,e){
	evento=document.all?event:e;
	
	if (evento.keyCode==13)
	{
		if (obj.value.length < 3){
			alert ('Debes introducir m�nimo 3 caracteres');
			return false;
		}
		document.frmCateg.submit();
	}
}


function submitarF(){
	if (document.frmCateg.txtPalClave.value.length < 3){
		alert ('Debes introducir m�nimo 3 caracteres');
	}
	else {
		document.frmCateg.submit();
	}
}

pim='';

function pth(valor){
	var i=0;
	var inicio=0;
	var cestr='';
	var valor_on="<img src='"+pim+"images/estrella_pequenya_on.gif' width='12' height='12' border='0'>";
	var valor_off="<img src='"+pim+"images/estrella_pequenya_off.gif' width='12' height='12' border='0'>";

	if(!valor){
		inicio=1;
		cestr=cestr+"<img src='"+pim+"images/estrella_pequenya_0.gif' width='12' height='12' border='0'>";
	}
	for(i=inicio;i<4;i++){
		if(i<valor){cestr=cestr+valor_on;}
		else{cestr=cestr+valor_off;}
	}
	document.write(cestr);
}

function verMasOpos(verMas, idMas, footerTematicas)
{
	/**
	*	Copia los nodos hijos del elemento footerTematicas
	*	al elemento idMas si el nodo idMas no tiene hijos. Si los tiene,
	*	entonces los borra (actua como "toggle").
	*	Se usa para mostrar/ocultar las tematicas en la pagina de busqueda
	*	a traves del link "ver mas tematicas".
	*/
	
	var verMas, layerTop, layerBottom, i;
	
	layerMas=document.getElementById(verMas);
	layerTop=document.getElementById(idMas);
	layerBottom=document.getElementById(footerTematicas);
	
	// esta funcion hace de "toggle", si ya tenemos nodos los petamos					
	if (layerTop.childNodes.length==0)
	{
		// copiamos los nodos de footerTematicas a idMas
		for (i=0; i<layerBottom.childNodes.length; i++)
		{
			layerTop.appendChild(layerBottom.childNodes[i].cloneNode(true));
		}					
		
		// de momento vamos a ocultar el enlace para no poder "contraer" las tematicas
		layerMas.innerHTML='&laquo; Ocultar Subtem&aacute;ticas';
	}
	else
	{
		// borramos los nodos de idMas
		layerTop.innerHTML='';
		layerMas.innerHTML='Ver todas las tem&aacute;ticas &raquo;';
	}
}


function verificatxtmm(campo,minimo,maximo,texto){
	retorno=true;
	longitud=campo.value.length;
	mensajemin="Debes escribir al menos "+minimo+" caracteres";
	if(texto){mensajemin=texto}
	if(longitud>maximo){alert(superadomax);campo.focus();retorno=false;}
	if(longitud<minimo){alert(mensajemin);campo.focus();retorno=false;}
	return retorno;
}
function validabusq_opos(){
    var i;
	if (document.frmcateg.tipo_search[1].selected){
		document.frmcateg.action.value = 'search';
		SetCookieSessionOpos('OPOSTIPOSEARCH','curso');
	}else if (document.frmcateg.tipo_search[2].selected){
		document.frmcateg.action.value = 'temariosearch';
		SetCookieSessionOpos('OPOSTIPOSEARCH','temario');
	}else if (document.frmcateg.tipo_search[0].selected){
		document.frmcateg.action.value = 'opossearch';
		SetCookieSessionOpos('OPOSTIPOSEARCH','convo');
	}

	if(!verificatxtmm(document.frmcateg.frmStrBusqueda,3,100)){return false}
}
			
function detectsub(keCo) {
	if (keCo==13){ busqMet(); }
}

function resetear(){}

function busqMet()
{	
	
	ref="";
	dom='http://'+location.host;
	domb=dom+'/';
	domi=domb+'index.cfm';	

	if(document.frmcateg.tipo_search.value == 'curso'){
		urldestino =  'http://'+location.host+'/oposiciones-convocatorias/';
	}else if(document.frmcateg.tipo_search.value == 'temario'){
		urldestino =  'http://'+location.host+'/temarios-oposiciones/';
	}else if(document.frmcateg.tipo_search.value == 'convos'){
		urldestino =  'http://'+location.host+'/empleo-publico/';
	}
	
	document.frmcateg.setAttribute('action',urldestino+'index_buscador.cfm');

	if (top.location.href==dom || top.location.href==domb || top.location.href==domi){
		ref='HOME';
	}
	if (top.location.href.indexOf('/cursos-')!=-1){
		ref='HOME';
	}
	if (top.location.href.indexOf('-cursos-')!=-1){
		ref='PCURSO';
	}
	if (top.location.href.indexOf('cursos_gratis.htm')!=-1){
		ref='HOME';
	}	
	
	cS('BUSCADOR',ref,'','','',document.frmcateg.frmStrBusqueda.value.replace(new RegExp(' ','gi'), ' '));
}

function selectTiposearch(id_segmento){

	    // Recupera ultimo estado de busqueda		
				
		if(id_segmento == 6){
			document.frmcateg.tipo_search[1].selected = 'true';
		}else if(id_segmento == 10){
			document.frmcateg.tipo_search[0].selected = 'true';
		}else{
			document.frmcateg.tipo_search[2].selected = 'true';
		}

		//if(GetCookie('OPOSTIPOSEARCH') == "curso"){
//			//document.frmcateg.tipo_search[1].checked = 'checked';
//			document.frmcateg.tipo_search[1].selected = 'true';
//		}else if(GetCookie('OPOSTIPOSEARCH') == "temario"){
//			document.frmcateg.tipo_search[2].selected = 'true';
//		}else{
//			document.frmcateg.tipo_search[0].selected = 'true';
//		}		
}

function SetCookieSessionOpos (name, value) {  	
	document.cookie = name + "=" + escape (value) + 
	"; path=/" +  
	"; domain="+location.host;
} 
function escribe_push(id_provincia, id_categ, precio, id_tipocurso){
	
	document.write('<form action="/emag_users/pcurso/act_adduserpush.cfm" onsubmit="return ajax_alta_push(this)">');
	document.write('<input type="hidden" name="id_categ" value="'+id_categ+'" >');
	document.write('<input type="hidden" name="precio" value="'+precio+'" >');
	document.write('<input type="hidden" name="id_tipocurso" value="'+id_tipocurso+'" >');
	if (GetCookie("EM_SESSIONINFO")) {
		document.write('<input type="hidden" name="logado" value="1" >');
	}
	else {
		document.write('<input type="hidden" name="logado" value="0" >');
		document.write('<input type="hidden" name="id_provincia" value="'+id_provincia+'" >');
		document.write('<b>email</b><br/><input name="mail" value="" ><br/><br/>');
	}	
	
	document.write('<button name="boton" type="submit">suscribirme</button>');
	document.write('<br /><br /><small>Al presionar "Suscribirme" est&aacute;s aceptando expresamente nuestras ');
	document.write('<a href="javascript:void(0)" onclick="window.open(\'http://www.emagister.com/reglas_uso.cfm\',\'\'');
	document.write(',\'width=600,height=400,scrollbars=yes\')">reglas de uso</a> y ');
	document.write('<a href="javascript:void(0)" onclick="window.open(\'http://www.emagister.com/privacidad.cfm\',\'\'');
	document.write(',\'width=600,height=400,scrollbars=yes\')">pol&iacute;tica de protecci&oacute;n de datos</a>');
	document.write('.</small>');
	document.write('</form>');
}


function ajax_alta_push(f) {
	if (f.mail){
		if (!verificamail(f.mail,'Por favor, introduce tu e-mail correctamente.'))
			return false;
	}
	
	f.boton.disabled = "disabled";
	xmlhttp_alta=creaXML();
	parametrourl= f.action + "?";
	var i=0;
	var params = "";
	for (i=0; i<f.elements.length; i++){
		if (f.elements[i].nodeName == "INPUT") 
			params+= f.elements[i].name + "=" + f.elements[i].value + "&";
	}
	url = parametrourl + params;
		
	xmlhttp_alta.open("GET", url, true);
	xmlhttp_alta.onreadystatechange=function() {
		if (xmlhttp_alta.readyState==4) {
		   alert('Suscripción realizada. Muchas gracias.')
		}
	}
	xmlhttp_alta.setRequestHeader('Accept','message/x-jl-formresult');
	xmlhttp_alta.send(null);
	return false;
}

function rlcentro(){
	if(GetCookie('nombre_centro') && GetCookie('login_centro') && GetCookie('password_centro')){
		document.getElementById('lincentro').href="http://www.emagister.com/emag_users/pcentro"+"/index.cfm?id_centro="+idcentro;
	}
}

function cierraTags(){
	document.write('</em></strong></b></u></i></ul></ol>');
}

function openDocumentFiles(fic,ibusq,lnkvolv)
{
	window.open('/emag_users/pcurso/ficheros/frame_uploadfiles.cfm?id_busqueda='+ibusq+'&linkvolver='+lnkvolv+'&urlbase='+fic,'win','height='+(screen.availHeight-10)+',width='+(screen.availWidth-10)+',left=0,top=0,status=yes,toolbar=no,menubar=no,location=no,scrollbars=yes');
}


function perfil_usuario(idUsuario,action){
	openw(concatenar_cadena('/emag_users/pcurso/opiniones/','index','.cfm?idUsuario='+idUsuario+'&action='+action),635,800,'yes','0');
}

function reCS(){}

function metFin(){}


function recocurso(idbusqcurso){
	window.open('/emag_users/recomendar/index.cfm?id_busqueda='+idbusqcurso,'','width=470,height=500');
}

function caducado(){
	objat=document.getElementById('relaccionados');
	objat.style.position='absolute';
	objat.style.backgroundColor='white';
	objat.style.zIndex='20';
	objat.style.top='270px';
	objat.style.border='10px solid #4aa7af';
	msg=document.getElementById('msgcaduc');
	objat.style.padding='10px 10px 40px 10px';
	prieca=objat.childNodes[0];
	objat.insertBefore(msg,prieca);
}

function vmi(enl){
	todes=document.getElementById("masinff");
	if(todes.style.display==''){
		todes.style.display='none';
		enl.className='promcns';
	}
	else{
		todes.style.display='';
		enl.className='enlacenegro';
	}
}

function desptem(enl){
	contint=document.getElementById("conttem");
	eldfn=enl.parentNode;
	pdconte=contint.parentNode;
	pdconte.style.height=(contint.offsetHeight+(document.all?0:30))+'px';
	eldfn.style.display='none';
	if(typeof(capmaps)!='undefined'){
		if(capmaps.style.visibility=='visible'){
			modtop()
		}
	}
}

function desptemb(){
	contint=document.getElementById("conttem");
	eldfn=document.getElementById("ttemamp");
	pdconte=contint.parentNode;
	if(contint.offsetHeight<243){
		pdconte.style.height=(contint.offsetHeight+(document.all?0:30))+'px';
		eldfn.style.display='none';
	}
}

var old_objeto;

function modtop(){
	capmaps.style.top=(capamapa.offsetTop+1)+'px';
	capmaps.style.left=(capamapa.offsetLeft)+'px';
	capmaps.style.visibility='visible';
}


function vermapa(objeto,latitud,longitud){
	padre=objeto.parentNode;
	if(objeto.style.backgroundImage=='url(/emag_users/pcurso/images/fnorm.gif)'){
		objeto.style.backgroundImage='url(/emag_users/pcurso/images/finvert.gif)';
		objeto.innerHTML='ver mapa';
		capamapa.style.display='none';
		capmaps.style.visibility='hidden';
	}
	else{
		if(old_objeto){
			old_objeto.style.backgroundImage='url(/emag_users/pcurso/images/finvert.gif)';
			old_objeto.innerHTML='ver mapa';
		}
		
		if(padre.getElementsByTagName('div').length>0){
			capamapa.style.display='block';
			capmaps.style.visibility='visible';
		}
		else{
			if(typeof(capamapa)!='undefined'){
				padre.appendChild(capamapa);
				capamapa.style.display='block';
				window.frames['mgo'].load(latitud,longitud);
				
				setTimeout("modtop()",1);
				
			}
			else{
				capamapa=document.createElement('div');
				capamapa.className='mapagoogle';
				capmaps=document.createElement('div');
				capmaps.className="mapabsol";
				
				ifrfmaps='<iframe frameborder="0" marginheight="0" marginwidth="0" scrolling="no" height="302" width="503" name="mgo" id="mgo"></iframe>';
				capmaps.innerHTML=ifrfmaps;
				capmaps.style.marginLeft='1px';
				padre.appendChild(capamapa);
				padre.style.minHeight='300px';
				//alert(padre.parentNode.parentNode.tagName)
				padre.parentNode.parentNode.parentNode.getElementsByTagName('caption')[0].appendChild(capmaps);
				window.frames['mgo'].location='/emag_users/pcurso/dsp_mapagoogle.cfm?lat='+latitud+'&lon='+longitud;
				modtop();
			}
		}
		objeto.style.backgroundImage='url(/emag_users/pcurso/images/fnorm.gif)';
		objeto.innerHTML='ocultar mapa';
		old_objeto=objeto;
	}
}

function rtlstchkcursos(){
	var i=0;
	var r='';
	collpuentes=document.getElementsByName('puentes');
	for(i=0;i<collpuentes.length;i++){
		if(collpuentes[i].checked)
			r+=','+collpuentes[i].value;
	}
	return r;
}

var fecha;
function vercalendario(u,msg){
	padreu=u.parentNode;
	misfechas=padreu.getElementsByTagName('span');
	var primerafecha='';
	var segundafecha='';
	
	if(u.innerHTML=='ocultar calendario'){
		u.innerHTML='ver calendario';
		u.style.backgroundImage='url(/emag_users/pcurso/images/finvert.gif)';
		padreu.removeChild(capaaFecha);
		padreu.removeChild(capaMensaje);
		if(typeof(capmaps)!='undefined'){
			if(capmaps.style.visibility=='visible'){
				modtop()
			}
		}
	}
	else{
		u.innerHTML='ocultar calendario';
		u.style.backgroundImage='url(/emag_users/pcurso/images/fnorm.gif)';
		
		if(misfechas.length==2){
			primerafecha=misfechas[0].getElementsByTagName('input')[0].value;
			segundafecha=misfechas[1].getElementsByTagName('input')[0].value;
		}
		else if(misfechas.length==1)
			primerafecha=misfechas[0].getElementsByTagName('input')[0].value;
		fecha=primerafecha+(segundafecha?','+segundafecha:'');
		if(document.getElementById("calendarios")){
			padreuold.removeChild(capaaFecha);
			padreuold.removeChild(capaMensaje);
			uold=padreuold.getElementsByTagName('u')[0];
			uold.innerHTML='ver calendario';
			uold.style.backgroundImage='url(/emag_users/pcurso/images/finvert.gif)';
		}
		capaaFecha=document.createElement('div');
		capaaFecha.setAttribute("id","calendarios");
		padreu.appendChild(capaaFecha);
		
		capaMensaje=document.createElement('div');
		capaMensaje.style.clear='both';
		capaMensaje.style.paddingTop='10px';
		capaMensaje.innerHTML=msg;
		padreu.appendChild(capaMensaje);
		
		if(typeof(miscript)=='undefined'){
			miscript=document.createElement('script');
			miscript.setAttribute('src','/emag_users/pcurso/js/calendarios.cfm');
			mihead=document.getElementsByTagName('head')[0];
			mihead.appendChild(miscript);
		}
		else
			ccal();
		
		padreuold=padreu;
	}
}


function brras(valor){
	var u=1;
	document.write('<div class="brr">');
	for(u=1;u<=5;u++){
		if(u<=valor)
			document.write('<i></i>');
		else
			document.write('<s></s>');
	}
	document.write('</div>');
}

function brvas(valor){
	var u=1;
	document.write('<div class="brr">');
	for(u=1;u<=5;u++){
		if(u<=valor)
			document.write('<i></i>');
		else
			document.write('<del></del>');
	}
	document.write('</div>');
}


function registrar_new(obj,uti,idus,idop){
	obj.parentNode.getElementsByTagName('button')[0].disabled = "disabled";
	obj.parentNode.getElementsByTagName('button')[1].disabled = "disabled";
	if(obj.parentNode.getElementsByTagName('button')[2]){
		obj.parentNode.getElementsByTagName('button')[2].disabled = "disabled";
	}
	xmlhttpb=creaXML();
	var urlaux="/emag_users/pcurso/act_utility.cfm?utilidad="+uti+"&idusuario="+idus+"&idopinion="+idop;
	xmlhttpb.open("GET",urlaux,true);
	xmlhttpb.onreadystatechange=function() {
		if (xmlhttpb.readyState==4) {
			alert(xmlhttpb.responseText);
		}
	}
	xmlhttpb.setRequestHeader('Accept','message/x-jl-formresult');
	enviou=document.all?null:xmlhttpb.responseText;
	xmlhttpb.send(enviou);	
}

function rlnkpht(){
	if(document.getElementById("phthome") && GetCookie('EM_SESSIONINFO'))
		document.getElementById("phthome").href+='index_buscador.cfm';
}


function msjsb(p,s,l,im){
	if (document.getElementById("titcentroficha")) {	
		if (s.length > 1) {
			mensaje='<span class="'+im+'"></span><span class="b"></span>Curso 100% subvencionado s&oacute;lo para<br /> <b>'+p+'</b>'+(s?(' del <b>sector '+s+'</b>'):'')+' <b>'+l+'</b>';
		}
		else
			mensaje='<span class="'+im+'"></span><span class="b"></span>Curso 100% subvencionado s&oacute;lo para<br /> <b>'+p+' '+l+'</b>';
		
		cpf=document.createElement('div');
		cpf.className='sbsmf';
		cpf.innerHTML=mensaje;
		eleinst=document.getElementById("titcentroficha");
		pdr=eleinst.parentNode;
		pdr.insertBefore(cpf,eleinst);
	}
}

/* Toggle muestra y oculta requisitos */
function reqvmas(){
	var a = document.getElementById('requ');
  	var b = document.getElementById('requlnk');
  	if(a.style.overflow == 'auto'){
  		a.style.height='45px';
  		a.style.overflow='hidden';
  		b.style.background='url(/emag_users/pcurso/images/finvert.gif) no-repeat right';
  		b.firstChild.innerHTML = 'ver m'+ String.fromCharCode(225)+'s';
  	}else{
  		a.style.height='auto';
  		a.style.overflow='auto';
  		b.style.background='url(/emag_users/pcurso/images/fnorm.gif) no-repeat right';	
 		b.firstChild.innerHTML = 'ocultar';		
  	}
}
  
/* Si es mayor de tres lineas ocultar y mostrar link */
function despRequis(){
  	if(document.getElementById('requ')){
  		var b = document.getElementById('requ');
  		//alert(b.offsetHeight);
  		if(b.offsetHeight > 45){
  			b.style.height='45px';
  			document.getElementById('requlnk').style.display='inline';							
  		}
  	}
}

function er(idelement){
	if(document.getElementById(idelement).scrollHeight>390){
		document.write('<cite class="todarv" id="d'+idelement+'" style="background-image:url(/emag_users/pcurso/images/finvert.gif)"><a href="javascript:void(0)" onclick="desprev(this)" class="azule">ver toda la review</a></cite>')
	}
}


function desprev(c){
	tm=c.parentNode;
	divid=tm.id.substring(1);
	toflow=document.getElementById(divid);
	
	if(tm.style.backgroundImage=='url(/emag_users/pcurso/images/finvert.gif)'){
		toflow.style.height='auto';
		tm.style.backgroundImage='url(/emag_users/pcurso/images/fnorm.gif)';
		tm.getElementsByTagName('a')[0].innerHTML='ocultar review';
	}
	else{
		toflow.style.height='357px';
		tm.style.backgroundImage='url(/emag_users/pcurso/images/finvert.gif)';
		tm.getElementsByTagName('a')[0].innerHTML='ver toda la review';
	}
}


function q(){
	if(navpag){
		deleteCookie('lstidbusquedas');
	}
}
function mostrarpaginacion(idbusqueda){
	if(document.referrer.indexOf(domipto)==-1)
		deleteCookie('lstidbusquedas');
	
	dtbcookie=GetCookie('lstidbusquedas');	
	var ncurso=0;
	var esta=false;
	if(dtbcookie){
		/*caso de posibles idbusquedas duplicados*/
		if(location.search){
			nposco=location.search.indexOf('&n=');
			if(nposco!=-1){
				ncurso=location.search.substring(nposco+3);
				esta=true;
			}
		}
		
		
		info=dtbcookie.split('|;|');
		alstbusquedas=info[0].split(',');
		lareferencia=info[1];
		var i=0;
		
		var tcursos=alstbusquedas.length;

		if(tcursos>1){
			
			if(document.all){
				document.body.onmousedown=function(){
					lnk=event.srcElement;
					if(lnk.tagName=='A' && lnk.outerHTML.indexOf('http://')!='-1'){navpag=1}
				}
			}
			else{
				document.body.onmousedown=function(event){
					lnk=event.target;
					if(lnk.tagName=='A' && lnk.getAttribute('href').indexOf('http://')!=-1){navpag=1}
				}
			}
			
			window.onunload=q;
			
			zpag=document.createElement('div');
			zpag.className='ziz';
			zpag.style.padding='0px 0px 0px 10px';
			
			
			if(!ncurso){
				for(i=0;i<tcursos;i++){
					if(alstbusquedas[i]==idbusqueda){
						ncurso=i+1;
						esta=true;
						break;
					}
				}
			}
			
			urchin("/pcurso/paginacion");
            
			if(esta){
				htpg='<div class="cjpaginacion" style="margin:0px 10px 10px 0px">';
				htpg+='<a href="'+lareferencia+'" onclick="urchin(\'/pcurso/refinar\')" style="float:right;font-weight:bold">Refinar B&uacute;squeda</a>';
				if(ncurso>1)
					htpg+='<a href="/view_cursos.cfm?page=view_course&id_busqueda='+alstbusquedas[(parseInt(ncurso)-2)]+'&n='+(parseInt(ncurso)-1)+'" onclick="navpag=0;urchin(\'/pcurso/siguiente\')">&laquo; anterior</a> ';
				else
					htpg+='<a></a>';
				
				htpg+=ncurso+' de '+tcursos;
				
				if(ncurso<tcursos)
					htpg+=' <a href="/view_cursos.cfm?page=view_course&id_busqueda='+alstbusquedas[ncurso]+'&n='+(parseInt(ncurso)+1)+'" onclick="navpag=0;urchin(\'/pcurso/siguiente\')">siguiente &raquo;</a>';
				
				htpg+='</div>';
				
				zpag.innerHTML=htpg;
				
				referente=document.getElementById('impresion').nextSibling;
				referente.parentNode.insertBefore(zpag,referente)
			}
			else{
				deleteCookie('lstidbusquedas');
			}
		}
	}
}

function change_status(){
	if (document.getElementById('feedback').style.display == "none") {
		document.getElementById('feedback').style.display = "block";
		document.getElementById('flecha').src = "subvencionados_content/alertas/images/darrow.gif";
		}
	else {
		document.getElementById('feedback').style.display = "none";
		document.getElementById('flecha').src = "subvencionados_content/alertas/images/larrow.gif";
		}
}


$(function(){
	dependencia_puesto();
});

function dependencia_puesto(){
	
	// disable combos
	$('.puesto').attr('disabled','disabled');	
	$('.puesto').attr('disabled','disabled');
	
	// Ajax courses
	$("#opos_cursos_sector").bind("change", function() {
		$.post("/oposiciones_content/home/async/act_categ.cfm", {opos_cursos_sector: $(this).val(), type: "xml", mode: "cursos"}, function(xml){
			$("#opos_cursos_puesto").empty();
			$(xml).find("option").each(function(x,el) {
			 $("#opos_cursos_puesto").append('<option value="'+$(el).attr("value")+'">' +$(el).text() + '</option>');
			});
		}, "xml");
			
		disable_combo(this);
	});			
	
	// Ajax books
	$("#opos_temarios_sector").bind("change", function() {
		$.post("/oposiciones_content/home/async/act_categ.cfm", {opos_temarios_sector: $(this).val(), type: "xml", mode: "temarios"}, function(xml){
			$("#opos_temarios_puesto").empty();
			$(xml).find("option").each(function(x,el) {
			 $("#opos_temarios_puesto").append('<option value="'+$(el).attr("value")+'">' +$(el).text() + '</option>');
			});
		}, "xml");
		disable_combo(this);
	});	

}

// disable combos toogle
function disable_combo(obj){
		 var padre = $(obj).parents('form'); 
		if ($(obj).val() != "" && $(obj).val() != null && $(obj).val() != undefined && $(obj).val() != -1) {
			$('.puesto', padre).removeAttr('disabled');		
		}
		else if($(obj).val() == "" || $(obj).val() == null || $(obj).val() == undefined || $(obj).val() == -1){
			$('.puesto', padre).attr('disabled','disabled');		
		}
}




function getCourseResults(frm){
	
	loc = "http://www.emagister.com/oposiciones-convocatorias/index_buscador.cfm?action=search";
	loc = loc + "&frmIdPaisBusqueda=6";
		
	if(frm.frmIdProvincia.value < 0){
		alert('Debes seleccionar una provincia');
		frm.frmIdProvincia.focus();
		return false;
	}else if(frm.frmIdProvincia.value > 0){
		loc += "&frmIdProvincia="+frm.frmIdProvincia.value;
	}
	
	if(frm.opos_cursos_sector.value <= 0){
		alert('Debes seleccionar una categoria ');
		frm.opos_cursos_sector.focus();
		return false;
	}else if(frm.opos_cursos_puesto.value > 0){
		loc += "&frmIdCateg="+frm.opos_cursos_puesto.value;
	}else{
		loc += "&frmIdCateg="+frm.opos_cursos_sector.value;
	}
	
	window.location = loc;
	return false;
	
}

function getTemarioResults(frm){
	
	loc = "http://www.emagister.com/oposiciones-convocatorias/index_buscador.cfm?action=temariosearch";
	
	if(frm.opos_temarios_sector.value <= 0){
		alert('Debes seleccionar una categoria ');
		frm.opos_temarios_sector.focus();
		return false;
	}else if(frm.opos_temarios_puesto.value > 0){
		loc += "&frmIdCategOpo404="+frm.opos_temarios_puesto.value;
	}else{
		loc += "&frmIdCategOpo404="+frm.opos_temarios_sector.value;
	}
	
	window.location = loc;
	return false;
	
}

