function GoBack()
{
	javascript:window.history.back();
}

function openWin(url) {
  myWin= open(url, "viewWindow", 
    "width=500,height=400,status=no,toolbar=no,menubar=no,location=no,screenX=500,screenY=250");
}

function txtBoxOnKeyPress(object, maxlength) {
	if ( object.value.length >= maxlength)	return false;
	return true;
}

/////////////////////////////////////////////////////////////////////////
// Date Function //////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////

function MLS_getdate() {
  today = new Date();
  var day = today.getDate(); 
  var month = today.getMonth();
  var weekday = today.getDay();
  var year = today.getFullYear();

  days = new Array;
  days[0] = "Sunday";
  days[1] = "Monday";
  days[2] = "Tuesday";
  days[3] = "Wednesday";
  days[4] = "Thursday";
  days[5] = "Friday";
  days[6] = "Saturday";

  months = new Array;
  months[0] = "January";
  months[1] = "February";
  months[2] = "March";
  months[3] = "April";
  months[4] = "May";
  months[5] = "June";
  months[6] = "July";
  months[7] = "August";
  months[8] = "September";
  months[9] = "October";
  months[10] = "November";
  months[11] = "December"; 

  var output = days[weekday] + " " + months[month] + " " + day + ", " + year;
  document.write(output);
}

// removes trailing spaces from string
function rtrim(string)
{
        return string.replace(/\s+$/gi, "");
}
 
// removes leading spaces from string
function ltrim(string)
{
        return string.replace(/^\s*/gi, "");
}
 
// removes trailing and leading spaces from string
function trim(string)
{
        return ltrim(rtrim(string));
}

// checks required fields on a form
// you can pass in an arbitrary number of parameters
// parameters must be made up of a seqence of field and label.  
// Label will be displayed in the message box if the field is missing.
// e.g. checkRequiredFields(field1, "Description")
// if field1 is blank, a message box will display the following
// Description is required
// focus will then be set to that field
function checkRequiredFields()
{
	if( (arguments.length % 2) != 0 )
	{
		alert("Invalid parameter list [checkRequiredFields]");
		return false;
	}
	
	for( var i = 0; i < arguments.length; i += 2)
	{
		if( trim(arguments[i].value) == "" )
		{
			alert( arguments[i+1] + " is required." );
			arguments[i].focus();
			return false;
		}
	}
	
	return true;
}
function isEmail(str) {   
  // are regular expressions supported? 
  var supported = 0;
  if (window.RegExp) {
    var tempStr = "a";
    var tempReg = new RegExp(tempStr);
    if (tempReg.test(tempStr)) supported = 1;
  }
  if (!supported) 
    return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
  var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
  var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
  return (!r1.test(str) && r2.test(str));
}

// TabNext()
// Function to auto-tab phone field
// Arguments:
//   obj :  The input object (this)
//   event: Either 'up' or 'down' depending on the keypress event
//   len  : Max length of field - tab when input reaches this length
//   next_field: input object to get focus after this one
// -------------------------------------------------------------------
var phone_field_length=0;
function TabNext(obj,event,len,next_field) {
	if (event == "down") {
		phone_field_length=obj.value.length;
		}
	else if (event == "up") {
		if (obj.value.length != phone_field_length) {
			phone_field_length=obj.value.length;
			if (phone_field_length == len) {
				next_field.focus();
				}
			}
		}
	}

function isNumeric( objName )
{
	var numberfield = objName;

	if( numberfield.value != "" ) 
	{
	    re = /^[0-9]/;
    
	    if (re.test(numberfield.value) == true)
		    return true;
		else
		{
			alert("Must be Numeric.");
			return false;
		}
	}
    return true;    
}

//  End -->