function trim(valor){
    var re = /^(\s)*|(\s)*$/;
    var str = (valor ? valor : this);
    return str.replace(re, "");
}

String.prototype.trim = trim;

function $(){
    var elements = new Array(), i, e;
    for (i = 0; i < arguments.length; ++i) {
        e = arguments[i];
        if (typeof element == "string") 
            e = document.getElementById(e);
        if (arguments.length == 1) 
            return e;
        elements.push(e);
    }
    return elements;
}

/* Debug */
function isMSIE(){
    return (navigator.appName == "Microsoft Internet Explorer");
}

function dump(o, func){
    var str = "";
    for (p in o) {
        if (typeof o[p] != "function" || func) 
            str += "\t" + p + " => " + o[p] + "\r\n";
    }
    str = "(" + typeof(o) + ") " + o + " \r\n{\r\n" + str + "}";
    return str;
}

function dumpWindow(o, nombre, func){
    func = func == true;
    nombre = (typeof(nombre) == "undefined") ? "Debug" : nombre;
    var hw = popup("", nombre, 600, 600, "yes", "yes");
    var htmlDump = dump(o, func).replace(/<(\/)?script/gi, "< $1script");
    var htmlDoc = '<html><body><pre style="font:13px \'Courier New\'">' + htmlDump + '</pre></body></html>';
    hw.document.open();
    hw.document.write(htmlDoc);
    hw.document.close();
}

function sumVisitasAdjunto(idAdjunto){
    _post("../_post/contar_adjunto.php?idAdjunto=" + idAdjunto);
}

function popup(url, name, width, height, isResizable, hasScrollbars, hasToolbar, hasMenubar, hasStatus){
    isResizable = typeof(isResizable) == 'undefined' ? 'no' : isResizable;
    hasScrollbars = typeof(hasScrollbars) == 'undefined' ? 'auto' : hasScrollbars;
    hasToolbar = typeof(hasToolbar) == 'undefined' ? 'no' : hasToolbar;
    hasMenubar = typeof(hasMenubar) == 'undefined' ? 'no' : hasMenubar;
    hasStatus = typeof(hasStatus) == 'undefined' ? 'yes' : hasStatus;
    
    var top = (screen.height - height) / 2;
    var left = (screen.width - width) / 2;

    var settings = 'width=' + width + ', height=' + height + ', top=' + top + ', left=' + left + ', resizable=' + isResizable + ', scrollbars=' + hasScrollbars + ', toolbar=' + hasToolbar + ', menubar=' + hasMenubar + ', status=' + hasStatus;
    return window.open(url, name, settings);
}

/* Fin Debug */

function _attachEvent(element, name, observer){
    if (element.addEventListener) 
        element.addEventListener(name.replace("on", ""), observer, true);
    else 
        if (element.attachEvent) 
            element.attachEvent(name, observer);
}

var request = new Object();
var aParams = document.location.search.substr(1).split('&');
for (i = 0; i < aParams.length; i++) {
    var aParam = aParams[i].split('=');
    var sParamName = aParam[0];
    var sParamValue = aParam[1];
    request[sParamName] = sParamValue;
}
/**/
function swapLang(idCMSIdioma){
    if (typeof parent.window.objPortales != 'undefined') 
        parent.window.objPortales._reload();
    document.cookie = "idCMSIdioma=" + idCMSIdioma + "; path=/; ";
    window.location.reload();
}

function cambioIdioma(idCMSIdioma){
    if (typeof parent.window.objPortales != 'undefined') 
        parent.window.objPortales._reload();
    document.cookie = "idCMSIdioma=" + idCMSIdioma + "; path=/; ";
    window.location.reload();
}

