<!--

function ventanaexpedientes(pagina,llarg,ample,barra){
   var propietats="toolbar=0, location=0, directories=0, menuBar="+barra+", resizable=0, left=25, top=25, scrollbars="+barra+", width="+ample+", height="+llarg;
   window.open(pagina, 'expedientes', propietats);
}


function tabular(tab,nombretab)
{
	for(i=0;i<10;i++)
		{
			num=i+1;
			if(document.getElementById('cont'+nombretab+num))
				{
					document.getElementById('cont'+nombretab+num).className='invisible';
					document.getElementById('link'+nombretab+num).className='noselect';
				}
		}	
	document.getElementById('cont'+tab).className='visible';
	document.getElementById('link'+tab).className='select';
}
function quetab(nombretab)
{
	enviado=location.href.split("#");
	temptab=enviado[1];
	
		
		
		if(document.getElementById('cont'+temptab))
		{
			if(temptab.substr(0,(temptab.length-1))==nombretab)
				{
					tab=temptab;
				}
			else
				{
					tab=nombretab+'1';
				}
		}
		else
		{
			tab=nombretab+'1';
		}
	
	return tab
}

function startab(nombretab)
{
	tabular(quetab(nombretab),nombretab);
}



//Código para asignar a un input oculto llamado accion el valor de 'Borrar'.
//----------------------------------
function BorrarDetalleCarro(i)
{ 
    
	if ( confirm("¿Estas seguro que quieres eliminarlo?") )
		
	{ 
       document.forms.listacesta.borrardetallecarro.value=i;
	   document.forms.listacesta.submit() 
    }
}
//----------------------------------

function BorrarDato(idform,idcampo,idborrar)
{ 
    
	if ( confirm("¿Estas seguro que quieres eliminarlo?") )
		
	{ 
       document.forms[idform].elements[idcampo].value=idborrar;
	   //document.getElementById(idcampo).value=idborrar;
	   document.getElementById(idform).submit() 
    }
}


//Código para asignar a un input oculto llamado accion el valor de 'Borrar'.
//----------------------------------
function BorrarPresupuesto(i)
{ 
    
	if ( confirm("¿Estas seguro que quieres eliminarlo?") )
		
	{ 
       document.forms.listadopresupuestos.borrarpresupuesto.value=i;
	   document.forms.listadopresupuestos.submit() 
    }
}
//----------------------------------

//Código para asignar a un input oculto llamado accion el valor de 'Borrar'.
//----------------------------------
function BorrarRegistroGrid(IDDATOS, TABLA)
{ 
    
	if ( confirm("¿Estas seguro que quieres eliminarlo?") )
		
	{ 
		self.location.href = '?IDDATOS='+IDDATOS+'&TB='+TABLA+'&ACCION=dformulario';
    }
}
//----------------------------------

var ie4 = (document.all) ? true : false;
var ns4 = (document.layers) ? true : false;
var ns6 = (document.getElementById && !document.all) ? true : false;

function obtenerValorCampo(nombreCampo){

	//Misión:
	//	Función encargada de devolver el valor de alguno de los campos del formulario.
	//
	//Parámetros entrada:
	//	* nombreCampo : nombre del campo cuyo valor se desea obtener.
	//
	//Parámetros salida:
	//	* Valor del campo.
	
	if (ns6)
		return document.getElementById([nombreCampo]).value;
	else	
		return document.all[nombreCampo].value;
	
}

function establecerValorCampo(nombreCampo, valor){

	//Misión:
	//	Función encargada de establecer el valor de alguno de los campos del formulario.
	//
	//Parámetros entrada:
	//	* nombreCampo : nombre del campo cuyo valor se desea modificar.
	//	* valo : valor que se desea guardar en el campo indicado.
	
	if (ns6)
		document.getElementById([nombreCampo]).value = valor;
	else	
		document.all[nombreCampo].value = valor;
	
	return true;
	
}

function masCantidad(strCampoCantidad, strCampoMultiplo){

	//Misión:
	//	Función encargda de incrementar el número de unidades del artículo indicado.
	//
	//Parámetros entrada:
	//	* strCampoCantidad : nombre del campo que guarda la cantidad actual del artículo 
	//		cuya cantidad se desea incrementar.
	//	* strCampoMultiplo : nombre del campo que guarda el dato 'múltiplo' del artículo
	//		cuya cantidad se desea incrementar.
		

	//Declaración de variables empleadas.
	var lngCantidad; //Cantidad actual del artículo.
	var lngMultiplo; //Valor múltiplo del artículo.
		
	
	//Obtenemos el valor múltiplo del artículo.
	lngMultiplo = Number(obtenerValorCampo(strCampoMultiplo));
	if (lngMultiplo < 1) lngMultiplo = 1;

	//Calculamos la nueva cantidad.	
	lngCantidad = Number(obtenerValorCampo(strCampoCantidad));
	if (lngCantidad < 99)
		establecerValorCampo(strCampoCantidad ,lngCantidad + lngMultiplo);
	
	//Actualizamos la cesta.
	if (x == null){
		x = setTimeout("document.listacesta.submit();", 500);
	}else{
		clearTimeout(x);
		x = setTimeout("document.listacesta.submit();", 500);
	}
	
}

