function moveBlock(updateDiv, method, blockId, formId)
{
	if (blockId)
	{
		blocksSelect = document.getElementById(blockId);
		try
		{
			block = blocksSelect.options[blocksSelect.selectedIndex].value;
			params = "formId=" + formId + "&blockId=" + block;
			new Ajax.Updater(updateDiv, method,
				{onLoading:function(request) {
					javascript:waitPointer(element)
				} ,
				onComplete:function(request) {
					javascript:defaultPointer(element)
				} , asynchronous:true, evalScripts:true, parameters:params});
		}
		catch(e)
		{
			alert('Primero seleccione un bloque:' + e);
		}
	}
	else
	{
		alert('Primero seleccione un bloque');
	}
}

function moveQuestion(updateDiv, method, questionId, blockFormId)
{
	if (questionId)
	{
		questionsSelect = document.getElementById(questionId);
		try
		{
			question = questionsSelect.options[questionsSelect.selectedIndex].value;
			params = "blockFormId=" + blockFormId + "&questionId=" + question;
			new Ajax.Updater(updateDiv, method,
				{onLoading:function(request) {
					javascript:waitPointer(element)
				} ,
				onComplete:function(request) {
					javascript:defaultPointer(element)
				} , asynchronous:true, evalScripts:true, parameters:params});
		}
		catch(e)
		{
			alert('Primero seleccione una pregunta:' + e);
		}
	}
	else
	{
		alert('Primero seleccione un bloque');
	}
}

function changeBlockFormOrder(updateDiv, method, blockId, action)
{
	if (blockId)
	{
		blocksSelect = document.getElementById(blockId);
		try
		{
			block = blocksSelect.options[blocksSelect.selectedIndex].value;
			params = "blockFormId=" + block + "&action=" + action;
			new Ajax.Updater(updateDiv, method,
				{onLoading:function(request) {
					javascript:waitPointer(element)
				} ,
				onComplete:function(request) {
					javascript:defaultPointer(element)
				} , asynchronous:true, evalScripts:true, parameters:params});
		}
		catch(e)
		{
			alert('Primero seleccione un bloque:' + e);
		}
	}
	else
	{
		alert('Primero seleccione un bloque');
	}
}

function changeQuestionFormOrder(updateDiv, method, questionId, action)
{
	if (questionId)
	{
		questionsSelect = document.getElementById(questionId);
		try
		{
			question = questionsSelect.options[questionsSelect.selectedIndex].value;
			params = "questionFormId=" + question + "&action=" + action;
			new Ajax.Updater(updateDiv, method,
				{onLoading:function(request) {
					javascript:waitPointer(element)
				} ,
				onComplete:function(request) {
					javascript:defaultPointer(element)
				} , asynchronous:true, evalScripts:true, parameters:params});
		}
		catch(e)
		{
			alert('Primero seleccione un bloque:' + e);
		}
	}
	else
	{
		alert('Primero seleccione un bloque');
	}
}

function cal(name)
{
	Calendar.setup({
		inputField     :    name,     // id of the input field
		ifFormat       :    "%d/%m/%Y",      // format of the input field
		showsTime      :    true,            // will display a time selector
		button         :    "f_trigger_" + name,  // trigger for the calendar (button ID)
		align          :    "Tl",           // alignment (defaults to "Bl")
		singleClick    :    true,
		firstDay       :    1
	});
}


var numero = 0;
function AddDocument()
{
	container = document.getElementById('documents');
	span = document.createElement('SPAN');
	span.className = 'document';
	span.id = 'document' + (++numero);

   inputCode = document.createElement('INPUT');
   inputCode.name = 'doccode_' + numero;
   inputCode.type = 'text';

   inputName = document.createElement('INPUT');
   inputName.name = 'docname_' + numero;
   inputName.type = 'text';

   inputDescription = document.createElement('INPUT');
   inputDescription.name = 'docdescription_' + numero;
   inputDescription.type = 'text';

	strongCode = document.createElement('STRONG');
	strongCode.innerHTML = 'C&oacute;digo : ';

	strongName = document.createElement('STRONG');
	strongName.innerHTML = 'Nombre : ';

	strongDescription = document.createElement('STRONG');
	strongDescription.innerHTML = 'Descripci&oacute;n : ';

	br = document.createElement('BR');

	span.appendChild(strongCode);
	span.appendChild(inputCode);
	span.appendChild(strongName);
	span.appendChild(inputName);
	span.appendChild(strongDescription);
	span.appendChild(inputDescription);

   a = document.createElement('A');
   a.name = span.id;
   a.href = '#';
   a.onclick = removeField;
   a.innerHTML = 'Quitar';
	span.appendChild(a);

	span.appendChild(br);

	container.appendChild(span);
}

function removeField(evt)
{
	lnk = f(e(evt));
	span = document.getElementById(lnk.name);
	span.parentNode.removeChild(span);
}

