
var User = "";
var Pwd = "";
var Step = 0;
var txtUser = '<input id="Dato" type="text" style="width:100px" />';
var txtPwd = '<input id="Dato" type="password" style="width:100px" />';
var MsgInicial = 'Ingrese login y presione enter';

var altura = '150px';
var ie5=document.all&&document.getElementById;
var ns6=document.getElementById&&!document.all;

function CreaToolbar(){
document.writeln('<div onSelectStart=\"return false\" id=\"ventana\" onmousedown="dragStart(event,\'ventana\')" style=\"left:1;top:1; width:140px; position:absolute; overflow:auto; z-index:10; border-color:#6b8ec6; background-color:Whitesmoke; filter:alpha(opacity=90); border-style:solid; border-width:1px;  visibility:visible">');
document.writeln('<div ondblclick="maximize();" onSelectStart="return false" id="encabezado" style="background-position:top;background-image:url(images/others/pixelOrange.jpg);height:23px; width:100%; position:relative; overflow:hidden; z-index:8; border-color:#6b8ec6; filter:alpha(opacity=99); border-style:none; border-width:1px;  ) \'">');
    document.writeln('<div   id="encabezadoA" style="height:20px; width:120px; position:absolute; overflow:hidden; z-index:8; border-color:#6b8ec6; filter:alpha(opacity=90); border-style:none; border-width:1px;  ) \'">');
      document.writeln('<b class="TitleWhite" style="cursor:move;">&nbsp;<font face="Tahoma">Opciones:</font></b>');
      document.writeln('</div>');
      document.writeln('<div style="left:125px;top:0px;height:20px; width:15px; position:absolute; overflow:hidden; z-index:8; border-color:#6b8ec6; filter:alpha(opacity=90); border-style:none; border-width:1px;)\'">');
            document.writeln('<a href="#" style="text-decoration:none;" onclick="closeit(); return false;"><img border=0 align="middle" alt="cerrar sesion" onclick="" src="images/others/closebox_small.gif"/></a>');
      document.writeln('</div>');
 document.writeln('</div>');


document.writeln('<div onSelectStart="return false" id="ventanacontent">');
 document.writeln('<table border=0 width=130px>');

 document.writeln('<tr><td height="10px"  class="MenuT" colspan=2 style="background-image:url(images/icons/chart.png);background-repeat:no-repeat">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;reportes</td></tr>');
 document.writeln('<tbody>');

 document.writeln('<tr><td width=20px valign=top></td><td><a class="SubMenuT"  href="jsps/reporte.jsp" target="contenido">&bull;&nbsp;resúmen de ventas</a></td></tr>');
 document.writeln('<tr><td width=20px valign=top></td><td><a class="SubMenuT"  href="jsps/reporte_hora.jsp" target="contenido">&bull;&nbsp;ventas x hora</a></td></tr>');
/* document.writeln('<tr><td width=20px valign=top></td><td><a class="SubMenuT"  href="jsps/reporte.jsp" target="contenido">&bull;&nbsp;ventas x hora</a></td></tr>');
 document.writeln('<tr><td width=20px valign=top></td><td><a class="SubMenuT"  href="jsps/reporte.jsp" target="contenido">&bull;&nbsp;ventas x mes</a></td></tr>');
 document.writeln('<tr><td width=20px valign=top></td><td><a class="SubMenuT"  href="jsps/reporte.jsp" target="contenido">&bull;&nbsp;ventas x dia semana</a></td></tr>');*/
document.writeln('</tbody>');

 document.writeln('<tr><td valign=bottom height="10px" class="MenuT" colspan=2 style="background-image:url(images/icons/download.png);background-repeat:no-repeat">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="MenuT" target="contenido" href=\"jsps/descarga.jsp\">descargas</a></td></tr>');
 document.writeln('<tr><td valign=bottom height="10px" class="MenuT" colspan=2 style="background-image:url(images/icons/money2.png);background-repeat:no-repeat">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="MenuT" target="contenido" href=\"jsps/pago.jsp\">pagos</a></td></tr>');
 document.writeln('<tr><td valign=bottom height="10px" class="MenuT" colspan=2 style="background-image:url(images/icons/sort_ascending.png);background-repeat:no-repeat">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="MenuT" target="contenido" href=\"jsps/precio.jsp\">precios</a></td></tr>');
 document.writeln('<tr><td valign=bottom height="10px" class="MenuT" colspan=2 style="background-image:url(images/icons/codigos.png);background-repeat:no-repeat">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="MenuT" target="contenido" href=\"jsps/licencia.jsp\">licencias</a></td></tr>');
 document.writeln('<tr><td valign=bottom height="10px" class="MenuT" colspan=2 style="background-image:url(images/icons/user1_information.png);background-repeat:no-repeat">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="MenuT" target="contenido" href=\"jsps/micuenta.jsp\">perfil</a></td></tr>');

// document.writeln('<tr><td align=left valign=top height="20px" class="MenuT" colspan=2 style="background-position:right bottom;background-image:url(images/icons/logoff.gif);background-repeat:no-repeat"><hr>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="MenuT" target="_top" href=\"valida?cierrasesion=1\">cerrar sesión</a></td></tr>');

 document.writeln('</tr></table>');
 document.writeln('</div>');

 document.writeln('</div>');}