function menosCantidad(strCampoCantidad, strCampoMultiplo){

	//Misión:
	//	Función encargada de decrementar las unidades del artículo indicado.
	//
	//Parámetros entrada:
	//	* strCampoCantidad : campo que guarda la cantidad actual del artículo.
	//	* strCampoMultiplo : campo que guarda el dato múltiplo del artículo.
	
	
	//Declaración de variables empleadas.
	var lngCantidad; //Cantidad actual del artículo.
	var lngMultiplo; //Valor múltiplo del artículo.

	
	//Obtenemos el valor múltiplo del artículo.
	lngMultiplo = Number(obtenerValorCampo(strCampoMultiplo));
	if (lngMultiplo < 1) lngMultiplo = 1;

	//Calculamos la nueva cantidad.
	lngCantidad = Number(obtenerValorCampo(strCampoCantidad));
	if (lngCantidad > 1){
		
		lngCantidad = lngCantidad - lngMultiplo;
		if (lngCantidad < 0) lngCantidad = 0;
	
		establecerValorCampo(strCampoCantidad, lngCantidad);
	}
	
	//Actualizamos la cesta.
	if (x == null){
		x = setTimeout("document.listacesta.submit();", 500);
	}else{
		clearTimeout(x);
		x = setTimeout("document.listacesta.submit();", 500);
	}

}
function ValidaCantidad(cantidad_botellas,objeto_texto){
	var cantidad_modif = objeto_texto.value;
	var division;

	if ( isNaN(cantidad_modif)){
		alert("Debe de introducir una cantidad numérica.");
		objeto_texto.value = cantidad_botellas;
		objeto_texto.focus();
		return false;
	}
	division = cantidad_modif/cantidad_botellas;
	division = new String(division);
	// Comprobamos que ha introducido una cantidad múltiplo de la  cantidad de embalaje
	if ( !isInt(division)){
		alert("La cantidad del producto deber ser múltiplo de "+ cantidad_botellas + ".");
		objeto_texto.focus();
		return false;
	}
}
function actualizar()		{
	document.listacesta.submit();
}
var x;



//##################################### Para ver imagenes en popup #############################


var offsetfrommouse=[15,15]; //image x,y offsets from cursor position in pixels. Enter 0,0 for no offset
var currentimageheight = 650;	// maximum image size.

if (document.getElementById || document.all){
	document.write('<div id="trailimageid">');
	document.write('</div>');
}

function gettrailobj(){
if (document.getElementById)
return document.getElementById("trailimageid").style
else if (document.all)
return document.all.trailimagid.style
}

function gettrailobjnostyle(){
if (document.getElementById)
return document.getElementById("trailimageid")
else if (document.all)
return document.all.trailimagid
}


function truebody(){
return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}
function showtrail(imagename,title,description,showthumb,height){

	if (height > 0){
		currentimageheight = height;
	}

	document.onmousemove=followmouse;

	newHTML = '<div id=ventanaimagen><div style="padding: 5px; background-color: #FFF; border: 1px solid #888;">';
	newHTML = newHTML + '<div id=titulo><font>' + title + '</font></div>';
	newHTML = newHTML + description + '<br/>';

	if (showthumb > 0){
		newHTML = newHTML + '<div align="center" style="padding: 8px 2px 2px 2px;"><img src="' + imagename + '" border="0"></div>';
	}

	newHTML = newHTML + '</div></div>';

	gettrailobjnostyle().innerHTML = newHTML;

	gettrailobj().visibility="visible";

}
function gettrailobj2(){
if (document.getElementById)
return document.getElementById("popup").style
else if (document.all)
return document.all.trailimagid.style
}
function gettrailobjnostyle2(){
if (document.getElementById)
return document.getElementById("popup")
else if (document.all)
return document.all.trailimagid
}

function showtrail2(url){

	document.onmousemove=followmouse2;
	ocultarselects();
	abrircontenidoajax(url);
	document.getElementById('popup').style.width="500px";
	gettrailobj2().visibility="visible";

}
function gettrailobj3(){
if (document.getElementById)
return document.getElementById("popup").style
else if (document.all)
return document.all.trailimagid.style
}
function gettrailobjnostyle3(){
if (document.getElementById)
return document.getElementById("popup")
else if (document.all)
return document.all.trailimagid
}
function showtrail3(imagename,title,description,showthumb,height){

	if (height > 0){
		currentimageheight = height;
	}
	document.getElementById('popup').style.width="200px";
	document.onmousemove=followmouse3;

	newHTML = ' ';
	newHTML = newHTML + '<div id=titulo><font>' + title + '</font></div>';
	newHTML = newHTML + '<div id=texto><font>' +description + '</font></div><br/>';

	if (showthumb > 0){
		newHTML = newHTML + '<div align="center" style="padding: 8px 2px 2px 2px;"><img src="' + imagename + '" border="0"></div>';
	}

	newHTML = newHTML + ' ';

	gettrailobjnostyle3().innerHTML = newHTML;

	gettrailobj3().visibility="visible";

}
function hidetrail3(){
	gettrailobj3().visibility="hidden"
	document.onmousemove=""
	gettrailobj3().left="-500px"
	gettrailobjnostyle3().innerHTML="<br/><br/><br/><div align='center'><img src='../Imagenes/cargando.gif'/></div><br/><br/><br/>";
}

