/* author: stemcc@ats.ca */
/* Generated by AceHTML Freeware http://freeware.acehtml.com */
/* Creation date: 9/13/2005 */
<!--
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;
}

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 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;
}

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];}
}
 
//---------------------------------- Shipment Number length Validation ---------------------------------
function CheckProLength(TrackNbr)  // Validate length of input data on Home page
{
	if (getTracing.TrackNbr.value.length != 11)
	{
		alert("Tracing number must be exactly 11 digits only!");
		getTracing.TrackNbr.focus();	
		return(false);
	}	
return(true);
}

//---------------------------------- Fade function for Online services login ---------------------------------
function fadeo(el) {  
		var browserName = navigator.appName;
		if (browserName == "Microsoft Internet Explorer")
		{
        if (el.filters.blendTrans.status==0) {
                el.filters.blendTrans.Apply();
                if (el.style.visibility == "hidden" || el.style.visibility == "") {
                        el.style.visibility = "visible";
                } else {
                        el.style.visibility = "hidden";
                }
                el.filters.blendTrans.Play();
        }
		}
		else {	   if (el.style.visibility == "hidden" || el.style.visibility == "") {
                        el.style.visibility = "visible";
                } else {
                        el.style.visibility = "hidden";
                }
		}
		
} 

//---------------------------------- Flashing changing color on a specific button id ---------------------------------
function ChangeColor()
{							  

	var element = document.getElementById("btnClose");		 	
				 if(element.style.background == 'red')
				 {
				 	element.style.background = 'yellow';
				 }
				 else
				 {
				 	element.style.background = 'red';
				 }
	if(Colorchk)
		{
			clearTimeout(Colorchk);
		}
	
	Timer = setTimeout('ChangeColor()', 500);	  
}
//---------------------------------- Submit Form from Document Retrieval Click --------------------------------------------------

	function sbmFormDocs(Shipment,doctype)
	{
		element1 = document.getElementById("DocShipmentID");
		element1.value = Shipment;
		element2 = document.getElementById("DocType");
		element2.value = doctype;

		document.GetImages.Submit.click();
	}

//---------------------------------- Submit Form to send PDF email --------------------------------------------------

	function sbmFormEml(Shipment,doctype)
	{
		element1 = document.getElementById("EmlShipmentID");
		element1.value = Shipment;
		element2 = document.getElementById("EmlType");
		element2.value = doctype;

		document.EmailPdf.Submit.click();
	}


//---------------------------------- Submit Form from Shipment Search Click --------------------------------------------------

	function sbmForm(Shipment)
	{
		element = document.getElementById("ShipmentID");
		element.value = Shipment;
		document.LookupPro.Submit.click();
	}
//---------------------------------- Disable an on screen Element --------------------------------------------------

	function setDisabled(el)
	{
		
		if (el == "btnUpdate")
			{
				el.value = "Processing..";
			}
		el.disabled = true;
		
	}
	
//---------------------------------- Enable an on screen element  --------------------------------------------------

	function setEnabled(el)
	{
		if (el = "all")
		{
			var theForm = document.forms["ShipmentSearch"];
			
			for(i=0;i<theForm.elements.length;i++)
			{	if (theForm.elements[i].disabled == true)
				{	
					theForm.elements[i].disabled = false;
				}
			}
		}
		if (el.disabled == true)
		{
			el.disabled = false;
		
		 }
	}

//----------------------------------Reset page contents for Sort Selections  --------------------------------------------------
	function clearSearch()
		{
			sortlist.innerHTML=' ';
				for (x=0;x<5;x++)
				{addSearch[x] = null;}	
		}
