var ventanaCalendario=false

function muestraCalendario(formulario,campo,campo1,campo2)
{
	if (typeof ventanaCalendario.document == "object") {
		ventanaCalendario.close()
	}
	ventanaCalendario = window.open("calendario/index.php?formulario=" + formulario + "&nomcampo=" + campo + "&nomcampo1=" + campo1 + "&nomcampo2=" + campo2,"calendario","width=250,height=320,left=400,top=200,scrollbars=no,menubars=no,statusbar=no,status=no,resizable=no,location=NO")
}


function Val_Email(p_mail,p_mensaje)
{
	var Template = /^[a-z][a-z-_0-9.]+@[a-z-_=>0-9.]+.[a-z]{2,3}$/i //Formato de direccion de correo electronico
	if(p_mail.value!="") 
	{
		if (Template.test(p_mail.value)) 
		{				}
		else
		{   alert(p_mensaje);
			p_mail.focus();
			p_mail.select();
		}		
	}
	return false;
}


function Val_Campo(p_campo,p_msg_vacio,p_msg_invalido,p_msg_link)
{
 	var filter=/^[A-Za-z][A-Za-z0-9_]*@[A-Za-z0-9_]+\.[A-Za-z0-9_.]+[A-za-z]$/;
	var tem = p_campo.value;
    var i = tem.length;
	var j = 0;
	var x = 0;
	var z = 0;

  if (p_campo.value == "")
  {		alert (p_msg_vacio);
		p_campo.focus();
		return false;
  }
  else
  {		
	// verirficamos que no se ingrese una direccion web
	for (k = 0; k<=i; k++)
	{
		j = tem.indexOf(" ",0);
		tem = tem.substring(0,j) + tem.substring(j+1,tem.length);
	}
	x = tem.indexOf("<a href=",0);
	z = tem.indexOf("</a>",0);

	if ((x >= 0) || (z >= 0))
	{
		alert (p_msg_link);
		p_campo.focus();
		return false;
	}
	else 
	{
		// verificamos que no se le ingresen comillas
		for(i=0; i<tem.length; i++)
		{	if(tem.charAt(i)=="'")	
			{	
				alert (p_msg_invalido);
				p_campo.focus();
				return false;	
				break;
			}				
		}
	return true;
	}

  }
}


var win = null;
function NewWindow(mypage,myname,w,h,scroll,resi){
LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
settings =
'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable='+resi+''
win = window.open(mypage,myname,settings,resi)

if(win.window.focus){win.window.focus();}
}