function hidetrail2(){
	gettrailobj2().visibility="hidden"
	document.onmousemove=""
	gettrailobj2().left="-500px"
	mostrarselects();
	document.getElementById('popup').style.width="300px";
	gettrailobjnostyle2().innerHTML="<br/><br/><br/><div align='center'><img src='../Imagenes/cargando.gif'/></div><br/><br/><br/>";
}


function hidetrail(){
	gettrailobj().visibility="hidden"
	document.onmousemove=""
	gettrailobj().left="-500px"
	gettrailobjnostyle().innerHTML="<br/><br/><br/><div align='center'><img src='../Imagenes/cargando.gif'/></div><br/><br/><br/>";

}

function followmouse3(e){

	var xcoord=offsetfrommouse[0]
	var ycoord=offsetfrommouse[1]

	var docwidth=document.all? truebody().scrollLeft+truebody().clientWidth : pageXOffset+window.innerWidth-15
	var docheight=document.all? Math.min(truebody().scrollHeight, truebody().clientHeight) : Math.min(window.innerHeight)

	//if (document.all){
	//	gettrailobjnostyle().innerHTML = 'A = ' + truebody().scrollHeight + '<br>B = ' + truebody().clientHeight;
	//} else {
	//	gettrailobjnostyle().innerHTML = 'C = ' + document.body.offsetHeight + '<br>D = ' + window.innerHeight;
	//}
	
	//
	
	if (typeof e != "undefined"){
		if (docwidth - e.pageX < 200){
			xcoord = e.pageX - xcoord - 200; // Move to the left side of the cursor
		} else {
			xcoord += e.pageX;
		}
		if (docheight - e.pageY < (currentimageheight + 20)){
			ycoord += e.pageY - Math.max(0,(20 + currentimageheight + e.pageY - docheight - truebody().scrollTop));
		} else {
			ycoord += e.pageY;
		}

	} else if (typeof window.event != "undefined"){
		if (docwidth - event.clientX < 200){
			xcoord = event.clientX + truebody().scrollLeft - xcoord - 200; // Move to the left side of the cursor
		} else {
			xcoord += truebody().scrollLeft+event.clientX
		}
		if (docheight - event.clientY < (currentimageheight + 20)){
			ycoord += event.clientY + truebody().scrollTop - Math.max(0,(20 + currentimageheight + event.clientY - docheight));
		} else {
			ycoord += truebody().scrollTop + event.clientY;
		}
	}

	var docwidth=document.all? truebody().scrollLeft+truebody().clientWidth : pageXOffset+window.innerWidth-15
	var docheight=document.all? Math.max(truebody().scrollHeight, truebody().clientHeight) : Math.max(document.body.offsetHeight, window.innerHeight)
		if(ycoord < 0) { ycoord = ycoord*-1; }
	gettrailobj3().left=xcoord+"px"
	gettrailobj3().top=ycoord+"px"

}