//---------------------------------- Load Array for Sort Selections  --------------------------------------------------
	function setSearch(option)
		{
			var cnt = 0;
			for (cnt=0;cnt<5;cnt++)
			{
				if (addSearch[cnt] == null)
				{
				addSearch[cnt] = option;
				var ele = addSearch[cnt];
				cnt = 5;
				}
			}
			
			for(var y=0;y<addSearch.length;++y){
			for(var z=(y+1);z<=addSearch.length;++z){
			if(addSearch[y]==addSearch[z] && addSearch[z] != null){
				addSearch[z] = null;
			}
			}
			}


		// output the new HTML fields to the screen
					sortlist.innerHTML =" ";
					var x = 0;
					for (x=0;x<5;x++)
					{
						if(addSearch[x] != null)
						{
				        if(x==0)
						    {
							var field = document.getElementById("re-sort");
							field.style.visibility = "visible";
							sortlist.innerHTML += '<input type="text"  name="' +addSearch[x] + '" value = "' +addSearch[x] + '"readonly="readonly" style="border-Style:none;font-size:7pt;visibility:visible;background:none;">'
							}
                		else 
							{
							sortlist.innerHTML += '<input type="text"  name="' +addSearch[x] + '" value = "' +addSearch[x] + '"readonly="readonly" style="border-Style:none;font-size:7pt;visibility:visible;background:none;">'};
							}				
					}
					
		
		}


//---------------------------------- show FRP003 Movements Section  --------------------------------------------------
function showFrp003()
		{
			document.getElementByID["movements"].style.visibility='visible';
		}


//---------------------------------- setStatus function used to control update in RPG program  --------------------------------------------------
function setStatus(el)
{
		if(document.getElementById) {
				el.value = 'DoUpdate';
   		}
   		else if (document.all) {  
				document.all(el).value = 'DoUpdate';
  		 } 
  		else if (document.layers) { 
				document.layers[el].value = 'DoUpdate';
   		} 
}
 
//---------------------------------- HideMe function used to hide an element with an ID -----------------------------------

function HideMe(el)
{ 
		if(document.getElementById) 
		{
			if(el == "Result_Div" || el == "Result_Div1"){el.innerHTML = ' ';el.outerHTML = ' ';el.outerText = ' '; el.innerText = ' ';}
			el.style.visibility = "hidden" ;
		}
		else if (document.all) 
		{		
			if(el == "Result_Div" || el == "Result_Div1"){el.innerHTML = ' ';el.outerHTML = ' ';el.outerText = ' '; el.innerText = ' ';}
			document.all(el).style.visibility = "hidden" ;
		}
}
//---------------------------------- ShowMe function used to unHide an element with an ID -----------------------------------

function ShowMe(el)
{ 
		if(document.getElementById) 
		{
			el.style.visibility = "visible" ;
		}
		else if (document.all) 
		{		
			document.all(el).style.visibility = "visible" ;
		}
}
//---------------------------------- ShowHide function used to change a Div sections visibility Style attribute -------------------------------

function ShowHide(el)
{ 
		if(document.getElementById) 
		{
			if (el.style.visibility == "hidden" || el.style.visibility == "") 
			{
				el.style.visibility = "visible";
			} else 	{
					el.style.visibility = "hidden" ;
					}
		}
		else if (document.all) 
		{		
			  	if (document.all(el).style.visibility == "hidden" || document.all(el).style.visibility == "") 
				{
					document.all(el).style.visibility = "visible";
				} else 	{
					document.all(el).style.visibility = "hidden" ;
				}
		}
}
//--------------------------------  Show/Hide DIV Sections Code Starts --------------------------------------------------
// function switchDiv()
//  this function takes the id of a div
//  and calls the other functions required
//  to show that div
//
function switchDiv(div_id)
{
  var style_sheet = getStyleObject(div_id);
  if (style_sheet)
  {
    // hideAll();
    changeObjectVisibility(div_id,"visible");
  }
  else 
  {
    alert("sorry, this only works in browsers that do Dynamic HTML");
  }
}

// function hideAll()
//  hides a bunch of divs
//
function hideAll(div_id)
{
  changeObjectVisibility(div_id,"hidden");
  
}

// function getStyleObject(string) -> returns style object
//  given a string containing the id of an object
//  the function returns the stylesheet of that object
//  or false if it can't find a stylesheet.  Handles
//  cross-browser compatibility issues.
//
function getStyleObject(objectId) {
  // checkW3C DOM, then MSIE 4, then NN 4.
  //
  if(document.getElementById && document.getElementById(objectId)) {
	return document.getElementById(objectId).style;
   }
   else if (document.all && document.all(objectId)) {  
	return document.all(objectId).style;
   } 
   else if (document.layers && document.layers[objectId]) { 
	return document.layers[objectId];
   } else {
	return false;
   }
}

