function foca_RequestInit() {
    // non-IE: create this object once.
    if (window.XMLHttpRequest) {
          foca_XmlRequest = new XMLHttpRequest();
    }

      // IE still needs a request object
     if (!window.XMLHttpRequest) {
        foca_XmlRequest = new ActiveXObject("Microsoft.XMLHTTP");
      }

    // When the HTTP transfer is over,
    // the internal state of the object will change
    // When that happens, it will run the function
    // assigned here
      foca_XmlRequest.onreadystatechange = foca_procReqChange;
}

function foca_RequestSuggest(focaId,focaPass,focaLogOut) {
    // Iniciamos el XmlHttpRequest
    foca_RequestInit()
    // Reiniciamos indice por cambio en la lista de sugerencias
    foca_Index=0;
    // Armamos el Query y Cerramos la conexion
    foca_XmlRequest.open("POST", "loginServicios.php");
    foca_XmlRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    foca_XmlRequest.send("focaId="+focaId+"&focaPass="+focaPass+"&focaCheck=revisar&focaOut="+focaLogOut);
}

function foca_procReqChange() {
    // If the HTTP code changes at all, this function foca_is called
    // If it's a success, then populate the element with the
    // HTML we've received
    if (foca_XmlRequest.readyState == 4) {
        // Get the element with ID 'syndicElem'
        elem = document.getElementById("serviciosCont");
        elem.innerHTML = foca_XmlRequest.responseText;
    }
}

function focaStats_RequestInit() {
    // non-IE: create this object once.
    if (window.XMLHttpRequest) {
          focaStats_XmlRequest = new XMLHttpRequest();
    }

      // IE still needs a request object
     if (!window.XMLHttpRequest) {
        focaStats_XmlRequest = new ActiveXObject("Microsoft.XMLHTTP");
      }

    // When the HTTP transfer is over,
    // the internal state of the object will change
    // When that happens, it will run the function
    // assigned here
      focaStats_XmlRequest.onreadystatechange = focaStats_procReqChange;
}

function focaStats_RequestSuggest(focaStatsRes,focaIdStat) {
    // Iniciamos el XmlHttpRequest
    focaStats_RequestInit()
    // Reiniciamos indice por cambio en la lista de sugerencias
    focaStats_Index=0;
    // Armamos el Query y Cerramos la conexion
    focaStats_XmlRequest.open("POST", "orca/index.php");
    focaStats_XmlRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    focaStats_XmlRequest.send("focaStatsRes="+focaStatsRes+"&focaIdStat="+focaIdStat);
}

function focaStats_procReqChange() {
    // If the HTTP code changes at all, this function focaStats_is called
    // If it's a success, then populate the element with the
    // HTML we've received
    if (focaStats_XmlRequest.readyState == 4) {
        // Get the element with ID 'syndicElem'
        //elem = document.getElementById("statsDiv");
        //elem.innerHTML = focaStats_XmlRequest.responseText;
      }
}

function showHideID(id,prefix,txtCerrado,txtAbierto) {
    //classN = getCookie('FOCA_COOKIE_'+id)
    if (document.getElementById(prefix+id).style.display != 'none') {
          if(document.getElementById(prefix+id)){
            document.getElementById(prefix+id).style.display = 'none'
            document.getElementById('legendLeerMas'+id).innerHTML=txtCerrado;
          }
    } else {
          if(document.getElementById(prefix+id)){
            document.getElementById(prefix+id).style.display = ''
            document.getElementById('legendLeerMas'+id).innerHTML=txtAbierto;
          }
    }
}

function showHideIDMod(id,prefix) {
    classN = getCookie('FOCA_COOKIE_'+id)
    if (classN == "true") {
          if(document.getElementById(prefix+id)){
            document.getElementById(prefix+id).style.display = 'none'
          }
    } else {
          if(document.getElementById(prefix+id)){
            document.getElementById(prefix+id).style.display = ''
          }
    }
}

function showHideIDMod2(id,prefix) {               
          if(document.getElementById(prefix+id).style.display=='none'){
            document.getElementById(prefix+id).style.display = ''
          }else{
            document.getElementById(prefix+id).style.display = 'none'
          }
}

function switchClassID(id,prefix,class1,class2) {
       classN = getCookie('FOCA_COOKIE_'+id)
    if (classN == "true") {
        document.getElementById(prefix+id).className = class1
     } else {
          document.getElementById(prefix+id).className = class2
     }

}
function switchClassID2(id,class1,class2) {
    if (document.getElementById(id).className = class2) {
        document.getElementById(id).className = class1
     } else {
        document.getElementById(id).className = class2
     }

}
function switchCookieID(id) {
       classN = getCookie('FOCA_COOKIE_'+id)
    if (classN == "true") {
        setCookie('FOCA_COOKIE_'+id,"false")
     } else {
        setCookie('FOCA_COOKIE_'+id,"true")
     }
}
function TurnClassID(id,class1,class2) {
       classN = getCookie('FOCA_COOKIE_'+id)
    if (document.getElementById('FS'+id) != null) {
        if (classN == "true") {
            document.getElementById('DV'+id).style.display = ""
            document.getElementById('FS'+id).className = class2
         } else {
               document.getElementById('DV'+id).style.display = "none"
              document.getElementById('FS'+id).className = class1
         }
     }
}
function TurnClassIDMod(id) {
       classN = getCookie('FOCA_COOKIE_'+id)
    if (document.getElementById('MOD'+id) != null) {
        if (classN == "true") {
            document.getElementById('MOD'+id).style.display = ""
         } else {
            document.getElementById('MOD'+id).style.display = "none"
         }
     }
}
/**
 * Sets a Cookie with the given name and value.
 *
 * name       Name of the cookie
 * value      Value of the cookie
 * [expires]  Expiration date of the cookie (default: end of current session)
 * [path]     Path where the cookie is valid (default: path of calling document)
 * [domain]   Domain where the cookie is valid
 *              (default: domain of calling document)
 * [secure]   Boolean value indicating if the cookie transmission requires a
 *              secure transmission
 */
function setCookie(name, value, expires, path, domain, secure)
{
    document.cookie= name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires.toGMTString() : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}

/**
 * Gets the value of the specified cookie.
 *
 * name  Name of the desired cookie.
 *
 * Returns a string containing value of specified cookie,
 *   or null if cookie does not exist.
 */
function getCookie(name)
{
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1)
    {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    }
    else
    {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1)
    {
        end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
}

/**
 * Deletes the specified cookie.
 *
 * name      name of the cookie
 * [path]    path of the cookie (must be same as path used to create cookie)
 * [domain]  domain of the cookie (must be same as domain used to create cookie)
 */
function deleteCookie(name, path, domain)
{
    if (getCookie(name))
    {
        document.cookie = name + "=" +
            ((path) ? "; path=" + path : "") +
            ((domain) ? "; domain=" + domain : "") +
            "; expires=Thu, 01-Jan-70 00:00:01 GMT";
    }
}
function loadThumb(dir,alto,ancho) {
   if(ancho==null){
     ancho=550;
   }
   if(alto==null){
     alto=480;
   }
   window.open(dir,'','resizable=no,scrollbars=no,menubar=no,height='+alto+',width='+ancho+',toolbar=no,location=no,status=no');
}