function runSWF(archivo, ancho, alto, version, bgcolor, id, idm, menu, FlashVars, quality, allowScriptAccess, writeScript){
    if (version != "") {
        var version_data = version;
    }
    else {
        var version_data = "6, 0, 0, 0";
    }
    if (menu != "") {
        menu_data = menu;
    }
    else {
        menu_data = false;
    }
    if (bgcolor != "") {
        var bgcolor_data = bgcolor;
    }
    else {
        var bgcolor_data = "#FFFFFF";
    }
    if (id != "") {
        id_data = id;
    }
    else {
        id_data = "flashMovie";
    }
    if (quality != "") {
        quality_data = quality;
    }
    else {
        quality_data = "high";
    }
    if (allowScriptAccess != "") {
        allowScriptAccess_data = allowScriptAccess;
    }
    else {
        allowScriptAccess_data = "always";
    }
    if (typeof(writeScript) == "undefined") {
        writeScript = "1";
    }
    //alert(archivo);
    var quality = "high"; // calidad de visualización de la peli
    html = "";
    html += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=' + version_data + '" width=' + ancho + ' height=' + alto + ' id=' + id_data + '>\n';
    html += '<param name="movie" value=' + archivo + '>\n';
    html += '<param name="allowScriptAccess" value=' + allowScriptAccess_data + '>\n';
    html += '<param name="quality" value=' + quality_data + '>\n';
    html += '<param name="FlashVars" value=' + FlashVars + '>\n';
    html += '<param name="bgcolor" value=' + bgcolor_data + '>\n';
    html += '<param name="menu" value=' + menu_data + ' >\n';
    html += '<param name="wmode" value="transparent">\n';
    html += '<embed wmode="transparent" src=' + archivo + ' bgcolor=' + bgcolor_data + ' FlashVars=' + FlashVars + ' menu=' + menu_data + ' allowScriptAccess=' + allowScriptAccess_data + ' quality=' + quality_data + ' pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width=' + ancho + ' height=' + alto + ' swLiveConnect="true" id=' + idm + ' ></embed>';
    html += '</object>\n';
    
    if (writeScript == "1") {
        document.write(html);
    }
    else {
        return html;
    }
}

function IrAPagina(pagina){
    var url = "../interior/index.php?pagina=" + pagina;
    for (var i in request) {
        if (i != 'pagina') {
            url += "&" + i + "=" + request[i];
        }
    }
    window.location = url;
}

function setRequest(campo, valor){
    request[campo] = valor;
    IrAPagina(0);
}

/** [EA 15/05/2007 16:17] - Esta funcion la utiliza el flash del cabezal de MD
 * Por favor, no modificar
 */
function search(text){
    var page = page || "resultado";
    window.location = '../interior/index.php?p=' + page + '&text=' + text + '&dinamica=1';
}


function _search(text, page){
    if (text.length < 1) {
        alert("Por favor, ingrese un texto para buscar.");
    }
    else {
        var page = page || "resultado";
        window.location = '../interior/index.php?p=' + page + '&text=' + text;
    }
}

var objBlock = null;
function block(){
    if (objBlock == null) {
        //		document.body.scroll = "no";
        document.body.style.overflow = "hidden";
        objBlock = document.createElement("iframe");
        objBlock.src = "../interior/block.html";
        objBlock.style.position = "absolute";
        objBlock.style.top = "0px";
        objBlock.style.left = "0px";
        objBlock.style.width = screen.width + "px";
        objBlock.style.height = (document.body.offsetHeight + document.body.scrollHeight) + "px";
        objBlock.className = "blockPage";
        document.body.appendChild(objBlock);
    }
}

function unblock(){
    if (objBlock != null) {
        //		document.body.scroll = "yes";
        document.body.style.overflow = "auto";
        objBlock.parentNode.removeChild(objBlock);
        delete (objBlock);
        objBlock = null;
    }
}

window.openGaleria = function(src){
    if (typeof(window.parent.objAdministratorBar) == "undefined") {
        block();
        var strFrame = isMSIE() ? '<iframe frameborder="0" scrolling="no">' : "iframe";
        objPopup = document.createElement(strFrame);
        objPopup.style.position = "absolute";
        objPopup.setAttribute("frameborder", "0");
        objPopup.setAttribute("scrolling", "no");
        objPopup.src = src;
        document.body.appendChild(objPopup);
    }
    else 
        window.location = src;
}

window.closeGaleria = function(){
    unblock();
    objPopup.parentNode.removeChild(objPopup);
    delete (objPopup);
    objPopup = null;
}

window._post = function(url){
    var _objPost = document.createElement("iframe");
    _objPost.style.display = "none";
    _objPost.style.width = "100%";
    _objPost.style.height = "200px";
    _objPost.src = url;
    document.body.appendChild(_objPost);
}

function getCookie(name){
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    var end = -1;
    
    if (begin == -1) {
        begin = dc.indexOf(prefix);
        if (begin != 0) 
            return null;
        end = dc.indexOf('; ');
    }
    else {
        begin += 2;
        var end = document.cookie.indexOf("; ", begin);
        if (end == -1) {
            end = dc.length;
        }
    }
    return unescape(dc.substring(begin + prefix.length, end));
}