function changeObjectVisibility(objectId, newVisibility) {
    // first get a reference to the cross-browser style object 
    // and make sure the object exists
    var styleObject = getStyleObject(objectId);
    if(styleObject) {
	styleObject.visibility = newVisibility;
	return true;
    } else {
	// we couldn't find the object, so we can't change its visibility
	return false;
    }
}
//-----------------------------------------------  Show/Hide DIV Sections Code Ends  --------------------------------------------------


//------------------------------- AJAX Library functions start - Used for form submissions  --------------------------------------------------

/**
 * The AjaxRequest class is a wrapper for the XMLHttpRequest objects which 
 * are available in most modern browsers. It simplifies the interfaces for
 * making Ajax requests, adds commonly-used convenience methods, and makes 
 * the process of handling state changes more intuitive.
 * An object may be instantiated and used, or the Class methods may be used 
 * which internally create an AjaxRequest object.
 */
function AjaxRequest() {
	var req = new Object();
	
	// -------------------
	// Instance properties
	// -------------------

	/**
	 * Timeout period (in ms) until an async request will be aborted, and
	 * the onTimeout function will be called
	 */
	req.timeout = null;
	
	/**
	 *	Since some browsers cache GET requests via XMLHttpRequest, an
	 * additional parameter called AjaxRequestUniqueId will be added to
	 * the request URI with a unique numeric value appended so that the requested
	 * URL will not be cached.
	 */
	req.generateUniqueUrl = true;
	
	/**
	 * The url that the request will be made to, which defaults to the current 
	 * url of the window
	 */
	req.url = window.location.href;
	
	/**
	 * The method of the request, either GET (default), POST, or HEAD
	 */
	req.method = "GET";
	
	/**
	 * Whether or not the request will be asynchronous. In general, synchronous 
	 * requests should not be used so this should rarely be changed from true
	 */
	req.async = true;
	
	/**
	 * The username used to access the URL
	 */
	req.username = null;
	
	/**
	 * The password used to access the URL
	 */
	req.password = null;
	
	/**
	 * The parameters is an object holding name/value pairs which will be 
	 * added to the url for a GET request or the request content for a POST request
	 */
	req.parameters = new Object();
	
	/**
	 * The sequential index number of this request, updated internally
	 */
	req.requestIndex = AjaxRequest.numAjaxRequests++;
	
	/**
	 * Indicates whether a response has been received yet from the server
	 */
	req.responseReceived = false;
	
	/**
	 * The name of the group that this request belongs to, for activity 
	 * monitoring purposes
	 */
	req.groupName = null;
	
	/**
	 * The query string to be added to the end of a GET request, in proper 
	 * URIEncoded format
	 */
	req.queryString = "";
	
	/**
	 * After a response has been received, this will hold the text contents of 
	 * the response - even in case of error
	 */
	req.responseText = null;
	
	/**
	 * After a response has been received, this will hold the XML content
	 */
	req.responseXML = null;
	
	/**
	 * After a response has been received, this will hold the status code of 
	 * the response as returned by the server.
	 */
	req.status = null;
	
	/**
	 * After a response has been received, this will hold the text description 
	 * of the response code
	 */
	req.statusText = null;

	/**
	 * An internal flag to indicate whether the request has been aborted
	 */
	req.aborted = false;
	
	/**
	 * The XMLHttpRequest object used internally
	 */
	req.xmlHttpRequest = null;

	// --------------
	// Event handlers
	// --------------
	
	/**
	 * If a timeout period is set, and it is reached before a response is 
	 * received, a function reference assigned to onTimeout will be called
	 */
	req.onTimeout = null; 
	
	/**
	 * A function reference assigned will be called when readyState=1
	 */
	req.onLoading = null;

	/**
	 * A function reference assigned will be called when readyState=2
	 */
	req.onLoaded = null;

	/**
	 * A function reference assigned will be called when readyState=3
	 */
	req.onInteractive = null;

	/**
	 * A function reference assigned will be called when readyState=4
	 */
	req.onComplete = null;

	/**
	 * A function reference assigned will be called after onComplete, if 
	 * the statusCode=200
	 */
	req.onSuccess = null;

	/**
	 * A function reference assigned will be called after onComplete, if 
	 * the statusCode != 200
	 */
	req.onError = null;
	
	/**
	 * If this request has a group name, this function reference will be called 
	 * and passed the group name if this is the first request in the group to 
	 * become active
	 */
	req.onGroupBegin = null;

	/**
	 * If this request has a group name, and this request is the last request 
	 * in the group to complete, this function reference will be called
	 */
	req.onGroupEnd = null;

	// Get the XMLHttpRequest object itself
	req.xmlHttpRequest = AjaxRequest.getXmlHttpRequest();
	if (req.xmlHttpRequest==null) { return null; }
	
	// -------------------------------------------------------
	// Attach the event handlers for the XMLHttpRequest object
	// -------------------------------------------------------
	req.xmlHttpRequest.onreadystatechange = 
	function() {
		if (req==null || req.xmlHttpRequest==null) { return; }
		if (req.xmlHttpRequest.readyState==1) { req.onLoadingInternal(req); }
		if (req.xmlHttpRequest.readyState==2) { req.onLoadedInternal(req); }
		if (req.xmlHttpRequest.readyState==3) { req.onInteractiveInternal(req); }
		if (req.xmlHttpRequest.readyState==4) { req.onCompleteInternal(req); }
	};
	
	// ---------------------------------------------------------------------------
	// Internal event handlers that fire, and in turn fire the user event handlers
	// ---------------------------------------------------------------------------
	// Flags to keep track if each event has been handled, in case of 
	// multiple calls (some browsers may call the onreadystatechange 
	// multiple times for the same state)
	req.onLoadingInternalHandled = false;
	req.onLoadedInternalHandled = false;
	req.onInteractiveInternalHandled = false;
	req.onCompleteInternalHandled = false;
	req.onLoadingInternal = 
		function() {
			if (req.onLoadingInternalHandled) { return; }
			AjaxRequest.numActiveAjaxRequests++;
			if (AjaxRequest.numActiveAjaxRequests==1 && typeof(window['AjaxRequestBegin'])=="function") {
				AjaxRequestBegin();
			}
			if (req.groupName!=null) {
				if (typeof(AjaxRequest.numActiveAjaxGroupRequests[req.groupName])=="undefined") {
					AjaxRequest.numActiveAjaxGroupRequests[req.groupName] = 0;
				}
				AjaxRequest.numActiveAjaxGroupRequests[req.groupName]++;
				if (AjaxRequest.numActiveAjaxGroupRequests[req.groupName]==1 && typeof(req.onGroupBegin)=="function") {
					req.onGroupBegin(req.groupName);
				}
			}
			if (typeof(req.onLoading)=="function") {
				req.onLoading(req);
			}
			req.onLoadingInternalHandled = true;
		};
	req.onLoadedInternal = 
		function() {
			if (req.onLoadedInternalHandled) { return; }
			if (typeof(req.onLoaded)=="function") {
				req.onLoaded(req);
			}
			req.onLoadedInternalHandled = true;
		};
	req.onInteractiveInternal = 
		function() {
			if (req.onInteractiveInternalHandled) { return; }
			if (typeof(req.onInteractive)=="function") {
				req.onInteractive(req);
			}
			req.onInteractiveInternalHandled = true;
		};
	req.onCompleteInternal = 
		function() {
			if (req.onCompleteInternalHandled || req.aborted) { return; }
			req.onCompleteInternalHandled = true;
			AjaxRequest.numActiveAjaxRequests--;
			if (AjaxRequest.numActiveAjaxRequests==0 && typeof(window['AjaxRequestEnd'])=="function") {
				AjaxRequestEnd(req.groupName);
			}
			if (req.groupName!=null) {
				AjaxRequest.numActiveAjaxGroupRequests[req.groupName]--;
				if (AjaxRequest.numActiveAjaxGroupRequests[req.groupName]==0 && typeof(req.onGroupEnd)=="function") {
					req.onGroupEnd(req.groupName);
				}
			}
			req.responseReceived = true;
			req.status = req.xmlHttpRequest.status;
			req.statusText = req.xmlHttpRequest.statusText;
			req.responseText = req.xmlHttpRequest.responseText;
			req.responseXML = req.xmlHttpRequest.responseXML;
			if (typeof(req.onComplete)=="function") {
				req.onComplete(req);
			}
			if (req.xmlHttpRequest.status==200 && typeof(req.onSuccess)=="function") {
				req.onSuccess(req);
			}
			else if (typeof(req.onError)=="function") {
				req.onError(req);
			}

			// Clean up so IE doesn't leak memory
			delete req.xmlHttpRequest['onreadystatechange'];
			req.xmlHttpRequest = null;
		};
	req.onTimeoutInternal = 
		function() {
			if (req!=null && req.xmlHttpRequest!=null && !req.onCompleteInternalHandled) {
				req.aborted = true;
				req.xmlHttpRequest.abort();
				AjaxRequest.numActiveAjaxRequests--;
				if (AjaxRequest.numActiveAjaxRequests==0 && typeof(window['AjaxRequestEnd'])=="function") {
					AjaxRequestEnd(req.groupName);
				}
				if (req.groupName!=null) {
					AjaxRequest.numActiveAjaxGroupRequests[req.groupName]--;
					if (AjaxRequest.numActiveAjaxGroupRequests[req.groupName]==0 && typeof(req.onGroupEnd)=="function") {
						req.onGroupEnd(req.groupName);
					}
				}
				if (typeof(req.onTimeout)=="function") {
					req.onTimeout(req);
				}
			// Opera won't fire onreadystatechange after abort, but other browsers do. 
			// So we can't rely on the onreadystate function getting called. Clean up here!
			delete req.xmlHttpRequest['onreadystatechange'];
			req.xmlHttpRequest = null;
			}
		};

	// ----------------
	// Instance methods
	// ----------------
	/**
	 * The process method is called to actually make the request. It builds the
	 * querystring for GET requests (the content for POST requests), sets the
	 * appropriate headers if necessary, and calls the 
	 * XMLHttpRequest.send() method
	*/
	req.process = 
		function() {
			if (req.xmlHttpRequest!=null) {
				// Some logic to get the real request URL
				if (req.generateUniqueUrl && req.method=="GET") {
					req.parameters["AjaxRequestUniqueId"] = new Date().getTime() + "" + req.requestIndex;
				}
				var content = null; // For POST requests, to hold query string
				for (var i in req.parameters) {
					if (req.queryString.length>0) { req.queryString += "&"; }
					req.queryString += encodeURIComponent(i) + "=" + encodeURIComponent(req.parameters[i]);
				}
				if (req.method=="GET") {
					if (req.queryString.length>0) {
						req.url += ((req.url.indexOf("?")>-1)?"&":"?") + req.queryString;
					}
				}
				req.xmlHttpRequest.open(req.method,req.url,req.async,req.username,req.password);
				if (req.method=="POST") {
					if (typeof(req.xmlHttpRequest.setRequestHeader)!="undefined") {
						req.xmlHttpRequest.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
					}
					content = req.queryString;
				}
				if (req.timeout>0) {
					setTimeout(req.onTimeoutInternal,req.timeout);
				}
				req.xmlHttpRequest.send(content);
			}
		};

	/**
	 * An internal function to handle an Object argument, which may contain
	 * either AjaxRequest field values or parameter name/values
	 */
	req.handleArguments = 
		function(args) {
			for (var i in args) {
				// If the AjaxRequest object doesn't have a property which was passed, treat it as a url parameter
				if (typeof(req[i])=="undefined") {
					req.parameters[i] = args[i];
				}
				else {
					req[i] = args[i];
				}
			}
		};

	/**
	 * Returns the results of XMLHttpRequest.getAllResponseHeaders().
	 * Only available after a response has been returned
	 */
	req.getAllResponseHeaders =
		function() {
			if (req.xmlHttpRequest!=null) {
				if (req.responseReceived) {
					return req.xmlHttpRequest.getAllResponseHeaders();
				}
				alert("Cannot getAllResponseHeaders because a response has not yet been received");
			}
		};

	/**
	 * Returns the the value of a response header as returned by 
	 * XMLHttpRequest,getResponseHeader().
	 * Only available after a response has been returned
	 */
	req.getResponseHeader =
		function(headerName) {
			if (req.xmlHttpRequest!=null) {
				if (req.responseReceived) {
					return req.xmlHttpRequest.getResponseHeader(headerName);
				}
				alert("Cannot getResponseHeader because a response has not yet been received");
			}
		};

	return req;
}

