﻿/*Url del servidor y variables GET*/

var ServidorUrlocation = location.href;

var VariablesUrl = ServidorUrlocation.replace(/.*\?(.*?)/, "$1");

var Variables = VariablesUrl.split("&");

ServidorUrl = ServidorUrlocation.split("/");
var ServidorUrl = 'http://' + ServidorUrl[2] + '';

/*
for (i = 0; i < Variables.length; i++) {
Separ = Variables[i].split("=");
eval('var ' + Separ[0] + '="' + Separ[1] + '"');
}
alert(ServidorUrl);
alert(Variables);
*/


/*Encripta password*/

function changeInputType(
  oldElm, // a reference to the input element
  iType, // value of the type property: 'text' or 'password'
  iValue, // the default value, set to 'password' in the demo
  blankValue, // true if the value should be empty, false otherwise
  noFocus) {  // set to true if the element should not be given focus
    if (!oldElm || !oldElm.parentNode || (iType.length < 4) ||
    !document.getElementById || !document.createElement) return;
    var isMSIE = /*@cc_on!@*/false; //http://dean.edwards.name/weblog/2007/03/sniff/
    if (!isMSIE) {
        var newElm = document.createElement('input');
        newElm.type = iType;
    } else {
        var newElm = document.createElement('span');
        newElm.innerHTML = '<input type="' + iType + '" name="' + oldElm.name + '">';
        newElm = newElm.firstChild;
    }
    var props = ['name', 'id', 'className', 'size', 'tabIndex', 'accessKey'];
    for (var i = 0, l = props.length; i < l; i++) {
        if (oldElm[props[i]]) newElm[props[i]] = oldElm[props[i]];
    }
    newElm.onfocus = function() {
        return function() {
            if (this.hasFocus) return;
            var newElm = changeInputType(this, 'password', iValue,
      (this.value.toLowerCase() == iValue.toLowerCase()) ? true : false);
            if (newElm) newElm.hasFocus = true;
        }
    } ();
    newElm.onblur = function() {
        return function() {
            if (this.hasFocus)
                if (this.value == '' || (this.value.toLowerCase() == iValue.toLowerCase())) {
                changeInputType(this, 'text', iValue, false, true);
            }
        }
    } ();
    // hasFocus is to prevent a loop where onfocus is triggered over and over again
    newElm.hasFocus = false;
    // some browsers need the value set before the element is added to the page
    // while others need it set after
    if (!blankValue) newElm.value = iValue;
    oldElm.parentNode.replaceChild(newElm, oldElm);
    if (!isMSIE && !blankValue) newElm.value = iValue;
    if (!noFocus || typeof (noFocus) == 'undefined') {
        window.tempElm = newElm;
        setTimeout("tempElm.hasFocus=true;tempElm.focus();", 1);
    }
    return newElm;
}

function toggleDivState(divName) {
    var ctl = window.document.getElementById(divName);
    if (ctl.style.display == "none")
        ctl.style.display = "";
    else
        ctl.style.display = "none";
}

/******** Scripts auxiliares para acoplables ************/

function Mostrar_Div(desc) {
    if (document.getElementById(desc) != null) {
        document.getElementById(desc).style.display = "block";
    }
}
function Ocultar_Div(desc) {
    if (document.getElementById(desc) != null) {
        document.getElementById(desc).style.display = "none";
    }
}
function toggle_Div(num, pref) {
    if (document.getElementById(pref + num).style.display == "none") {
        Mostrar_Div(pref + num);
        for (i = 0; i <= 10; i++) {
            //alert(pref+i);
            if (num != i) {
                Ocultar_Div(pref + i);
            }
        }
    } else {
        Ocultar_Div(pref + num);
    } // if display none
}

/************************************************************/
/**Scripts auxiliares para solapas de encuesta en la master**/
function MostrarSolapa(id) {
    if (document.getElementById(id).className == "EncuestaPestanas2") {
        document.getElementById(id).className = 'EncuestaPestanas';
    }
    else {
        document.getElementById(id).className = 'EncuestaPestanas2';
    }
}
function setClassSolapa(id, className) {
    document.getElementById(id).className = className;
}
function mostrarSolapaUno() {
    document.getElementById('divEncuPestanas').className = 'EncuestaPestanas';
}
function mostrarSolapaDos() {
    document.getElementById('divEncuPestanas').className = 'EncuestaPestanas2';
}


