// JavaScript Document

var popup = null;

<!--

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];}

}





function popnew2(url,ancho,largo){

// kind 0 is for individuals

x = (screen.width/2)-(ancho/2);

y = (screen.height/2)-(largo/2);

popup=window.open(url,"","width="+ancho+",height="+largo+",top="+y+",left="+x+",status=no,location=no,menu=no,scrollbars=yes,toolbar=no");

popup.focus();

}









<!-- Begin



//Animated Window- By Rizwan Chand (rizwanchand@hotmail.com)

//Modified by DD for NS compatibility

//Visit http://www.dynamicdrive.com for this script



function expandingWindow(website) {

var windowprops='width=10,height=10,scrollbars=no,status=no,resizable=no'

var heightspeed = 20; // vertical scrolling speed (higher = slower)

var widthspeed = 10;  // horizontal scrolling speed (higher = slower)

var leftdist = 700;    // distance to left edge of window

var topdist = 250;     // distance to top edge of window



if (window.resizeTo&&navigator.userAgent.indexOf("Opera")==-1) {

var winwidth = 350;

var winheight = 400;

var sizer = window.open("","","left=" + leftdist + ",top=" + topdist +","+ windowprops);

for (sizeheight = 1; sizeheight < winheight-100; sizeheight += heightspeed)

sizer.resizeTo("1", sizeheight);

for (sizewidth = 1; sizewidth < winwidth-50; sizewidth += widthspeed)

sizer.resizeTo(sizewidth, sizeheight);

sizer.location = website;

}

else

window.open(website,'mywindow');

}



function popnew(url,ancho,largo){

// kind 0 is for individuals

x = (screen.width/2)-(ancho/2);

y = (screen.height/2)-(largo/2);

popup=window.open(url,"","width="+ancho+",height="+largo+",top="+y+",left="+x+",status=yes,location=no,menu=no,scrollbars=no,toolbar=no");

popup.focus();

}



function popkill(url){

opener.location = url;

self.close();

}





function closer(){

if (popup != null && popup.open){ 

if(!popup.closed){

popup.window.close();

}

popup = null;

}

}





function redirect(direction){



return window.location = direction;



}



function previewImage(fileInfo) {



          if(navigator.appName != "Microsoft Internet Explorer")

		    {

			   alert("Su navegador no soporta la opcion de preview\n  pero aun asi puede subir su imagen ahora");

			   popup.close();

			}

		  



		  var cerrar = 0;

		  var Img = new Image();

          Img.src = fileInfo;

          



          popup = window.open('test2.htm', 'same', 'width=200,height=200,left=670,top=350,scrollbars=no,location=no,menubar=no,status=no,toolbar=no,resizable=no');

		  popup.focus();

		  popup.document.writeln("<html><body bgcolor='#000000' leftmargin='0' topmargin='0' onBlur='self.close()'>");

          popup.document.writeln("<table width='100%' border='0' cellpadding='0' cellspacing='0'>"+

                                 "<tr>"+

                                    "<td height='200' align='center' valign='middle'>");

		  

		  var i = Math.round(Img.width);

		  var j = Math.round(Img.height); 

		  

		  if(i > j)

		     {

			    var porc = Math.round(20000/Img.width);

			 }

		  else

		     {

			    var porc = Math.round(20000/Img.height);

			 }



          var w = Math.round(Img.width * porc)/100;

		  var h = Math.round(Img.height * porc)/100;

	  

		  var fileExtension = fileInfo.substring(fileInfo.lastIndexOf(".")+1);

            if (fileExtension == "jpg" || fileExtension == "JPG" || fileExtension == "JPEG" || fileExtension == "jpeg")

			      {

				      popup.document.writeln("<img src='" + Img.src + "' width='" + w + "' height='" + h + "'>");

				  }

            else

			   {

			      cerrar = 1;

			   }

          popup.document.writeln("</td>"+

                                 "</tr>"+

                                 "</table>");

          

		  popup.document.writeln("</body></html>");

	      popup.document.title = "Preview";

          popup.document.close();

          popup.focus();

		  

		  if(cerrar == 1)

		     {

			   closer();

			   if(fileExtension != "")

			     {

				   alert("Formato de la Imagen Invalido (solo admite .jpg)");

				 }

			 }

}

