
<!-- Begin
   // Set up the image files to be used.
   var theImages = new Array() // do not change this
   // To add more image files, continue with the
   // pattern below, adding to the array.

   theImages[0] = 'media/srv.jpg'
   theImages[1] = 'media/srv2.jpg'
   theImages[2] = 'media/srv3.jpg'
  
   // do not edit anything below this line

   var j = 0
   var p = theImages.length;
   var preBuffer = new Array()
   for (i = 0; i < p; i++){
   preBuffer[i] = new Image()
   preBuffer[i].src = theImages[i]
   }
   var whichImage = Math.round(Math.random()*(p-1));
   function showImage(){
   document.write('<img src="'+theImages[whichImage]+'">');
   }

   // End -->

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;
}
/* Functions that swaps images. */
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 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;
}

/* Functions that handle preload. */
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 printdoc()
{
	alert("Queira modificar os parametros de impressão para 'Landscape'");
	if(document.all && navigator.appVersion.substring(22,23)==4) {
		self.focus();
		var OLECMDID_PRINT = 6;
		var OLECMDEXECOPT_DONTPROMPTUSER = 2;
		var OLECMDEXECOPT_PROMPTUSER = 1;
		var WebBrowser = '<object id="WebBrowser1" width="0" height="0" classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></object>';
		document.body.insertAdjacentHTML('beforeEnd',WebBrowser);
		WebBrowser1.ExecWB(OLECMDID_PRINT,OLECMDEXECOPT_DONTPROMPTUSER);
		WebBrowser1.outerHTML = '';
		}
	else{
		window.print();
		}
	}	


function printpage()

{
window.print()
}

function show(menu)
{
document.all(menu).style.visibility="visible";
}
function hide(menu)
{
document.all(menu).style.visibility="hidden"
}


function MM_reloadPage(init) {  //reloads the window if Nav4 resized

  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {

    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}

  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();

}

function popupcentree(page,largeur,hauteur,options)
{
var top=(screen.height-hauteur)/2;
var left=(screen.width-largeur)/2;
window.open(page,"","top="+top+",left="+left+",width="+largeur+",height="+hauteur+","+options);
}

function CheckForm(form)
{
	var i;
	var arr;
	var str;
	var x;
	
	for (i=0;i<form.elements.length;i++)
	{
		if(form.elements[i].name.substr(0,4) == "CHK_")
		{			
			
			str = GetFieldValueByName(form,form.elements[i].name.substr(4));
			
			if(str != null)
			{
			
				str = Trim(str);
							
				arr = form.elements[i].value.split("|");			
				
				switch(arr[0])
				{
					case "STR":
						//check mandatory field							
						if ((str.length == 0) && (arr[3] == "True"))
						{
							alert("" + arr[4] + "");
							return false;
						}
						
						//check min length	
						if (str.length < parseInt(arr[1]))
						{
							alert("" + arr[4] + "");
							return false;
						}
						
						//check max length
						if (str.length > parseInt(arr[2]))
						{
							alert("" + arr[4] + "");
							return false;
						}
							break;
							
							case "NUM":
						//check mandatory field							
						if ((str.length == 0) && (arr[3] == "True"))
						{
							alert("" + arr[4] + "");
							return false;
						}
						
						//check min length	
						if (str.length < parseInt(arr[1]))
						{
							alert("" + arr[4] + "");
							return false;
						}
						
						//check max length
						if (str.length > parseInt(arr[2]))
						{
							alert("" + arr[4] + "");
							return false;
						}
						//check sanity
						if(!(IsNumeric(str)))
						{
							alert("" + arr[4] + "");
							return false;
						}
							break;
							
						case "EMAIL":
	
					if (str.indexOf('@')==-1)
					{
					alert("" + arr[4] + "");
							return false;
						}
					if (str.indexOf('.')==-1)
					{
					alert("" + arr[4] + "");
							return false;
						}
					break;
						
					case "INT":
																
						//check mandatory field
						if ((str.length == 0) && (arr[3] == "True"))
						{
							alert("" + arr[4] + "");
							return false;
						}
						
						//check sanity
						if(!(IsNumeric(str)))
						{
							alert("" + arr[4] + "");
							return false;
						}
												
						//check min value
						if (arr[1] != "x")
						{
							if (parseInt(str) < parseInt(arr[1]))
							{
								alert("" + arr[4] + "");
								return false;
							}
						}
						
						//check max length
						if (arr[2] != "x")
						{
							if (parseInt(str) > parseInt(arr[2]))
							{
								alert("" + arr[4] + "");
								return false;
							}
						}
						
						break;
					
					case "FLOAT":
																		
						//check mandatory field
						if ((str.length == 0) && (arr[3] == "True"))
						{
							alert("" + arr[4] + "");
							return false;
						}
						
						//check sanity
if(!(IsNumeric(str)))
						{
							alert("" + arr[4] + "");
							return false;
						}
												
						//check min value
						if (arr[1] != "x")
						{
							if (parseFloat(str) < parseFloat(arr[1]))
							{
								alert("" + arr[4] + "");
								return false;
							}
						}
						
						//check max length
						if (arr[2] != "x")
						{
							if (parseFloat(str) > parseFloat(arr[2]))
							{
								alert("" + arr[4] + "");
								return false;
							}
						}
						
						break;
										
						
					case "DATE":
						
						//check mandatory field
						if ((str.length == 0) && (arr[3] == "True"))
						{
							alert("" + arr[4] + "");
							return false;
						}
						
						//check sanity
						if(!(IsDate(str)))
						{
							alert("" + arr[4] + "");
							return false;
						}
						
						//check min value
						if (arr[1] != "x")
						{
							if (GetDate(str) < GetDate(arr[1]))
							{
								alert("" + arr[4] + "");
								return false;
							}
						}
						
						//check max length
						if (arr[2] != "x")
						{
							if (GetDate(str) > GetDate(arr[2]))
							{
								alert("" + arr[4] + "");
								return false;
							}
						}
						
						break;
				}
			}
		}
	}

}

