//document.onmousedown=right;
// if(document.layers)window.captureEvents
//   (Event.MOUSEDOWN);
//window.onmousedown=right;
//window.onContextMenu="return false";
//document.onContextMenu="return false";
function right(e)
  {
  if(navigator.appName=='Netscape'&& (e.which==3||e.which==2))
     return false;
     else 
      if(navigator.appName=='Microsoft Internet Explorer'&&(event.button==2||event.button==3))
        { return false;}
     return true;
   }

function sacarFrame(x,y,srcaux,idFrameAux)
  {
    if (idFrameAux){
    idFrameAux.style.left=x;
    idFrameAux.style.top=y;
	if (idFrameAux.style.visibility!="visible"){
	    idFrameAux.src=srcaux;
	    idFrameAux.style.visibility="visible";
	    }
	}    
   }
	
function estado(texto)
   {
     window.defaultStatus=texto;
   }
function dentro (obj,color)
   {
     if (color==null)
       color='#add8e6'
     obj.style.background=color;
     obj.style.CURSOR="hand";
   }
function fuera (obj,color)
   {
     if (color==null)
          color='#33cc99'
     obj.style.background=color;
     obj.style.CURSOR="crosshair";
   }
   
function right(e)
  {
  if(navigator.appName=='Netscape'&& (e.which==3||e.which==2))
     return false;
     else 
      if(navigator.appName=='Microsoft Internet Explorer'&&(event.button==2||event.button==3))
        { 
           alert("[ Boton derecho del raton desabilitado ] (Mapfre Asistencia)® 2002");
           return false;
       }
     return true;
   }

function verdatos(pagina)
{
  window.parent.frames['datos'].location.href=pagina; 
}


function LimitarTexto(field, len) 
{
if (field.value.length > len) 
   field.value = field.value.substring(0, len);
}

function activar(tiempo)
{
 self.focus();
 if (navigator.appName == 'Microsoft Internet Explorer')
	{
	  setTimeout('activar()',tiempo);
	}
	else 
	 {
	  setTimeout('activar()',tiempo/30);
	 }
 }

 function abrir(url,nombre,ancho,alto,left,top)
 {
 	
  window.open(url,nombre,"alwaysRaised=1,scrollbars=0,toolbar=0,menubar=0,directories=0,status=0,width=" + ancho + ",height=" + alto + ",top=" + top +",left=" + left);
  return false;
 }


/*
	Ejemplo de llamada al método: 
	//Array con los nombres de las varibles a pasar
	var param_c = new Array("cdCarpeta","cdIndice","cdApartado","idSecuenc","idDocumentum");
	//Array con los valores de las variables en el mismo orden
	var param_v = new Array(cdCarpeta_param,cdIndice_param,cdApartado_param,idSecuenc_param,idDocumentum_param);	
	//Llamada al método
	openWindowWithPost('<bean:write name="beanParametros" property="uri"/>verDocumentoComercial.do',param_c,param_v,'DescargaDocumento','alwaysRaised=1,scrollbars=yes,resizable=yes,toolbar=0,menubar=0,directories=0,status=0,width=500,height=500,top=30,left=30');
*/
function openWindowWithPost(url, keys, values, name, info)
{
	var sData = "<html><head></head><body><form name='formid' id='formid' action='" + url + "' method='post'>";
	for (var i=0; i < keys.length; i++)
		sData += "<input type='hidden' name='" + keys[i] + "' value='" + values[i] + "'/>";
    sData = sData + "</form><script type='text/javascript'>document.getElementById('formid').submit();</sc" + "ript></body></html>";
    OpenWindow=window.open("", name, info);
    OpenWindow.document.write(sData);
    OpenWindow.document.close();
}

function checBox(formulario, valorSelect, valorNoSelect){
	var elementos = formulario.elements;
	var longitud = elementos.length;
	var i = 0;
	while ( i< longitud)
	{
		var elem = elementos[i];
		var tipo = elem.type;
		if ( tipo == 'checkbox' ){
            if (!elem.checked){
              elem.value=valorNoSelect;
              elem.checked=true;
            }
	    else{
                 elem.value=valorSelect;
		}
       }
       i++;
    }
    return true;
}
function genera_links(size, offset, length, action, anterior, siguiente)
{
	// Calculamos el nº de páginas para esta colección
	var numPages = (Math.floor(size / length))
                  + ((Math.floor(size % length) != 0) ? 1 : 0);
	var currentPage = (Math.floor(offset / length));
	var output = "";

	// Si es la primera página “Anterior” no tendrá enlace
	if (currentPage == 0)
	{
	     output += anterior +"\t";
	}
	// Si no, tendrá un link a la página anterior
	else
   {
       output += "<a href='" +action+ "?offset="
               + (Math.max((currentPage - 1), 0) * length)
               + "&length=" + length + "'>" + anterior + "\t"
               + "</a>";
	}

	// Ponemos una sucesión de números apuntando a cada página
	for (i = 0; i < numPages; i++)
	{
	     // La página actual no tiene enlace
	     if(i == currentPage)
	     {
	          output += (i + 1);
	     }
	     else
	     {
             output +=
                    "<a href='"+action+"?offset="
                    + (i * length) + "&length=" + length + "'>"
                    + (i + 1) + "</a>";
	     }
	     output += "\t";
	}
   // Si es la última página “Siguiente” no tendrá enlace
	if ((currentPage + 1) == numPages)
	{
	     output += siguiente;
	}
	// Si no, tendrá un link a la página siguiente
	else
	{
        output +=
               "<a href='"+action+"?offset="
               + (Math.min(currentPage + 1, numPages) * length)
               + "&length=" + length + "'>" + siguiente + "</a>";
   }

	return (output);
	
}

 function cambiarmenu(campo,clase){
      campo.className=clase;
 }