function followmouse2(e){
var offsetfrommouse=[15,25]; 
//image x,y offsets from cursor position in pixels. Enter 0,0 for no offsetvar 
displayduration=5; 
//duration in seconds image should remain visible. 0 for always.var 
defaultimageheight = 300;   // maximum image size.var 
defaultimagewidth = 500;   // maximum image size.
var xcoord=offsetfrommouse[0]   
var ycoord=offsetfrommouse[1]   
var docwidth=document.all? truebody().scrollLeft+truebody().clientWidth : pageXOffset+window.innerWidth-15   
var docheight=document.all? Math.min(truebody().scrollHeight, truebody().clientHeight) : Math.min(window.innerHeight)   
if (typeof e != "undefined"){
      if (docwidth - e.pageX < defaultimagewidth + 2*offsetfrommouse[0]){    
	  xcoord = e.pageX - xcoord - defaultimagewidth; // Move to the left side of the cursor    
	  } else {         xcoord += e.pageX;      }     
	  if (docheight - e.pageY < defaultimageheight + 2*offsetfrommouse[1]){ 
	  ycoord += e.pageY - Math.max(0,(2*offsetfrommouse[1] + defaultimageheight + e.pageY - docheight - truebody().scrollTop));      } else {         ycoord += e.pageY;      }  
	  } else if (typeof window.event != "undefined"){      if (docwidth - event.clientX < defaultimagewidth + 2*offsetfrommouse[0]){     
	  xcoord = event.clientX + truebody().scrollLeft - xcoord - defaultimagewidth; // Move to the left side of the cursor    
	  } else {         xcoord += truebody().scrollLeft+event.clientX      }     
	  if (docheight - event.clientY < (defaultimageheight + 2*offsetfrommouse[1])){
	  ycoord += event.clientY + truebody().scrollTop - Math.max(0,(2*offsetfrommouse[1] + defaultimageheight + event.clientY - docheight));    
	  } else {         ycoord += truebody().scrollTop + event.clientY;      } 
	  }

	gettrailobj2().left=xcoord+"px"
	gettrailobj2().top=ycoord+"px"

}
function followmouse(e){

	var xcoord=offsetfrommouse[0]
	var ycoord=offsetfrommouse[1]

	var docwidth=document.all? truebody().scrollLeft+truebody().clientWidth : pageXOffset+window.innerWidth-15
	var docheight=document.all? Math.min(truebody().scrollHeight, truebody().clientHeight) : Math.min(window.innerHeight)

	//if (document.all){
	//	gettrailobjnostyle().innerHTML = 'A = ' + truebody().scrollHeight + '<br>B = ' + truebody().clientHeight;
	//} else {
	//	gettrailobjnostyle().innerHTML = 'C = ' + document.body.offsetHeight + '<br>D = ' + window.innerHeight;
	//}
	
	//
	
	if (typeof e != "undefined"){
		if (docwidth - e.pageX < 380){
			xcoord = e.pageX - xcoord - 650; // Move to the left side of the cursor
		} else {
			xcoord += e.pageX;
		}
		if (docheight - e.pageY < (currentimageheight + 210)){
			ycoord += e.pageY - Math.max(0,(210 + currentimageheight + e.pageY - docheight - truebody().scrollTop));
		} else {
			ycoord += e.pageY;
		}

	} else if (typeof window.event != "undefined"){
		if (docwidth - event.clientX < 380){
			xcoord = event.clientX + truebody().scrollLeft - xcoord - 650; // Move to the left side of the cursor
		} else {
			xcoord += truebody().scrollLeft+event.clientX
		}
		if (docheight - event.clientY < (currentimageheight + 210)){
			ycoord += event.clientY + truebody().scrollTop - Math.max(0,(210 + currentimageheight + event.clientY - docheight));
		} else {
			ycoord += truebody().scrollTop + event.clientY;
		}
	}

	var docwidth=document.all? truebody().scrollLeft+truebody().clientWidth : pageXOffset+window.innerWidth-15
	var docheight=document.all? Math.max(truebody().scrollHeight, truebody().clientHeight) : Math.max(document.body.offsetHeight, window.innerHeight)
		if(ycoord < 0) { ycoord = ycoord*-1; }
	gettrailobj().left=xcoord+"px"
	gettrailobj().top=ycoord+"px"

}

//Ocultar selects, embeds y objetos
function ocultarselects()
{
	var selectElems=document.getElementsByTagName('select');
	for(var i = 0; i < selectElems.length; ++i) 
	{
		selectElems[i].style.visibility = 'hidden';
	}
	var objectElems=document.getElementsByTagName('object');
	for(var i = 0; i < objectElems.length; ++i) 
	{
		objectElems[i].style.visibility = 'hidden';
	}
	var embedElems=document.getElementsByTagName('embed');
	for(var i = 0; i < embedElems.length; ++i) 
	{
		embedElems[i].style.visibility = 'hidden';
	}
}
//mostrar selects, embeds y objetos
function mostrarselects()
{
	var selectElems=document.getElementsByTagName('select');
	for(var i = 0; i < selectElems.length; ++i) 
	{
		selectElems[i].style.visibility = 'visible';
	}
	var objectElems=document.getElementsByTagName('object');
	for(var i = 0; i < objectElems.length; ++i) 
	{
		objectElems[i].style.visibility = 'visible';
	}
	var embedElems=document.getElementsByTagName('embed');
	for(var i = 0; i < embedElems.length; ++i) 
	{
		embedElems[i].style.visibility = 'visible';
	}
}

//averiguar el ancho y alto del navegador
function getViewportSize() { 
var x, y; 
if (self.innerHeight) { // MOS 
y = self.innerHeight; 
x = self.innerWidth; 
} else if (document.documentElement && document.documentElement.clientWidth) { // IE6 Strict 
x = document.documentElement.clientWidth; 
y = document.documentElement.clientHeight; 
} else if (document.body.clientHeight) { // IE quirks 
y = document.body.clientHeight; 
x = document.body.clientWidth; 
} 
return {x: x, y: y}; 
} //getViewportSize().x para visualizar


function Borrar(i)
{ 
    
	if ( confirm("¿Estas seguro que quieres eliminarlo?") )
		
	{ 
       document.forms.formulario.idborrar.value=i;
	   document.forms.formulario.submit() 
    }
}
function Verificar(i)
{ 
    
	if ( confirm("¿Estas seguro que quieres Verificarlo?") )
		
	{ 
       document.forms.formulario.verificar.value=i;
	   document.forms.formulario.submit() 
    }
}
function Editar(i)
{ 
       document.forms.formulario.ideditar.value=i;
	   document.forms.formulario.submit() 
}
function Nuevo()
{ 
       document.forms.formulario.nuevo.value=1;
	   document.forms.formulario.submit() 
}
function IndiceUp(i)
{ 
       document.forms.formulario.idup.value=i;
	   document.forms.formulario.submit() 
}
function IndiceDown(i)
{ 
       document.forms.formulario.iddown.value=i;
	   document.forms.formulario.submit() 
}


