function SubirArchivo()
{
	window.open("SubeArchivoEnlace.asp", null, "height=200,width=400,status=no,titlebar=no,toolbar=no,menubar=no,location=no,resizable=no,scrollbars=no")
}
function AttachFile()
{
	window.open("SubeArchivoFoto.asp", null, "height=200,width=400,status=no,titlebar=no,toolbar=no,menubar=no,location=no,resizable=no,scrollbars=no")
}

function getNovedadPorId(sId)
{
  	var xmlHttp;
	var respuesta;
	  try{ // Firefox, Opera 8.0+, Safari
	    xmlHttp=new XMLHttpRequest();}
	  catch (e){// Internet Explorer
	    try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");}
	    catch (e){ 
	    	try {xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");}
	      catch (e){
	        alert("Please upgrade your browser to use full functionality on this page");
	        return false; }
	      }    }
	    xmlHttp.onreadystatechange=function()
	    {
	    	
//  Aqui se recibe el resultado de la creación del XML
    if(xmlHttp.readyState==4)
    {
    	respuesta=xmlHttp.responseText;
	document.getElementById('DivTabla').innerHTML=respuesta;
    }
	}
	lblReportType = '';
	URL="asp/getNovedadPorId.asp?sId="+sId;
	xmlHttp.open("POST",URL,true);
	xmlHttp.setRequestHeader("Content-Length", 5124);
	xmlHttp.send("");
}


function RefrescarHomefff(sLeng)
{
	document.getElementById('novedadesHome').innerHTML="<br>123456789012345<br>2<br>3<br>4<br><hr>123456789012345<br>2<br>3<br>4<br><hr>123456789012345<br>2<br>3<br>4<br>";
}

function RefrescarHome(sLeng)
{
  	var xmlHttp;
	var respuesta;
	  try{ // Firefox, Opera 8.0+, Safari
	    xmlHttp=new XMLHttpRequest();}
	  catch (e){// Internet Explorer
	    try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");}
	    catch (e){ 
	    	try {xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");}
	      catch (e){
	        alert("Please upgrade your browser to use full functionality on this page");
	        return false; }
	      }    }
	    xmlHttp.onreadystatechange=function()
	    {
	    	
//  Aqui se recibe el resultado de la creación del XML
    if(xmlHttp.readyState==4)
    {
    	respuesta=xmlHttp.responseText;
	document.getElementById('novedadesHome').innerHTML=respuesta;
    }
	}
	lblReportType = '';
	URL="asp/getNovedadesHome.asp?sLeng="+sLeng;
	xmlHttp.open("POST",URL,true);
	xmlHttp.setRequestHeader("Content-Length", 5124);
	xmlHttp.send("");
}


function Accion(sAccion, sID) 
{
	//alert("Accion="+sAccion+"  Id="+sID);
	switch (sAccion)
	{
	// Borrar
	case "B":
	  muestraConsultaBorrado(sID)
	  break;
	// Modificar
	case "M":
	  window.location.href='asp/Modifica.asp?'+sID;
	  break;
	// Visualizar	  
	case "V":
	  window.open('Detalle_Novedad.htm?'+sID, 'Detalle', 'width=900,height=768,type=fullWindow,scrollbars=yes');
	  //window.location.href='es/Detalle_Novedad.htm?'+sID;
	  ///Visualiza(sID);
	  break;	
	// Nueva novedad
	case "N":
		window.location.href='asp/Nueva.asp';
	break;
	default:
	  alert("Error en acción. Por favor, consulte con su administrador");
	}
}

function Visualiza(sID)
{
  	var xmlHttp;
	var respuesta;
	
	document.getElementById('Contenedor').innerHTML='<img src="Img/Processing.gif" width="32" height="32" hspace="300" vspace="150">';

	  try{ // Firefox, Opera 8.0+, Safari
	    xmlHttp=new XMLHttpRequest();}
	  catch (e){// Internet Explorer
	    try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");}
	    catch (e){ 
	    	try {xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");}
	      catch (e){
	        alert("Please upgrade your browser to use full functionality on this page");
	        return false; }
	      }    }
	    xmlHttp.onreadystatechange=function()
	    {
//  Aqui se recibe el resultado de la creación del XML
    if(xmlHttp.readyState==4)
    {
    	respuesta=xmlHttp.responseText;
	document.getElementById('Contenedor').innerHTML=respuesta;
    }
	}
	lblReportType = '';
	URL="asp/getNovedad.asp?sId="+sID;
	xmlHttp.open("POST",URL,true);
	xmlHttp.send(null);
}

function muestraConsultaBorrado(sId)
{
	actualRow = sId;
	showConsultaDelBox('Está segura de eliminar estos datos?');
	//actualRow = '';
}
function showConsultaDelBox(sTextWarning){
	$('cajaConsultaDel').show();
	center('ConsultaDelBox');
	if(document.all){
		document.getElementById("sDeletionMessage").innerText=sTextWarning;
	} else{
		document.getElementById("sDeletionMessage").textContent=sTextWarning;		
	}
	return false;
}

function hideConsultaDelBox(){
    $('ConsultaDelBox').hide();
    $('cajaConsultaDel').hide();
    return false;
}
function BorraLinea(sId)
  {
  var xmlHttp;
  var respuesta;
  try {
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
    }
  catch (e)     {
    // Internet Explorer
    try       {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
    catch (e)       {
      try         {
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
      catch (e)         {
        alert("Please upgrade your browser to use full functionality on this page");
        return false;
        }
      }
    }
    xmlHttp.onreadystatechange=function()
      {
      if(xmlHttp.readyState==4)
        {
		var sReturn=xmlHttp.responseText.charAt(0);
	        var sResult=xmlHttp.responseText;
		if (sResult==1){
			alert('An error has occurred. Please retry later or contact your administrator');
		}else{
			hideConsultaDelBox();
			RefrescaEntrada('ES');
		}
        }
      }
    URL='asp/borraItem.asp?id='+ sId;
    xmlHttp.open("POST",URL,true);
    xmlHttp.send(null);
  }
function RefrescaEntrada(sIdioma)
{
  	var xmlHttp;
	var respuesta;
		
	document.getElementById('Contenedor').innerHTML='<img src="Img/Processing.gif" width="32" height="32" hspace="300" vspace="150">';

	  try{ // Firefox, Opera 8.0+, Safari
	    xmlHttp=new XMLHttpRequest();}
	  catch (e){// Internet Explorer
	    try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");}
	    catch (e){ 
	    	try {xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");}
	      catch (e){
	        alert("Please upgrade your browser to use full functionality on this page");
	        return false; }
	      }    }
	    xmlHttp.onreadystatechange=function()
	    {
//  Aqui se recibe el resultado de la creación del XML
    if(xmlHttp.readyState==4)
    {
    	respuesta=xmlHttp.responseText;
	document.getElementById('Contenedor').innerHTML=respuesta;
    }
	}
	lblReportType = '';
	URL="asp/getDatos.asp?sLeng="+sIdioma;
	xmlHttp.open("POST",URL,true);
	xmlHttp.send(null);
}

function disableEnterKey(e)
{
     var key;

     if(window.event)
          key = window.event.keyCode;    	 //IE
     else
          key = e.which;     			//firefox

     if(key == 13)
          return false;
     else
          return true;
}
function CompruebaEntrada()
  {
  var xmlHttp;
  var respuesta;
  try    {      // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();    }
  catch (e)    {      // Internet Explorer
    try       {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");      }
    catch (e)       {
      try         {
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");         }
      catch (e)         {
        alert("Please upgrade your browser to use full functionality on this page");
        return false;   }
      }
    }
    xmlHttp.onreadystatechange=function()
      {
      if(xmlHttp.readyState==4)
        {
        var sReturn=xmlHttp.responseText
        if (sReturn == '1'){
		respuesta = "Login correcto. ";
		window.location.href="Entrada.htm";
	} else if (sReturn == '3') {
			respuesta = "Falta usuario/contraseña";
			document.getElementById("usuario").focus();
		} else {
			respuesta = "Usuario/Contraseña no correcto";
			document.getElementById("contras").focus();
			document.getElementById("contras").select();
		}
	document.getElementById("info").innerText=respuesta;
        }
      }
    usuario  = document.forms.Formulario_Acceso.usuario.value;
    contras  = document.forms.Formulario_Acceso.contras.value;
    URL="asp/comprobarUsuario.asp?usuario=" + usuario + "&contras=" + contras;
    xmlHttp.open("POST",URL,true);
    xmlHttp.send(null);
  } 
  
function MuestraCaja(){
    $('cajaUser').show();
    center('UserBox');
    document.getElementById("bEnterUserPassword").style.visibility="visible"; 
    document.getElementById("info").innerText='';
    document.getElementById("contras").disabled=false
    document.getElementById("usuario").disabled=false
    return false;
}


function CompruebaUsuario()
{
  {
  var xmlHttp;
  var respuesta;
  try{ // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();}
  catch (e){// Internet Explorer
    try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");}
    catch (e){ 
    	try {xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");}
      catch (e){
        alert("Por favor actualiza tu navegador para poder utilizar las funciones de la pagina");
        return false; }
      }    }
    xmlHttp.onreadystatechange=function()
    {
//  Aqui se recibe el resultado de si es válido el usuario o no
    if(xmlHttp.readyState==4)
    {
    	respuesta=xmlHttp.responseText;
    	//alert(respuesta);
    	if (respuesta=='N')
    	{
    		window.location.href="Acceso.htm"; 
    	}
    }
    }
    URL="asp/SesionValida.asp";
    xmlHttp.open("POST",URL,true);
    xmlHttp.send(null);
  }
}

function center(element){
    try{
        element = $(element);
    }catch(e){
        return;
    }

    var my_width  = 0;
    var my_height = 0;

    if ( typeof( window.innerWidth ) == 'number' ){
        my_width  = window.innerWidth;
        my_height = window.innerHeight;
    }else if ( document.documentElement && 
             ( document.documentElement.clientWidth ||
               document.documentElement.clientHeight ) ){
        my_width  = document.documentElement.clientWidth;
        my_height = document.documentElement.clientHeight;
    }
    else if ( document.body && 
            ( document.body.clientWidth || document.body.clientHeight ) ){
        my_width  = document.body.clientWidth;
        my_height = document.body.clientHeight;
    }

    element.style.position = 'absolute';
    element.style.zIndex   = 99;

    var scrollY = 0;

    if ( document.documentElement && document.documentElement.scrollTop ){
        scrollY = document.documentElement.scrollTop;
    }else if ( document.body && document.body.scrollTop ){
        scrollY = document.body.scrollTop;
    }else if ( window.pageYOffset ){
        scrollY = window.pageYOffset;
    }else if ( window.scrollY ){
        scrollY = window.scrollY;
    }

    var elementDimensions = Element.getDimensions(element);

    var setX = ( my_width  - elementDimensions.width  ) / 2;
    var setY = ( my_height - elementDimensions.height ) / 2 + scrollY;

    setX = ( setX < 0 ) ? 0 : setX;
    setY = ( setY < 0 ) ? 0 : setY;

    element.style.left = setX + "px";
    element.style.top  = setY + "px";

    element.style.display  = 'block';
}

function Refrescar(sLeng)
{
  	var xmlHttp;
	var respuesta;
	  try{ // Firefox, Opera 8.0+, Safari
	    xmlHttp=new XMLHttpRequest();}
	  catch (e){// Internet Explorer
	    try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");}
	    catch (e){ 
	    	try {xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");}
	      catch (e){
	        alert("Please upgrade your browser to use full functionality on this page");
	        return false; }
	      }    }
	    xmlHttp.onreadystatechange=function()
	    {
	    	
//  Aqui se recibe el resultado de la creación del XML
    if(xmlHttp.readyState==4)
    {
    	respuesta=xmlHttp.responseText;
	document.getElementById('DivCentro').innerHTML=respuesta;
    }
	}
	lblReportType = '';
	URL="asp/getNovedades.asp?sLeng="+sLeng;
	xmlHttp.open("POST",URL,true);
	xmlHttp.setRequestHeader("Content-Length", 5124);
	xmlHttp.send("");
}
function RefrescarANT(sLeng)
{
  	var xmlHttp;
	var respuesta;
	  try{ // Firefox, Opera 8.0+, Safari
	    xmlHttp=new XMLHttpRequest();}
	  catch (e){// Internet Explorer
	    try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");}
	    catch (e){ 
	    	try {xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");}
	      catch (e){
	        alert("Please upgrade your browser to use full functionality on this page");
	        return false; }
	      }    }
	    xmlHttp.onreadystatechange=function()
	    {
	    	
//  Aqui se recibe el resultado de la creación del XML
    if(xmlHttp.readyState==4)
    {
    	respuesta=xmlHttp.responseText;
	document.getElementById('DivCentro').innerHTML=respuesta;
    }
	}
	lblReportType = '';
	URL="asp/getNovedadesAnt.asp?sLeng="+sLeng;
	xmlHttp.open("POST",URL,true);
	xmlHttp.setRequestHeader("Content-Length", 5124);
	xmlHttp.send("");
}


function cargaContenidoProductos(sLeng)
{
  	var xmlHttp;
	var respuesta;
	  try{ // Firefox, Opera 8.0+, Safari
	    xmlHttp=new XMLHttpRequest();}
	  catch (e){// Internet Explorer
	    try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");}
	    catch (e){ 
	    	try {xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");}
	      catch (e){
	        alert("Please upgrade your browser to use full functionality on this page");
	        return false; }
	      }    }
	    xmlHttp.onreadystatechange=function()
	    {
	    	
//  Aqui se recibe el resultado de la creación del XML
    if(xmlHttp.readyState==4)
    {
    	respuesta=xmlHttp.responseText;
    	//alert(respuesta);
	document.getElementById('DivTabla').innerHTML=respuesta;
    }
	}
	URL="asp/getProductos.asp?sLeng="+sLeng;
	xmlHttp.open("POST",URL,true);
	xmlHttp.setRequestHeader("Content-Length", 5124);
	xmlHttp.send("");
}