function responder(idTextarea){
    document.getElementById(idTextarea).focus();
}

function insertar_comentario(idPortal, idIdioma, idModulo, idContenido, idNota, tipoEnvio){

    var autor = document.getElementById('autor_' + idContenido);
    var comentario = document.getElementById('comentario_' + idContenido);
    var randomUsuario = document.getElementById('randomUsuario_' + idContenido) || '';
    var randomSistema = document.getElementById('random_' + idContenido) || '';
    
    var autorTxt = autor.value;
    var comentarioTxt = comentario.value;
    var randomUsuarioTxt = randomUsuario.value;
    var randomTxt = randomSistema.value;
    
    var tableLanguages = {
        1: {
						exitoso: 'Your comment has been sent',
            errNombre: 'Please enter your namess',
            errPaswd: 'Please enter the validation code',
            errPaswdInc: 'Pleasen re-enter the correct validation code',            
            errComent: 'Please write your comment'         		
        },
        14: {
            exitoso: 'Seu comentário foi enviado',
            errNombre: 'Por favor, coloque seu nome',
            errPaswd: 'Por favor, coloque o código de validação',
            errPaswdInc: 'Por favor, insira novamente o código de validação correto',            
            errComent: 'Por favor, coloque seu comentário'
        },
        17: {
            exitoso: 'A sua mensagem foi enviada',
            errNombre: '',
            errPaswd: '',
            errPaswdInc: '',            
            errComent: ''            
        },        
        20: {
            exitoso: 'Messaggio inviato',
            errNombre: '',
            errPaswd: '',
            errPaswdInc: 'La preghiamo di inserire nuovamente il codice corretto',            
            errComent: ''
        },
        15: {
            exitoso: 'Su comentario fue enviado',
            errNombre: 'Por Favor, ingrese su Nombre',
            errPaswd: 'Por Favor, ingrese el Codigo de Validación',
						errPaswdInc: 'Por Favor, reingrese el codigo de validacion correcto',            
            errComent: 'Por Favor, ingrese su comentario'
        },
        18: {
						exitoso: 'Su comentario fue enviado',
            errNombre: 'Por Favor, ingrese su Nombre',
            errPaswd: 'Por Favor, ingrese el Codigo de Validación',
						errPaswdInc: 'Por Favor, reingrese el codigo de validacion correcto',            
            errComent: 'Por Favor, ingrese su comentario'       	
        },
        16: {
             exitoso: 'Su comentario fue enviado',
            errNombre: 'Por Favor, ingrese su Nombre',
            errPaswd: 'Por Favor, ingrese el Codigo de Validación',
						errPaswdInc: 'Por Favor, reingrese el codigo de validacion correcto',            
            errComent: 'Por Favor, ingrese su comentario'       	
        },        
		19: {
						exitoso: 'Your comment has been sent',
            errNombre: 'Please enter your name',
            errPaswd: 'Please enter the validation code',
            errPaswdInc: 'Pleasen re-enter the correct validation code',            
            errComent: 'Please write your comment'         		
        },
        21: {
			exitoso: 'Ihre Nachricht wurde gesendet',
            errNombre: '',
            errPaswd: '',
            errPaswdInc: '',            
            errComent: ''         		
        },
        88: {
            exitoso: 'Su comentario fue enviado',
            errNombre: 'Por Favor, ingrese su Nombre',
            errPaswd: 'Por Favor, ingrese el Codigo de Validación',
						errPaswdInc: 'Por Favor, reingrese el codigo de validacion correcto',            
            errComent: 'Por Favor, ingrese su comentario'
        }
    };
    
    tipoEnvio = false;
    bool = true;
    
    if (bool && !autorTxt.trim()) {
        alert(tableLanguages[idPortal].errNombre);
        autor.focus();
        bool = false;
    }
    
    if (bool && !comentarioTxt.trim()) {
        alert(tableLanguages[idPortal].errComent);
        comentario.focus();
        bool = false;
    }
    
    if (bool && !randomUsuarioTxt.trim() && !tipoEnvio) {
        alert(tableLanguages[idPortal].errPaswd);
        randomUsuario.focus();
        bool = false;
    }
    
    if (bool && (randomUsuarioTxt.trim() != randomTxt) && !tipoEnvio) {
        alert(tableLanguages[idPortal].errPaswdInc);
        randomUsuario.focus();
        bool = false;
    }
    
    if (bool) {
        var src = "../_post/insertar_comentario.php?idPortal=" + idPortal + "&idModulo=" + idModulo + "&idContenido=" + idContenido + "&autor=" + autorTxt + "&comentario=" + comentarioTxt + "&idNota=" + idNota + "&tipoEnvio=" + tipoEnvio + "&exitoso=" + escape(tableLanguages[idPortal].exitoso);
        window._post(src);
    }
    
}