function closeit()
{document.location = 'valida?cierrasesion=1';}




function maximize(){
if (document.getElementById("ventanacontent").style.display=="none"){
  //mostrar contenido
  document.getElementById("ventana").style.height = '';
  document.getElementById("ventanacontent").style.display="";
/*  document.getElementById("footer").style.display="";
  document.getElementById('imagen').style.pixelLeft = document.getElementById('ventana').style.pixelLeft - ImgOpAncho;
  document.getElementById('imagen').style.pixelTop = document.getElementById('ventana').style.pixelTop;

  document.getElementById("imagen").style.display="";*/
}

else{//ocultar contenido
  document.getElementById("ventana").style.height = "25px";
  document.getElementById("ventanacontent").style.display="none";
/*  document.getElementById("footer").style.display="none";
  document.getElementById("imagen").style.display="none";

  */
}
}

function iecompattest(){
return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function Inicializa(mostrar_sesion)
{
if (mostrar_sesion){ //si no ha iniciado sesion
document.onkeydown = checkKeycode
document.getElementById('InicioSesion').innerHTML = txtUser;
document.getElementById('Message').innerHTML = MsgInicial;
setTimeout('document.getElementById(\'Dato\').focus();',100);}
else //mostrar toolbar
{
/*CREA TOOLBAR*/
CreaToolbar();
document.getElementById('InicioSesion').innerHTML = '<a target="_top" href=\"valida?cierrasesion=1\"><b>cerrar sesión</a></b>';}

}

function checkKeycode(e) {
  var keycode;
  var obj = document.getElementById('InicioSesion');
  var Msg = document.getElementById('Message');
  var Dato = document.getElementById('Dato').value;
  if (window.event) keycode = window.event.keyCode;else if (e) keycode = e.which;
  if(keycode==13)
  { if (Dato != '' ){

    if (Step == 0)
    {Step = 1;
     Msg.innerHTML = 'contraseña...ESC para cancelar';
     obj.innerHTML = txtPwd;
     User = Dato;
     setTimeout('document.getElementById(\'Dato\').focus();',10);
   }

    else if (Step == 1)
    {Pwd = Dato;
     Msg.innerHTML = 'espere...';
     obj.innerHTML = '<p class="Small" id="Dato"></p>';
     Step = 0;
     document.Validacion.User.value = User;
     document.Validacion.Pwd.value = Pwd;
     document.Validacion.submit();
     window.status = 'validando usuario...';
     }
     else
     {Reset();}
}
else
{alert(Step==0?'Escriba su nombre de usuario':'Escriba su contraseña');}
}
  else if (keycode==27)
  { Reset();}
}

function Reset()
{Step = 0;
 User = "";
 Pwd = "";
 document.getElementById('InicioSesion').innerHTML = txtUser;
 document.getElementById('Message').innerHTML = MsgInicial;
 setTimeout('document.getElementById(\'Dato\').focus();',10);}


///FUNCIONES DE DRAG N DROP
function Browser() {

  var ua, s, i;

  this.isIE    = false;
  this.isNS    = false;
  this.version = null;

  ua = navigator.userAgent;

  s = "MSIE";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isIE = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  s = "Netscape6/";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  // Treat any other "Gecko" browser as NS 6.1.

  s = "Gecko";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = 6.1;
    return;
  }
}

