var ACTUAL_FONTSIZE =12;
function txt_more() {
		ACTUAL_FONTSIZE++;
		document.getElementById('texto_vernota').style.fontSize = ACTUAL_FONTSIZE + "px";
}
function txt_less() {
		ACTUAL_FONTSIZE--;
		document.getElementById('texto_vernota').style.fontSize = ACTUAL_FONTSIZE + "px";
}
function txt_normal() {
		ACTUAL_FONTSIZE = 12;
		document.getElementById('texto_vernota').style.fontSize = ACTUAL_FONTSIZE + "px";
}
function popup(url,ancho,alto){
	derecha=(screen.width-ancho)/2;
	arriba=0
		day = new Date();
	id = day.getTime();
	string="toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width="+ancho+",height="+alto+",left="+derecha+",top="+arriba;
	url2 = '/code/verfoto.php?foto='+url+'&ancho='+ancho+'&alto='+alto;
	fin=window.open(url2,id,string);
}
/////////////// funciones para abrir popup para reproducir audio y video ///////////
function openAudio (url,titulo) {
	day = new Date();
	id = day.getTime();
	alto=80;
	ancho=180;
	arriba = 50;
	derecha=100
	string="toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width="+ancho+",height="+alto;
	fin=window.open("/admin/incl/verAudio.php?url="+url+"&titulo="+titulo,id,string);
}
function openVideo (url,titulo) {
	day = new Date();
	id = day.getTime();
	alto=300;
	ancho=300;
	arriba = 50;
	derecha=100
	string="toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width="+ancho+",height="+alto+",left="+derecha+",top="+arriba;
	fin=window.open("/admin/incl/verVideo.php?url="+url+"&titulo="+titulo,id,string);
}
//////////////////// funcion para abrir popup de foto con watermark //////////////
function verFoto(url,ancho,alto){
	derecha=(screen.width-ancho)/2;
	arriba=0
	day = new Date();
	id = day.getTime();
	var dif = 30;
	var alto2 = eval(alto)+dif;
	string="toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width="+ancho+",height="+alto2+",left="+derecha+",top="+arriba;
	url2 = '/incl/verfoto.php?foto='+url+'&ancho='+ancho+'&alto='+alto+'&alto2='+alto2+'&dif='+dif;
	fin=window.open(url2,id,string);
}
//////// funcion para validar el archivo que se eligio para subir /////////////
function validar(form1,boton,que,cant) {
	switch (que){
	case "img": exte = ".jpg"; break;
	case "aud": exte = ".mp3"; break;
	case "flv": exte = ".flv"; break;
	case "pdf": exte = ".pdf"; break;
	case "zip": exte = ".zip"; break;
	}
	var fin = false;
	var fin2 = true;
	boton.disabled=true;
	for (var i = 1; i <= cant; i++) {
		if (eval('form1.userfile'+i+'.value') != ""){
			var ext = eval('form1.userfile'+i+'.value').slice(eval('form1.userfile'+i+'.value').lastIndexOf(".")).toLowerCase();
			if (exte != ext) { 
				eval('form1.userfile'+i).style.background="#ffaaaa";
				fin = true
			} 
		}
	}
	if(fin){
		alert("Se permiten únicamente archivos con la extención: "+exte+" \nPor favor, seleccione otro archivo e intente de nuevo.");
		boton.disabled=true;
		return;
	}
	for (var i = 1; i <= cant; i++) {
		if (eval('form1.userfile'+i+'.value') != ""){
			fin2 = false
		}
	}
	if(fin2){
		alert("Debe seleccionar al menos 1 archivo para subir.");
		boton.disabled=true;
		return;
	}
	form1.submit();
}
//////////// funcion que vuelve a blanco los form que tiraron error //////////////
function poneBlanco(cual,boton) {
	boton.disabled=false;
	if (cual.style.background != "") {
		cual.style.background="#ffffff";
	}
}
////////////////////////////
function cambioComboFecha() {
	var mydate=new Date();
	var ano=mydate.getYear()+'';
	year = ano.substring(1,3);
	if (document.forms[0].ano.value > year) {
		var year2='19';
	} else {
		var year2='20';
	}
	document.forms[0].fecha.value=year2+document.forms[0].ano.value+'-'+document.forms[0].mes.value+'-'+document.forms[0].dia.value;
}
//////////////////////////////////////////////////
function muestraDescSeccion(combo) {
for (a=0;a<combo.options.length;a++) {
		document.getElementById('desc_seccion_'+combo.item(a).value).style.display = 'none';
	}
	document.getElementById('desc_seccion_'+combo.value).style.display = 'inline';
}
///////// estas dos funciones son para elegir una foto de la DB
///// y completar ese dato despues /////////////////////////////
function FotoAntigua(tipo) {
	day = new Date();
	id = day.getTime();
	alto=400;
	ancho=600;
	string="toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width="+ancho+",height="+alto+",left=50,top=50";
	fin=window.open("/admin/noticias/selec_archivo_viejo.php?tipo="+tipo,id,string);
}
function pasavariable(valor) {
	window.opener.document.forms[0].archivo1.value = valor;
	window.opener.document.forms[0].action = window.opener.document.forms[0].action +'&archivo1='+valor;
	window.opener.document.forms[0].submit();
}
function openFoto (url,titulo,ancho,alto) {
	day = new Date();
	id = day.getTime();
	string="toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width="+ancho+",height="+alto+",left=150,top=150";
	fin=window.open("/admin/incl/verFoto.php?ancho="+ancho+"&alto="+alto+"&url="+url+"&titulo="+titulo,id,string);
}
function cambiarPriori(id,vieja,nueva,redirect) {
	//alert(vieja)
	//alert(nueva)
	location.href='?acc=cambiar&id='+id+'&vieja='+vieja+'&nueva='+nueva+'&redirect='+redirect;
}
//////////////////////////////////////////////////////////////////////////////////////
function ValidaPublicidad(form1,boton) {
	boton.disabled=true;
	if (form1.userfile1.value != ""){
		var ext = form1.userfile1.value.slice(form1.userfile1.value.lastIndexOf(".")).toLowerCase();
		if ('.jpg' != ext && '.swf' != ext) { 
			form1.userfile1.style.background="#ffaaaa";
			alert("Se permiten únicamente archivos con la extención: .jpg o .swf \nPor favor, seleccione otro archivo e intente de nuevo.");
			boton.disabled=true;
			return;
		} 
	} else {
		alert("Debe seleccionar un archivo para subir.");
		boton.disabled=true;
		return;
	}
	form1.submit();
}
/////////////////////////////////////////////////////////////////////////////////////
function extiendeForo(tema) {
	total2= document.getElementById("totaltemas").value;
	for (b=1;b<=total2;b++) {
		total= document.getElementById("total_tema"+(b-1)).value;
		for (a=1;a<=total;a++) {
			document.getElementById("tema"+(b-1)+"_resp"+a).style.display = "none";
		}
		if (('tema'+(b-1))!=tema) {
			document.getElementById('form_tema'+(b-1)).style.display = "none";
			document.getElementById("masResp_tema"+(b-1)).style.display = "none";
			document.getElementById('tema'+(b-1)).style.background = '#FFFFFF';
			document.getElementById("oculta_tema"+(b-1)).style.display = "none";
			document.getElementById("extiende_tema"+(b-1)).style.display = "inline";
			document.getElementById('tema'+(b-1)).style.cursor = 'pointer';
		}
	}	
			total= document.getElementById("total_"+tema).value;
			for (a=1;a<=total;a++) {
				document.getElementById(tema+"_resp"+a).style.display = "block";
			}
			if (document.getElementById('form_'+tema).style.display != "inline") {
				document.getElementById('masResp_'+tema).style.display = "block";
			}
			document.getElementById(tema).style.background = '#F9F9EF';
			document.getElementById("oculta_"+tema).style.display = "inline";
			document.getElementById("extiende_"+tema).style.display = "none";
			document.getElementById(tema).style.cursor = 'default';
}
function ocultaForo(tema) {
	total= document.getElementById("total_"+tema).value;
	document.getElementById(tema).style.background = '#FFFFFF';
	for (a=1;a<=total;a++) {
		//alert(tema+"_resp"+a);
		document.getElementById(tema+"_resp"+a).style.display = "none";
	}
	document.getElementById('masResp_'+tema).style.display = "none";
	document.getElementById('form_'+tema).style.display = "none";
	document.getElementById("oculta_"+tema).style.display = "none";
	document.getElementById("extiende_"+tema).style.display = "inline";
	document.getElementById(tema).style.cursor = 'pointer';
}
function cambiaEstadoForo(tema) {
	if (document.getElementById(tema+"_resp1").style.display == "block") {
		if (document.getElementById('form_'+tema).style.display == "none") {
			ocultaForo(tema)
		}
	} else {
		extiendeForo(tema)
	}
}
function muestraForm(form,boton) {
	document.getElementById(boton).style.display = "none";
	document.getElementById(form).style.display = "inline";
}
function limitarForo(texto) {
	txt = texto.value
	largo = txt.length
	if (largo > 600) {
		alert ("Se permiten 600 caracteres como máximo.");
		texto.value = txt.substring(0,600);
	}
}