// ---------------------------------------
// Static methods of the AjaxRequest class
// ---------------------------------------

/**
 * Returns an XMLHttpRequest object, either as a core object or an ActiveX 
 * implementation. If an object cannot be instantiated, it will return null;
 */
AjaxRequest.getXmlHttpRequest = function() {
	if (window.XMLHttpRequest) {
		return new XMLHttpRequest();
	}
	else if (window.ActiveXObject) {
		// Based on http://jibbering.com/2002/4/httprequest.html
		/*@cc_on @*/
		/*@if (@_jscript_version >= 5)
		try {
			return new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				return new ActiveXObject("Microsoft.XMLHTTP");
			} catch (E) {
				return null;
			}
		}
		@end @*/
	}
	else {
		return null;
	}
};

/**
 * See if any request is active in the background
 */
AjaxRequest.isActive = function() {
	return (AjaxRequest.numActiveAjaxRequests>0);
};

/**
 * Make a GET request. Pass an object containing parameters and arguments as 
 * the second argument.
 * These areguments may be either AjaxRequest properties to set on the request 
 * object or name/values to set in the request querystring.
 */
AjaxRequest.get = function(args) {
	AjaxRequest.doRequest("GET",args);
};

/**
 * Make a POST request. Pass an object containing parameters and arguments as 
 * the second argument.
 * These areguments may be either AjaxRequest properties to set on the request 
 * object or name/values to set in the request querystring.
 */