function votar_encuesta(idForm, idEncuesta){
    var opcion = false;
    var form = document.forms[idForm];
    for (i = 0; i < form.elements.length; i++) {
        if (form.elements[i].name.substr(0, 6) == "opcion") {
            if (form.elements[i].checked == true) {
                var opcion = true;
                if (getCookie("CMSVotosEncustas[" + idEncuesta + "]") != idEncuesta) {
                    var expire = new Date('2049, 08, 12'); // Este dia voy a a tener.... 69:P
                    window._post("../_post/votar_encuesta.php?encuesta_opcion=" + form.elements[i].value);
                    document.cookie = "CMSVotosEncustas[" + idEncuesta + "]=" + idEncuesta + "; path=/; expire=" + expire.toGMTString();
                    habilitar_encuesta(idEncuesta);
                    alert("Gracias por participar.");
                    
                }
                else 
                    alert("Usted ya voto esta encuesta");
                break;
            }
        }
    }
    if (!opcion) 
        alert("Debe seleccionar una opcion para votar");
}

function habilitar_encuesta(idEncuesta){
    var div_encuesta = document.getElementById("encuesta_" + idEncuesta);
    var div_resultadoEncuesta = document.getElementById("resultadoEncuesta_" + idEncuesta);
    
    if (getCookie("CMSVotosEncustas[" + idEncuesta + "]") != idEncuesta) {
        div_resultadoEncuesta.style.display = "none";
        div_encuesta.style.display = "block";
    }
    else {
        div_encuesta.style.display = "none";
        div_resultadoEncuesta.style.display = "block";
    }
}

/** [EA 28/04/2007 15:28]
 * Crea un iframe, y lo ubica en el centro de la pagina
 */
window.PopUp = function(src, iframeName){

    if (typeof(window.parent.objAdministratorBar) == "undefined") {
        block();
        if (!iframeName) 
            iframeName = (Math.random() * 10000).toString();
        var strFrame = isMSIE() ? '<iframe name="' + iframeName + '" frameborder="0">' : "iframe";
        objPopup = document.createElement(strFrame);
        objPopup.setAttribute("frameborder", "0");
        objPopup.setAttribute("scrolling", "no");
        objPopup.name = iframeName;
        objPopup.src = src;
        objPopup.style.position = "absolute";
        objPopup.style.top = "100px";
        objPopup.style.left = '100px';
        objPopup.style.zIndex = "9999";        
        document.body.appendChild(objPopup);  
    }
    else  {
        window.location = src;
      }
}
/** [EA 28/04/2007 15:28]
 * Cierro el iframe creado por la funcion PopUp
 */
window.closePopUp = function(){
    if (typeof(window.parent.objAdministratorBar) == "undefined") {
        unblock();
        objPopup.parentNode.removeChild(objPopup);
        delete (objPopup);
        objPopup = null;
    }
    else 
        history.back();
}

function enviar_error(tipoEnvio){
    window.PopUp("../_post/enviar_email.php?tipoEnvio=" + tipoEnvio);
}

/* Guille: para que sirve esta funcion???? */
/* dentro del cuerpo de la nota, abajo de todo, esta COMPARTIR, la funcion te redirije a la url de cada Icono*/
function link(url){
    window.open(url);
}

/**/
var actual_font_size = 16;
function aumentar_tipografia(id){
    if (actual_font_size < 31) 
        actual_font_size++;
    $(id).style.fontSize = actual_font_size;
}

function reducir_tipografia(id){
    if (actual_font_size > 9) 
        actual_font_size--;
    $(id).style.fontSize = actual_font_size;
}

window.imprimirNota = function(src){
    if (typeof(window.parent.objAdministratorBar) == "undefined") {
        PopUp(src);
    }
    else {
        window.location = src;
    }
}

