	    var agt=navigator.userAgent.toLowerCase();
	    var is_major = parseInt(navigator.appVersion);
	    var is_minor = parseFloat(navigator.appVersion);
	
	    var is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
	                && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
	                && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1));
	    var is_nav4 = (is_nav && (is_major == 4));
	    var is_nav6 = (is_nav && (is_major == 5));
	    var is_nav6up = (is_nav && (is_major >= 5));
	    var is_ie     = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));

		

function popup(url,nombre,ancho,alto)
{
	window.open (url,nombre,'toolbar=no,resizable=no,top=10,left=20,width='+ancho+',height='+alto+',scrollbars=no');
}

function isDateLong(Cadena){
	var Fecha= new String(Cadena)	// Crea un string
	var RealFecha= new Date()	// Para sacar la fecha de hoy
	if(Fecha.indexOf("-")>0)
	{
		// Cadena Año
		var Ano= new String(Fecha.substring(Fecha.lastIndexOf("-")+1,Fecha.length))
		// Cadena Mes
		var Mes= new String(Fecha.substring(Fecha.indexOf("-")+1,Fecha.lastIndexOf("-")))
		// Cadena Día
		var Dia= new String(Fecha.substring(0,Fecha.indexOf("-")))
	}
	else
	{
		// Cadena Año
		var Ano= new String(Fecha.substring(Fecha.lastIndexOf("/")+1,Fecha.length))
		// Cadena Mes
		var Mes= new String(Fecha.substring(Fecha.indexOf("/")+1,Fecha.lastIndexOf("/")))
		// Cadena Día
		var Dia= new String(Fecha.substring(0,Fecha.indexOf("/")))
	}

	// Valido el año
	if (isNaN(Ano) || Ano.length<4 || parseFloat(Ano)<1900){
		return false
	}
	// Valido el Mes
	if (isNaN(Mes) || parseFloat(Mes)<1 || parseFloat(Mes)>12){
		return false
	}
	// Valido el Dia
	if (isNaN(Dia) || parseFloat(Dia)<1 || parseFloat(Dia)>31){
		return false
	}
	if (Mes==4 || Mes==6 || Mes==9 || Mes==11 || Mes==2) {
		if (Mes==2 && Dia > 28 || Dia>30) {
			return false
		}
	}

  //para que envie los datos, quitar las  2 lineas siguientes
  return true;
}


function isEmpty(pcStr)
{
		var rExp = /^[\s]*/
		return pcStr.replace(rExp,'').length == 0
}


function isNum(pnNum)
	{
		if(isEmpty(pnNum)) return false
		return !isNaN(pnNum)
	}

function isMail(psMail)
	{
		var rExp =/^[^@\s]+@[^@\.\s]+(\.[^@\.\s]+)+$/
		return rExp.test(psMail)
	}



function selectChk(poForm)
	{
		var iCount, count = new Number();
		for(iCount=0; iCount<poForm.elements.length; iCount++)
			{
				with(poForm.elements[iCount])
					{
						if(type=='checkbox')
							{
								checked = !checked
							}
					}
			}
		return count;
	}

function getChkSel(poForm)
	{
		var iCount, count = new Number();
		for(iCount=0; iCount<poForm.elements.length; iCount++)
			{
				with(poForm.elements[iCount])
					{
						if(type=='checkbox')
							{
								if(checked) count++;
							}
					}
			}
		return count;
	}

function getChkTxt(poForm)
	{
		var iCount, Id = new String();
		for(iCount=0; iCount<poForm.elements.length; iCount++)
			{
				with(poForm.elements[iCount])
					{
						if(type=='checkbox')
							{
								if(checked) Id= Id + value + ',';
							}
					}
			}
		return Id.substring(0, Id.length-1);
	}
	
function IsImage(str)
{
	if(str.toLowerCase().substring(str.length-3) != "gif" &&  str.toLowerCase().substring(str.length-3) != "jpg")
		return false;
	else
		return true;
}

function ImgOpen(url) {
	win = window.open(url, '', 'location=no toolbars=no width=200 height=200 left=100 top=100 resizable=no');
	win.document.open();
	win.document.write('<HEAD><TITLE>Imagen</TITLE><STYLE>body { margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px;</STYLE>');
	win.document.write('<SCRIPT language=javascript> function autosize() { img=document.obrazek; window.resizeTo(img.width + 12, img.height + 38); }</SCRIPT></HEAD>');
	win.document.write('<BODY onload="autosize()"><IMG name="obrazek" onclick="window.close()" border=0 src="' + url + '"></BODY>');
	win.document.close();
}
	