function grande(image) 

   { 

   

        var Img = new Image();

        Img.src = image;



		var w = Math.round(Img.width);

		var h = Math.round(Img.height);

		  

		popup = window.open('big.htm', 'same', 'width='+ w +',height='+ h +',left=670,top=350,scrollbars=no,location=no,menubar=no,status=no,toolbar=no,resizable=no');

        popup.focus();

        popup.document.writeln("<html><body bgcolor='#000000' leftmargin='0' topmargin='0' onBlur='self.close()'>");

        popup.document.writeln("<img src='"+ Img.src +"' width='"+ w +"' height='" + h +"'>");

        popup.document.writeln("</body></html>");

        popup.document.title = "Preview";

        popup.document.close();

        popup.focus();

	

   }

   

function validar_tipo(objeto)

   {

	  var ext = "";

	  var path = objeto.value;

	  var pos = path.lastIndexOf(".");

	  ext = ext+path.charAt(pos+1)+path.charAt(pos+2)+path.charAt(pos+3);

	  if(ext == "JPG")

	     {

		   ext = "jpg";

		 }

		 

	  if(ext == "JPE")

	     {

		   ext = "jpg";

		 }

	 

	 if(ext == "jpe")

	     {

		   ext = "jpg";

		 }

		 

      var submi = document.getElementById("submi");      

	  

	  if(ext != "jpg")

	     {

		   alert("Seleccione un archivo valido\n - admitido solo (.jpg) - ");

		   submi.disabled = true;

		   return false

		 }

	  else

	     { 

	      previewImage(objeto.value);

		  submi.disabled = false;

		  return true;

         }

   }   



function validar_jpg(objeto)

   {

	  var ext = "";

	  var path = objeto.value;

	  var pos = path.lastIndexOf(".");

	  ext = ext+path.charAt(pos+1)+path.charAt(pos+2)+path.charAt(pos+3);

	  if(ext == "JPG")

	     {

		   ext = "jpg";

		 }

		 

	  if(ext == "JPE")

	     {

		   ext = "jpg";

		 }

	 

	 if(ext == "jpe")

	     {

		   ext = "jpg";

		 }



	  if(ext != "jpg")

	     {

		   return false

		 }

	  else

	     { 

		  return true;

         }

   }   



//INICIO DE FUNCIONES PARA VALIDAR FORMULARIOS ----------------------------------------------------------------------

function isEmailAddr(email)

{

  var result = false;

  var theStr = new String(email);

  var index = theStr.indexOf("@");

  if (index > 0)

  {

    var pindex = theStr.indexOf(".",index);

    if ((pindex > index+1) && (theStr.length > pindex+1))

	result = true;

  }

  return result;

}



function validRequired(formField,fieldLabel)

{

	var result = true;

	

	if (formField.value == "")

	{

		alert('Introduzca un valor en el campo "' + fieldLabel +'". ');

		formField.focus();

		result = false;

	}

	

	return result;

}





function validEquals(formField,formField2,fieldLabel1,fieldLabel2)

{

	var result = true;

	

	if (formField.value != formField2.value)

	{

		formField.value = "";

		formField2.value = "";

		alert('El campo "' + fieldLabel1 +'" es diferente al campo "'+ fieldLabel2 +'" verifique porfavor');

		formField.focus();

		result = false;

	}

	

	return result;

}



function allDigits(str)

{

	return inValidCharSet(str,"0123456789");

}



function inValidCharSet(str,charset)

{

	var result = true;



	// Note: doesn't use regular expressions to avoid early Mac browser bugs	

	for (var i=0;i<str.length;i++)

		if (charset.indexOf(str.substr(i,1))<0)

		{

			result = false;

		break;

		}

	

	return result;

}



function validEmail(formField,fieldLabel,required)

{

	var result = true;

	

	if (required && !validRequired(formField,fieldLabel))

		result = false;



	if (result && ((formField.value.length < 3) || !isEmailAddr(formField.value)) )

	{

		alert("Itroduzca una direccion de correo valida en la forma: su_nombre@su_dominio.com");

		formField.focus();

		result = false;

	}

   

  return result;



}



function validNum(formField,fieldLabel,required)

{

	var result = true;



	if (required && !validRequired(formField,fieldLabel))

		result = false;

  

 	if (result)

 	{

 		if (!allDigits(formField.value))

 		{

 			alert('Introduzca el numero correspondiente al campo "' + fieldLabel +'".');

			formField.focus();		

			result = false;

		}

	} 

	

	return result;

}





function validInt(formField,fieldLabel,required)

{

	var result = true;



	if (required && !validRequired(formField,fieldLabel))

		result = false;

  

 	if (result)

 	{

 		var num = parseInt(formField.value,10);

 		if (isNaN(num))

 		{

 			alert('Introduzca el numero correspondiente al campo "' + fieldLabel +'" .');

			formField.focus();		

			result = false;

		}

	} 

	

	return result;

}





