//fxBrowser
//sendForm
//placeFocus
//highlight
//MM_validateForm
//date
//warnInvalid
//textCounter

function fxBrowser()
{
	var agt = navigator.userAgent.toLowerCase();
	if ( ((nVersion < 4) && (agt.indexOf('msie') != -1)) || (strBrowser == "Netscape 4") )
		alert(' You must to be using Internet Explorer 4 or better, Please switch to IE.')
}

var fPrePrefix = "I Need Your Help With This:\n\n"
var nVersion = (parseInt(navigator.appVersion));
var strBrowser = ((navigator.appName) + ' ' + nVersion);
function sendForm() {
	if (strBrowser != "Netscape 4"){
		return confirm("Is all the information correct?\nHit OK to submit or CANCEL to make changes.\n\n Please be patient while the application is sent.");
	}else{
		alert("You CANNOT submit this data using Netscape 4.\n\n Please switch to IE 4 or higher and complete the form again.");
		return false
	}
}

function placeFocus() {
if (document.forms.length > 0) {
var field = document.forms[0];
for (i = 0; i < field.length; i++) {
if ((field.elements[i].type == "text") || (field.elements[i].type == "textarea") || (field.elements[i].type.toString().charAt(0) == "s")) {
document.forms[0].elements[i].focus();
break;
         }
      }
   }
}

var highlightcolor="#87CEEB"

var ns6=document.getElementById&&!document.all
var previous=''
var eventobj

//Regular expression to highlight only form elements
var intended=/INPUT|TEXTAREA|SELECT|OPTION/

//Function to check whether element clicked is form element
function checkel(which)
{
	if (which.style&&intended.test(which.tagName))
	{
		if (ns6&&eventobj.nodeType==3)
			eventobj=eventobj.parentNode.parentNode
		return true
	}else return false
}

//Function to highlight form element
function highlight(e)
{
  if (strBrowser != "Netscape 4"){
	eventobj=ns6? e.target : event.srcElement
	if (previous!=''){
		if (checkel(previous))
			previous.style.backgroundColor=''
			previous=eventobj
				if (checkel(eventobj))
					eventobj.style.backgroundColor=highlightcolor
	}else{
		if (checkel(eventobj))
			eventobj.style.backgroundColor=highlightcolor
			previous=eventobj
	}
  }
}

function MM_findObj(n, d) 
{ //v3.0
  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); 
		return x;
}

var submitcount = 0;
function MM_validateForm() 
{ //v3.0
   if (submitcount == 0)
   {
	  submitcount++;
	  document.all.submit.value = "  Sending...  ";
	  document.all.submit.disabled = true;

	  	var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
	  	for (i=0; i < (args.length-2); i+=4) 
		{ test=args[i+2]; val=MM_findObj(args[i]);
	    	if (val) 
			{ nm=args[i+3]; 
				if ((val=val.value)=="") 
				{
	      		errors += '- '+nm+' is required.\n'; 
				}
	  		}
		} 

		if (errors) alert('The following error(s) occurred:\n'+errors);
	  	document.MM_returnValue = (errors == '');

		if (document.MM_returnValue == false)
		{
		  document.all.submit.value = "  Re-Submit...  ";
		  document.all.submit.disabled = false;
		  submitcount = 0;
		}
   }

}


function date(){
  var date = new Date();
  var d  = date.getDate();
  var day = (d < 10) ? '0' + d : d;
  var m = date.getMonth() + 1;
  var month = (m < 10) ? '0' + m : m;
  var yy = date.getYear();
  var year = (yy < 100) ? yy + 2000 : yy;

  document.all.Today.value = month + "/" + day + "/" + year;

}

function warnInvalid (theField, s)
{   theField.focus()
    theField.select()
    alert(s)
    return false
}

function textCounter(field, countfield, maxlimit) {
if (field.value.length > maxlimit) // if too long...trim it!
field.value = field.value.substring(0, maxlimit);
// otherwise, update 'characters left' counter
else 
countfield.value = maxlimit - field.value.length;
}



