function openWindow(parametros, ancho, alto) {
		derecha=(screen.width-ancho)/2;
		arriba=(screen.height-alto)/2;
		string="toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width="+ancho+",height="+alto+",left="+derecha+",top="+arriba+"";
			
		fin=window.open('popup.php?'+parametros,"ventana", string);
}
	
function openWindow2(pgn, parametros, ancho, alto, scrollbars, resizable) {
	derecha=(screen.width-ancho)/2;
	arriba=(screen.height-alto)/2;
	
	if(resizable==true)
		resizable = 1;
	else
		resizable = 0;
		
	if(scrollbars==true)
		scrollbars = 1;
	else
		scrollbars = 0;
	
	string="toolbar=0,scrollbars="+scrollbars+",location=0,statusbar=0,menubar=0,resizable="+resizable+",width="+ancho+",height="+alto+",left="+derecha+",top="+arriba+"";
		
	fin=window.open(pgn+'?'+parametros,"ventana", string);
}

function dimensionar(ancho, alto, centro) {
	if(centro==true) {
		derecha=(screen.width-ancho)/2;
		arriba=(screen.height-alto)/2;
		window.moveTo(derecha,arriba);
	}
	
	window.resizeTo(ancho,alto);
}

function darFoco(id) {
	id = document.getElementById(id);
	if(id)  {
		id.focus();
	} else {
		self.focus();
	}
}


/*****************************************************************************************/



function validarContactenos(formulario) // usado contactenos.php
{
var error = false;
var mensaje="Se han encontrado los siguientes errores:\n";

if (formulario.nombre.value=='')
{
mensaje=mensaje + " ==> Ingrese su nombre completo.\n";
error=true; 
}

if (formulario.email.value=='')
{
mensaje=mensaje + " ==> Ingrese el email.\n";
error=true; 
}
else { 

var filter=/^(\w+\.)*\w+\@([-!"&,;\w]+\.)+\w{2,3}$/;
if (filter.test(formulario.email.value))
error=false;
else {
mensaje=mensaje + " ==> Ingrese un email válido!!.\n";
error=true;
}
}


if (formulario.ciudad.value=='')
{
mensaje=mensaje + " ==> Ingrese su ciudad.\n";
error=true; 
}

if (formulario.pais.value=='')
{
mensaje=mensaje + " ==> Ingrese su pais.\n";
error=true; 
}

if (formulario.comentario.value=='')
{
mensaje=mensaje + " ==> Ingrese su comentario.\n";
error=true; 
}

if (error)
{
mensaje=mensaje+" Por favor corrija los errores....";
alert(mensaje);
return false;
}
}



/****************************************************************************************/



function validarMaterias(formulario){ // usado adm/cursos.php
var ms = '';
var err = false;



if (formulario.nombre.value=='')
{
ms += '==> Ingrese el nombre del curso.\n';
err=true; 
}



err1 = true;
for(var i=0;i<formulario.length;i++){           
	if (formulario.elements[i].type == "checkbox" && formulario.elements[i].checked == true)
	{
	err1 = false;   
	break;
	}
	
}
if (err1){ ms += '==> Seleccione al menos una materia.\n'; }

if (err || err1) {
//if (err) {
alert(ms); 
return false;
}
else return true; 
}



/***************************************************************************/




function validarProfesor(formulario){ // usado adm/usuarios.php
var ms = '';
var err = false;



if (formulario.nombre.value=='')
{
ms = '==> Ingrese el nombre de profesor.\n';
err=true; 
}


if (formulario.apellido.value=='')
{
ms += '==> Ingrese el apellido.\n';
err=true; 
}


if (formulario.email.value=='')
{
ms += ' ==> Ingrese el email.\n';
err=true; 
}
else { 

var filter=/^(\w+\.)*\w+\@([-!"&,;\w]+\.)+\w{2,3}$/;
if (filter.test(formulario.email.value))
err=false;
else {
ms = ms + ' ==> Ingrese un email válido!!.\n';
err=true;
}
}


if (formulario.telefono.value=='')
{
ms += '==> Ingrese el telefono.\n';
err=true; 
}


if (formulario.direccion.value=='')
{
ms += '==> Ingrese la dirección.\n';
err=true; 
}


if (formulario.ciudad.value=='')
{
ms += '==> Ingrese la ciudad.\n';
err=true; 
}


if (formulario.usuario.value=='')
{
ms += '==> Ingrese el nombre de usuario.\n';
err=true; 
}


err1 = true;
for(var i=0;i<formulario.length;i++){           
	if (formulario.elements[i].type == "checkbox" && formulario.elements[i].checked == true)
	{
	err1 = false;   
	break;
	}
	
}
if (err1){ ms += '==> Seleccione al menos una materia.\n'; }

if (err || err1) {
//if (err) {
alert(ms); 
return false;
}
else return true; 
}