function imprimir(){
	window.print();
}

function cerrar()
{
	capa=document.getElementById("masinfo");
	capa.style.visibility="hidden";
}
function abrirVentanaSeccion(dire){
		var wLinks = window.open(dire+'info-profesionales.html', 'Profesionales', 'toolbars=no, width=600, height=200, centerscreen, scrollbars=no');
     	wLinks.focus();
}

function abrirVentana(pagina){
	popup=window.open(pagina, 'aa', "status=no,toolbar=no,directories=no,menubar=no,location=no,resizable=yes,scrollbars=no,history=no,width=800,height=600,top=0,left=0");
}
function buscar()
{
	with(document.datos)
	{
		pagina.value = 1;
		submit();
	}
}

function GetParentTable(obj)
{
	objParent = obj.offsetParent;
    while( objParent.tagName != 'BODY')
    {
    	if(objParent.id.substr(0, 3) == "tbl")
			return objParent.id.substr(3);
		objParent = objParent.offsetParent;
	}
	return;
}

function verImagen(imagen)
{
	var w = window.open('verImagen.php?imagen=' + imagen, 'WinImagen', 'toolbars=no, scrollbars=yes');
}

function eliminarSeleccionados()
{
	with(document.datos)
	{
		if(confirm("¿Está seguro que desea eliminar los items seleccionados?"))
		{
			accion.value = "ELIMINAR";
			submit();
		}
	}
}


function cambiarOrden()
{
	with(document.datos)
	{
		if(confirm("¿Está seguro que desea cambiar el orden de las notas?"))
		{
			accion.value = "CAMBIARORDEN";
			submit();
		}
	}
}

function ir(psig)
{

	var params = "";
	var campos="";
	campos=document.getElementsByTagName("input");
	for(i=0; i < campos.length; i++)
	{
		if(campos[i].type == "hidden"){
			params += "&" + campos[i].name + "=" + campos[i].value;
		}

	}
	params += "&pagina="+psig;
	var result = fwkHttpTransfer.Request("post", "/directorio-resultado.php", params, "Content-Type=application/x-www-form-urlencoded");
	var resultado= result.responseText;
	celdaResultado=document.getElementById("resultado");
	celdaResultado.innerHTML=resultado;

}


function irEquipo(psig)
{
	with(document.datos)
	{
		paginaEquipo.value = psig;
		submit();
	}
}

function SetRecordFocus(cId)
{
	document.getElementById(cId).style.backgroundColor = "#F5F5F5";
}

function UnSetRecordFocus(cId)
{
	document.getElementById(cId).style.backgroundColor = "white";
}

function ordenar(campo)
{
	with(document.datos)
	{
		if(orden_campo.value != campo)
		{
			orden_campo.value = campo;
			orden_direccion.value = "ASC";
		}
		else
		{
			if(orden_direccion.value == "ASC")
				orden_direccion.value = "DESC";
			else
				orden_direccion.value = "ASC";
		}
		
		submit();
		
	}
}

function Expand(cSectionName)
{
	document.getElementById("tbl" + cSectionName).style.display = "";
	document.getElementById("img" + cSectionName).src = "images/ButtonCollapse.gif";
}

function Collapse(cSectionName)
{
	document.getElementById("tbl" + cSectionName).style.display = "none";
	document.getElementById("img" + cSectionName).src = "images/ButtonExpand.gif";
}

function ExpandCollapse(cSectionName)
{
	if (document.getElementById("tbl" + cSectionName).style.display == "none")
		Expand(cSectionName);
	else
		Collapse(cSectionName);
}

function checkEmail(strEmail)
{
	return (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(strEmail))
}

function SetFocus(elemFoco)
{
	try
	{
		var oTable = GetParentTable(elemFoco);
		if(oTable != "") Expand(oTable);
		elemFoco.focus();
	}
	catch(e)
	{
		alert(e.description);
	}
}


function seleccAll(val)
{
	with(document.datos)
	{
		for(i=0; i <elements['items[]'].length ; i++)
			elements['items[]'][i].checked = val;
	}
}