function abrirventanaajax(url,id){
	ocultarselects();
	espacio=(getViewportSize().x-700)/2;
	if (document.getElementById)
	{
		document.getElementById("ventanaajax").className='ventanacentro';
		document.getElementById('ventanaajax').style.left=espacio;
		document.getElementById('tapar').className='fondotodo';
		document.getElementById('tapar').style.height=document.getElementById('todo2').offsetHeight;
		abrirurlajax(url,id);
		
		//document.getElementById('ventanaajax').innerHTML=buscador;
	}
	else if (document.all)
	{
		document.all.ventanaajax
		document.all.ventanaajax.className='ventanacentro';
		document.all.ventanaajax.style.left=espacio;
		document.all.tapar.className='fondotodo';
		document.all.tapar.height=document.all.body.height;
		abrirurlajax(url,id);
		//document.all.ventanaajax.innerHTML=buscador;
	}
}
function cerrarventana()
	{
		mostrarselects();
		if (document.getElementById)
		{
			document.getElementById('ventanaajax').className='invisible';
			document.getElementById('tapar').className='invisible';
		}
		else if (document.all)
		{
			document.all.ventanaajax.className='invisible';
			document.all.tapar.className='invisible';
		}
	}
function cerrarventanaadmin()
	{
		mostrarselects();
		if (document.getElementById)
		{
			document.getElementById('ventanaajax').className='invisible';
			document.getElementById('tapar').className='invisible';
		}
		else if (document.all)
		{
			document.all.ventanaajax.className='invisible';
			document.all.tapar.className='invisible';
		}
		location.reload(false);
	}
function abrirurlajax(url,id)
	{// obtener contenido del buscador
	
	if (window.XMLHttpRequest)
	{
	var req3=new XMLHttpRequest();
	}
	else if (window.ActiveXObject)
	{
	var req3=new ActiveXObject("Microsoft.XMLHTTP");
	}
		req3.open("GET",url + "?ID="+id,false);
		req3.send(null);
	
		if (document.getElementById)
		{
		document.getElementById('ventanaajax').innerHTML=req3.responseText;
		}
		else if(document.all)
		{
		document.all.ventanaajax.innerHTML=req3.responseText;
		}
	}

function mostrar123(nombre)
{
	if (document.getElementById)
	{
		document.getElementById('1_'+nombre).className='invisible';
		document.getElementById('2_'+nombre).className='visible';
		document.getElementById('3_'+nombre).className='visible';
	}
}
function ocultar123(nombre)
{
	if (document.getElementById)
	{
		document.getElementById('1_'+nombre).className='visible';
		document.getElementById('2_'+nombre).className='invisible';
		document.getElementById('3_'+nombre).className='invisible';
	}
}	

/* ######################   Calendario ##########################  */

