function confirmLink(theLink, theText){
    if (theText == '' || typeof(window.opera) != 'undefined') {
        return true;
    }
    var is_confirmed = confirm(theText);
    if (is_confirmed) {
        theLink.href += '&confirmado=1';
    }
    return is_confirmed;
}
//------------------------------------------------------------------------
function doPreview(wich, where){
	var objFile = document.getElementById(wich); //imagen
	var objImg = document.getElementById(where); //preview
	objImg.src = objFile.value;
}
//------------------------------------------------------------------------
var idControlEdicion;
function EditarContenido(idControl){
	idControlEdicion = idControl;
	var newWindow = window.open('../../cOmmOns/html_editor/editor_html.php', 'HTMLEditor', 'scrollbars=yes,width=620,height=500');
	newWindow.focus();
}

function RecuperarContenido(){
	return document.getElementById(idControlEdicion).value;	
}

function CallbackEditarContenido(value){
	document.getElementById(idControlEdicion).value = value;
}
//------------------------------------------------------------------------
function openWin(ventana,popW,popH,nombre_ventana){
	if (nombre_ventana == undefined){
		var nom = 'Window';
	} else {
		var nom = nombre_ventana;
	}
	var w = 0, h = 0;
	
   	w = window.innerWidth;
   	h = window.innerHeight;
   	
	var leftPos = (w-popW)/2, topPos = (h-popH)/2;
	
    popupWindow=open(''+ventana+'',nom,'resizable=no,scrollbars=yes,width='+popW+',height='+popH+',top='+topPos+',left='+leftPos);
    if (popupWindow.opener == null)
		popupWindow.opener = self;
}
//------------------------------------------------------------------------
function modalWin(ventana,popW,popH){
	if (window.showModalDialog){
		window.showModalDialog(''+ventana+'','Window','dialogWidth:'+popW+'px;dialogHeight:'+popH+'px');
	} else {
		window.open(''+ventana+'','Window','height='+popH+',width='+popW+',toolbar=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,modal=yes');
	}
}
//------------------------------------------------------------------------
function getOptions(padre){
	window.frames['iframeOculto'].location = '../../cOmmOns/carga_dinamica.php?padre='+padre;
}

function fillSelect(arrOptions){
	var cantidad = arrOptions.length;
	var mi_objeto = document.frmOrigen.hijo;

	mi_objeto.options.length = 0;

	for (i = 0; i < cantidad; i++){
		mi_objeto.options[i] = new Option(arrOptions[i].nombre);
		mi_objeto.options[i].value = arrOptions[i].id;
	}
	mi_objeto.options[0].selected = true;
}
//------------------------------------------------------------------------
function MostrarOcultarOrden(tipo){
	var divOrden = document.getElementById('div_orden');
	if (tipo == 2){
		divOrden.style.display = 'block';
	} else {
		divOrden.style.display = 'none';
	}
}
//------------------------------------------------------------------------
function MostrarOcultarOrdenCheck(objeto){
	if (document.getElementById(objeto).style.display == 'none'){
		document.getElementById(objeto).style.display = '';
	} else {
		document.getElementById(objeto).style.display = 'none';
	}
}
//------------------------------------------------------------------------
function MostrarOcultarDivMenues(tipo){
	var divExterna = document.getElementById('opcionExterna');
	var divInterna = document.getElementById('opcionInterna');
	var divEditor  = document.getElementById('opcionEditor');
	var divTemplate= document.getElementById('opcionTemplate');

	divExterna.style.display = 'none';
	divInterna.style.display = 'none';
	divEditor.style.display  = 'none';
	divTemplate.style.display= 'none';

	switch (tipo){
		case 'externa' : divExterna.style.display = 'block'; break;
		case 'interna' : divInterna.style.display = 'block'; break;
		case 'editor'  : divEditor.style.display  = 'block'; break;
		case 'template': divTemplate.style.display= 'block'; break;
		default: divExterna.style.display = 'block';
	}
}
//------------------------------------------------------------------------
function highlight_div(checkbox_node){
    label_node = checkbox_node.parentNode;

    if (checkbox_node.checked){
		label_node.style.backgroundColor='#e57e21';
		label_node.style.color='#ffffff';
	} else {
		label_node.style.backgroundColor='#ffffff';
		label_node.style.color='#000000';
	}
}
//------------------------------------------------------------------------
var contadorTemas = 0;
function agregarTema(theTable){
	contadorTemas++;

	theRow = theTable.insertRow(theTable.rows.length);
	theCell= theRow.insertCell(0);
	theCell.innerHTML = '<input class="tmInput" name="temas['+contadorTemas+'][rank]" type="checkbox">&nbsp;';
	theCell= theRow.insertCell(1);
	theCell.innerHTML = '<input class="tmInput" name="temas['+contadorTemas+'][tema]" size="60">';
	theCell = theRow.insertCell(2);
	theCell.innerHTML ='&nbsp;<img id="delRow" onClick="borrarFila(this)" src="../../cOmmOns/images/borrar.gif" title="Borrar">';
}
//------------------------------------------------------------------------
var contadorOpciones = 0;
function agregarOpcion(theTable){
	contadorOpciones++;
	
	theRow = theTable.insertRow(theTable.rows.length);
	theCell= theRow.insertCell(0);
	theCell.innerHTML = '<input class="tmInput" name="opciones['+contadorOpciones+'][preg]" size="62">&nbsp;';
	theCell= theRow.insertCell(1);
	theCell.innerHTML = '<input class="tmInput" name="opciones['+contadorOpciones+'][voto]" size="7" value="0" style="text-align:center;">';
	theCell = theRow.insertCell(2);
	theCell.innerHTML ='&nbsp;<img id="delRow" onClick="borrarOpcion(this)" src="../../cOmmOns/images/borrar.gif" title="Borrar">';
}
//------------------------------------------------------------------------
function borrarFila(theRow){
	theRow.parentNode.parentNode.parentNode.deleteRow(theRow.parentNode.parentNode.rowIndex);
}