//============================================================================================

function Replace(string,replacechar,replacewith) 
{
	var temp = "";
	var i;
	
	string = '' + string;
	splitstring = string.split(replacechar);
	for(i = 0; i < splitstring.length; i++)
	{
		if(i < (splitstring.length -1))
			temp += splitstring[i] + replacewith;
		else
			temp += splitstring[i];
	}
	return temp;
}

//============================================================================================

function GetFieldValueByName(form,name)
{
	var i;
	
	for (i=0;i<form.elements.length;i++)
	{
		if(form.elements[i].name == name)
			return (form.elements[i].value);
	}
	return null
}

/*

======================= STANDARD HELPER FUNCTIONS BELOW =======================================

*/
function IsNumeric(str)
{
	var i;
	for(i=0;i<str.length;i++)
	{
		/*if(!(	((str.charAt(i) <= '9') && (str.charAt(i) >= '0')) ||
				(str.charAt(i) == ' ') || (str.charAt(i) == '.') || (str.charAt(i) == '-')))
				*/
				if(!(	((str.charAt(i) <= '9') && (str.charAt(i) >= '0')) ||
				(str.charAt(i) == ' ') || (str.charAt(i) == ',') || (str.charAt(i) == '-')))
			return(false);
	}
	return(true);
}

//============================================================================================

function IsAlphaNumeric(str)
{
	var i;
	for(i=0;i<str.length;i++)
	{
		if(!(	((str.charAt(i) <= '9') && (str.charAt(i) >= '0')) ||
				((str.charAt(i) <= 'z') && (str.charAt(i) >= 'a')) ||
				(str.charAt(i) == ' ') || (str.charAt(i) == '-') ||
				(str.charAt(i) == 'ü') || (str.charAt(i) == 'ä') ||
				(str.charAt(i) == 'ö') || (str.charAt(i) == 'Ü') ||
				(str.charAt(i) == 'Ä') || (str.charAt(i) == 'Ö') ||
				(str.charAt(i) == 'é') || (str.charAt(i) == 'ß') ||
				((str.charAt(i) <= 'Z') && (str.charAt(i) >= 'A')) ))
			return(false);
	}
	return(true);
}

//============================================================================================

function IsAlpha(str)
{
	var i;
	
	for(i=0;i<str.length;i++)
	{
		if(!(	((str.charAt(i) <= 'z') && (str.charAt(i) >= 'a')) ||
				(str.charAt(i) == ' ') || (str.charAt(i) == '-') ||
				(str.charAt(i) == 'ü') || (str.charAt(i) == 'ä') ||
				(str.charAt(i) == 'ö') || (str.charAt(i) == 'Ü') ||
				(str.charAt(i) == 'Ä') || (str.charAt(i) == 'Ö') ||
				(str.charAt(i) == 'é') || (str.charAt(i) == 'ß') ||
				((str.charAt(i) <= 'Z') && (str.charAt(i) >= 'A')) ))
			return(false);

	}
	return(true);
}

//============================================================================================

function Trim(str)
{
	//trim leding spaces
	while(true)
	{
		if(str.charAt(0) == ' ')
			str = str.substr(1);
		else
			break;
	}
	
	//trim trailing spaces
	while(true)
	{
		if(str.charAt(str.length-1) == ' ')
			str = str.substr(0,str.length-1);
		else
		break;
	}
	return(str);	
}

//============================================================================================

function IsDate(argDate)
{
	var date_split;
	var i;
	var tdate, tmonth, tyear;
	
	date_split = argDate.split('/');
	
	//check for date parts
	if(date_split.length != 3)
		return(false);
		
	//check for zero values
	for(i=0;i<date_split.length;i++)
	{
		if(parseInt(date_split[i]) == 0)
			return(false);
	}
	
	//check for 4-digit year
	if(date_split[2].length != 4)
		return(false);
		
	//check for valid date, e.g. 02/29/1997
	tdate = parseInt(date_split[1]);
	tmonth = parseInt(date_split[0]);
	tyear = parseInt(date_split[2]);
	
	var date = new Date(parseInt(date_split[2]),parseInt(date_split[0])-1,parseInt(date_split[1]));
		
	if(date.getDate() != tdate)
		return(false);
	
	if(date.getMonth() != (tmonth-1))
		return(false);
	
	if(date.getFullYear() != tyear)
		return(false);
		
	return(true);
}


function GetDate(argDate)
{
	//use IsDate() first !!!!
	
	var date_split;	
	var tdate, tmonth, tyear;
	
	date_split = argDate.split('/');
	
		
	
	tdate = parseInt(date_split[1]);
	tmonth = parseInt(date_split[0]);
	tyear = parseInt(date_split[2]);
	
	return date = new Date(parseInt(date_split[2]),parseInt(date_split[0])-1,parseInt(date_split[1]));
		
}