function Roll(id, path)
{
	document.getElementById(id).src = path;
}		
	
//
// ToolTip
//
var offsetX = 0;
var offsetY = 5;
var opacity = 100;
var toolTipSTYLE;

function initToolTips(){
  if(document.getElementById){
          toolTipSTYLE = document.getElementById("toolTipLayer").style;
  }
  if(is_ie || is_nav6up)
  {
    if(toolTipSTYLE != null)
    {
    	toolTipSTYLE.visibility = "visible";
    	toolTipSTYLE.display = "none";
    	document.onmousemove = moveToMousePos;
    }
  }
}
function moveToMousePos(e)
{
  if(!is_ie){
    x = e.pageX;
    y = e.pageY;
  }else{
    x = event.x + document.body.scrollLeft;
    y = event.y + document.body.scrollTop;
  }

  toolTipSTYLE.left = x + offsetX+'px';
  toolTipSTYLE.top = y + offsetY+'px';
  return true;
}


function toolTip(msg, fg, bg)
{
  if(toolTip.arguments.length < 1) // if no arguments are passed then hide the tootip
  {
  	if(toolTipSTYLE != null)
	{  	
	    if(is_nav4)
	        toolTipSTYLE.visibility = "hidden";
	    else
	        toolTipSTYLE.display = "none";
	}
  }
  else // show
  {
    if(!fg) fg = "#ffffff";
    if(!bg) bg = "#ffffff";
    var content = '<table style="border:1px solid #939598" cellspacing="0" cellpadding="0" class="toolTip"><tr><td bgcolor="' + fg + '">' +
                                  '<table border="0" cellspacing="0" cellpadding="0"<tr><td bgcolor="' + bg + '">'+
                                  '<font face="sans-serif" color="' + fg + '" size="-2">' + msg +
                                  '</font></td></tr></table>'+
                                  '</td></tr></table>';
   if(is_nav4)
    {
      toolTipSTYLE.document.write(content);
      toolTipSTYLE.document.close();
      toolTipSTYLE.visibility = "visible";
    }

    else if(is_ie || is_nav6up)
    {
       document.getElementById("toolTipLayer").innerHTML = content;
       if(toolTipSTYLE != null)
	   	toolTipSTYLE.display='block'
	   
    }
  }
}

	
function Combo(myHeight, comboText, multi, adjustButton, adjustDiv)
{
	var comboObject = this;
	comboObject.version = '0.5';
	var textValues = new Array();
	var newText;
	var comboIDS = 0;
	comboObject.value = -1;
	
	//Create our combo box elements
	var comboDiv = document.createElement('div');
	var comboFrame = document.createElement('iframe');
	var comboButton = document.createElement('input');
	
	//Set our styles, positioning, etc.
	//The text box we are converting
	
	comboText.style.position = 'relative';
	comboText.setAttribute('autocomplete', 'off');
	//Combo Div.  Container for the options
	comboDiv.style.position = 'absolute';
	comboDiv.style.display = 'none';
	comboDiv.style.zIndex = '101';
	comboDiv.style.backgroundColor = '#ffffff';
	comboDiv.style.border = '1px solid #CCCCCD';
	comboDiv.style.overflow = 'auto';
	comboDiv.style.height = myHeight + 'px';
	comboDiv.style.width = comboText.offsetWidth + 'px';
	//Combo Button.  Displays/hides the combo div
	comboButton.type = 'image';
	comboButton.src = 'img/imCombo.jpg';
	comboButton.style.textAlign = 'center';
	comboButton.style.position = 'absolute';
	comboButton.style.height = comboText.offsetHeight + 'px';
	//comboButton.style.border = '1px groove #000000';
	comboButton.value = '...';
	comboButton.style.width = '20px';
	comboButton.style.zIndex = '100';
	comboButton.style.padding = '0px';
	//Combo Frame.  Used to hide form elements in IE
	comboFrame.style.position = 'absolute';
	comboFrame.style.display = 'none';
	comboFrame.style.zIndex = '100';
	comboFrame.src = 'javascript:void(0)';
	comboFrame.style.width = comboText.offsetWidth + 'px';
	comboFrame.style.height =  myHeight - 1 + 'px';
	comboFrame.frameBorder = '0';
	
	comboObject.Adjust = function()
	{
		comboDiv.style.left = comboText.offsetLeft + 'px';
		comboDiv.style.top = comboText.offsetTop + comboText.offsetHeight + 'px';
		comboFrame.style.left = comboText.offsetLeft + 'px';
		comboFrame.style.top = comboText.offsetTop + comboText.offsetHeight + 'px';
		comboButton.style.left = 20 + comboText.offsetLeft + comboText.offsetWidth - comboButton.offsetWidth +'px';
		comboButton.style.top = comboText.offsetTop + 'px';
	}
	
	//Hide the combobox if we click anywhere except our button.
	function hideCombo(e) 
	{
		e = (e == null) ? window.event : e;
		target = (e.target) ? e.target : e.srcElement;
		if(target == comboButton)
		{
			return;
		}
		else
		{
			comboDiv.style.display = 'none';
			comboFrame.style.display = 'none';
		}
	}

	comboObject.hideComboNow = function () 
	{
		comboDiv.style.display = 'none';
		comboFrame.style.display = 'none';
	}

	//Show matching items
	function showMatch() 
	{
		var divOptions = comboDiv.getElementsByTagName('div');
		if(comboText.value != "")
		{
			var noMatch = true;
			comboDiv.style.display = 'block';
			comboFrame.style.display = 'block';
			for(var i = 0; i < divOptions.length; i++)
			{
				if(divOptions[i].innerHTML.replace(/\<.*?\>/ig, '').toLowerCase().indexOf(comboText.value.toLowerCase()) != '-1')
				{
					noMatch = false;
					divOptions[i].style.display = 'block';
				}
				else
				{
					divOptions[i].style.display = 'none';
				}
			}
			if(noMatch)
			{
				comboDiv.style.display = 'none';
				comboFrame.style.display = 'none';
				comboText.value = "";
				return;
			}
		}
		else
		{
			for(var i = 0; i < divOptions.length; i++)
			{
					divOptions[i].style.display = 'block';
			}
			comboDiv.style.display = 'none';
			comboFrame.style.display = 'none';
		}
	}
	//Show the combo div and frame
	function showCombo()
	{
		var divOptions = comboDiv.getElementsByTagName('div');
		for(var i = 0; i < divOptions.length; i++)
		{
			divOptions[i].style.display = 'block';
		}
		if(comboDiv.style.display == 'none')
		{
			comboDiv.style.display = 'block';
			comboFrame.style.display = 'block'
		}
		else
		{
			comboDiv.style.display = 'none';
			comboFrame.style.display = 'none'		
		}
	}

	comboObject.setSelected = function(index)
	{
		if(index < 0)
			return;
		comboDiv.childNodes[index].onclick();
	}
	
	//Create divs for our options.
	comboObject.addOption = function(comboOptionText, comboOptionValue)
	{
		var comboOption = document.createElement('div')
		comboOption.innerHTML = comboOptionText;
		comboOption.value = comboOptionValue;
		comboOption.style.backgroundColor = '#ffffff';
		comboOption.style.color = '#939598';
		comboOption.style.cursor = 'pointer';
		comboOption.style.paddingLeft = '3px';
		comboOption.style.fontFamily = "Arial";
		comboOption.style.fontWeight = '600';
		comboOption.style.fontSize = "11px";
		comboOption.selected = false;
		comboOption.id = '_combo' + comboIDS;
		comboIDS++;
		comboOption.onmouseover = function()
		{
			if(comboOption.selected)
			{
				return;
			}
			comboOption.style.backgroundColor = '#CCCCCD';
			comboOption.style.color = '#939598';
			comboOption.style.fontWeight = '600';
			comboOption.style.fontFamily = "Arial";
			
		}
		comboOption.onmouseout = function()
		{
			if(comboOption.selected)
			{
				return;
			}
			comboOption.style.backgroundColor = '#CCCCCD';
			comboOption.style.backgroundColor = '#ffffff';
			comboOption.style.color = '#939598';
		}
		comboOption.onclick = function()
		{
			if(!multi)
			{
				if(document.all)
					comboText.value = comboOption.outerText;
				else
					comboText.value = comboOption.textContent;
				comboObject.value = comboOption.value;
				value = comboOption.value; 
				comboDiv.style.display = 'none';
				comboFrame.style.display = 'none';
				return;
			}
			comboOption.selected = (comboOption.selected) ? false : true ;
			comboOption.style.color = (!comboOption.selected) ? '#000000' : '#ffffff';
			comboOption.style.backgroundColor = (!comboOption.selected) ? '#ffffff' : '#333399';
			if(comboOption.selected)
			{
				newText = '';
				textValues[comboOption.id] = comboOption.value;
				for(var i in textValues)
				{
					if(textValues[i])
					{
						newText += textValues[i] + ',';
					}
				}
				comboText.value = newText.substring(0, newText.length - 1);
			}
			else
			{
				delete textValues[comboOption.id];
				newText = '';
				for(var i in textValues)
				{
					if(textValues[i])
					{
						newText += textValues[i] + ',';
					}
				}
				comboText.value = newText.substring(0, newText.length - 1);
			}
		}
		comboDiv.appendChild(comboOption);
	}
	
	comboObject.deleteOptions = function(index)
	{
		if(typeof(index) == 'number')
		{
			if(comboDiv.childNodes[index])
			{
				delete textValues[comboDiv.childNodes[index].id];
				comboDiv.removeChild(comboDiv.childNodes[index]);
			}
		}
		else
		{
			while(comboDiv.firstChild)
			{
				comboDiv.removeChild(comboDiv.firstChild);
			}
			textValues = [];
			comboIDS = 0;
		}
	}
	
		
	//Set our callbacks/functions.
	if(window.addEventListener)
	{
		window.addEventListener('resize', function(){comboObject.Adjust()}, false);
		comboText.addEventListener('keyup', function(){showMatch()}, false);
		comboButton.addEventListener('click', function(){showCombo()}, false);
		if(!multi)
		{
			window.addEventListener('click', function(e){hideCombo(e)}, false);
		}
		
	}
	else
	{
		window.onresize = function(){comboObject.Adjust()};
		comboText.onkeyup = function(){showMatch()};
		comboButton.onclick = function(){showCombo()};
		if(!multi)
		{
			document.onclick = function(e){hideCombo(e)};
		}
	}
	
	//Draw our stuff
	document.body.appendChild(comboDiv);
	document.body.appendChild(comboFrame);
	document.body.appendChild(comboButton);
	comboObject.Adjust();
}
	
	
function PreloadImage(path)
{
	var imgs
	Imgs = new Image();
	Imgs.src = path;
}
	
	
var offsetX = 0;
var offsetY = 5;
var opacity = 100;
var toolTipSTYLE;