// Flooble Dynamic  Calendar. 
	// Copyright (c) 2004 by Animus Pactum Consulting Inc.
	//---------------------------------------------------------------------
	// You may use this code freely on your site as long as you do not make
	// modifications to it other than editing the stylesheet settings to 
	// make it fit your design. You may not remove this notice or any links
	// to flooble.com.
	// More information about this script is available at
	//    http://www.flooble.com/scripts/calendar.php
	//--Global Stuff-------------------------------------------------------
	var fc_ie = false;
	if (document.all) { fc_ie = true; }
	
	var calendars = Array();
	var fc_months = Array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');
	var fc_openCal;

	var fc_calCount = 0;
	
	function getCalendar(fieldId) {
		return calendars[fieldId];
	}
	
	function displayCalendarFor(fieldId) {
		var formElement = fc_getObj(fieldId);
		displayCalendar(formElement);
	}
	
	function displayCalendar(formElement) {
		if (!formElement.id) {
			formElement.id = fc_calCount++;
		} 
		var cal = calendars[formElement.id];
		if (typeof(cal) == 'undefined') {
			cal = new floobleCalendar();
			cal.setElement(formElement);
			calendars[formElement.id] = cal;
		}
		if (cal.shown) {
			cal.hide();
		} else {
			cal.show();
		}
	}
	
	function display3FieldCalendar(me, de, ye) {
		if (!me.id) { me.id = fc_calCount++; }
		if (!de.id) { de.id = fc_calCount++; }
		if (!ye.id) { ye.id = fc_calCount++; }
		var id = me.id + '-' + de.id + '-' + ye.id;
		var cal = calendars[id];
		if (typeof(cal) == 'undefined') {
			cal = new floobleCalendar();
			cal.setElements(me, de, ye);
			calendars[id] = cal;
		}
		if (cal.shown) {
			cal.hide();
		} else {
			cal.show();
		}
	}

	//--Class Stuff--------------------------------------------------
	function floobleCalendar() {
		// Define Methods
		this.setElement = fc_setElement;
		this.setElements = fc_setElements;
		this.parseDate = fc_parseDate;
		this.generateHTML = fc_generateHTML;
		this.show = fc_show;
		this.hide = fc_hide;
		this.moveMonth = fc_moveMonth;
		this.setDate = fc_setDate;
		this.formatDate = fc_formatDate;
		this.setDateFields = fc_setDateFields;
		this.parseDateFields = fc_parseDateFields;
		
		this.shown = false;
	}
	
	function fc_setElement(formElement) {
		this.element = formElement;
		this.format = this.element.title;
		this.value = this.element.value;
		this.id = this.element.id;
		this.mode = 1;
	}
	
	function fc_setElements(monthElement, dayElement, yearElement) {
		this.mElement = monthElement;
		this.dElement = dayElement;
		this.yElement = yearElement;
		this.id = this.mElement.id + '-' + this.dElement.id + '-' + this.yElement.id;
		this.element = this.mElement;
		if (fc_absoluteOffsetLeft(this.dElement) < fc_absoluteOffsetLeft(this.element)) {
			this.element = this.dElement;
		}
		if (fc_absoluteOffsetLeft(this.yElement) < fc_absoluteOffsetLeft(this.element)) {
			this.element = this.yElement;
		}
		if (fc_absoluteOffsetTop(this.mElement) > fc_absoluteOffsetTop(this.element)) {
			this.element = this.mElement;
		}
		if (fc_absoluteOffsetTop(this.dElement) > fc_absoluteOffsetTop(this.element)) {
			this.element = this.dElement;
		}
		if (fc_absoluteOffsetTop(this.yElement) > fc_absoluteOffsetTop(this.element)) {
			this.element = this.yElement;
		}

		this.mode = 2;
	}
	
	function fc_parseDate() {
		if (this.element.value) {
			this.date = new Date();
			var out = '';
			var token = '';
			var lastCh, ch;
			var start = 0;
			lastCh = this.format.substring(0, 1);
			for (i = 0; i < this.format.length; i++) {
				ch = this.format.substring(i, i+1);
				if (ch == lastCh) { 
					token += ch;
				} else {
					fc_parseToken(this.date, token, this.element.value, start);
					start += token.length;
					token = ch;
				}
				lastCh = ch;
			}
			fc_parseToken(this.date, token, this.element.value, start);
		} else {
			this.date = new Date();
		}
		if ('' + this.date.getMonth() == 'NaN') {
			this.date = new Date();
		}
	}	
	
	function fc_parseDateFields() {
		this.date = new Date();
		if (this.mElement.value) this.date.setMonth(fc_getFieldValue(this.mElement) - 1);
		if (this.dElement.value) this.date.setDate(fc_getFieldValue(this.dElement));
		if (this.yElement.value) this.date.setFullYear(fc_getFieldValue(this.yElement));
		if ('' + this.date.getMonth() == 'NaN') {
			this.date = new Date();
		}
	}
	
	function fc_setDate(d, m, y) {
		this.date.setYear(y);
		this.date.setMonth(m);
		this.date.setDate(d);
		if (this.mode == 1) {
			this.element.value = this.formatDate();
		} else {
			this.setDateFields();
		}
		this.hide();
	}
	
	function fc_setDateFields() {
		fc_setFieldValue(this.mElement, fc_zeroPad(this.date.getMonth() + 1));
		fc_setFieldValue(this.dElement, fc_zeroPad(this.date.getDate()));
		fc_setFieldValue(this.yElement, this.date.getFullYear());
	}
	
	function fc_formatDate() {
		var out = '';
		var token = '';
		var lastCh, ch;
		lastCh = this.format.substring(0, 1);
		for (i = 0; i < this.format.length; i++) {
			ch = this.format.substring(i, i+1);
			if (ch == lastCh) { 
				token += ch;
			} else {
				out += fc_formatToken(this.date, token);
				token = ch;
			}
			lastCh = ch;
		}
		out += fc_formatToken(this.date, token);
		return out;
	}
	
	function fc_show() {
		if (typeof(fc_openCal) != 'undefined') { fc_openCal.hide(); }
	
		if (this.mode == 1) {
			this.parseDate();
		} else {
			this.parseDateFields();
		}
		this.showDate = new Date(this.date.getTime());
		if (typeof(this.div) != 'undefined') {
			this.div.innerHTML = this.generateHTML();
		}
		
		if (typeof(this.div) == 'undefined') {
			this.div = document.createElement('DIV');
			this.div.style.position = 'absolute';
			this.div.style.display = 'none';
			this.div.className = 'fc_main';
			this.div.innerHTML = this.generateHTML();
			this.div.style.left = fc_absoluteOffsetLeft(this.element);
			this.div.style.top = fc_absoluteOffsetTop(this.element) + this.element.offsetHeight + 1;
			document.body.appendChild(this.div);
		}
		this.div.style.display = 'block';
		this.shown = true;
		fc_openCal = this;
	}
	
	function fc_generateHTML() {
		var html = '<TABLE><TR><TD CLASS="fc_head" COLSPAN="6"><DIV STYLE="float: right"><a class="fc_head" href="http://www.flooble.com/scripts/calendar.php" target="_blank">©</a></DIV>CALENDAR:</TD><TD CLASS="fc_date" onMouseover="this.className = \'fc_dateHover\';" onMouseout="this.className=\'fc_date\';" onClick="getCalendar(\'' + this.id + '\').hide();"><B>X</B></TD></TR>';
		html += '<TR><TD CLASS="fc_date" onMouseover="this.className = \'fc_dateHover\';" onMouseout="this.className=\'fc_date\';" onClick="getCalendar(\'' + this.id + '\').moveMonth(-12);"><B><<</B></TD><TD CLASS="fc_date" onMouseover="this.className = \'fc_dateHover\';" onMouseout="this.className=\'fc_date\';" onClick="getCalendar(\'' + this.id + '\').moveMonth(-1);"><B><</B></TD><TD COLSPAN="3" CLASS="fc_wk">' + fc_months[this.showDate.getMonth()] + ' ' + fc_getYear(this.showDate) + '</TD><TD CLASS="fc_date" onMouseover="this.className = \'fc_dateHover\';" onMouseout="this.className=\'fc_date\';" onClick="getCalendar(\'' + this.id + '\').moveMonth(1);"><B>></B></TD><TD CLASS="fc_date" onMouseover="this.className = \'fc_dateHover\';" onMouseout="this.className=\'fc_date\';" onClick="getCalendar(\'' + this.id + '\').moveMonth(12);"><B>>></B></TD></TR>';
		html += '<TR><TD WIDTH="14%" CLASS="fc_wk">Mo</TD><TD WIDTH="14%" CLASS="fc_wk">Tu</TD><TD WIDTH="14%" CLASS="fc_wk">We</TD><TD WIDTH="14%" CLASS="fc_wk">Th</TD><TD WIDTH="14%" CLASS="fc_wk">Fr</TD><TD class="fc_wknd" WIDTH="14%">Sa</TD><TD class="fc_wknd" WIDTH="14%">Su</TD></TR>';
		html += '<TR>';
		var dow = 0;
		var i, style;
		var totald = fc_monthLength(this.showDate);
		for (i = 0; i < fc_firstDOW(this.showDate); i++) {
			dow++;
			html += '<TD> </TD>';
		}
		for (i = 1; i <= totald; i++) {
			if (dow == 0) { html += '<TR>'; }
			if (this.showDate.getMonth() == this.date.getMonth() && this.showDate.getYear() == this.date.getYear() && this.date.getDate() == i) { 
				style = ' style="font-weight: bold;"';
			} else {
				style = '';
			}
			html += '<TD CLASS="fc_date" onMouseover="this.className = \'fc_dateHover\';" onMouseout="this.className=\'fc_date\';" onClick="getCalendar(\'' + this.id + '\').setDate(' + i + ', ' + this.showDate.getMonth() + ', ' + this.showDate.getFullYear() + ');" ' + style + '>' + i + '</TD>';
			dow++;
			if (dow == 7) {
				html += '</TR>';
				dow = 0;
			}
		}
		if (dow != 0) {
			for (i = dow; i < 7; i++) {
				html += '<TD> </TD>';
			}
		}
		html +='</TR>';
		html += '</TABLE>';
		return html;
	}
	
	function fc_hide() {
		if (this.div != false) {
			this.div.style.display = 'none';
		}
		this.shown = false;
		fc_openCal = undefined;
	}
	
	function fc_moveMonth(amount) {
		var m = this.showDate.getMonth();
		var y = fc_getYear(this.showDate);
		if (amount == 1)  {
			if (m == 11)  {
				this.showDate.setMonth(0);
				this.showDate.setYear(y + 1);
			} else {
				this.showDate.setMonth(m + 1);
			}
		} else if (amount == -1)  {
			if (m == 0)  {
				this.showDate.setMonth(11);
				this.showDate.setYear(y - 1);
			} else {
				this.showDate.setMonth(m - 1);
			}
		} else if (amount == 12) {
			this.showDate.setYear(y + 1);
		} else if (amount == -12) {
			this.showDate.setYear(y - 1);
		}
		this.div.innerHTML = this.generateHTML();
	}
	
	//--Utils-------------------------------------------------------------
	function fc_absoluteOffsetTop(obj) {
     	var top = obj.offsetTop;
     	var parent = obj.offsetParent;
     	while (parent != document.body) {
     		top += parent.offsetTop;
     		parent = parent.offsetParent;
     	}
     	return top;
     }
     
     function fc_absoluteOffsetLeft(obj) {
     	var left = obj.offsetLeft;
     	var parent = obj.offsetParent;
     	while (parent != document.body) {
     		left += parent.offsetLeft;
     		parent = parent.offsetParent;
     	}
     	return left;
     }
     
     function fc_firstDOW(date) {
     	var dow = date.getDay();
     	var day = date.getDate();
 		if (day % 7 == 0) return dow;
     	return (7 + dow - (day % 7)) % 7; 
     }
     
     function fc_getYear(date) {
     	var y = date.getYear();
     	if (y > 1900) return y;
     	return 1900 + y;
     }
     
     function fc_monthLength(date) {
		var month = date.getMonth();
		var totald = 30;
		if (month == 0 
			|| month == 2
			|| month == 4
			|| month == 6
			|| month == 7
			|| month == 9
			|| month == 11) totald = 31;
		if (month == 1) {
			var year = date.getYear();
			if (year % 4 == 0 && (year % 400 == 0 || year % 100 != 0))
		 		totald = 29;
			else
				totald = 28;
		}
		return totald;
     }
     
     function fc_formatToken(date, token) {
		var command = token.substring(0, 1);
		if (command == 'y' || command == 'Y') {
			if (token.length == 2) { return fc_zeroPad(date.getFullYear() % 100); }
			if (token.length == 4) { return date.getFullYear(); } 
		}
		if (command == 'd' || command == 'D') {
			if (token.length == 2) { return fc_zeroPad(date.getDate()); }
		}
		if (command == 'm' || command == 'M') {
			if (token.length == 2) { return fc_zeroPad(date.getMonth() + 1); }
			if (token.length == 3) { return fc_months[date.getMonth()]; } 
		}
		return token;
     }
     
     function fc_parseToken(date, token, value, start) {
		var command = token.substring(0, 1);
		var v;
		if (command == 'y' || command == 'Y') {
			if (token.length == 2) { 
				v = value.substring(start, start + 2);
				if (v < 70) { date.setFullYear(2000 + parseInt(v)); } else { date.setFullYear(1900 + parseInt(v)); } 
			}
			if (token.length == 4) { v = value.substring(start, start + 4); date.setFullYear(v);} 
		}
		if (command == 'd' || command == 'D') {
			if (token.length == 2) { v = value.substring(start, start + 2); date.setDate(v); }
		}
		if (command == 'm' || command == 'M') {
			if (token.length == 2) { v = value.substring(start, start + 2); date.setMonth(v - 1); }
			if (token.length == 3) { 
				v = value.substring(start, start + 3);
				var i;
				for (i = 0; i < fc_months.length; i++) {
					if (fc_months[i].toUpperCase() == v.toUpperCase()) { date.setMonth(i); }
				}
			} 
		}
     }
     
     function fc_zeroPad(num) {
		if (num < 10) { return '0' + num; }
		return num;
     }

	function fc_getObj(id) {
		if (fc_ie) { return document.all[id]; } 
		else { return document.getElementById(id);	}
	}

      function fc_setFieldValue(field, value) {
                if (field.type.substring(0,6) == 'select') {
                        var i;
                        for (i = 0; i < field.options.length; i++) {
                                if (fc_equals(field.options[i].value, value)) {
                                        field.selectedIndex = i;
                                }
                        }
                } else {
                        field.value = value;
                }
      }

      function fc_getFieldValue(field) {
                if (field.type.substring(0,6) == 'select') {
                        return field.options[field.selectedIndex].value;
                } else {
                        return field.value;
                }
      }
      
      function fc_equals(val1, val2) {
      		if (val1 == val2) return true;      		
      		if (1 * val1 == 1 * val2) return true;
      		return false;
      }
     
     
	 /*###########################################################################*/
	 /*###########  ABRIR UNA Página en AJAX ################################################*/
	 
	 
	 function abrircontenidoajax(url,nombreobjeto) {

        http_request = false;

        if (window.XMLHttpRequest) { // Mozilla, Safari,...
            http_request = new XMLHttpRequest();
            if (http_request.overrideMimeType) {
                http_request.overrideMimeType('text/xml');
                // Ver nota sobre esta linea al final
            }
        } else if (window.ActiveXObject) { // IE
            try {
                http_request = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
                try {
                    http_request = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (e) {}
            }
        }

        if (!http_request) {
            alert('Falla :( No es posible crear una instancia XMLHTTP');
            return false;
        }
        http_request.onreadystatechange = alertContents;
        http_request.open('GET', url, true);
        http_request.send(null);
    }

    function alertContents() {

        if (http_request.readyState == 4) {
            if (http_request.status == 200) {
              gettrailobjnostyle2().innerHTML=http_request.responseText;
			
            } else {
                alert('Hubo problemas con la petición.');
            }
        }

    }

function xGetElementById(e) {
  if(typeof(e)!="string") return e;
  if(document.getElementById) e=document.getElementById(e);
  else if(document.all) e=document.all[e];
  else e=null;
  return e;
}

function ocultar(nombre)
{
	xGetElementById(nombre).className='invisible';
}
function mostrar(nombre)
{
	xGetElementById(nombre).className='visible';
}
function cambiarclase(nombre,clase)
{
		xGetElementById(nombre).className=clase;
}

function abrirtree(id)
{
	if(xGetElementById(id).style.display=='none')
	{
		xGetElementById(id).style.display='';
	}
	else
	{
		xGetElementById(id).style.display='none';
	}
}

//menu desplegable
navHover = function() {
	var lis = document.getElementById("menu").getElementsByTagName("LI");
	for (var i=0; i<lis.length; i++) {
		lis[i].onmouseover=function() {
			this.className+=" iehover";
		}
		lis[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" iehover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", navHover);

navHover2 = function() {
	var lis = document.getElementById("menu2").getElementsByTagName("LI");
	for (var i=0; i<lis.length; i++) {
		lis[i].onmouseover=function() {
			this.className+=" iehover";
		}
		lis[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" iehover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", navHover2);
-->