// ***********************************************************************************************
// GENERAL
// ***********************************************************************************************

function MM_openBrWindow(theURL, winName, features) {
	window.open(theURL, winName, features);
}

function cargar(tC, tM, tP, tPor){
	with(document.frm_cargar)	{
		oculto_cabeza.value = tC 
		oculto_medio.value = tM
		oculto_pie.value = tP 
		oculto_porcentaje3.value = tPor
		
		submit()
	}
}

function combo_seleccionar(combo, tValor){	
	var nIndice, nCant;
				
	nIndice = -1
	nCant = combo.length - 1
		
	do
		nIndice ++			
	while(nIndice != nCant && tValor != combo[nIndice].value)		
		
	if(tValor == combo[nIndice].value)
		combo.selectedIndex = nIndice
}

function EsEmail(tEmail) {
	var filter;
	
	filter = /^[A-Za-z][A-Za-z0-9_.]*@[A-Za-z0-9_]+\.[A-Za-z0-9_.]+[A-za-z]$/
		
	if(filter.test(tEmail)) 
		return true;
	else
		return false;
}


// ***********************************************************************************************
// Medio
// ***********************************************************************************************

function inicializar_medio(cCodigo, tMensaje){
	var nIndice;

	var tChk;

	with(document.frm)	{	
		if(cCodigo > 0)	{
			tChk = 'chk_' + String(cCodigo)

			for(nIndice = 0; nIndice < length; nIndice++) {
				if(elements[nIndice].name == tChk)
					elements[nIndice].focus()
			}
		}

		if(tMensaje != '')
			alert(tMensaje)
	}	
}

function EnviarConsulta_medio(tCampo) {
	with(document.frm)	{
		oculto_campo.value = tCampo		
		submit()
	}
}

function baja_medio(){
	with(document.frm) 	{
		if(confirm('¿Esta seguro que desea eliminar este/os registro/s?'))
			FormAction.value = 'Delete'; 
			submit()
	}
}


// ***********************************************************************************************
// Pie
// ***********************************************************************************************	

function enviar_carpeta() {
	if(document.frm.cmb_carpetas.value == '0')	{
		alert('Debe seleccionar una carpeta.')
		document.frm.cmb_carpetas.focus()
	}
	else {
		document.frm_carpeta.oculto_carpeta.value = document.frm.cmb_carpetas.value
		document.frm_carpeta.submit()
	}
}

function limpiar_pie() {
	var nIndice;
	
	with(document.frm)	{	
		for(nIndice = 0; nIndice < length; nIndice++) {
			tAux1 = elements[nIndice].name.substring(0, 4)
			tAux2 = elements[nIndice].name.substring(0, 1)

			if(tAux1 == 'txt_' || tAux2 == 'f_') {
				elements[nIndice].value = '';
			}
			else {
				if(tAux1 == 'cmb_') {
					elements[nIndice].selectedIndex = 0;
				}
			}
		}
	}
}

function actualizacion_pie(tOp){
	with(document.frm)	{	
		if(tOp == 'a')		{
			if(confirm('¿Desea avisar de la actualización a los inscriptos en la lista de correo?'))
				oculto_actualizacion.value = 'Si'			
		}
	}
}

function chkColor(Obj) {
	if (Obj.checked == true) {
		Obj.parentNode.parentNode.className = "chkColor";
	}
	else {
		Obj.parentNode.parentNode.className = "";
	}
}

function CmbSelectIndex(Obj, Id) {
	//alert(Obj.options.length);
	//return;
	for (i=0;i<Obj.options.length;i++ )	{
		if (Obj.options[i].value == Id) {
			Obj.options[i].selected = true;
			break;
		}
	}
}

function CmbCarpeta(Obj, Id, FolderPath){ // valida que una carpeta no este dentro de si misma
	// TRATAR EL TIPO DE CARPETA EN EL MANEJO DE ERRORES
	//alert(String(Obj[Obj.selectedIndex].text).substr(0, FolderPath.length));
	if ((Obj[Obj.selectedIndex].value == Id) || (String(Obj[Obj.selectedIndex].text).substr(0, FolderPath.length) == String(FolderPath))) {
		alert('No puede poner una carpeta dentro de sí misma');
		Obj.options[0].selected = true;
		return;
	}
}

function popup(url, width, height, scrolling){
    var newwin = window.open(url, 'ventana', 'width='+width+',height='+height+',resizable=no,titlebar=no,scrollbars='+scrolling+''); 
    return;
}

function SpanShowHide(Obj){
	if (Obj.style.display == "none") {
		Obj.style.display = "";
	}
	else {
		Obj.style.display = "none";
	}
}