
function cambiaDestacada(key) 
{
	if(key == "undefined"){ 
		key = 0; 
	}
	titulo = "<a href='"+arrLinks[key]+"'>"+arrTitulos[key]+"</a>";
	copete = arrCopetes[key];
	document.getElementById("titulo_destacada").innerHTML = titulo;
	document.getElementById("copete_destacada").innerHTML = copete;
}
function jsPopupEnviarNota(idNota) 
{
	nombre 			=  document.getElementById('formNombre');
	remitente 		= document.getElementById('formRemitente');
	destinatarios 	= document.getElementById('formDestinatarios');
	//subject 		= document.getElementById('formSubject');
	mensaje 		= document.getElementById('formMensaje');
	bool 			= true;
	
	if(bool && nombre.value == ""){
		alert("Por favor, ingrese su nombre");
		nombre.focus();
		bool = false;
	}
	
	if(bool && remitente.value == ""){
		alert("Por favor, ingrese un email como remitente");
		remitente.focus();
		bool = false;
	}
	
	var strRegExp = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9])+$/;
	if (bool && !strRegExp.test(remitente.value) ){
		alert("Por favor, ingrese un email valido como remitente");
		remitente.focus();
		bool = false;
	}
	
	if(bool && destinatarios.value == ""){
		alert("Por favor, ingrese al menos un destinatario");
		destinatarios.focus();
		bool = false;
	}
	

  var emails = destinatarios.value.split(",");
   for(i=0; i<emails.length; i++ ) {
     
      if (bool && !strRegExp.test(emails[i].replace(/^\s*|\s*$/g,"")) ){
      alert("Por favor, ingrese un email valido como destinatario");
      destinatarios.focus();
      bool = false;
      } 
    }
  
	if(bool){
		window._post("../_post/recomendar_nota.php?idNota="+idNota+"&email="+remitente.value+"&emailTo="+destinatarios.value+"&comentarios="+mensaje.value+"&nombre="+nombre.value);
	}
}

function showemail()
{
 	document.getElementById("emailbox").style.display="block";
}

function closeemail()
{
	document.getElementById("emailbox").style.display="none";
}

function showprint()
{
    document.getElementById("showprint").style.display = "block";
    document.getElementById("detailfla").style.display = "none";
}

function changestyletosmall()
{
	document.getElementById("cssstyle").setAttribute('href',"style.css"); 
}

function changestyletomid()
{
	document.getElementById("cssstyle").setAttribute('href',"style2.css"); 
}

function changestyletolarge()
{
	document.getElementById("cssstyle").setAttribute('href',"style3.css"); 
}

function cancelemail()
{
  document.emailform.reset();
  document.getElementById("emailbox").style.display="none";
}

function expandEvent()
{
	document.getElementById("newEvent").style.display="block";
}

function collapseEvent()
{
	document.getElementById("newEvent").style.display="none";
}

function buscar_guias(){
	var form = document.forms['filtro'];
	form.text.value 			= document.getElementById("buscador").value;
	traerResultadosGuia('resetPaginador');
}


//Inicializar valores segun el numero de la vista de Front en carrusel
var actualGaleria = 0,
	ultimaGaleria = 6,
	primeraGaleria = 0;
function girarGaleria(accion) {
	switch (accion) {
		case "back":
			if (primeraGaleria > 0) {
				--ultimaGaleria;
				--primeraGaleria;
				document.getElementById("back").style.display = "block";	
				document.getElementById("go").style.display = "block";
			} 
			if(primeraGaleria == 0) {
				document.getElementById("back").style.display = "none";	
				document.getElementById("go").style.display = "block";
			}
		break;
	
		case "go":
			if (ultimaGaleria < arrAdjuntos.length) {
				++ultimaGaleria;
				++primeraGaleria;
				document.getElementById("back").style.display = "block";	
				document.getElementById("go").style.display = "block";
			} 
			if(ultimaGaleria == arrAdjuntos.length) {
				document.getElementById("back").style.display = "block";	
				document.getElementById("go").style.display = "none";
			} 
		break;
	}
	if(primeraGaleria >= 0 && ultimaGaleria <= arrAdjuntos.length) {
		var otra, i;
		for (i = 0; i < arrAdjuntos.length; ++i) {
			otra = document.getElementById("minifoto_"+arrAdjuntos[i]);
			otra.style.display = ((i >= primeraGaleria && i < ultimaGaleria)? "": "none");
		}
	}
}

function traerResultadosGuia(sentido) {
	var form = document.forms['filtro'];
	document.getElementById('resetPaginador').value = 0;
	if(sentido == 'sgte'){
		form.pagina.value = Number(form.pagina.value)+1;
	}
	if(sentido == 'ant'){
		form.pagina.value = Number(form.pagina.value)-1;
	}
	if(sentido == 'resetPaginador'){
		document.getElementById('resetPaginador').value = 1;
		form.pagina.value = 0;
	}
	if(arrCaracteristicas.length > 0){
		for(var i=0; i < arrCaracteristicas.length; i++){
			if(document.getElementById("tipoEvento_"+arrCaracteristicas[i]).checked == true){
				document.getElementById("carac_"+arrCaracteristicas[i]).value = arrCaracteristicas[i];
			} else {
				document.getElementById("carac_"+arrCaracteristicas[i]).value = 0;	
			}
		}
	}
	loadHttpRequest('../_post/hc_washington/filtroGuias.php', 'result', form);
}