String.prototype.trim = function() {
    return this.replace(/^\s+|\s+$/g, "");
}
String.prototype.ltrim = function() {
    return this.replace(/^\s+/, "");
}
String.prototype.rtrim = function() {
    return this.replace(/\s+$/, "");
}


/*********************************************************************************/

var CMenu = 0;

function CerrarMenuTime() {
    CMenu = setTimeout("CerrarMenu()", 1500);
}

function CerrarMenu() {    
    $("#ItemsCatPersonalizado").hide("slow");
}

function MantenerMenu() {
    clearTimeout(CMenu);
}

function AbrirMenu() {
    if (document.getElementById('ItemsCatPersonalizado').style.display == 'block') {
        //document.getElementById('ItemsCatPersonalizado').style.display = 'none';
        $("#ItemsCatPersonalizado").hide("slow");
    } else {
        //document.getElementById('ItemsCatPersonalizado').style.display = 'block';
        $("#ItemsCatPersonalizado").show("slow");
    }
}

function SelItemsCat(ItemsCat, NombreItemsCat) {
    document.getElementById('LCatPersonalizado').InnerHTML = NombreItemsCat;
}
/*********************************************************************************/
/*********************************************************************************/
/*DROPDOWNLIST_LINDO general*/

var CDropDownTimers = new Array();

function DropDownList_Abrir(id) {
    if (document.getElementById(id).style.display == 'block') {
        //document.getElementById('ItemsCatPersonalizado').style.display = 'none';
        $("#" + id).hide("slow");
    } else {
        //document.getElementById('ItemsCatPersonalizado').style.display = 'block';
        $("#" + id).show("slow");
    }
}

function DropDownList_CerrarMenuTime(id) {
    CDropDownTimers[id] = setTimeout("DropDownList_CerrarMenu('" + id + "')", 1500);
}

function DropDownList_CerrarMenu(id) {
    //document.getElementById('ItemsCatPersonalizado').style.display = 'none';
    $("#"+id).hide("slow");
}

function DropDownList_MantenerMenu(id) {
    clearTimeout(CDropDownTimers[id]);
}
function DropDownList_SelItem(id, control) {
    document.getElementById(id + "_title").innerHTML = control.innerHTML;

    script = $("#" + id).attr("onSelectedItem");

    value = $(control).attr("value");
    script = script.replace("_VALUE_", value);
    setTimeout(script, 0);
    return false;
    
}
/*********************************************************************************/
/*********************************************************************************/


function SetCookieBkShop(name, value) {
    if (!name || !value) { return 0; }

    document.cookie = name + "=" + value + ";path=/;";
}

function GetCookieBkShop(name) {
    var dc = document.cookie;
    var begin = dc.indexOf(name);
    var end = (dc.indexOf(";", begin) == -1) ? dc.length : dc.indexOf(";", begin);
    if (begin < 0)
        return null;
    return unescape(dc.substring((begin + (name.length + 1)), end));
}


/*********************************************************************************/

var CDespProdCarrito = 0;

function CerrarDespProdCarritoTime() {
    CDespProdCarrito = setTimeout("CerrarDespProdCarrito()", 4000);
}

function CerrarDespProdCarrito() {
    $("#CDespProdCarrito").hide("slow");
}

function MantenerDespProdCarrito() {
    clearTimeout(CDespProdCarrito);
}

function AbrirDespProdCarrito() {
    if (document.getElementById('CDespProdCarrito') != null) {
        if (document.getElementById('CDespProdCarrito').style.display == 'block') {
            //CerrarDespProdCarritoTime();
        } else {
            //$("#CDespProdCarrito").toggle("slide", {}, 2500);
            $("#CDespProdCarrito").show("slow");
            clearTimeout(CDespProdCarrito);
            CerrarDespProdCarritoTime();
        }
    }
}

/********************************************************/

/*********************************************************************************/

var CDespEncuestas = 0;

function CerrarEncuestasTime() {
    CDespEncuestas = setTimeout("CerrarDespEncuestas()", 4000);
}

function CerrarDespEncuestas() {
    $("#misEncuestas").hide("slow");
    $("#infoDesplegar").show("slow"); 
}

function MantenerDespEncuestas() {
    clearTimeout(CDespEncuestas);
}

function AbrirEncuestas() {
    if (document.getElementById('misEncuestas') != null) {
        if (document.getElementById('misEncuestas').style.display == 'block') {            
        } else {
            $("#misEncuestas").show("slow");
            $("#infoDesplegar").hide("slow"); 
            clearTimeout(CDespEncuestas);
            CerrarEncuestasTime();
        }
    }
}

/********************************************************/