AjaxRequest.post = function(args) {
	AjaxRequest.doRequest("POST",args);
};

/**
 * The internal method used by the .get() and .post() methods
 */
AjaxRequest.doRequest = function(method,args) {
	if (typeof(args)!="undefined" && args!=null) {
		var myRequest = new AjaxRequest();
		myRequest.method = method;
		myRequest.handleArguments(args);
		myRequest.process();
	}
}	;

/**
 * Submit a form. The requested URL will be the form's ACTION, and the request 
 * method will be the form's METHOD.
 * Returns true if the submittal was handled successfully, else false so it 
 * can easily be used with an onSubmit event for a form, and fallback to 
 * submitting the form normally.
 */
AjaxRequest.submit = function(theform, args) {
	var myRequest = new AjaxRequest();
	if (myRequest==null) { return false; }
	var serializedForm = AjaxRequest.serializeForm(theform);
	myRequest.method = theform.method.toUpperCase();
	myRequest.url = theform.action;
	myRequest.handleArguments(args);
	myRequest.queryString = serializedForm;
	myRequest.process();
	return true;
};

/**
 * Serialize a form into a format which can be sent as a GET string or a POST 
 * content.It correctly ignores disabled fields, maintains order of the fields 
 * as in the elements[] array. The 'file' input type is not supported, as 
 * its content is not available to javascript. This method is used internally
 * by the submit class method.
 */
