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 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';
	}
}
//------------------------------------------------------------------------
function emailCheck(emailStr){
	var emailPat = /^(.+)@(.+)$/
	var specialChars = "\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
	var validChars = "\[^\\s" + specialChars + "\]"
	var quotedUser = "(\"[^\"]*\")"
	var ipDomainPat= /^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
	var atom = validChars + '+'
	var word = "(" + atom + "|" + quotedUser + ")"
	var userPat = new RegExp("^" + word + "(\\." + word + ")*$")
	var domainPat = new RegExp("^" + atom + "(\\." + atom +")*$")
	var matchArray=emailStr.match(emailPat)

	if (matchArray == null){
		alert("El email ingresado parece incorrecto (revise el @ y los puntos)")
		return false
	}
	var user = matchArray[1]
	var domain = matchArray[2]
	if (user.match(userPat) == null){
	    alert("El nombre de usuario parece no ser válido.")
	    return false
	}
	var IPArray = domain.match(ipDomainPat)
	if (IPArray!=null){
		for (var i=1;i<=4;i++){
			if (IPArray[i]>255){
				alert("La dirección IP de destino no es válida!")
				return false
			}
		}
    	return true
	}
	var domainArray=domain.match(domainPat)
	if (domainArray==null){
		alert("El nombre de dominio parece no ser válido.")
	    return false
	}
	var atomPat = new RegExp(atom,"g")
	var domArr = domain.match(atomPat)
	var len = domArr.length
	if (domArr[domArr.length-1].length<2 || domArr[domArr.length-1].length>3){
	   alert("La dirección debe terminar en un dominio de tres letras ó en un país de dos letras.")
	   return false
	}
	if (len<2){
	   alert("La dirección no tiene el nombre del host!")
	   return false
	}
	return true;
}
//------------------------------------------------------------------------
	function calcularTotal(){
		var total = document.getElementById('total');

		var r1 = parseInt(document.getElementById('ronda1').value);
		var r2 = parseInt(document.getElementById('ronda2').value);
		var r3 = parseInt(document.getElementById('ronda3').value);
		var r4 = parseInt(document.getElementById('ronda4').value);
		
		total.value = r1 + r2 + r3 + r4;
	}
//------------------------------------------------------------------------
function spanish(){
	document.getElementById('english').style.display = "none";
	document.getElementById('spanish').style.display = "";
	
	document.forms[0]['nombre1'].focus();
}
function english(){
	document.getElementById('english').style.display = "";
	document.getElementById('spanish').style.display = "none";

	document.forms[0]['nombre2'].focus();
}
function change(cual) {
	if (cual == 1){
		td1 = document.getElementById('tdspanish');
		ln1 = document.getElementById('link1');
		td1.className = 'bordetab';
		ln1.className = 'tmDataLink1';
		
		td2 = document.getElementById('tdenglish');
		ln2 = document.getElementById('link2');
		td2.className = 'bordetab1';
		ln2.className = 'tmDataLink';
	} else {
		td1 = document.getElementById('tdenglish');
		ln1 = document.getElementById('link2');
		td1.className = 'bordetab';
		ln1.className = 'tmDataLink1';
		
		td2 = document.getElementById('tdspanish');
		ln2 = document.getElementById('link1');
		td2.className = 'bordetab1';
		ln2.className = 'tmDataLink';
	}
}
function getOptions(padre){
	window.frames['iframeOculto'].location = '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;
}


