document.write('<link rel="stylesheet" type="text/css" media="all" href="/NUCLEO/jscalendar/calendar-win2k-1.css" title="win2k-1" />');
document.write('<script type="text/javascript" src="/NUCLEO/jscalendar/calendar.js"></script>');
document.write('<script type="text/javascript" src="/NUCLEO/jscalendar/lang/calendar-es.js"></script>');
document.write('<script type="text/javascript" src="/NUCLEO/jscalendar/calendar-setup.js"></script>');
document.write('<script type="text/javascript" src="/NUCLEO/FCKeditor263/fckeditor.js"></script>');

// Definici?n de un calendario
function setupCalendario(idcampo) {
    Calendar.setup( {
        inputField: idcampo,
        ifFormat  : "%d-%m-%Y",
        button    : "trigger_" + idcampo
    } );
}

function setupCalendarioIniPaco(idcampo) {
	function dateStatusHandler(date, y, m, d) {
		hoy = new Date();
		if (hoy > date) {
			return true;
		}
	}
    Calendar.setup( {
        inputField: idcampo,
        ifFormat  : "%d-%m-%Y",
        button    : "trigger_" + idcampo,
        dateStatusFunc : dateStatusHandler
    } );
}

function setupCalendarioHM(idcampo) {
    Calendar.setup( {
        inputField: idcampo,
        ifFormat  : "%d-%m-%Y %H:%M",
        button    : "trigger_" + idcampo,
        showsTime : true
    } );
}


var startDate;
var endDate;

function resetDates() {
	startDate = endDate = null;
}

function filterDates1(cal) {
	startDate = new Date(cal.date)
	startDate.setHours(0,0,0,0)	// used for compares without TIME
	if (endDate == null) {
		Calendar.setup({
			inputField	   : "fecha_fin",
        	ifFormat  	   : "%d-%m-%Y",
        	button    	   : "trigger_fecha_fin",
			date      	   : cal.date,
			dateStatusFunc : disallowDateBefore,
			onUpdate       : filterDates2
		});
	}
}

function filterDates2(cal) {
	var date = cal.date;
	endDate = new Date(cal.date)
	endDate.setHours(0,0,0,0)	// used for compares without TIME
}

function disallowDateBefore(dateCheckOut) {
	dateCheckOut.setHours(0,0,0,0)
	if ((startDate != null) && startDate > dateCheckOut)
		// startDate is defined, make sure cal date is NOT before start date
		return true;

	var now = new Date()
	now.setHours(0,0,0,0)
	if (dateCheckOut <= now)
		// check out date can not be befor today if startDate NOT defined
		return true;

	return false;
}


function disallowDateAfter(dateCheckIn) {
	dateCheckIn.setHours(0,0,0,0)
	if ((endDate != null) && dateCheckIn > endDate)
		// endDate defined, calendar date can NOT be after endDate
		return true;

	var now = new Date()
	now.setHours(0,0,0,0)
	if (dateCheckIn <= now)
		// endDate NOT defined, calendar date can not be before today
		return true;

	return false;
}

function setupCalendarioIni(idcampo) {
    Calendar.setup( {
	    inputField	   : idcampo,
	    ifFormat  	   : "%d-%m-%Y",
	    button    	   : "trigger_" + idcampo,
        dateStatusFunc : disallowDateAfter, //the function to call
        onUpdate       : filterDates1
    } );
}


function setupCalendarioFin(idcampo) {
    Calendar.setup( {
        inputField	   : idcampo,
        ifFormat  	   : "%d-%m-%Y",
        button    	   : "trigger_" + idcampo,
        dateStatusFunc : disallowDateBefore,
        onUpdate  	   : filterDates2
    } );
}
var listaFCKs = new Array();
// Definicion de un editor avanzado
function setupEditor(idcampo) {
    var oFCKeditor        = new FCKeditor(idcampo);
    oFCKeditor.BasePath   = "/NUCLEO/FCKeditor263/";
    oFCKeditor.ToolbarSet = "mvc_default",
    oFCKeditor.Width      = "505px",
    oFCKeditor.Height     = "200px",
    oFCKeditor.ReplaceTextarea();
    listaFCKs[listaFCKs.length] = idcampo;
}

// Definicion de un editor avanzado
function setupEditorBoletines(idcampo) {
    var oFCKeditor        = new FCKeditor('boletin');
    oFCKeditor.BasePath   = "/NUCLEO/FCKeditor263/";
    oFCKeditor.ToolbarSet = "mvc_boletin",
    oFCKeditor.Width      = "940px",
    oFCKeditor.Height     = "400px",
    oFCKeditor.ReplaceTextarea();
}

function excel(){
    document.getElementById('excel').value = 'excel';
    document.forms.filtrar.submit();
}