AjaxRequest.serializeForm = function(theform) {
	var els = theform.elements;
	var len = els.length;
	var queryString = "";
	this.addField = 
		function(name,value) { 
			if (queryString.length>0) { 
				queryString += "&";
			}
			queryString += encodeURIComponent(name) + "=" + encodeURIComponent(value);
		};
	for (var i=0; i<len; i++) {
		var el = els[i];
		if (!el.disabled) {
			switch(el.type) {
				case 'text': case 'password': case 'hidden': case 'textarea': 
					this.addField(el.name,el.value);
					break;
				case 'select-one':
					if (el.selectedIndex>=0) {
						this.addField(el.name,el.options[el.selectedIndex].value);
					}
					break;
				case 'select-multiple':
					for (var j=0; j<el.options.length; j++) {
						if (el.options[j].selected) {
							this.addField(el.name,el.options[j].value);
						}
					}
					break;
				case 'checkbox': case 'radio':
					if (el.checked) {
						this.addField(el.name,el.value);
					}
					break;
			}
		}
	}
	return queryString;
};

// -----------------------
// Static Class variables
// -----------------------

/**
 * The number of total AjaxRequest objects currently active and running
 */
AjaxRequest.numActiveAjaxRequests = 0;

/**
 * An object holding the number of active requests for each group
 */