function validDate(formField,fieldLabel,required)

{

	var result = true;



	if (required && !validRequired(formField,fieldLabel))

		result = false;

  

 	if (result)

 	{

 		var elems = formField.value.split("/");

 		

 		result = (elems.length == 3); // should be three components

 		

 		if (result)

 		{

 			var month = parseInt(elems[0],10);

  			var day = parseInt(elems[1],10);

 			var year = parseInt(elems[2],10);

			result = allDigits(elems[0]) && (month > 0) && (month < 13) &&

					 allDigits(elems[1]) && (day > 0) && (day < 32) &&

					 allDigits(elems[2]) && ((elems[2].length == 2) || (elems[2].length == 4));

 		}

 		

  		if (!result)

 		{

 			alert('Introduzca una fecha valida con el formato MM/DD/AAAA para el campo "' + fieldLabel +'" .');

			formField.focus();		

		}

	} 

	

	return result;

}



function validateusu(theForm,kind)

{



	if (!validRequired(theForm.nombre,"Nombre"))

		return false;



	if (!validEmail(theForm.correo,"E-mail",true))

		return false;



	if (!validRequired(theForm.login,"Nombre de Usuario"))

		return false;

	

	if (!validRequired(theForm.password,"Contraseña"))

		return false;

		

	if (!validRequired(theForm.password2,"Repetir Contraseña"))

		return false;

		

	if (!validEquals(theForm.password,theForm.password2,"Contraseña","Repetir Contraseña"))

	    return false;

		

	if (!validRequired(theForm.permiso,"Tipo de Usuario"))

		return false;

	

	if(theForm.permiso.value == 2 && kind == 1){

	alert("No es posible cambiar el tipo de usuario \ndebido a que tiene temas asignados.");

		theForm.permiso.focus();

		return false;

		}

	if (!validRequired(theForm.perfil,"Perfil"))

		return false;

	

	return true;

}

function validatetema(theForm)

{



	if (!validRequired(theForm.title,"Título"))

		return false;



	if (!validRequired(theForm.encargado,"Usuario Encargado"))

		return false;

	

	if (!validRequired(theForm.descri,"Descripción"))

		return false;

			

	return true;

}



function validatecapnew(theForm)

{



	if (!validRequired(theForm.titulo,"Título"))

		return false;



	if (theForm.img1.value != "")

	   {

	      if (!validRequired(theForm.tit1,"Título Img. 1"))

		  return false;

	   }

	   

    if (theForm.img2.value != "")

	   {

	      if (!validRequired(theForm.tit2,"Título Img. 2"))

		  return false;

	   }

	   

	if (theForm.img3.value != "")

	   {

	      if (!validRequired(theForm.tit3,"Título Img. 3"))

		  return false;

	   }	      

	   

	if (theForm.img4.value != "")

	   {

	      if (!validRequired(theForm.tit4,"Título Img. 4"))

		  return false;

	   }

	   

	if(theForm.img1.value != '')

	     {

			  if(!validar_jpg(theForm.img1))

				 {

					alert("Formato de la Imagen 1 Invalido (solo admite .jpg)");

					return false;

				 }

		 }	   



	if(theForm.img2.value != '')

	     {

			  if(!validar_jpg(theForm.img2))

				 {

					alert("Formato de la Imagen 2 Invalido (solo admite .jpg)");

					return false;

				 }

		 }	   



	if(theForm.img3.value != '')

	     {

			  if(!validar_jpg(theForm.img3))

				 {

					alert("Formato de la Imagen 3 Invalido (solo admite .jpg)");

					return false;

				 }

		 }	   



	if(theForm.img4.value != '')

	     {

			  if(!validar_jpg(theForm.img4))

				 {

					alert("Formato de la Imagen 4 Invalido (solo admite .jpg)");

					return false;

				 }

		 }	   

	    

	return true;

}





function validatecapedit(theForm)

{



      if (!validRequired(theForm.titulo,"Título Capitulo"))

		  return false;



	return true;

}



function validateimg(theForm)

{



   if(theForm.img)

   {

   if(theForm.img.value != '')

	    {

		  if(!validar_jpg(theForm.img))

			 {

				alert("Formato de la Imagen Invalido (solo admite .jpg)");

				return false;

			 }

	    }

	}

	

	if (theForm.img.value != "")

	   {

	      if (!validRequired(theForm.titulo,"Título Imgagen"))

		  return false;

	   }



	return true;

}



function validatediario(theForm)