window.recomendarNota = function(src){
    if (typeof(window.parent.objAdministratorBar) == "undefined") {
        PopUp(src);
    }
    else {
        window.location = src;
    }
}

window.loginForm = function(src){
    if (typeof(window.parent.objAdministratorBar) == "undefined") {
        PopUp(src);
    }
    else {
        window.location = src;
    }
}

String.prototype.pad = function(c, l){
    var s = String(this);
    c = String(c);
    l = parseInt(l, 10);
    while (s.length < l) {
        s = c + s;
    }
    return s;
}

function Combo_clear(form, id){
    if (form != '') {
        var o = document.forms[form][id];
    }
    else {
        var o = $(id);
    }
    if (o) 
        o.options.length = 0;
}

function Combo_add(form, id, text, value, selected){
    if (form != '') {
        var o = document.forms[form][id];
    }
    else {
        var o = $(id);
    }
    
    var opt = null;
    if (o) {
        o.options[o.options.length] = new Option(text, value);
        opt = o.options[o.options.length - 1];
        opt.selected = selected;
    }
    return opt;
}

function Combo_clearAndFill(form, id, options, keyText, keyValue, valueSelected){
    Combo_clear(form, id);
    Combo_fill(form, id, options, keyText, keyValue, valueSelected);
}

function Combo_fill(form, id, options, keyText, keyValue, valueSelected){
    for (var i = 0; i < options.length; i++) {
        Combo_add(form, id, options[i][keyText], options[i][keyValue], valueSelected == options[i][keyValue]);
    }
}

window.SwitchLogin = function(){
    var CMSLoginBox = document.getElementById("CMSLoginBox");
    var CMSLoginBoxUser = document.getElementById("CMSLoginBoxUser"); 
    var CMSLogoutBox = document.getElementById("CMSLogoutBox");
    if (CMSLoginBox && CMSLoginBoxUser && CMSLogoutBox) {
        var loginCookie = getCookie("CMSFrontendLogin");
        if (loginCookie != null && loginCookie != "") {
            var CMSFrontendLogin = loginCookie.split(/\|/);
            CMSLoginBoxUser.innerHTML = CMSFrontendLogin[0];
            CMSLoginBox.style.display = "none";
            CMSLogoutBox.style.display = "";
        }
        else {
            CMSLoginBoxUser.innerHTML = "";
            CMSLoginBox.style.display = "";
            CMSLogoutBox.style.display = "none";
        }
    }
}

getCookieData = function(intKey){
    var loginCookie = getCookie("CMSFrontendLogin");
    if (loginCookie != null && loginCookie != "") {
        var CMSFrontendLogin = loginCookie.split(/\|/);
        return CMSFrontendLogin[intKey];
    }
    return "";
}


window.LogOut = function(){
    window.SwitchLogin();
    _post("../_post/logout.php");
}

window.logOut2 = function() {
    _post("../_post/logout.php?referrer=videoteca");	
}

function toogleMarquee(sourceImgPlay, sourceImgPause){
    if ($('bt_marquee').src.indexOf('play') == -1) {
        $('bt_marquee').src = sourceImgPlay;
        $('marquee').stop();
    }
    else {
        $('bt_marquee').src = sourceImgPause;
        $('marquee').start();
    }
}

function getElementsByAttribute(oElm, strTagName, strAttributeName, strAttributeValue){
    var arrElements = (strTagName == "*" && oElm.all) ? oElm.all : oElm.getElementsByTagName(strTagName);
    var arrReturnElements = new Array();
    var oAttributeValue = (typeof strAttributeValue != "undefined") ? new RegExp("(^|\s)" + strAttributeValue + "(\s|$)") : null;
    var oCurrent;
    var oAttribute;
    
    for (var i = 0; i < arrElements.length; i++) {
        oCurrent = arrElements[i];
        oAttribute = oCurrent.getAttribute && oCurrent.getAttribute(strAttributeName);
        if (typeof oAttribute == "string" && oAttribute.length > 0) {
            if (typeof strAttributeValue == "undefined" || (oAttributeValue && oAttributeValue.test(oAttribute))) {
                arrReturnElements.push(oCurrent);
            }
        }
    }
    return arrReturnElements;
}