AjaxRequest.numActiveAjaxGroupRequests = new Object();

/**
 * The total number of AjaxRequest objects instantiated
 */
AjaxRequest.numAjaxRequests = 0;

//-------------------- Date Validations -------------------------------	  
function checkdate(objName) {
var datefield = objName;
if (chkdate(objName) == false) {
datefield.select();
alert("That date is invalid.  Date must be In YYYYMMDD format.");
datefield.focus();
return false;
}
else {
return true;
   }
}
function chkdate(objName) {
var strDatestyle = "YMD"; // Year Month Day
//var strDatestyle = "US"; //United States date style
//var strDatestyle = "EU";  //European date style
var strDate;
var strDateArray;
var strDay;
var strMonth;
var strYear;
var intday;
var intMonth;
var intYear;
var booFound = false;
var datefield = objName;
var strSeparatorArray = new Array("-"," ","/",".");
var intElementNr;
var err = 0;
var strMonthArray = new Array(12);
strMonthArray[0] = "Jan";
strMonthArray[1] = "Feb";
strMonthArray[2] = "Mar";
strMonthArray[3] = "Apr";
strMonthArray[4] = "May";
strMonthArray[5] = "Jun";
strMonthArray[6] = "Jul";
strMonthArray[7] = "Aug";
strMonthArray[8] = "Sep";
strMonthArray[9] = "Oct";
strMonthArray[10] = "Nov";
strMonthArray[11] = "Dec";
strDate = datefield.value;
if (strDate.length < 1) {
return true;
}
for (intElementNr = 0; intElementNr < strSeparatorArray.length; intElementNr++) {
	if (strDate.indexOf(strSeparatorArray[intElementNr]) != -1) {
			strDateArray = strDate.split(strSeparatorArray[intElementNr]);
		if (strDateArray.length != 3) {
			err = 1;
			return false;
			}
		else{
			strYear = strDateArray[0];
			strMonth = strDateArray[1];
			strDay = strDateArray[2];
		}

	booFound = true;
	}
}
if (booFound == false) {
	if (strDate.length>5) {
		strDay = strDate.substr(6, 2);
		strMonth = strDate.substr(4, 2);
		strYear = strDate.substr(0,4);
   }
}
if (strYear.length == 2) {
	strYear = '20' + strYear;
}
// US style
if (strDatestyle == "US") {
	strTemp = strDay;
	strDay = strMonth;
	strMonth = strTemp;
}
intday = parseInt(strDay, 10);

if (isNaN(intday)) {
	err = 2;
	return false;
}

intMonth = parseInt(strMonth, 10);
if (isNaN(intMonth)) {
	for (i = 0;i<12;i++) {
		if (strMonth.toUpperCase() == strMonthArray[i].toUpperCase()) {
			intMonth = i+1;
			strMonth = strMonthArray[i];
			i = 12;
   		}
	}
	if (isNaN(intMonth)) {
		err = 3;
		return false;
   }
}

intYear = parseInt(strYear, 10);
if (isNaN(intYear)) {
	err = 4;
	return false;
}
if (intMonth>12 || intMonth<1) {
	err = 5;
	return false;
}
if ((intMonth == 1 || intMonth == 3 || intMonth == 5 || intMonth == 7 || intMonth == 8 || intMonth == 10 || intMonth == 12) && (intday > 31 || intday < 1)) {
	err = 6;
	return false;
}
if ((intMonth == 4 || intMonth == 6 || intMonth == 9 || intMonth == 11) && (intday > 30 || intday < 1)) {
	err = 7;
	return false;
}
if (intMonth == 2) {
	if (intday < 1) {
		err = 8;
		return false;
	}
	if (LeapYear(intYear) == true) {
		if (intday > 29) {
			err = 9;
			return false;
		}
	}
	else {
		if (intday > 28) {
		err = 10;
		return false;
		}
	}
}
if (strDatestyle == "US") {
	// datefield.value = strMonthArray[intMonth-1] + " " + intday+" " + strYear;
}
else {
	//datefield.value = intday + " " + strMonthArray[intMonth-1] + " " + strYear;
}
return true;
}
function LeapYear(intYear) {
if (intYear % 100 == 0) {
if (intYear % 400 == 0) { return true; }
}
else {
if ((intYear % 4) == 0) { return true; }
}
return false;
}
function doDateCheck(from, to) {

if (from.value == "" || to.value == "") {
	alert("Both dates must be entered.");
} 
if (from.value > to.value) {
alert("To date must occur after the from date.");
   }
}			 

