function despMenu(nombre,num)
{
	obj = document.getElementById(nombre);
	
	if(num>0){
		obj.style["display"] = "block";
	}else{
		obj.style["display"] = "none";
	}
}
//usabilidad
function usabilidad(path,href,target,width,height) {
	 // alert("path: "+path+"\n"+"href: "+href+"\n"+"target: "+target+"\n"+"width: "+width+"\n"+"height: "+height+"\n");
		
		if (width!=undefined && height!=undefined) {
				cert_registerHitAndOpenWindow(href, 200425, path, 'cert_Pivot', '_blank', 'width='+width+',height='+height+',scrollbars=no,resizable=no,menubar=no');
		} else if (href!=undefined && (target==undefined || target=="" || target=="_self")) {
				cert_registerHitAndRedirect(href, 200425, path);
		} else if (href!=undefined) {
				cert_registerHit(200425, path);
				window.open(href,"_blank");
		} else {
				cert_registerHit(200425, path);
		}
		//alert(path);
		
		return false;
}
		
//buscador
function validarBuscadorTopPortada()
{
    var error=new Array();
		var todo = document.getElementById('todo').checked;
		var recursos = document.getElementById('recursos').checked;
    		
    //alert(todo);
    //alert(recursos);
		
    // Limpiar datos
    $('buscaesto').value=$$('buscaesto').trim();
    
    // Validar Campos
    if ($('buscaesto').value=="") {
      error.push("Debe escribir algo a buscar");
    }
    
    // Imprimir errores sólo si hay, sino enviar formulario
    if (error.length) {  
      alert(error.join("\n"))      
      //$('errores').innerHTML=error.join("<br />");
      return false;
    } else {
			if(todo){
					usabilidad('/Portada/Buscador/TodoelPortal/');	
			}
			else
			if(recursos){
					usabilidad('/Portada/Buscador/Recursos/');
			}
      return true;
      
    }
}
function validarBuscadorTop()
{
    var error=new Array();
    var todo = document.getElementById('todo').checked;
		var recursos = document.getElementById('recursos').checked;
		
    // Limpiar datos
    $('buscaesto').value=$$('buscaesto').trim();
    
    // Validar Campos
    if ($('buscaesto').value=="") {
      error.push("Debe escribir algo a buscar");
    }
    
    // Imprimir errores sólo si hay, sino enviar formulario
    if (error.length) {  
      alert(error.join("\n"))      
      //$('errores').innerHTML=error.join("<br />");
      return false;
    } else {
			if(todo){
					usabilidad('/Transversal/Buscador/TodoelPortal/');	
			}
			else
			if(recursos){
					usabilidad('/Transversal/Buscador/Recursos/');
			}    
      return true;
      
    }
}
function validarBuscadorTopBuscador()
{
		var error=new Array();
    var todo = document.getElementById('todo').checked;
		var recursos = document.getElementById('recursos').checked;
    
    //alert(todo);
    //alert(recursos);
    
		// Limpiar datos
		$('buscaesto').value=$$('buscaesto').trim();
		
		// Validar Campos
		if ($('buscaesto').value=="") {
			error.push("Debe escribir algo a buscar");
		}
		
		// Imprimir errores sólo si hay, sino enviar formulario
		if (error.length) {	
			alert(error.join("\n"))			
			//$('errores').innerHTML=error.join("<br />");
			return false;
		} else {
			if(todo){
					usabilidad('/Buscador/Top/TodoelPortal/');
					
			}
			else
			if(recursos){
					usabilidad('/Buscador/Top/Recursos/');
			}
      //usabilidad('/Buscador/Top//','Buscador.php')"
			return true;
      
		}
}