function initToolTips(){
  if(document.getElementById){
          toolTipSTYLE = document.getElementById("toolTipLayer").style;
  }
  if(is_ie || is_nav6up)
  {
    if(toolTipSTYLE != null)
    {
    	toolTipSTYLE.visibility = "visible";
    	toolTipSTYLE.display = "none";
    	document.onmousemove = moveToMousePos;
    }
  }
}
function moveToMousePos(e)
{
  if(!is_ie){
    x = e.pageX;
    y = e.pageY;
  }else{
    x = event.x + document.body.scrollLeft;
    y = event.y + document.body.scrollTop;
  }

  toolTipSTYLE.left = x + offsetX+'px';
  toolTipSTYLE.top = y + offsetY+'px';
  return true;
}


function toolTip(msg, fg, bg)
{
  if(toolTip.arguments.length < 1) // if no arguments are passed then hide the tootip
  {
  	if(toolTipSTYLE != null)
	{  	
	    if(is_nav4)
	        toolTipSTYLE.visibility = "hidden";
	    else
	        toolTipSTYLE.display = "none";
	}
  }
  else // show
  {
    if(!fg) fg = "#ffffff";
    if(!bg) bg = "#ffffff";
    var content = '<table style="border:1px solid #939598" cellspacing="0" cellpadding="0" class="toolTip"><tr><td bgcolor="' + fg + '">' +
                                  '<table border="0" cellspacing="0" cellpadding="0"<tr><td bgcolor="' + bg + '">'+
                                  '<font face="sans-serif" color="' + fg + '" size="-2">' + msg +
                                  '</font></td></tr></table>'+
                                  '</td></tr></table>';
   if(is_nav4)
    {
      toolTipSTYLE.document.write(content);
      toolTipSTYLE.document.close();
      toolTipSTYLE.visibility = "visible";
    }

    else if(is_ie || is_nav6up)
    {
       document.getElementById("toolTipLayer").innerHTML = content;
       if(toolTipSTYLE != null)
	   	toolTipSTYLE.display='block'
	   
    }
  }
}

function ShowToolTip(text, libro)
{
	s = '<table width="100%" cellspacing="0" cellpadding="0" border="0">';
	s += '<tr><td class="Text">' + '' + '</td></tr>';
	s += '<tr><td><img src="fotolibro.php?idlibro=' + libro+ '&w=200&h=200" border="0"/></td></tr>';
	s += '</table>'
	toolTip(s);
}
	