﻿function abrir(direccion,pantallacompleta,herramientas,direcciones,estado,barramenu,barrascroll,cambiatamano,ancho,alto,sustituir){
    var izquierda = (screen.availWidth - ancho) / 2;
    var arriba = (screen.availHeight - alto) / 2;
    var opciones = "fullscreen=" + pantallacompleta +
                 ",toolbar=" + herramientas +
                 ",location=" + direcciones +
                 ",status=" + estado +
                 ",menubar=" + barramenu +
                 ",scrollbars=" + barrascroll +
                 ",resizable=" + cambiatamano +
                 ",width=" + ancho +
                 ",height=" + alto +
                 ",left=" + izquierda +
                 ",top=" + arriba;
    var ventana = window.open(direccion,"ventana",opciones,sustituir);
    }

function ismaxlength(obj){
  var mlength=obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : ""
  if (obj.getAttribute && obj.value.length>mlength)
  obj.value=obj.value.substring(0,mlength)
  }

function LimitAttach(tField,iType){ 
  file=tField.value;
  if (iType==1)
    extArray = new Array(".gif",".jpg",".png");
  else if (iType==2)
    extArray = new Array(".swf");
  else if (iType==3)
    extArray = new Array(".exe",".sit",".zip",".tar",".swf",".mov",".hqx",".ra",".wmf",".mp3",".qt",".med",".et");
  else if (iType==4)
    extArray = new Array(".mov",".ra",".wmf",".mp3",".qt",".med",".et",".wav");
  else if (iType==5)
    extArray = new Array(".mp3",".wav");
  else if (iType==6)
    extArray = new Array(".html",".htm",".shtml");
  else if (iType==7)
    extArray = new Array(".doc",".xls",".ppt");
  allowSubmit = false;
  if (!file)
    return; 
  //window.alert("File="+file+" Lenght="+file.length);
  salir = false;
  ext = "";
  for(i=(file.length-1);i>=0;i--){
    if(salir) break;
    if(file[i] == ".")
      salir = true;
    ext = file[i]+ext;
    }
  //window.alert("Ext="+ext);
  /*while (file.indexOf("\\") != -1){
    file = file.slice(file.indexOf("\\") + 1);
    window.alert("File="+file);
    }
  ext = file.slice(file.indexOf(".")).toLowerCase();*/
  for (var i = 0; i < extArray.length; i++){ 
    if (extArray[i] == ext){
      allowSubmit = true;
      break;
      }
    }
  if (allowSubmit)
    document.getElementById(tField.id).value=document.getElementById(tField.id).value;
  else{
    //tField.value="";
    document.getElementById(tField.id).value="";
    window.alert("Usted sólo puede subir archivos con extensiones " + (extArray.join(" ")) + "\nPor favor seleccione un nuevo archivo");
    }
  }

function showId(id) {
  //alert('Id='+id);
  document.getElementById(id).style.visibility = "visible";
}

function hideId(id) {
  //alert('Id='+id);
  document.getElementById(id).style.visibility = "hidden";
}

  function HandleOnClose() {
      if (event.clientY < 0) {
        sIFR.preferenceManager.storage.reset();
        sIFR.preferenceManager.enable();
        sIFR.preferenceManager.enable();
        }
      }

  function send(block_id){
    var bloque = document.getElementById(block_id);
    bloque.style.display = "inline";
    //window.alert("Entro con:"+block_id);
    if(document.getElementById("Enviar").disabled == false)
      document.getElementById("Enviar").disabled = true;
    //window.alert(document.getElementById("Enviar").disabled);
    if(document.getElementById("Limpiar").disabled == false)
      document.getElementById("Limpiar").disabled = true;
    //window.alert(document.getElementById("Limpiar").disabled);
    }
  
  function send2(block_id){
    //window.alert("Entro Enviar="+document.getElementById("Enviar").disabled);
    var bloque = document.getElementById(block_id);
    bloque.style.display = "inline";
    //window.alert("Entro con:"+block_id);
    if(document.getElementById("Enviar").disabled == false)
      document.getElementById("Enviar").disabled = true;
    //window.alert("Enviar="+document.getElementById("Enviar").disabled);
    //document.getElementById("Limpiar").disabled = true;
    //window.alert(document.getElementById("Limpiar").disabled);
    }
  
  function sending(){
    var boton = document.getElementById("enviar");
    boton.disabled = true;
    var bloque = document.getElementById("enviado3");
    if(bloque != null){
      bloque.style.display = "none";
      bloque.innerHTML = "";
      //window.alert("BLOQUE:"+bloque);
      }
    var bloque = document.getElementById("enviado4");
    if(bloque != null){
      bloque.style.display = "none";
      bloque.innerHTML = "";
      //window.alert("BLOQUE:"+bloque);
      }
    }

  
  var xmlHttp;
  
  function loadXMLDoc(dname){
    try{ //Internet Explorer
      xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
      }
    catch(e){
      try{ //Firefox, Mozilla, Opera, etc.
        xmlDoc = document.implementation.createDocument("","",null);
        }
      catch(e) {alert(e.message)}
      }
    try{
      xmlDoc.async = false;
      xmlDoc.load(dname);
      return(xmlDoc);
      }
    catch(e) {alert(e.message)}
    return(null);
    } 

  function getVote(vall){
    xmlHttp = GetXmlHttpObject();
    if (xmlHttp == null){
      alert ("Browser does not support HTTP Request");
      return;
      } 
    /*xmlDoc = loadXMLDoc("encuesta.xml");
    x = xmlDoc.getElementsByTagName(vall)[0];
    value = x.childNodes[0];
    value.nodeValue++;
    alert(vall+"="+value.nodeValue);*/
    xmlHttp.onreadystatechange = stateChanged;
    xmlHttp.open("GET","encuesta.php?nodo="+vall,true);
    xmlHttp.send(null);
    } 

  function stateChanged(){
    if (xmlHttp.readyState == 4 || xmlHttp.readyState == "complete"){ 
      document.getElementById("encuesta").
      innerHTML = xmlHttp.responseText;
      } 
    } 

  function GetXmlHttpObject(){
    var objXMLHttp = null;
    if (window.XMLHttpRequest)
      objXMLHttp = new XMLHttpRequest();
    else if (window.ActiveXObject)
      objXMLHttp = new ActiveXObject("Microsoft.XMLHTTP");
    return objXMLHttp;
    }