function Maximize(window_name, maximizador, contenido, ancho,alto){
//	alert(alto);
e = $('#'+contenido);	
	if (e.css('display') == 'none'){
	e.slideToggle('slow', $('#'+window_name).animate({ width: ancho , height: alto  }, 'slow') );
	$('#'+maximizador).html('<img src="images/minimize.gif" width="9" height="9">');
	}else{
	e.slideToggle('slow', $('#'+window_name).animate({ width: '350px'}, 'slow') );
	$('#'+maximizador).html('<img src="images/max.gif" width="9" height="9">');
	}
}

function Recuperar(){
email = $('#email_password').val();

	if (email == ''){ alert('Debes ingresar un email'); return false;}
	$.ajax({type: "GET",dataType: "script", url: "includes/recuperar.php?email="+email});	
	return false;
}

function LoadWindow(nombre,destino){
$('#'+destino).html('<img src="images/spinner.gif">');
$.ajax({type: "GET",dataType: "html", url: "load.php?modulo_nombre="+nombre+'&destino='+destino,success: HandleBarResponde});
return false;
}
function HandleBarResponde(msg){
separador = msg.indexOf('|');		
layer = msg.substring(0,separador);
contenido = msg.substring(separador+1, msg.length) ;
$('#'+ layer ).show().html(contenido).slideDown('slow');
}
function FiltrarCursos(el, classs){
	clase = el.attr('class');
	$('.cursos_filtro input').removeClass('selected');	
		if (clase == 'selected'){
			$('.curso').show('slow');
			return false;
		}
	$('.curso').show();	
	el.toggleClass("selected");	
	$('.'+classs).hide('slow');
}
function ChangeBox(){
$('#email_window .cursos_filtro input').toggleClass('selected'); $('#email_window .mailbox').toggle('slow');
}
function ChangeNotes(){
$('#notas_div .cursos_filtro input').toggleClass('selected'); $('#notas_div .mailbox').toggle('slow');
}
function LoadCurso(curso_id){
$.ajax({type: "GET",dataType: "html", url: "load.php?modulo_nombre=modulos&destino=windowContent&curso_id="+curso_id,success: HandleBarResponde});
}
function LoadExamen(curso_id){
$.ajax({type: "GET",dataType: "html", url: "load.php?modulo_nombre=examen&destino=windowContent&curso_id="+curso_id,success: HandleBarResponde});
}
function LoadFaqs(curso_id){
$.ajax({type: "GET",dataType: "html", url: "load.php?modulo_nombre=faqs&destino=windowContent&curso_id="+curso_id,success: HandleBarResponde});
}
function LoadModule(modulo_id){
$.ajax({type: "GET",dataType: "html", url: "load.php?modulo_nombre=multimedia&destino=multiContent&modulo_id="+modulo_id,success: HandleBarResponde});	
}

function LoadVideo(modulo_id,video_id){
$.ajax({type: "GET",dataType: "html", url: "load.php?modulo_nombre=multimedia&destino=multiContent&modulo_id="+modulo_id+"&video_id="+video_id,success: HandleBarResponde});	
}

function CargarNotas(curso_id){
$.ajax({type: "GET",dataType: "html", url: "notas.php?modulo_nombre=notas&destino=notas_div&curso_id="+curso_id,success: HandleBarResponde});	
return false;
}


function GuardarNota(){
	$('#advertencia').hide();
	error = '';
	cur = document.getElementById('curso_id');
	curso_id = cur.options[cur.selectedIndex].value;	
	nota_id = $('#nota_id').attr('value');
	cuerpo = $('#nota_body').attr('value');
	datos = "accion=send&nota_id="+ nota_id  + "&cuerpo="+ cuerpo + '&curso_id='+curso_id;
	$.ajax({type: "POST",dataType: "html",data: datos , url: "includes/notas.php"});		
	return false;
}
function EliminarNota(nota_id, offset){
	$.ajax({type: "POST",dataType: "html",data: "accion=eliminar&nota_id="+ nota_id + "&offset="+ offset, url: "includes/notas.php"});		
}
function Inscribir(curso_id){
$('#curso_'+curso_id+' .curso_opciones').html('<img src="/calendar/images/calWaiting.gif"/>');

$.ajax({type: "GET",dataType: "script", url: "includes/inscribir.php?curso_id="+curso_id});
return false;	
}

function EnviarEmail(){
	$('#advertencia').hide();
	error = '';
	para = $('#to').attr('value');
	tema = $('#subject').attr('value');
	cuerpo = $('#body').attr('value');
		if (para === '' || para === undefined){
			error += 'Debe ingresar un destinatario <br/>';  
		}
		if (tema === '' || tema === undefined){
			error += 'Debe ingresar un Asunto <br/>';  
		}
		if (cuerpo === '' || cuerpo === undefined){
			error += 'Debe ingresar un Cuerpo <br/>';  
		}
		if (error === ''){
			$.ajax({type: "POST",dataType: "html",data: "accion=send&to="+ para + "&subject="+ tema + "&body="+ cuerpo, url: "includes/email.php"});
		}else{
			$('#advertencia').html(error).show('slow');
		}

}

function EliminarMail(email_id, offset){
$.ajax({type: "POST",dataType: "html",data: "accion=eliminar&email_id="+ email_id + "&offset="+ offset, url: "includes/email.php"});
}

	
function EliminarMail2(email_id, offset){
	if (confirm("Seguro que desea eliminar este mensaje?")) {
		$.ajax({type: "POST",dataType: "html",data: "accion=eliminar&email_id="+ email_id + "&offset="+ offset, url: "includes/email.php"});
		}

}
function getCheckedValue(radioObj) {
		if(!radioObj){
			return "";
		}
		var radioLength = radioObj.length;
		if(radioLength === undefined){
			if(radioObj.checked){
				return radioObj.value;
			}else{
				return "";
			}
		}
		for(var i = 0; i < radioLength; i++) {
			if(radioObj[i].checked) {
				return radioObj[i].value;
			}
		}
		return "";
	}
	
	

function Suscribir(){
$('#alerta_sus').hide();
email = $("#suscribir_email").attr("value");

if ( email === '' || email === undefined){
	alert("Debes introducir un email"); return false;
}
$.ajax({type: "GET",dataType: "html", url: "includes/varios.php?email="+email,success: HandleBarResponde});	
	return true;
}

function MandarSugerencia(){
$('#alerta_sug').hide();
sugerencia = $("#sugerencia").attr("value");

if ( sugerencia === '' || sugerencia === undefined ){
	alert("Debes introducir un sugerencia"); return false;
}
$.ajax({type: "GET",dataType: "html", url: "includes/varios.php?sugerencia="+sugerencia,success: HandleBarResponde});	
	return true;

}

function EnviarAmigo(nota_id){
$('#alerta_tem').hide();

email = $("#email_"+nota_id).attr("value");
mensaje = $("#mensaje_"+nota_id).attr("value");
	if ( email === '' || email === undefined ){
		alert("Debes introducir un email"); return false;
	}
	
	$.ajax({type: "GET",dataType: "html", url: "includes/varios.php?amigo="+email + "&body="+mensaje+"&not_id="+nota_id,success: HandleBarResponde});	
	return true;
}

function MandarTema(){
$('#alerta_tem').hide();


tema = $("#tema").attr("value");
if ( tema === '' || tema === undefined ){
	alert("Debes introducir un tema"); return false;
}
$.ajax({type: "GET",dataType: "html", url: "includes/varios.php?tema="+tema,success: HandleBarResponde});	
	return true;

}