function contador(key){
	cont=key;
}

/*AJAX HANDLER*/
function XmlHttpRequest(){
    var ajax = false;
    try {
        ajax = new ActiveXObject("Msxml2.XMLHTTP");
    } 
    catch (e) {
        try {
            ajax = new ActiveXObject("Microsoft.XMLHTTP");
        } 
        catch (e) {
            ajax = false;
        }
    }
    if (!ajax && typeof XMLHttpRequest != 'undefined') {
        ajax = new XMLHttpRequest();
    }
    return ajax;
}

function loadHttpRequest(url, div, form) {
    var ajax = XmlHttpRequest();
    var div = document.getElementById(div);
    var data = ((form != '') ? get_data(form.name) : '');
    var ID = Math.random();
    ajax.open("POST", url, true);
    ajax.onreadystatechange = function(){
        if (ajax.readyState == 0) {
            div.innerHTML = "Enviando la solicitud...";
        }
        if (ajax.readyState == 1 || ajax.readyState == 2 || ajax.readyState == 3) {
            div.innerHTML = "<div align='center' style='margin-top:50px'><img src='../_modulos/eventos/_imgs/hc_washington/loader.gif' alt='Loading...'></div>";
        }
        if (ajax.readyState == 4) {
            if (ajax.status == 200) {
                div.innerHTML = ajax.responseText
                var scripts = div.getElementsByTagName('script');
                for (var i = 0; i < scripts.length; i++) {
                	eval(scripts[i].innerHTML);
                }
            } else {
                if (ajax.status == 404) {
                    div.innerHTML = "La direccion no existe";
                } else {
                    div.innerHTML = "Error: " + ajax.status;
                    return true;
                }
            }
        }
    }
    ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    ajax.setRequestHeader("Content-length", data.length);
    ajax.setRequestHeader("Connection", "close");
    ajax.send("ID=" + ID + data);
}

function get_data(form){
    var form_id = document.getElementById(form);
    var url_string = '';
    var delimiter = '&';
    for (var i = 0; i < form_id.elements.length; i++) {
        if (form_id.elements[i].type != 'reset' && form_id.elements[i].type != 'submit' && form_id.elements[i].type != 'button') {
            url_string += delimiter + form_id.elements[i].name + '=' + escape(encodeURI(get_value(form_id.elements[i])));
        }
    }
    return url_string;
}

function clean_form(form){
    var form_id = document.getElementById(form);
    for (var i = 0; i < form_id.elements.length; i++) {
        if (form_id.elements[i].type != 'reset' && form_id.elements[i].type != 'submit' && form_id.elements[i].type != 'button') {
            form_id.elements[i].value = '';
        }
    }
    form_id.elements[0].focus();
}

function get_value(obj){
    switch (obj.type) {
        case 'radio':
        case 'checkbox':
            if (obj.checked == true) {
                return obj.value;
            } else {
                return '';
            }
        break;
        case 'text':
        case 'hidden':
        case 'textarea':
        case 'password':
            return obj.value;
        break;
        case 'select-one':
        case 'select-multiple':
            if (obj.selectedIndex != 0) {
                return obj.value;
            } else {
                return '';
            }
		break;
    }
}
function PopUpGaleria(src, iframe_name) {
	if (typeof(window.parent.objAdministratorBar) == "undefined") {
		if (typeof(iframe_name) == "undefined") {
			iframe_name = (Math.random()*10000).toString();
		}
		window.scrollH = Number(document.documentElement.scrollTop || document.body.scrollTop);
		document.body.scroll = "no";
		block();
		var strFrame = isMSIE()? '<iframe name="'+iframe_name+'" frameborder="0" allowtransparency="true">': "iframe";
		objPopup = document.createElement(strFrame);
		objPopup.setAttribute("frameborder", "0");
		objPopup.setAttribute("scrolling", "no");
		objPopup.setAttribute("allowtransparency", "true");
		objPopup.name = iframe_name;
		objPopup.src = src;
		objPopup.style.position = "absolute";
		objPopup.style.height = "800px";
		objPopup.style.width = "100%";
		objPopup.style.top = "200px";
		objPopup.style.left = "600px";
		document.body.appendChild(objPopup);
	}
	else {
		window.location = src;
	}
}

function displayAfp(){
	var afp 		= document.getElementById('derechosAfp');
	var hiddenafp 	= document.getElementById('hiddenAfp');
	if(hiddenafp.value == 'si'){
		afp.style.display="block";
		hiddenafp.value = 'no';
	}else{
		afp.style.display="none";
		hiddenafp.value = 'si';
		
	}
}

function tamFuente(operacion)
{
  switch(operacion)
  {
	  case 1:
		  	tamanio0 = 11;
		  	tamanio1 = 13;
		  	break;
	  case 2:
		  	tamanio0 = 13;
		  	tamanio1 = 15;
			break;
	  case 3:
		  	tamanio0 = 14;
		 	tamanio1 = 16;
			break;
  }
    
	setTamFuente(document.getElementById('copete'),tamanio1);
	setTamFuente(document.getElementById('cuerpo'),tamanio0);
}