function openEdicionElectronica(){
    var width = screen.width;
    var height = screen.height;
    window.open('../edicion_impresa/index.php', 'EdicionImpresa', 'top=0, left=0, width=' + width + ', height=' + height + ', toolbar=no, menubar=no, scrollbars=no');
}

tamanio0 = 11;
tamanio1 = 12;

function tamFuente(operacion){

    if (operacion == 0) {
        if (tamanio0 > 8) 
            tamanio0 = tamanio0 - 1;
        if (tamanio1 > 8) 
            tamanio1 = tamanio1 - 1;
        
    }
    else {
        if (tamanio0 < 20) 
            tamanio0 = tamanio0 + 1;
        if (tamanio1 < 20) 
            tamanio1 = tamanio1 + 1;
    }
    
    document.getElementById('cuerpo').style.fontSize = tamanio0;
    document.getElementById('copete').style.fontSize = tamanio1;
}


function addNota(stitle, slink, flag){
    var strTypeAux = getCookie('favorito');
    if (strTypeAux) {
        var arrNota = strTypeAux.split('@@');
        var cantidad = arrNota.length;
        var agregar = true;
        
        for (var i = 0; agregar && i < cantidad; i++) {
            arrItem = arrNota[i].split('##');
            if (arrItem.length == 2 && slink == unescape(unescape(arrItem[0]))) {
                agregar = false;
            }
        }
        
        if (agregar) {
            var strType = escape(escape(slink)) + '##' + stitle + '@@' + strTypeAux;
            setCookie('favorito', strType, new Date(2010, 1, 1));
        }
        
    }
    else {
        var strType = escape(escape(slink)) + '##' + stitle + '@@' + strTypeAux;
        setCookie('favorito', strType, new Date(2010, 1, 1));
    }
    
    if (!flag) 
        loadFavorito();
}

function CambiarVisibility(obj){
    loadFavorito();
    var obj = document.getElementById(obj);
    if (obj.style.visibility == "hidden") {
        obj.style.visibility = "visible";
    }
    else {
        obj.style.visibility = "hidden";
    }
}

function setCookie(nombre, valor, caducidad){
    document.cookie = nombre + "=" + escape(valor) + ((caducidad == null) ? "" : ("; expires=" + caducidad.toGMTString()) + "; path=/; ")
}

function getCookie(nombre){
    var buscamos = nombre + "=";
    try {
        if (document.cookie.length > 0) {
            var i = document.cookie.indexOf(buscamos);
            if (i != -1) {
                i += buscamos.length;
                var j = document.cookie.indexOf("; ", i);
                if (j == -1) {
                    j = document.cookie.length;
                }
                return unescape(document.cookie.substring(i, j));
            }
        }
    } 
    catch (e) {
    };
    }

function loadFavorito(){
    var cHTMLClip = "";
    var strTypeAux = getCookie('favorito');
    var cantidad = 1;
    var can = 0;
    
    if (strTypeAux) {
        var arrNota = strTypeAux.split('@@');
        var cantidad = arrNota.length;
        cHTMLClip = '<table width=100% cellspacing=0 cellpadding=0 border=0>';
        for (var i = 0; i < cantidad; i++) {
            arrItem = arrNota[i].split('##');
            
            if (typeof(arrItem[1]) != 'undefined') {
                cHTMLClip += "<div id=div" + i + "><tr bgcolor=#FFFFFF>";
                cHTMLClip += "	<td valign=top><input value2='" + arrItem[0] + "' id=chkNota[] name=chkNota[] value='" + arrItem[1] + "' type=checkbox></td>";
                cHTMLClip += "	<td width=2></td>";
                cHTMLClip += "	<td><a class='arial s10 c048382' href=" + unescape(unescape(arrItem[0])) + ">" + arrItem[1] + "</a></td>";
                cHTMLClip += "</tr>";
                cHTMLClip += "<tr bgcolor=#FFFFFF>";
                cHTMLClip += "	<td colspan=3 height=10><td>";
                cHTMLClip += "</tr></div>";
                can++;
            }
        }
        cHTMLClip += "<tr><td colspan=3 style=padding:3px; bgcolor=#EBEBEB align=right><a class=arial s11 c4F5E66 b href=javascript:deleteFavorito()>Borrar</a></td></tr>";
        cHTMLClip += '</table>';
    }
    if (document.getElementById('DNotas')) {
        document.getElementById('DNotas').innerHTML = cHTMLClip;
    }
    if ($('countMisNotas')) 
        $('countMisNotas').innerHTML = can;
}

