function ValidateForm(form)
{
	var x = form.elements;
	for (var i=0;i<x.length;i++)
	{
		EleObj=x[i].id;
		LastIndex = EleObj.substring(EleObj.length-2,EleObj.length)
		switch(LastIndex)
		{
			case "_R":
				if(ValidateForm_Required(x[i],x[i].title)==false)
					return false;
			break;
			case "_E":
				if(ValidateForm_Email(x[i],x[i].title)==false)
					return false;
			break;
			case "_I":
				if(ValidateForm_Required(x[i],x[i].title)==false)
					return false;
				if(ValidateForm_Numeric(x[i],'0123456789 ',x[i].title)==false)
					return false;
			break;
			case "_N":
				if(ValidateForm_Numeric(x[i],'0123456789',x[i].title)==false)
					return false;
			break;
		}		
	}
return true;
}

function ValidateForm_Required(Ctrl,msg)
{
	if(trimString(Ctrl.value) == "")
	{
		alert(msg);
		Ctrl.focus();
		return false;
	}
	return true;
}
function ValidateForm_Checked(Ctrl,msg)
{
	if(Ctrl.checked == false)
	{
		alert(msg);
		Ctrl.focus();
		return false;
	}
	return true;
}
function ValidateForm_Numeric(Ctrl,valid_chars,msg)
{
	if(chkNumericValidate(Ctrl.value,valid_chars) == false)
	{
		alert(msg);
		Ctrl.focus();
		return false;
	}
	return true;
}
function chkNumericValidate(strString,strValidChars)
{
   var strChar;
   var blnResult = true; 
  	for (i = 0; i < strString.length && blnResult == true; i++)
   {
	  strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
      {
    	   blnResult = false;
      }
   }
   return blnResult;
}
function ValidateForm_Email(Ctrl,msg)
{
	if(chkEmailValidate(Ctrl.value) == false)
	{
		alert(msg);
		Ctrl.focus();
		return false;
	}
	return true;
}

function ValidateForm_Confirm(Ctrl1,Ctrl2,msg)
{
	if(Ctrl1.value != Ctrl2.value)
	{
		alert(msg);
		Ctrl2.focus();
		return false;
	}
	return true;
}

function chkEmailValidate(str)
{
	return(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(str));
}
function trimString (str)
{
  str = this != window? this : str;
  return str.replace(/^\s+/g, '').replace(/\s+$/g, '');
}




		
		// Set the horizontal and vertical position for the popup
		
		PositionX = 20;
		PositionY = 20;
		
		// Set these value approximately 20 pixels greater than the
		// size of the largest image to be used (needed for Netscape)
		
		defaultWidth  = 500;
		defaultHeight = 500;
		
		// Set autoclose true to have the window close automatically
		// Set autoclose false to allow multiple popup windows
		
		var AutoClose = true;
		
		// Do not edit below this line...
		// ================================
		if (parseInt(navigator.appVersion.charAt(0))>=4){
		var isNN=(navigator.appName=="Netscape")?1:0;
		var isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}
		var optNN='scrollbars=no,width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY;
		var optIE='scrollbars=no,width=150,height=100,left='+PositionX+',top='+PositionY;
		function popImage(imageURL,imageTitle)
		{
					if (isNN){imgWin=window.open('about:blank','',optNN);}
					if (isIE){imgWin=window.open('about:blank','',optIE);}
					with (imgWin.document){
					writeln('<html><head><title>Loading...</title><style>body{margin:0px;}</style>');writeln('<sc'+'ript>');
					writeln('var isNN,isIE;');writeln('if (parseInt(navigator.appVersion.charAt(0))>=4){');
					writeln('isNN=(navigator.appName=="Netscape")?1:0;');writeln('isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}');
					writeln('function reSizeToImage(){');writeln('if (isIE){');writeln('window.resizeTo(100,100);');
					writeln('width=250-(document.body.clientWidth-document.images[0].width);');
					writeln('height=100-(document.body.clientHeight-document.images[0].height);');
					writeln('window.resizeTo(width,height);}');writeln('if (isNN){');       
					writeln('window.innerWidth=document.images["George"].width;');writeln('window.innerHeight=document.images["George"].height;}}');
					writeln('function doTitle(){document.title="'+imageTitle+'";}');writeln('</sc'+'ript>');
					if (!AutoClose) writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()">')
					else writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()" onblur="self.close()">');
					writeln('<img name="George" src='+imageURL+' style="display:block"></body></html>');
					close();		
					}
		}
function mypopup(url,wwidth,wheight,iid)
 {
   mywindow = window.open (url,"mywindow","location=1,status=1,scrollbars=1,menubar=0,resizable=0,width="+wwidth+",height="+wheight+"");
   
   mywindow.moveTo(0,0);
   
 //  width=document.getElementById(iid).width;
 //  height=document.getElementById(iid).height;
   
   //window.resizeTo(width,height)
	  return false;
 } 
 function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