//-------------------- Display an element at mouse coordinates -------------------------------
/* function show_coords(event,ele)
{
x=event.clientX
y=event.clientY

   	if(document.getElementById) 
		{
		showme = document.getElementById(ele);
		}
	else if (document.all) 
		{
		showme = document.all(ele);
		}

showme.style.position = 'absolute';
showme.style.left = x+20;
showme.style.top = y;
showme.style.visibility = 'visible';
}	*/		 

function show_coords(e,ele)
{
var docX, docY;
   if( e )
   {
      if( typeof( e.pageX ) == 'number' )
      {
         docX = e.pageX;
         docY = e.pageY;
      }
      else
      {
         docX = e.clientX + document.body.scrollLeft;;
         docY = e.clientY + document.body.scrollTop;;
      }
   }
   
	if(document.getElementById) 
		{
		showme = document.getElementById(ele);
		}
	else if (document.all) 
		{
		showme = document.all(ele);
		} 
showme.style.position = 'absolute';
showme.style.left = docX;
showme.style.top = docY;
showme.style.visibility = 'visible';
}
  
//---------------------------------- Control Display of Partner Check Box --------------------------------------------------

	function checkPartner()
	{
		if (partner == 'N')
		{
	  		element = document.getElementById("chkPartner");
	  		element.style.visibility = 'hidden';
			element1 = document.getElementById("lblPartner");
	  		element1.style.visibility = 'hidden';
		}
		
	} 
	
//---------------------------------- User Setup Edits --------------------------------------------------
function check(el)
{
	document.frmAccounts.submit();
}

function MoveOption(from, to)
{				
	if (typeof from == 'undefined')
	{
		alert ('Type in an account name first.')
	}
	else
	{
				
		if (from.selectedIndex < 0 )
		{
			alert ('You must select an account first!')
		}
		else
		{
			for (var i=0;i<from.options.length;i++)
			{											
				if (from.options[i].selected)
				{
					for (var x=0;x<to.options.length;x++)
			  		{
			   			var fromval = from.options[i].value;
						var toval = to.options[x].value;
						if (toval == fromval) 
			 			{
			 				alert ('A duplicate account was selected');
							return false;
			 			}
					}
		   			var moveto = to.length++;
					to.options[moveto].text = from.options[i].text;
					to.options[moveto].value = from.options[i].value;
					to.options[moveto].selected = true;
					from.options[i].selected = false;
					var el = document.getElementById("commit");
					el.style.visibility='visible'; 
					document.frmAccounts.addaccount.value='Y'
				}
			}
		}
	}
}

function rmvAcct(account)
{											 
	if (account.selectedIndex < 0)
	{
		alert ('You must select an account first!')
	}
	else
	{
		for (var i=0;i<account.options.length;i++)
		{											
			if (account.options[i].selected)
			{
				//account.options[i].selected = false;
				//account.options[i].value = '**DELETED**';
				var el = document.getElementById("commit");
				el.style.visibility='visible';
				document.frmAccounts.rmvaccount.value='Y'
			}
		}
	}
}

function checkPwd(el)
{
	var chgFlag;
	if(document.getElementById) {
				chgFlag = document.getElementById("chgpwd");
   		}
   		else if (document.all) {  
				chgFlag = document.all("chgpwd");
  		 } 
  		else if (document.layers) { 
				chgFlag = document.layers["chgpwd"];
   		} 
		
	var chgValue = document.getElementById(el);
	if (chgValue.checked)
	{
		chgFlag.value = 'Y';
		alert ('Change status is: ' + chgFlag);
	}
	else
	{
		
		chgFlag.value = 'N';
		alert ('Change status is: ' + chgFlag);
	}
}
							 		
function validate(el)
{
	var valid = el.value;
	var formname = el.form.name;
	var field = el.name;
	if (valid.length == 0)
	{
		alert ('You must enter at least one value.');
		document.forms.focus();
		return false;
	}
}
//-->

 