{



	if (!validRequired(theForm.titu,"Título"))

		return false;

		

	if (!validRequired(theForm.texto,"Contenido"))

		return false;

		

   if(theForm.img1)

   {

   if(theForm.img1.value != '')

	    {

		  if(!validar_jpg(theForm.img1))

			 {

				alert("Formato de la Imagen Invalido (solo admite .jpg)");

				return false;

			 }

	    }

	}

		

	return true;

}



function validatelinks(theForm)

{



	if (!validRequired(theForm.lin,"Link"))

		return false;

		

	if (!validRequired(theForm.descri,"Descripción"))

		return false;

		

   if (!validRequired(theForm.img1,"Imagen"))

		return false;

		

   if(theForm.img1)

   {

   if(theForm.img1.value != '')

	    {

		  if(!validar_jpg(theForm.img1))

			 {

				alert("Formato de la Imagen 1 Invalido (solo admite .jpg)");

				return false;

			 }

	    }

	}

		

	return true;

}



function validatelinksedit(theForm)

{



	if (!validRequired(theForm.lin,"Link"))

		return false;

		

	if (!validRequired(theForm.descri,"Descripción"))

		return false;

		

	return true;

}



function validateevento(theForm)

{



	if (!validRequired(theForm.titu,"Titulo"))

		return false;

		

	if (!validRequired(theForm.texto,"Contenido"))

		return false;

	

	if (!validRequired(theForm.horas,"Horas"))

		return false;

		

	if (!validRequired(theForm.minutos,"Minutos"))

		return false;

		

	if(theForm.minutos.value > 60)

	   {

	      alert("Valor incorrecto en el campo Minutos");

		  theForm.minutos.focus();

		  return false;

	   }

	   

	if(theForm.horas.value > 12)

	   {

	      alert("Valor incorrecto en el campo Horas");

 		  theForm.horas.focus();

		  return false;

	   }

	   

    if(theForm.img1)

	{

	if(theForm.img1.value != '')

	    {

		  if(!validar_jpg(theForm.img1))

			 {

				alert("Formato de la Imagen Invalido (solo admite .jpg)");

				return false;

			 }

	    }

	}

		

	return true;

}



function validatehome(theForm)

{



	if(theForm.titu1)

	   {

	    if (!validRequired(theForm.titu1,"Titulo del Grupo 1"))

		    return false;

	   }



	if(theForm.texto1)

	   {

	    if (!validRequired(theForm.texto1,"Contenido del Grupo 1"))

		    return false;

	   }



	if(theForm.link1)

	   {

	    if (!validRequired(theForm.link1,"Link del Grupo 1"))

		    return false;

	   }

	   

	if(theForm.titu2)

	   {

	    if (!validRequired(theForm.titu2,"Titulo del Grupo 2"))

		    return false;

	   }



	if(theForm.texto2)

	   {

	    if (!validRequired(theForm.texto2,"Contenido del Grupo 2"))

		    return false;

	   }



	if(theForm.link2)

	   {

	    if (!validRequired(theForm.link2,"Link del Grupo 2"))

		    return false;

	   }

	   

	if(theForm.titu3)

	   {

	    if (!validRequired(theForm.titu3,"Titulo del Grupo 3"))

		    return false;

	   }



	if(theForm.texto3)

	   {

	    if (!validRequired(theForm.texto3,"Contenido del Grupo 3"))

		    return false;

	   }



	if(theForm.link3)

	   {

	    if (!validRequired(theForm.link3,"Link del Grupo 3"))

		    return false;

	   }



	if(theForm.titu4)

	   {

	    if (!validRequired(theForm.titu4,"Titulo del Grupo 4"))

		    return false;

	   }



	if(theForm.texto4)

	   {

	    if (!validRequired(theForm.texto4,"Contenido del Grupo 4"))

		    return false;

	   }



	if(theForm.link4)

	   {

	    if (!validRequired(theForm.link4,"Link del Grupo 4"))

		    return false;

	   }



	return true;

}



function validatepopedit(theForm)

{



if(theForm.img.value != '')

	    {

		  if(!validar_jpg(theForm.img))

			 {

				alert("Formato de la Imagen Invalido (solo admite .jpg)");

				return false;

			 }

	    }

		

	return true;



}



function validatecorreo(theForm)

{



	if (!validRequired(theForm.nombre,"Nombre"))

		return false;



	if (!validEmail(theForm.dir,"E-mail",true))

		return false;



	return true;

}



//FINAL DE FUNCIONES PARA VALIDAR FORMULARIOS  -----------------------------------------------------------------