var browser = new Browser();

// Global object to hold drag information.

var dragObj = new Object();
dragObj.zIndex = 0;

function dragStart(event, id) {

  var el;
  var x, y;

  // If an element id was given, find it. Otherwise use the element being
  // clicked on.

  if (id)
    dragObj.elNode = document.getElementById(id);
  else {
    if (browser.isIE)
      dragObj.elNode = window.event.srcElement;
    if (browser.isNS)
      dragObj.elNode = event.target;

    // If this is a text node, use its parent element.

    if (dragObj.elNode.nodeType == 3)
      dragObj.elNode = dragObj.elNode.parentNode;
  }

  // Get cursor position with respect to the page.

  if (browser.isIE) {
    x = window.event.clientX + document.documentElement.scrollLeft
      + document.body.scrollLeft;
    y = window.event.clientY + document.documentElement.scrollTop
      + document.body.scrollTop;
  }
  if (browser.isNS) {
    x = event.clientX + window.scrollX;
    y = event.clientY + window.scrollY;
  }

  // Save starting positions of cursor and element.

  dragObj.cursorStartX = x;
  dragObj.cursorStartY = y;
  dragObj.elStartLeft  = parseInt(dragObj.elNode.style.left, 10);
  dragObj.elStartTop   = parseInt(dragObj.elNode.style.top,  10);

  if (isNaN(dragObj.elStartLeft)) dragObj.elStartLeft = 0;
  if (isNaN(dragObj.elStartTop))  dragObj.elStartTop  = 0;

  // Update element's z-index.

  dragObj.elNode.style.zIndex = ++dragObj.zIndex;

  // Capture mousemove and mouseup events on the page.

  if (browser.isIE) {
    document.attachEvent("onmousemove", dragGo);
    document.attachEvent("onmouseup",   dragStop);
    window.event.cancelBubble = true;
    window.event.returnValue = false;
  }
  if (browser.isNS) {
    document.addEventListener("mousemove", dragGo,   true);
    document.addEventListener("mouseup",   dragStop, true);
    event.preventDefault();
  }
}

function dragGo(event) {

  var x, y;

  // Get cursor position with respect to the page.

  if (browser.isIE) {
    x = window.event.clientX + document.documentElement.scrollLeft
      + document.body.scrollLeft;
    y = window.event.clientY + document.documentElement.scrollTop
      + document.body.scrollTop;
  }
  if (browser.isNS) {
    x = event.clientX + window.scrollX;
    y = event.clientY + window.scrollY;
  }

  // Move drag element by the same amount the cursor has moved.

  dragObj.elNode.style.left = (dragObj.elStartLeft + x - dragObj.cursorStartX) + "px";
  dragObj.elNode.style.top  = (dragObj.elStartTop  + y - dragObj.cursorStartY) + "px";

  if (browser.isIE) {
    window.event.cancelBubble = true;
    window.event.returnValue = false;
  }
  if (browser.isNS)
    event.preventDefault();
}

function dragStop(event) {

  // Stop capturing mousemove and mouseup events.

  if (browser.isIE) {
    document.detachEvent("onmousemove", dragGo);
    document.detachEvent("onmouseup",   dragStop);
  }
  if (browser.isNS) {
    document.removeEventListener("mousemove", dragGo,   true);
    document.removeEventListener("mouseup",   dragStop, true);
  }
}