function validarBuscadorFooter()
{
		var error=new Array();
		var todo = document.getElementById('todoFooter').checked;
		var recursos = document.getElementById('recursosFooter').checked;
		
		//alert(todo);
    //alert(recursos);
		
		// Limpiar datos
		$('buscaesto2').value=$$('buscaesto2').trim();
		
		// Validar Campos
		if ($('buscaesto2').value=="") {
			error.push("Debe escribir algo a buscar");
		}
		
		// Imprimir errores sólo si hay, sino enviar formulario
		if (error.length) {	
			alert(error.join("\n"))			
			//$('errores').innerHTML=error.join("<br />");
			return false;
		} else {
			if(todo){
					usabilidad('/Buscador/Footer/TodoelPortal/');
			}
			else
			if(recursos){
					usabilidad('/Buscador/Footer/Recursos/');
			}
			return true;
		}
}
function validarBuscadorCentroRecursos()
{
		var error=new Array();
		/*
		var todo = document.getElementById('todoFooter').checked;
		var recursos = document.getElementById('recursosFooter').checked;
		*/
		//alert(todo);
    //alert(recursos);
		
		// Limpiar datos
		$('buscaesto2').value=$$('buscaesto2').trim();
		
		// Validar Campos
		if ($('buscaesto2').value=="") {
			error.push("Debe escribir algo a buscar");
		}
		
		// Imprimir errores sólo si hay, sino enviar formulario
		if (error.length) {	
			alert(error.join("\n"))			
			//$('errores').innerHTML=error.join("<br />");
			return false;
		} else {
			usabilidad('/Buscador/CentrodeRecursos/Recursos/');
			
			return true;
		}
}
function validarBuscadorCursos()
{
		var error=new Array();
		/*
		var todo = document.getElementById('todoFooter').checked;
		var recursos = document.getElementById('recursosFooter').checked;
		*/
		//alert(todo);
    //alert(recursos);
		
		// Limpiar datos
		$('buscaesto2').value=$$('buscaesto2').trim();
		
		// Validar Campos
		if ($('buscaesto2').value=="") {
			error.push("Debe escribir algo a buscar");
		}
		
		// Imprimir errores sólo si hay, sino enviar formulario
		if (error.length) {	
			alert(error.join("\n"))			
			//$('errores').innerHTML=error.join("<br />");
			return false;
		} else {
			usabilidad('/Buscador/Cursos/Recursos/');
			
			return true;
		}
}

//loguin
function showSelect(id){	
	var cajaSelect = document.getElementById(id);
	
	
	if(cajaSelect.style.display == 'none'){	
		cajaSelect.src = cajaSelect.src;
		cajaSelect.style.display = 'block';
		
	}else{
		cajaSelect.style.display  = 'none';
	}
}
/*
function cambiarImage(id){
	var cajaSelect = document.getElementById(id);

	if(cajaSelect.style.background == 'transparent url(../img/images/ini_btn.png) no-repeat scroll 75px 2px'){		
		cajaSelect.style.background = 'transparent url(../img/images/ini_btn2.png) no-repeat scroll 75px 2px';
	}
	else
	if(cajaSelect.style.background == 'transparent url(../img/images/ini_btn2.png) no-repeat scroll 75px 2px'){	
		cajaSelect.style.background = 'transparent url(../img/images/ini_btn.png) no-repeat scroll 75px 2px';
	}
}
*/

function cambiarImage(id){
	var cajaSelect = document.getElementById(id);

	if(cajaSelect.className == 'iniciar_secion abierto'){		
		cajaSelect.className = 'iniciar_secion cerrado';
	}
	else
	if(cajaSelect.className == 'iniciar_secion cerrado'){	
		cajaSelect.className = 'iniciar_secion abierto';
	}
}
function cajaNews(){
	$('input_news').value=$$('input_news').trim();
	
	if ($('input_news').value == "correo@correo.cl") {
		$('input_news').value =  '';
	}	
}

function newsletterIngreso() {
	
	var email = document.getElementById('input_news').value;
	window.setTimeout("restarurarEmailNewsletter()",2);
	//Llamar a php con AJAX
	var url 	= '/NewsletterAgregar/';
	var pars	= 'ejecutar=ingresaEmail&email='+email; 
	var myAjax = new Ajax.Request(url,{method: 'get',parameters: pars,onComplete: resNewsletterAgregar});
	
	function resNewsletterAgregar(originalRequest){		
		//alert(originalRequest.responseText);
		eval("var respuesta=" + originalRequest.responseText);			
		if(respuesta == 'OK'){
			//window.setTimeout("iBox.showIBox('#newsletter_agregar','ibox&width=50%','')",100);
		}
	}
}
	
function restarurarEmailNewsletter(){
	$('input_news').value =  'correo@correo.cl';	
}
	
function validarNews(){
	$('input_news').value=$$('input_news').trim();
	
	if ($('input_news').value == "") {
		$('input_news').value =  'correo@correo.cl';
	}	
	else{
		if(!$$('input_news').isEmail()){
				$('input_news').value =  'correo@correo.cl';
		}
		if($('input_news').value != 'correo@correo.cl'){
			window.setTimeout("iBox.showIBox('#newsletter_agregar','ibox&width=50%','')",1);
			
			newsletterIngreso();			
		}else{
			alert('Ingrese un correo.');	
		}
	}	
}