function deleteFavorito(){
    var strTypeAux = setCookie('favorito', '', new Date(1970, 1, 1));
    
    var arrChk = document.getElementsByName('chkNota[]');
    var cantDelete = arrChk.length;
    var arrDel = new Array();
    
    for (var i = 0; i < cantDelete; i++) {
        if (!arrChk[i].checked) {
            addNota(arrChk[i].value, arrChk[i].getAttribute('value2'), true);
        }
    }
    loadFavorito();
}

function PDF(strUrl){
    var url = '../html2pdf/demo/html2ps.php?';
    url += 'process_mode=single';
    url += '&URL=' + escape(strUrl);
    url += '&pixels=800';
    url += '&scalepoints=1';
    url += '&renderimages=1';
    url += '&renderlinks=1';
    url += '&renderfields=1';
    url += '&media=A4';
    url += '&cssmedia=screen';
    url += '&lm=2';
    url += '&rm=2';
    url += '&tm=2';
    url += '&bm=2';
    url += '&smartpagebreak=1';
    url += '&method=fpdf';
    url += '&pdfversion=1.3';
    url += '&output=0';
    window.open(url);
}

function HideMenu(id, n){
    var displayMenu = document.getElementById(id);
    if (displayMenu) {
        displayMenu.style.display = 'none';
        displayMenu.style.position = 'absolute';
    }
}

function ShowMenu(id, n){
    var displayMenu = document.getElementById(id);
    if (displayMenu) {
        displayMenu.style.display = 'block';
        displayMenu.style.position = 'absolute';
        
    }
}

function styleMenu(idelement, bgcolor, classFont){

    var bg = document.getElementById('mnu_' + idelement);
    var ln = document.getElementById('lnk_' + idelement);
    bg.style.backgroundColor = bgcolor;
    ln.className = classFont;
}

function resizePopup(){
    var width = document.getElementById('tablaPopup').offsetWidth;
    var height = document.getElementById('tablaPopup').offsetHeight;
    if (window.frameElement) {
        //window.document.body.scroll = "yes";
        window.frameElement.style.width = width;
        window.frameElement.style.height = height;
        window.frameElement.style.top = ((parent.document.body.scrollTop + (screen.height / 2)) - (height / 2)) - 80;
        window.frameElement.style.left = (parent.document.body.firstChild.offsetWidth / 2) - (width / 3);
    }
}

function esCUITValido(cuit){
    var tablaMul = new Array(5, 4, 3, 2, 7, 6, 5, 4, 3, 2);
    var sumatoria = 0;
    var diferencia = 0;
    var digito = 0;
    
    var resultado = /^\d{2}\-\d{8}\-\d$/.test(cuit);
    
    if (resultado) {
        cuit = cuit.replace(/\-/g, '');
        
        for (var i = 0; i < 10; i++) {
            sumatoria += Number(cuit.charAt(i)) * tablaMul[i];
        }
        
        diferencia = sumatoria - Math.floor(sumatoria / 11) * 11;
        digito = diferencia > 0 ? 11 - diferencia : diferencia;
        resultado = digito == cuit.charAt(10);
    }
    return resultado;
}

function addLoadEvent(func){
    var oldonload = window.onload;
    if (typeof window.onload != 'function') {
        window.onload = func;
    }
    else {
        window.onload = function(){
            if (oldonload) {
                oldonload();
            }
            func();
        }
    }
}

function nuevo_evento(elemento, evento, funcion){
    if (elemento.addEventListener) {
        elemento.addEventListener(evento, funcion, false);
    }
    else {
        elemento.attachEvent("on" + evento, funcion);
    }
}

function remover_evento(elemento, evento, funcion){
    if (elemento.removeEventListener) {
        elemento.removeEventListener(evento, funcion, false);
    }
    else {
        elemento.detachEvent("on" + evento, funcion);
    }
}
/*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/adjuntos/_imgs/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++) {
                	var script = scripts[i].innerHTML;
                	eval(script);
                }
            } 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 search_in_query_string(param) {
	if(location.search) {
		var query_str = location.search.substr(1);
		query_str = query_str.split('&');
		for (i in query_str) {
			var foo = query_str[i].split('=');
			if (foo[0] == param && foo[1] != '') {
				return foo[1];
			}
		}
	}
	return '';
}