function eliminar(i)
{
	if(typeof(document.datos.elements['items[]'].length)=="undefined")
	{
		document.datos.elements['items[]'].checked = true;
	}
	else
	{
		for(j=0; j<document.datos.elements['items[]'].length ; j++)
			document.datos.elements['items[]'][j].checked = j==i;
	}

	eliminarSeleccionados();
}

	function validar_news()
	{
		with(document.datos)
		{
			var errores="";
			if(nombre.value=="")
			{
				errores+="- Debe completar su nombre\n";
			}
			if(email.value=="")
			{
				errores+="- Debe completar su dirección de e-mail\n";
			} else {
				if(!checkEmail(email.value))
				{
					errores+="- La dirección de e-mail es inválida\n";
				}
			}
			if(errores!=""){
				alert(errores);
			} else {
				accion.value="GUARDAR";
				submit();
			}
		}
	}

	function validar_contacto()
	{
		with(document.datos)
		{
			var errores="";
			if(nombre.value=="")
			{
				errores+="- Debe completar su nombre\n";
			}
			if(tema.selectedIndex==0)
			{
				errores+="- Debe elegir un tema\n";
			}
			if(email.value=="")
			{
				errores+="- Debe completar su dirección de e-mail\n";
			} else {
				if(!checkEmail(email.value))
				{
					errores+="- La dirección de e-mail es inválida\n";
				}
			}

			if(consulta.value=="")
			{
				errores+="- Debe completar su comentario\n";
			}
			
			if(errores!=""){
				alert(errores);
			} else {
				accion.value="GUARDAR";
				submit();
			}
		}
	}

	function validar_amiga()
	{
		with(document.datos)
		{
			var errores="";
			if(tu_nombre.value=="")
			{
				errores+="- Debes completar tu nombre\n";
			}
			if(su_nombre.value=="")
			{
				errores+="- Debes completar el nombre de la persona a quien le envias esta nota\n";
			}
			if(tu_mail.value=="")
			{
				errores+="- Debes completar tu dirección de e-mail\n";
			} else {
				if(!checkEmail(tu_mail.value))
				{
					errores+="- La dirección de tu e-mail es inválida\n";
				}
			}
			if(su_mail.value=="")
			{
				errores+="- Debes completar tu dirección de la persona a quien le envias esta nota\n";
			} else {
				if(!checkEmail(su_mail.value))
				{
					errores+="- La dirección de e-mail de la persona a quien envias esta nota es inválida\n";
				}
			}
			
			if(errores!=""){
				alert(errores);
			} else {
				accion.value="GUARDAR";
				submit();
			}
		}
	}

		function abrirPrint(idNoticia, dire)
		{
			var wLinks = window.open(dire+'print.php?id_nota=' + idNoticia, 'Nota', 'toolbars=no, width=680, height=750, centerscreen, scrollbars=yes');
			wLinks.focus();
		}

		function abrirEnviarAmiga(idNoticia, dire)
		{
			var wLinks = window.open(dire+'enviar-amiga.php?id_nota=' + idNoticia, 'Nota', 'toolbars=no, width=630, height=300, centerscreen, scrollbars=yes');
			wLinks.focus();
		}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


_editor_url = "../includes/htmlarea/";                     // URL to htmlarea files
var win_ie_ver = parseFloat(navigator.appVersion.split("MSIE")[1]);
if (navigator.userAgent.indexOf('Mac')        >= 0) { win_ie_ver = 0; }
if (navigator.userAgent.indexOf('Windows CE') >= 0) { win_ie_ver = 0; }
if (navigator.userAgent.indexOf('Opera')      >= 0) { win_ie_ver = 0; }

if (win_ie_ver >= 5.5) {
  document.write('<scr' + 'ipt src="' +_editor_url+ 'editor.js"');
  document.write(' language="Javascript1.2"></scr' + 'ipt>');  
} else { document.write('<scr'+'ipt>function editor_generate() { return false; }</scr'+'ipt>'); }
