var valuebot="...";


function checkChk(form,esto,max) {
	var chch= 0;	
	if(esto.checked==true)
	{
		for (i = 0, n = form.elements.length; i < n; i++)
		{
			if(form.elements[i].checked == true) chch++; 
			if (chch > max) {
				alert('Selecciona un máximo de ' + max + ' categorías');
				break;
			}
		}
	}
 }	

function checkAll(form,esto) {
	if(esto.checked==true)
	{
		for (i = 0, n = form.elements.length; i < n; i++)
		{
			if(form.elements[i].type == "checkbox" && form.elements[i].disabled == false && !(form.elements[i].getAttribute('onclick',2))) {
				form.elements[i].checked = true;
			}
		}
	}
	else
	{
		for (i = 0, n = form.elements.length; i < n; i++)
		{
			if(form.elements[i].type == "checkbox" && !(form.elements[i].getAttribute('onclick',2))) {
				form.elements[i].checked = false;
			}
		}	
	}

}


function checkElim(form,name) {
	var seleccionado=false;
	for (i = 0, n = form.elements.length; i < n; i++) {
		if(form.elements[i].type == "checkbox" && !(form.elements[i].getAttribute('onclick',2))) {
			if(form.elements[i].checked == true)
			{
				seleccionado=true;
				break;
			}
		}
	}
	if(seleccionado==true)
	{
		if(window.confirm('¿Estás seguro que deseas eliminar las entradas seleccionadas?')){name.value=name.value+valuebot;}
	}
	else
	{
		alert('No has seleccionado nada');
	}
}


function procesar(e, name, elim)
	{
		if(elim==true)
		{
			if(window.confirm('¿Estás seguro?')) name.value=name.value+valuebot;
		}
		else
		{
			name.value=name.value+valuebot;
		}
	
	}

function recColor(hex)
{
	var recuadro= document.getElementById("recuadro");
	if(recuadro) {recuadro.style.backgroundColor="#"+hex;}
	
}	

function redirect(href)
{
	if(href==false) return;
	window.location=href;
}


function initPopupLinks()
{
  if (!document.getElementsByTagName) return true;
  var pageLinks = document.getElementsByTagName("a");
  for (var i = 0; i < pageLinks.length; i++) 
  {
    if (((pageLinks[i].className != null) && 
         (pageLinks[i].className != "")) ||
        ((pageLinks[i].parentNode.className != null) && 
         (pageLinks[i].parentNode.className != "")))
    {
      var linkClass = " " + pageLinks[i].className + " ";
      if ((linkClass == "  ") && (pageLinks[i].parentNode.className != ""))
      {
        linkClass = " " + pageLinks[i].parentNode.className + " ";
      }
      for (var theKey in popupLinkConfig) 
      {
        if (linkClass.indexOf(" " + theKey + " ") > -1)
        {
          if ((pageLinks[i].target == "") || (pageLinks[i].target == null))
          {
            pageLinks[i].target = (popupLinkConfig[theKey][0] != "") ? popupLinkConfig[theKey][0] : theKey;
          }
          pageLinks[i].settings = popupLinkConfig[theKey][1];
          pageLinks[i].onclick = popUp;
        }
      }
    }
  }
  return true;
}

function popUp()
{
  newWin = window.open(this.href, this.target, this.settings);
  newWin.focus();
  return false;
} 

var popupLinkConfig = new Array;
// Delete/copy/modify the following lines to configure your popup windows.
popupLinkConfig["popup"] = new Array ( "Condiciones", "width=350,height=450,scrollbar=yes,menubar=no");
popupLinkConfig["glossary"] = new Array ( "help", "width=550,height=350,resizable=no,scrollbars=no");


function hUsu()
{
 if (!document.getElementById("cli")) return false;
   var cli=document.getElementById("cli");
   cli.onfocus= function() {
   if(cli.value=="usuario") cli.value="";
   }
   cli.onblur= function() {
   if(cli.value=="") cli.value="usuario";
   }
}


function getInternetExplorerVersion()
// Returns the version of Internet Explorer or a -1
// (indicating the use of another browser).
{
  var rv = -1; // Return value assumes failure.
  if (navigator.appName == 'Microsoft Internet Explorer')
  {
    var ua = navigator.userAgent;
    var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
    if (re.exec(ua) != null)
      rv = parseFloat( RegExp.$1 );
  }
  return rv;
}
function checkVersion()
{
  var msg = "You're not using Internet Explorer.";
  var ver = getInternetExplorerVersion();
  if(document.getElementById('stopie6')) var docie=document.getElementById('stopie6');

  if ( ver > -1 )
  {
    if (ver >= 7.0) {
		msg = "You're using a recent copy of Internet Explorer.";
	}
	else {
		if(docie) docie.className = 'stopie6';
		if(docie) docie.innerHTML = '<strong>Importante:</strong> Su navegador es la versión 6 o inferior de Internet Explorer. Ésto puede suponer un importante riesgo de seguridad. Por favor actualize su navegador o instale alguno de los excelentes navegadores disponibles: <a href="http://www.mozilla-europe.org/es/firefox/" target="_blank"><strong>Firefox</strong></a>, <a href="http://www.google.com/chrome" target="_blank"><strong>Chrome</strong></a>, <a href="http://www.opera.com/" target="_blank"><strong>Opera</strong></a>, <a href="http://www.apple.com/es/safari/" target="_blank"><strong>Safari</strong></a>,.. ';
	}
  }
  //alert( msg );
}
