function JSUtil(){

}


JSUtil.customMessageHandler=function(data){
    /*if ($('_message_area'))
        DWRUtil.setValue('_message_area',data);
    else*/
        alert(data);
};


JSUtil.initPage = function (callbackMethod){
    
     if (window.addEventListener) {
 		 window.addEventListener("load", callbackMethod, false);
	}
	else if (window.attachEvent) {
  		window.attachEvent("onload", callbackMethod);
	}
	else {
 		 window.onload = callbackMethod;
	}
	
}

JSUtil.changeHeaderForeColor = function(idx, headers){
	for(var i=0; i<headers.length; i++){
		if(i==idx) $(headers[i]).style.color = '#DAA350';
		else $(headers[i]).style.color = '#FFFFFF';
	}
};

JSUtil.IE = (navigator.appName=='Microsoft Internet Explorer')?true:false;

JSUtil.composeDefaultLabel=function (label,e){
    var htmlTxt = '';
    if (e.style.display=='none'){
	     htmlTxt=htmlTxt + '<img src="images/arrow-down.gif" align="middle"> ';  
	}else{
	     htmlTxt=htmlTxt+ '<img src="images/arrow.gif" align="middle"> ';
	}
	htmlTxt=htmlTxt+label;
	return htmlTxt;
};


JSUtil.changeImageSource = function(imgobj,e){
    var e = document.getElementById(e);
    if (e){
    if (e.style.display=='none'){
        imgobj.src = 'images/arrow-down.gif';
    }else{
        imgobj.src = 'images/arrow.gif';
    }
    }
    return true;
};

JSUtil.stopRender =function(e,selectishidden){
	if(e.hidingLayer!=null)
 e.hidingLayer.style.display='none';
	e.style.display='none';
	if (!selectishidden)
	   JSUtil.hideSelectElements(false);
	
    
};


JSUtil.renderThis =function(e,hidingLayerElem,pleft,ptop,hideselect){
    if (!hideselect && hideselect!=false)
         JSUtil.hideSelectElements(true);
     
    var _innerWidth=JSUtil.clientWidth();
    var _innerHeight=JSUtil.clientHeight();
    
    var hidingLayerHeight=JSUtil.IE?$('mainbody').offsetHeight: document.documentElement.clientHeight;
    var hidingLayerWidth =JSUtil.IE?$('mainbody').offsetWidth:document.documentElement.clientWidth;
    var hidingLayerTop = 0;
    var hidingLayerLeft= JSUtil.scrollLeft;
    var hidingLayer = $('dummyFrame');
    if (hidingLayerElem)
       hidingLayer =hidingLayerElem;
    hidingLayer.style.cssText='position:absolute;left:'+hidingLayerLeft+';top:'+hidingLayerTop+';width:'+hidingLayerWidth+'px;height:'+hidingLayerHeight+'px;background-color:#ee8888;z-index:499;-moz-opacity:0.4;opacity:0.4;filter:alpha(opacity=40)';
    hidingLayer.style.visibility='visible';
    e.style.cssText='position:absolute;top:0px;left:0px;z-index:500;'; 
   
   if (pleft)
     e.style.left= pleft;
   else   
     e.style.left= '340px';
    if (ptop)
        e.style.top= ptop;
    else
        e.style.top= '200px';
   
    e.style.display='inline';
    e.hidingLayer=hidingLayer;
    document.body.appendChild(hidingLayer);
    
};

JSUtil.clientWidth =function(){
    return JSUtil.filterResults(window.innerWidth?window.innerWidth:0,
                                        document.documentElement?document.documentElement.clientWidth:0,
                                        document.body?document.body.clientWidth:0);
}

JSUtil.clientHeight =function(){
    
    return JSUtil.filterResults(window.innerWidth?window.innerWidth:0,
                                        document.documentElement?document.documentElement.clientHeight:0,
                                        document.body?document.body.clientHeight:0);
}

JSUtil.scrollLeft =function(){
    
    return JSUtil.filterResults(window.pageXOffset?window.pageXOffset:0,
                                        document.documentElement?document.documentElement.scrollLeft:0,
                                        document.body?document.body.scrollLeft:0);
}

JSUtil.scrollTop=function(){
    
    return JSUtil.filterResults(window.pageYOffset?window.pageYOffset:0,
                                        document.documentElement?document.documentElement.scrollTop:0,
                                        document.body?document.body.scrollTop:0);
}



JSUtil.filterResults =function(nwin,ndocel,nbody){
    var nresult= nwin?nwin:0;
    if (ndocel && (!nresult || nresult>ndocel))
        nresult=ndocel;
    return nbody && (!nresult || (nresult>nbody)) ?nbody:nresult;

}




JSUtil.composeTicketLabel=function(ticketName,status,ticketNumber){
	var htmlTxt='<table width="100%" cellspacing="0" cellpadding="0" class="paneHeader"><tr valign="middle"><td width="33%">';
	htmlTxt=htmlTxt + '<img src="images/arrow-down.gif" id="ticketBodyImage" align="absmiddle">'+ticketName+'</td>';  
	if (status=='I')
		status='IN PROCESS'
	else if (status=='C')
		status='COMPLETED';
	else if (status=='K')
		status='<font color="#983A1B">CANCELLED</font>';
	else if (status=='S')
		status='SUBMITTED';
	else if (status=='N')
		status='NEW';	
	
	htmlTxt =htmlTxt+ '<td width="33%" align="center">Status: '+status+'</td>';
	if (ticketNumber)
	htmlTxt =htmlTxt+ '<td width="33%" align="right">Ticket Number:&nbsp;'+ticketNumber+'&nbsp;&nbsp;</td>';
	else
	htmlTxt =htmlTxt+ '<td width="33%" align="right">&nbsp;</td>';
	
	htmlTxt =htmlTxt+ '</tr></table>';
	return htmlTxt;
};

JSUtil.customRowCreator = function(options) {
    var row = document.createElement("tr");
    var index = options.rowIndex;
    if(index%2==0)
      row.style.backgroundColor='#FFFFFF';
    else
      row.style.backgroundColor='#CDCDCD';
    row.style.float ='left';
    return row;
};

JSUtil.reportRowCreator = function(options){
	var row = document.createElement("tr");
    var index = options.rowIndex;
	row.style.verticalAlign='top';
    if(index%2==0)
      row.style.backgroundColor='#FFFFFF';
    else
      row.style.backgroundColor='#CDCDCD';
    row.style.float ='left';
    return row;
}

JSUtil.customCellCreator =function(options) {
    var td = document.createElement("td");
    td.style.textAlign='center';
   	if (options.cellNum<6){
   		td.width='15%';
   	}else{
   		td.width='10%';
   	}
  	
    
    return td;
};

JSUtil.reportCellCreator  =function(options) {
    var td = document.createElement("td");
	if (options.cellNum==5){
		td.style.textAlign='left';
	}
	else{
		td.style.textAlign='center';
	}
   	/*if (options.cellNum<6){
   		td.width='15%';
   	}else{
   		td.width='10%';
   	}*/
  	
    
    return td;
}; 
JSUtil.defaultCellCreator =function(options) {
    var td = document.createElement("td");
    td.style.textAlign='center';
    return td;
};
JSUtil.getRadioButtonValue=function(obj){
      for (var i=0;i<obj.length;i++){
          if (obj[i].checked){
              return obj[i].value;
          }
      }
};

JSUtil.setRadioButtonValue=function(obj,value){
      for (var i=0;i<obj.length;i++){
          if (obj[i].value==value){
              obj[i].checked=true;
          }else{
              obj[i].checked=false;
          }
      }
};

JSUtil.convertDateToMillis = function (date){
    if (date==null) return null;
    if (date=='') return null;
    var mydate =new Date(date);
    return mydate.getTime();
};
var separator = ",";  // use comma as 000's separator
  var decpoint = ".";  // use period as decimal point
  var percent = "%";
  var currency = "$";  // use dollar sign for currency

  JSUtil.formatNumber = function(number, format, print) {  // use: formatNumber(number, "format")
    if (print) document.write("formatNumber(" + number + ", \"" + format + "\")<br>");

    if (number - 0 != number) return null;  // if number is NaN return null
    var useSeparator = format.indexOf(separator) != -1;  // use separators in number
    var usePercent = format.indexOf(percent) != -1;  // convert output to percentage
    var useCurrency = format.indexOf(currency) != -1;  // use currency format
    var isNegative = (number < 0);
    number = Math.abs (number);
    if (usePercent) number *= 100;
    format = strip(format, separator + percent + currency);  // remove key characters
    number = "" + number;  // convert number input to string

     // split input value into LHS and RHS using decpoint as divider
    var dec = number.indexOf(decpoint) != -1;
    var nleftEnd = (dec) ? number.substring(0, number.indexOf(".")) : number;
    var nrightEnd = (dec) ? number.substring(number.indexOf(".") + 1) : "";

     // split format string into LHS and RHS using decpoint as divider
    dec = format.indexOf(decpoint) != -1;
    var sleftEnd = (dec) ? format.substring(0, format.indexOf(".")) : format;
    var srightEnd = (dec) ? format.substring(format.indexOf(".") + 1) : "";

     // adjust decimal places by cropping or adding zeros to LHS of number
    if (srightEnd.length < nrightEnd.length) {
      var nextChar = nrightEnd.charAt(srightEnd.length) - 0;
      nrightEnd = nrightEnd.substring(0, srightEnd.length);
      if (nextChar >= 5) nrightEnd = "" + ((nrightEnd - 0) + 1);  // round up

 // patch provided by Patti Marcoux 1999/08/06
      while (srightEnd.length > nrightEnd.length) {
        nrightEnd = "0" + nrightEnd;
      }

      if (srightEnd.length < nrightEnd.length) {
        nrightEnd = nrightEnd.substring(1);
        nleftEnd = (nleftEnd - 0) + 1;
      }
    } else {
      for (var i=nrightEnd.length; srightEnd.length > nrightEnd.length; i++) {
        if (srightEnd.charAt(i) == "0") nrightEnd += "0";  // append zero to RHS of number
        else break;
      }
    }

     // adjust leading zeros
    sleftEnd = strip(sleftEnd, "#");  // remove hashes from LHS of format
    while (sleftEnd.length > nleftEnd.length) {
      nleftEnd = "0" + nleftEnd;  // prepend zero to LHS of number
    }

    if (useSeparator) nleftEnd = separate(nleftEnd, separator);  // add separator
    var output = nleftEnd + ((nrightEnd != "") ? "." + nrightEnd : "");  // combine parts
    output = ((useCurrency) ? currency : "") + output + ((usePercent) ? percent : "");
    if (isNegative) {
      // patch suggested by Tom Denn 25/4/2001
      output = (useCurrency) ? "(" + output + ")" : "-" + output;
    }
    return output;
  };

  function strip(input, chars) {  // strip all characters in 'chars' from input
    var output = "";  // initialise output string
    for (var i=0; i < input.length; i++)
      if (chars.indexOf(input.charAt(i)) == -1)
        output += input.charAt(i);
    return output;
  }

  function separate(input, separator) {  // format input using 'separator' to mark 000's
    input = "" + input;
    var output = "";  // initialise output string
    for (var i=0; i < input.length; i++) {
      if (i != 0 && (input.length - i) % 3 == 0) output += separator;
      output += input.charAt(i);
    }
    return output;
  }

  // ===================================================================
// Author: Matt Kruse <matt@mattkruse.com>
// WWW: http://www.mattkruse.com/
//
// NOTICE: You may use this code for any purpose, commercial or
// private, without any further permission from the author. You may
// remove this notice from your final code if you wish, however it is
// appreciated by the author if at least my web site address is kept.
//
// You may *NOT* re-distribute this code in any way except through its
// use. That means, you can include it in your product, or your web
// site, or any other form where the code is actually being used. You
// may not put the plain javascript up on your site for download or
// include it in your javascript libraries for download.
// If you wish to share this code with others, please just point them
// to the URL instead.
// Please DO NOT link directly to my .js files from your site. Copy
// the files to your server and use them there. Thank you.
// ===================================================================

// HISTORY
// ------------------------------------------------------------------
// May 17, 2003: Fixed bug in parseDate() for dates <1970
// March 11, 2003: Added parseDate() function
// March 11, 2003: Added "NNN" formatting option. Doesn't match up
//                 perfectly with SimpleDateFormat formats, but
//                 backwards-compatability was required.

// ------------------------------------------------------------------
// These functions use the same 'format' strings as the
// java.text.SimpleDateFormat class, with minor exceptions.
// The format string consists of the following abbreviations:
//
// Field        | Full Form          | Short Form
// -------------+--------------------+-----------------------
// Year         | yyyy (4 digits)    | yy (2 digits), y (2 or 4 digits)
// Month        | MMM (name or abbr.)| MM (2 digits), M (1 or 2 digits)
//              | NNN (abbr.)        |
// Day of Month | dd (2 digits)      | d (1 or 2 digits)
// Day of Week  | EE (name)          | E (abbr)
// Hour (1-12)  | hh (2 digits)      | h (1 or 2 digits)
// Hour (0-23)  | HH (2 digits)      | H (1 or 2 digits)
// Hour (0-11)  | KK (2 digits)      | K (1 or 2 digits)
// Hour (1-24)  | kk (2 digits)      | k (1 or 2 digits)
// Minute       | mm (2 digits)      | m (1 or 2 digits)
// Second       | ss (2 digits)      | s (1 or 2 digits)
// AM/PM        | a                  |
//
// NOTE THE DIFFERENCE BETWEEN MM and mm! Month=MM, not mm!
// Examples:
//  "MMM d, y" matches: January 01, 2000
//                      Dec 1, 1900
//                      Nov 20, 00
//  "M/d/yy"   matches: 01/20/00
//                      9/2/00
//  "MMM dd, yyyy hh:mm:ssa" matches: "January 01, 2000 12:30:45AM"
// ------------------------------------------------------------------

var MONTH_NAMES=new Array('January','February','March','April','May','June','July','August','September','October','November','December','Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
var DAY_NAMES=new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sun','Mon','Tue','Wed','Thu','Fri','Sat');
function LZ(x) {return(x<0||x>9?"":"0")+x}

// ------------------------------------------------------------------
// isDate ( date_string, format_string )
// Returns true if date string matches format of format string and
// is a valid date. Else returns false.
// It is recommended that you trim whitespace around the value before
// passing it to this function, as whitespace is NOT ignored!
// ------------------------------------------------------------------
function isDate(val,format) {
	var date=getDateFromFormat(val,format);
	if (date==0) { return false; }
	return true;
	}

// -------------------------------------------------------------------
// compareDates(date1,date1format,date2,date2format)
//   Compare two date strings to see which is greater.
//   Returns:
//   1 if date1 is greater than date2
//   0 if date2 is greater than date1 of if they are the same
//  -1 if either of the dates is in an invalid format
// -------------------------------------------------------------------
function compareDates(date1,dateformat1,date2,dateformat2) {
	var d1=getDateFromFormat(date1,dateformat1);
	var d2=getDateFromFormat(date2,dateformat2);
	if (d1==0 || d2==0) {
		return -1;
		}
	else if (d1 > d2) {
		return 1;
		}
	return 0;
	}

// ------------------------------------------------------------------
// formatDate (date_object, format)
// Returns a date in the output format specified.
// The format string uses the same abbreviations as in getDateFromFormat()
// ------------------------------------------------------------------
function formatDate(date,format) {
    if (date=='') return null;
    if (date==null) return '';
    format=format+"";
	var result="";
	var i_format=0;
	var c="";
	var token="";
	var y=date.getYear()+"";
	var M=date.getMonth()+1;
	var d=date.getDate();
	var E=date.getDay();
	var H=date.getHours();
	var m=date.getMinutes();
	var s=date.getSeconds();
	var yyyy,yy,MMM,MM,dd,hh,h,mm,ss,ampm,HH,H,KK,K,kk,k;
	// Convert real date parts into formatted versions
	var value=new Object();
	if (y.length < 4) {y=""+(y-0+1900);}
	value["y"]=""+y;
	value["yyyy"]=y;
	value["yy"]=y.substring(2,4);
	value["M"]=M;
	value["MM"]=LZ(M);
	value["MMM"]=MONTH_NAMES[M-1];
	value["NNN"]=MONTH_NAMES[M+11];
	value["d"]=d;
	value["dd"]=LZ(d);
	value["E"]=DAY_NAMES[E+7];
	value["EE"]=DAY_NAMES[E];
	value["H"]=H;
	value["HH"]=LZ(H);
	if (H==0){value["h"]=12;}
	else if (H>12){value["h"]=H-12;}
	else {value["h"]=H;}
	value["hh"]=LZ(value["h"]);
	if (H>11){value["K"]=H-12;} else {value["K"]=H;}
	value["k"]=H+1;
	value["KK"]=LZ(value["K"]);
	value["kk"]=LZ(value["k"]);
	if (H > 11) { value["a"]="PM"; }
	else { value["a"]="AM"; }
	value["m"]=m;
	value["mm"]=LZ(m);
	value["s"]=s;
	value["ss"]=LZ(s);
	while (i_format < format.length) {
		c=format.charAt(i_format);
		token="";
		while ((format.charAt(i_format)==c) && (i_format < format.length)) {
			token += format.charAt(i_format++);
			}
		if (value[token] != null) { result=result + value[token]; }
		else { result=result + token; }
		}
	return result;
	}

// ------------------------------------------------------------------
// Utility functions for parsing in getDateFromFormat()
// ------------------------------------------------------------------
function _isInteger(val) {
	var digits="1234567890";
	for (var i=0; i < val.length; i++) {
		if (digits.indexOf(val.charAt(i))==-1) { return false; }
		}
	return true;
	}
function _getInt(str,i,minlength,maxlength) {
	for (var x=maxlength; x>=minlength; x--) {
		var token=str.substring(i,i+x);
		if (token.length < minlength) { return null; }
		if (_isInteger(token)) { return token; }
		}
	return null;
	}

// ------------------------------------------------------------------
// getDateFromFormat( date_string , format_string )
//
// This function takes a date string and a format string. It matches
// If the date string matches the format string, it returns the
// getTime() of the date. If it does not match, it returns 0.
// ------------------------------------------------------------------
function getDateFromFormat(val,format) {
	val=val+"";
	format=format+"";
	var i_val=0;
	var i_format=0;
	var c="";
	var token="";
	var token2="";
	var x,y;
	var now=new Date();
	var year=now.getYear();
	var month=now.getMonth()+1;
	var date=1;
	var hh=now.getHours();
	var mm=now.getMinutes();
	var ss=now.getSeconds();
	var ampm="";

	while (i_format < format.length) {
		// Get next token from format string
		c=format.charAt(i_format);
		token="";
		while ((format.charAt(i_format)==c) && (i_format < format.length)) {
			token += format.charAt(i_format++);
			}
		// Extract contents of value based on format token
		if (token=="yyyy" || token=="yy" || token=="y") {
			if (token=="yyyy") { x=4;y=4; }
			if (token=="yy")   { x=2;y=2; }
			if (token=="y")    { x=2;y=4; }
			year=_getInt(val,i_val,x,y);
			if (year==null) { return 0; }
			i_val += year.length;
			if (year.length==2) {
				if (year > 70) { year=1900+(year-0); }
				else { year=2000+(year-0); }
				}
			}
		else if (token=="MMM"||token=="NNN"){
			month=0;
			for (var i=0; i<MONTH_NAMES.length; i++) {
				var month_name=MONTH_NAMES[i];
				if (val.substring(i_val,i_val+month_name.length).toLowerCase()==month_name.toLowerCase()) {
					if (token=="MMM"||(token=="NNN"&&i>11)) {
						month=i+1;
						if (month>12) { month -= 12; }
						i_val += month_name.length;
						break;
						}
					}
				}
			if ((month < 1)||(month>12)){return 0;}
			}
		else if (token=="EE"||token=="E"){
			for (var i=0; i<DAY_NAMES.length; i++) {
				var day_name=DAY_NAMES[i];
				if (val.substring(i_val,i_val+day_name.length).toLowerCase()==day_name.toLowerCase()) {
					i_val += day_name.length;
					break;
					}
				}
			}
		else if (token=="MM"||token=="M") {
			month=_getInt(val,i_val,token.length,2);
			if(month==null||(month<1)||(month>12)){return 0;}
			i_val+=month.length;}
		else if (token=="dd"||token=="d") {
			date=_getInt(val,i_val,token.length,2);
			if(date==null||(date<1)||(date>31)){return 0;}
			i_val+=date.length;}
		else if (token=="hh"||token=="h") {
			hh=_getInt(val,i_val,token.length,2);
			if(hh==null||(hh<1)||(hh>12)){return 0;}
			i_val+=hh.length;}
		else if (token=="HH"||token=="H") {
			hh=_getInt(val,i_val,token.length,2);
			if(hh==null||(hh<0)||(hh>23)){return 0;}
			i_val+=hh.length;}
		else if (token=="KK"||token=="K") {
			hh=_getInt(val,i_val,token.length,2);
			if(hh==null||(hh<0)||(hh>11)){return 0;}
			i_val+=hh.length;}
		else if (token=="kk"||token=="k") {
			hh=_getInt(val,i_val,token.length,2);
			if(hh==null||(hh<1)||(hh>24)){return 0;}
			i_val+=hh.length;hh--;}
		else if (token=="mm"||token=="m") {
			mm=_getInt(val,i_val,token.length,2);
			if(mm==null||(mm<0)||(mm>59)){return 0;}
			i_val+=mm.length;}
		else if (token=="ss"||token=="s") {
			ss=_getInt(val,i_val,token.length,2);
			if(ss==null||(ss<0)||(ss>59)){return 0;}
			i_val+=ss.length;}
		else if (token=="a") {
			if (val.substring(i_val,i_val+2).toLowerCase()=="am") {ampm="AM";}
			else if (val.substring(i_val,i_val+2).toLowerCase()=="pm") {ampm="PM";}
			else {return 0;}
			i_val+=2;}
		else {
			if (val.substring(i_val,i_val+token.length)!=token) {return 0;}
			else {i_val+=token.length;}
			}
		}
	// If there are any trailing characters left in the value, it doesn't match
	if (i_val != val.length) { return 0; }
	// Is date valid for month?
	if (month==2) {
		// Check for leap year
		if ( ( (year%4==0)&&(year%100 != 0) ) || (year%400==0) ) { // leap year
			if (date > 29){ return 0; }
			}
		else { if (date > 28) { return 0; } }
		}
	if ((month==4)||(month==6)||(month==9)||(month==11)) {
		if (date > 30) { return 0; }
		}
	// Correct hours value
	if (hh<12 && ampm=="PM") { hh=hh-0+12; }
	else if (hh>11 && ampm=="AM") { hh-=12; }
	var newdate=new Date(year,month-1,date,hh,mm,ss);
	return newdate.getTime();
	}

// ------------------------------------------------------------------
// parseDate( date_string [, prefer_euro_format] )
//
// This function takes a date string and tries to match it to a
// number of possible date formats to get the value. It will try to
// match against the following international formats, in this order:
// y-M-d   MMM d, y   MMM d,y   y-MMM-d   d-MMM-y  MMM d
// M/d/y   M-d-y      M.d.y     MMM-d     M/d      M-d
// d/M/y   d-M-y      d.M.y     d-MMM     d/M      d-M
// A second argument may be passed to instruct the method to search
// for formats like d/M/y (european format) before M/d/y (American).
// Returns a Date object or null if no patterns match.
// ------------------------------------------------------------------
function parseDate(val) {
	var preferEuro=(arguments.length==2)?arguments[1]:false;
	generalFormats=new Array('y-M-d','MMM d, y','MMM d,y','y-MMM-d','d-MMM-y','MMM d');
	monthFirst=new Array('M/d/y','M-d-y','M.d.y','MMM-d','M/d','M-d');
	dateFirst =new Array('d/M/y','d-M-y','d.M.y','d-MMM','d/M','d-M');
	var checkList=new Array('generalFormats',preferEuro?'dateFirst':'monthFirst',preferEuro?'monthFirst':'dateFirst');
	var d=null;
	for (var i=0; i<checkList.length; i++) {
		var l=window[checkList[i]];
		for (var j=0; j<l.length; j++) {
			d=getDateFromFormat(val,l[j]);
			if (d!=0) { return new Date(d); }
			}
		}
	return null;
	}
	
//date sorting utils
var dateRE = /^(\d{2})[\/\- ](\d{2})[\/\- ](\d{2})/;
function dmyOrdA(a, b) {
	a = a.replace(dateRE,"$3$2$1");
	b = b.replace(dateRE,"$3$2$1");
	if (a>b) return 1;
	if (a <b) return -1;
	return 0; 
}

function dmyOrdD(a, b) {
	a = a.replace(dateRE,"$3$2$1");
	b = b.replace(dateRE,"$3$2$1");
	if (a>b) return -1;
	if (a <b) return 1;
	return 0; 
}

function mdyOrdA(a, b) {
	a = a.replace(dateRE,"$3$1$2");
	b = b.replace(dateRE,"$3$1$2");
	if (a>b) return 1;
	if (a <b) return -1;
	return 0; 
}

function mdyOrdD(a, b) {
	a = a.replace(dateRE,"$3$1$2");
	b = b.replace(dateRE,"$3$1$2");
	if (a>b) return -1;
	if (a <b) return 1;
	return 0; 
	}


function sortDist(a, b) {
	return formatDate(new Date(a.effectiveFrom),'MM/dd/yy').replace(dateRE,"$3$1$2") - formatDate(new Date(b.effectiveFrom),'MM/dd/yy').replace(dateRE,"$3$1$2");
	//return a.effectiveFrom - b.effectiveFrom;
}

/*-----------------------------------

Update effective to date


-----------------------------------*/
JSUtil.updateDistSets = function(dists) {
	if (dists.length > 1) {
		for (var i=0;i<dists.length;i++){
			dists[i].effectiveFrom = new Date(dists[i].effectiveFrom).getTime();
		}
		dists.sort(sortDist);
		for (var i=0;i<dists.length;i++) {
			if ((i+1) < dists.length){
				dists[i].effectiveTo = formatDate(new Date(dists[i+1].effectiveFrom-(1*24*60*60*1000)),'MM/dd/yyyy');  //subtract 1 day(converted from millis)
			}
			else
			    dists[i].effectiveTo = null;
				
		}
		for (var i=0;i<dists.length;i++){
			dists[i].effectiveFrom = formatDate(new Date(dists[i].effectiveFrom),'MM/dd/yyyy');
		}
	}
	else if (dists.length == 1) {
		dists[0].effectiveFrom = formatDate(new Date(dists[0].effectiveFrom),'MM/dd/yyyy');
		//alert('effective from: ' + dists[0].effectiveFrom);
	}
	return dists;

};



/*
Country State Drop Downs v1.0.
(c) Copyright 2005 Down Home Consulting, Inc.
www.DownHomeConsulting.com

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. The software is provided "as is", without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, itness for a particular purpose and noninfringement. in no event shall the authors or copyright holders be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the software or the use or other dealings in the software.

*/

// State table
//
// To edit the list, just delete a line or add a line. Order is important.
// The order displayed here is the order it appears on the drop down.
//
var state = '\
AL:AL - Alabama|\
AK:AK - Alaska|\
AS:AS - American Samoa|\
AZ:AZ - Arizona|\
AR:AR - Arkansas|\
CA:CA - California|\
CO:CO - Colorado|\
CT:CT - Connecticut|\
DC:DC - D.C.|\
DE:DE - Delaware|\
FL:FL - Florida|\
GA:GA - Georgia|\
GU:GU - Guam|\
HI:HI - Hawaii|\
ID:ID - Idaho|\
IL:IL - Illinois|\
IN:IN - Indiana|\
IA:IA - Iowa|\
KS:KS - Kansas|\
KY:KY - Kentucky|\
LA:LA - Louisiana|\
ME:ME - Maine|\
MP:MP - Marianas|\
MH:MH - Marshall Islands|\
MD:MD - Maryland|\
MA:MA - Massachusetts|\
MI:MI - Michigan|\
FM:FM - Micronesia|\
AA:AA - Military Americas|\
AE:AE - Military Europe/ME/Canada|\
AP:AP - Military Pacific|\
MN:MN - Minnesota|\
MS:MS - Mississippi|\
MO:MO - Missouri|\
MT:MT - Montana|\
NE:ME - Nebraska|\
NV:NV - Nevada|\
NH:NH - New Hampshire|\
NJ:NJ - New Jersey|\
NM:NM - New Mexico|\
NY:NY - New York|\
NC:NC - North Carolina|\
ND:ND - North Dakota|\
OH:OH - Ohio|\
OK:OK - Oklahoma|\
OR:OR - Oregon|\
PW:PW - Palau|\
PA:PA - Pennsylvania|\
PR:PR - Puerto Rico|\
RI:RI - Rhode Island|\
SC:SC - South Carolina|\
SD:SD - South Dakota|\
TN:TN - Tennessee|\
TX:TX - Texas|\
UT:UT - Utah|\
VT:VT - Vermont|\
VA:VA - Virginia|\
VI:VI - Virgin Islands|\
WA:WA - Washington|\
WV:WV - West Virginia|\
WI:WI - Wisconsin|\
WY:WY - Wyoming|\
';



JSUtil.TrimString=function(sInString) {
  if ( sInString ) {
    sInString = sInString.replace( /^\s+/g, "" );// strip leading
    return sInString.replace( /\s+$/g, "" );// strip trailing
  }
}


JSUtil.populateState=function (el) {
	var stateLineArray = state.split('|');
	var selObj = $('state');
	if (el){
	   selObj =el;
	}
	selObj.options[0] = new Option('','');
	selObj.selectedIndex = 0;
	for (var loop = 0; loop < stateLineArray.length-1; loop++) {
		lineArray = stateLineArray[loop].split(':');
		stateCode  = JSUtil.TrimString(lineArray[0]);
		stateName  = JSUtil.TrimString(lineArray[1]);
		if ( stateCode != '' ) {
			selObj.options[loop+1] = new Option(stateName, stateCode);
		}
		
		
	}
}

// Email Validation Javascript
// copyright 23rd March 2003, by Stephen Chapman, Felgall Pty Ltd

// You have permission to copy and use this javascript provided that
// the content of the script is not changed in any way.
/*The email address to be validated needs to be passed in place of email_field 
 * in the above code. If the email field is mandatory then the mandatory field 
 * should contain '1' otherwise it should be '0'. The messages field can be set 
 * to '1' to return individual messages about which particular test that the 
 * email address failed to meet. The error messages will be suppressed if this 
 * is set to '0' and you can provide your own failure message. The value 
 * returned will be true if the email address is considered to be valid and 
 * false if it isn't.
 * 
 */

JSUtil.validateEmail=function(addr,man,db) {
	if (addr == '' && man) {
   		if (db) alert('email address is mandatory');
   		return false;
	}
	var invalidChars = '\/\'\\ ";:?!()[]\{\}^|';
	for (i=0; i<invalidChars.length; i++) {
   		if (addr.indexOf(invalidChars.charAt(i),0) > -1) {
      		if (db) alert('email address contains invalid characters');
      		return false;
   		}
	}
	for (i=0; i<addr.length; i++) {
   		if (addr.charCodeAt(i)>127) {
      		if (db) alert("email address contains non ascii characters.");
      		return false;
   		}
	}

	var atPos = addr.indexOf('@',0);
	if (atPos == -1) {
   		if (db) alert('email address must contain an @');
   		return false;
	}
	if (atPos == 0) {
   		if (db) alert('email address must not start with @');
   		return false;
	}
	if (addr.indexOf('@', atPos + 1) > - 1) {
   		if (db) alert('email address must contain only one @');
   		return false;
	}
	if (addr.indexOf('.', atPos) == -1) {
   		if (db) alert('email address must contain a period in the domain name');
   		return false;
	}
	if (addr.indexOf('@.',0) != -1) {
   		if (db) alert('period must not immediately follow @ in email address');
   		return false;
	}
	if (addr.indexOf('.@',0) != -1){
   		if (db) alert('period must not immediately precede @ in email address');
   		return false;
	}
	if (addr.indexOf('..',0) != -1) {
   		if (db) alert('two periods must not be adjacent in email address');
   		return false;
	}
	var suffix = addr.substring(addr.lastIndexOf('.')+1);
	if (suffix.length != 2 && suffix != 'com' && suffix != 'net' && suffix != 'org' && suffix != 'edu' && suffix != 'int' && suffix != 'mil' && suffix != 'gov' & suffix != 'arpa' && suffix != 'biz' && suffix != 'aero' && suffix != 'name' && suffix != 'coop' && suffix != 'info' && suffix != 'pro' && suffix != 'museum') {
   		if (db) alert('invalid primary domain in email address');
   		return false;
	}
	return true;
}

<!-- Original:  Brian Swalwell -->

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

JSUtil.validateZIP=function (field) {
	var valid = "0123456789-";
	var hyphencount = 0;

	if (field.length!=5 && field.length!=10) {
		alert("Please enter your 5 digit or 5 digit+4 zip code like '12345-6789'.");
		return false;
	}
	for (var i=0; i < field.length; i++) {
		temp = "" + field.substring(i, i+1);
		if (temp == "-") hyphencount++;
		if (valid.indexOf(temp) == "-1") {
			alert("Invalid characters in your zip code.  Please try again.");
			return false;
		}
	
		if ((hyphencount > 1) || ((field.length==10) && ""+field.charAt(5)!="-")) {
			alert("The hyphen character should be used with a properly formatted 5 digit+four zip code, like '12345-6789'.   Please try again.");
			return false;
   		}
	}
	return true;
}


var phoneNumberDelimiters = "()- ";
var digitsInUSPhoneNumber = 10;
var reInteger = /^\d+$/
var reNumber = /^\d{1,3}(\.\d{1,2})?$/
var reNumber2 = /^\d{1,7}(\.\d{1,2})?$/
var reNumber9 = /^\d{1,9}(\.\d{1,2})?$/
//var reNumberIncentive =/^(((+|-)?\d+(\.\d*)?)|((+|-)?(\d*\.)?\d+))$/

JSUtil.checkUSPhone=function(phone)
{   var normalizedPhone = JSUtil.stripCharsInBag(phone, phoneNumberDelimiters);
	if (!JSUtil.isUSPhoneNumber(normalizedPhone, false)) 
        return false;
    else 
    {  // if you don't want to reformat as (123) 456-789, comment next line out
          //phone = reformatUSPhone(normalizedPhone)
          return true;
    }
}

// takes USPhone, a string of 10 digits
// and reformats as (123) 456-789

JSUtil.reformatUSPhone=function(USPhone)
{   return (JSUtil.reformat(JSUtil.stripCharsInBag(USPhone, phoneNumberDelimiters), "(", 3, ") ", 3, "-", 4))
}

JSUtil.reformat=function(s)
{   var arg;
    var sPos = 0;
    var resultString = "";

    for (var i = 1; i < JSUtil.reformat.arguments.length; i++) {
       arg = JSUtil.reformat.arguments[i];
       if (i % 2 == 1) resultString += arg;
       else {
           resultString += s.substring(sPos, sPos + arg);
           sPos += arg;
       }
    }
    return resultString;
}

// Removes all characters which appear in string bag from string s.
JSUtil.stripCharsInBag=function(s, bag)
{   var i;
    var returnString = "";

    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }

    return returnString;
}

// isUSPhoneNumber (STRING s [, BOOLEAN emptyOK])
// 
// isUSPhoneNumber returns true if string s is a valid U.S. Phone
// Number.  Must be 10 digits.
//
// NOTE: Strip out any delimiters (spaces, hyphens, parentheses, etc.)
// from string s before calling this function.
//
JSUtil.isUSPhoneNumber=function(s)
{   
	return (JSUtil.isInteger(s) && s.length == digitsInUSPhoneNumber)
}

// isInteger (STRING s [, BOOLEAN emptyOK])
// 
// Returns true if all characters in string s are numbers.
//
// Accepts non-signed integers only. Does not accept floating 
// point, exponential notation, etc.
//
// We don't use parseInt because that would accept a string
// with trailing non-numeric characters.
//
// By default, returns defaultEmptyOK if s is empty.
// There is an optional second argument called emptyOK.
// emptyOK is used to override for a single function call
//      the default behavior which is specified globally by
//      defaultEmptyOK.
// If emptyOK is false (or any value other than true), 
//      the function will return false if s is empty.
// If emptyOK is true, the function will return true if s is empty.
//
// EXAMPLE FUNCTION CALL:     RESULT:
// isInteger ("5")            true 
// isInteger ("")             defaultEmptyOK
// isInteger ("-5")           false
// isInteger ("", true)       true
// isInteger ("", false)      false
// isInteger ("5", false)     true

JSUtil.isInteger=function (s)
{   
	return reInteger.test(s)
}

JSUtil.checkRealNumber=function(s){
	if (isNaN(s)){
		return false;
	}
	return reNumber.test(s);
}

/*JSUtil.checkRealNumberIncentive=function(s){
	if (isNaN(s)){
		return false;
	}
	return reNumberIncentive.test(s);
}*/

JSUtil.checkRealNumberIncentive = function (s)
{   //var reSignedFloat = /^(((\+|\-)?\d{1,3}(\.\d{1,2})?)|((\+|\-)?(\d{1,3}\.)?\d{1,2}))$/
	 var reSignedFloat = /^((\+|\-)?\d{1,3}(\.\d{1,2})?)$/
	 //var reSignedFloat = /^(\d{1,3}(\.\d{1,2})?)$/
	return reSignedFloat.test(s)
}

JSUtil.checkRealNumber2=function(s){
	if (isNaN(s)){
		return false;
	}
	return reNumber2.test(s);
}

JSUtil.checkRealNumber9=function(s){
	if (isNaN(s)){
		return false;
	}
	return reNumber9.test(s);
}

JSUtil.xstooltip_show = function (tooltipId, parentId, posX, posY)
{
	it = document.getElementById(tooltipId);
	
    
    if ((it.style.top == '' || it.style.top == 0) 
        && (it.style.left == '' || it.style.left == 0))
    {
        // need to fixate default size (MSIE problem)
        it.style.width = it.offsetWidth + 'px';
        it.style.height = it.offsetHeight + 'px';
        
        img = document.getElementById(parentId); 
    			
		x = JSUtil.xstooltip_findPosX(img)- parseInt(posX);
        y = JSUtil.xstooltip_findPosY(img) + parseInt(posY);	
        
		it.style.top = y + 'px';
        it.style.left = x + 'px';
    }
    
    it.style.visibility = 'visible'; 
}

JSUtil.xstooltip_findPosY = function (obj) 
{
    var curtop = 0;
    if (obj.offsetParent) 
    {
        while (obj.offsetParent) 
        {
            curtop += obj.offsetTop
            obj = obj.offsetParent;
        }
    }
    else if (obj.y)
        curtop += obj.y;
    return curtop;
}

JSUtil.xstooltip_findPosX = function(obj) 
{
  var curleft = 0;
  if (obj.offsetParent) 
  {
    while (obj.offsetParent) 
        {
            curleft += obj.offsetLeft
            obj = obj.offsetParent;
        }
    }
    else if (obj.x)
        curleft += obj.x;
    return curleft;
}

JSUtil.validateSSN = function(ssn) {
	var re1=/^[0-9]{3}\-[0-9]{2}\-[0-9]{4}$/;
	var re2=/^[0-9]{2}\-[0-9]{7}$/;
	
	if (ssn.search(re1)==0)
		return true;
	if (ssn.search(re2)==0)
		return true;
	return false;
}

JSUtil.validateSSN_TIN = function(ssn, t) {
	if (t=='tin'){
		var re2=/^[0-9]{2}\-[0-9]{7}$/;
		if (ssn.search(re2)==0)
		return true;
	}
	else{
		var re1=/^[0-9]{3}\-[0-9]{2}\-[0-9]{4}$/;
		if (ssn.search(re1)==0)
		return true;
	}
	
	
	
	return false;
}

JSUtil.composeTicketAreaNotAllowedMessage=function(message){
	
	var htmlText = '<div style="font-weight:bold;font-size:15px;color:black;text-align:center;text-valign:center;height:300px;">'; 
	htmlText=htmlText+message;
	htmlText=htmlText+'</div>';
	return htmlText;
};


JSUtil.composeCodeMasterSelectArray = function(codemaster){
	var codedetails = codemaster.codeMasterDetails; 
	var selectArray = new Array();
	for (var i=0;i<codedetails.length;i++){
		selectArray[selectArray.length] = {id:codedetails[i].codeMasterDetailId.codeName,desc:codedetails[i].description};
	}
	return selectArray;
};

JSUtil._draft_days = 14*1000*60*60*24;
JSUtil.computeDraftDatesArray = function(selRestartDate,priorDateMillis,originalNextDraftDate,includeOrig){
	
	var restartDateMillis = JSUtil.convertDateToMillis(parseDate(selRestartDate));
			var originalNextDraftDateMillis = originalNextDraftDate.getTime();
			var notfound=true;
			var nextDraftMillis=originalNextDraftDateMillis;
			var firstDraftDateMillis = null;
			while (notfound){
				nextDraftMillis = nextDraftMillis+JSUtil._draft_days;
				if (nextDraftMillis>priorDateMillis){
					notfound=false;
					firstDraftDateMillis = nextDraftMillis;
				}
			}
			
			//check number of drafts before payment date
			notfound=true;
			nextDraftDateMillis = firstDraftDateMillis;
			var numDrafts=0;
			var draftDateArray =null;
			if (includeOrig)
				draftDateArray = [formatDate(new Date(originalNextDraftDate),"MM/dd/yyyy"),formatDate(new Date(nextDraftDateMillis),"MM/dd/yyyy")];
			else
				draftDateArray = [formatDate(new Date(nextDraftDateMillis),"MM/dd/yyyy")];
			while (notfound){
				numDrafts=numDrafts+1;
				nextDraftDateMillis = nextDraftDateMillis+JSUtil._draft_days;
				if (nextDraftDateMillis>restartDateMillis){
					notfound=false;
					
				}else{
					   if (!JSUtil.checkIfWeekEnd(new Date(nextDraftDateMillis)))
						  draftDateArray[draftDateArray.length] = formatDate(new Date(nextDraftDateMillis),"MM/dd/yyyy");
				
				}
			}
			return draftDateArray;
};

JSUtil.checkIfWeekEnd = function(date){
    if (DAY_NAMES[date.getDay()]=='Saturday' ||DAY_NAMES[date.getDay()]=='Sunday')
        return true;
     return false;
};

JSUtil.hideElement = function(e){
	e.style.visibility ='hidden';
};

JSUtil.unhideElement = function(e){
	e.style.visibility ='visible';
};

JSUtil.noDisplay =function(e){
	e.style.display='none';
};

JSUtil.display =function(e){
	e.style.display='inline';
};


JSUtil.disable =function(e){
	e.disabled=true;
};

JSUtil.enable=function(e){
	e.disabled=false;
};

JSUtil.getTicketTypeDescription =function(shortType){
	if (shortType=='CI')
		return 'Modify Customer Information';
	else if (shortType=='CN')
		return 'Cancel';
	else if (shortType=='AA')
		return 'Adhoc ACH';
	else if (shortType=='AL')
		return 'Add New Loan';
	else if (shortType=='BI')
		return 'Modify Bank Account';
	else if (shortType=='CA')
		return 'Modify Payment Amount';
	else if (shortType=='CM')
		return 'Comment';
	else if (shortType=='CP')
		return 'Change Business Partner ID';
	else if (shortType=='DD')
		return 'Delay Draft';
	else if (shortType=='DS')
		return 'Modify Draft Schedule';
	else if (shortType=='LD')
		return 'Modify Loan Due Date';
	else if (shortType=='PI')
		return 'Modify Payee';
	else if (shortType=='PL')
		return 'Print Letter';
	else if (shortType=='RD')
		return 'Research Ticket';
	else if (shortType=='RF')
		return 'Refund Fees';
	else if (shortType=='RS')
		return 'Research Ticket';
	else if (shortType=='RL')
		return 'Restart Existing Loan';
	else if (shortType=='SD')
		return 'Skip Draft';
	else if (shortType=='SP')
		return 'Skip Payment';
	else if (shortType=='UNLD')
		return 'Unload';
	else if (shortType=='EL')
		return 'Confirmation Letter';
	else if (shortType=='CL')
		return 'Cancellation Letter';		
	else if (shortType=='CE')
		return 'Customer Enrollment';	
	else if (shortType=='DA')
		return 'Deactivate';			
	else
		return shortType;
	
};

JSUtil.escapeNewLine=function(txt){
	
	return txt.replace('/n','<br>');
};

JSUtil.getInputTime=function(stringdate){
	/*var tzo = (new Date(stringdate).getTimezoneOffset()*(-1))/60;
	alert('tzo:' + tzo);
	return JSUtil.convertDateToMillis(parseDate(stringdate)) - ((tzo + 11)*60*60*1000);*/
	//alert('calling getInputTime');
	if (stringdate=='')
		return null;
	var time =parseDate(stringdate);
	//alert('time:' + time);
	var year = time.getFullYear();
	//alert('year: ' + year);
	//alert('year(in ms.): ' + (year-1970)*365*24*60*60*1000);
	var mnth = time.getMonth();
	//alert('month:' + mnth);
	//alert('month(in ms.): ' + (mnth+1)*1000*60*60*24/12);
	var day = time.getDate();
	//alert('day:' + day);
	//alert('day(in ms.): ' + day*1000*60*60*24);
	var date = new Date(year, mnth, day, 0,0,0);
	//alert('date(in ms.):' + date.getTime());
	var tzo = date.getTimezoneOffset()*(-1)/60;
	//alert('tzo:' + tzo);
	return date.getTime() +  ((tzo + 11)*60*60*1000);
}



JSUtil.getCurrentDistributionSet= function(dist, server_time){
	//var nowIn = formatDate(server_time, 'MM/dd/yyyy');
	//alert("getCurrentDistributionSet: nowIn" + server_time);
	for (var i=0;i<dist.length;i++) {
		if (dist[i].effectiveTo==null){
			if (compareDates(effectiveFromDate, 'MM/dd/yyyy', server_time , 'MM/dd/yyyy')==0)
				return i;
		}
		else{
			var effectiveToDate =  formatDate(new Date(dist[i].effectiveTo), 'MM/dd/yyyy');
			var effectiveFromDate = formatDate(new Date(dist[i].effectiveFrom), 'MM/dd/yyyy');
			if ((compareDates(server_time, 'MM/dd/yyyy', effectiveToDate , 'MM/dd/yyyy')==0)&&
				(compareDates(effectiveFromDate, 'MM/dd/yyyy', server_time , 'MM/dd/yyyy')==0))
				return i;
		}
		
		
		
	}
	return 0;
}


JSUtil.effectiveFromIsInSet= function(dist, effectFrom){
	for (var i=0;i<dist.length;i++) {
		if (dist[i].effectiveFromDisplay == effectFrom)
			return true;
	}
	return false;
}


JSUtil.showNotAllowed =function(e){
	e.innerHTML = '<table width="100%" style="background-color:#F6F3E2"><tr><td align="center" style="color:red;font-weight:bold;">Ticket is allowed only on active accounts.</td></tr></table>';
};


JSUtil.roundOff=function(value){
    
    var result=Math.round(value*100)/100;
    return result;
};


JSUtil.processTicketMessage =function(msg,showDflt){
    msg=msg.replace('~','<img align="absmiddle" height="16px;" src="images/arrow.gif">');
    var newmsg = JSUtil.replaceme(msg,'~','<br><img align="absmiddle" height="16px;" src="images/arrow.gif">');
    if (showDflt)
        newmsg = newmsg+'<div class="savemessagearea">Please click SAVE BUTTON to save this ticket.</div>';
    return newmsg;
    
}


JSUtil.replaceme=function(string,text,by) {

    var strLength = string.length, txtLength = text.length;
    if ((strLength == 0) || (txtLength == 0)) return string;

    var i = string.indexOf(text);
    if ((!i) && (text != string.substring(0,txtLength))) return string;
    if (i == -1) return string;

    var newstr = string.substring(0,i) + by;

    if (i+txtLength < strLength)
        newstr += JSUtil.replaceme(string.substring(i+txtLength,strLength),text,by);

    return newstr;
}


JSUtil.strip=  function(input, chars) {  // strip all characters in 'chars' from input
    var output = "";  // initialise output string
    for (var i=0; i < input.length; i++)
      if (chars.indexOf(input.charAt(i)) == -1)
        output += input.charAt(i);
    return output;
  }
 
 var validChar = /^[a-zA-Z0-9\.\-]+$/;
JSUtil.validateId = function(stringId){
 	/*if(stringId.match(validChar))
		return true;
	return false;*/
	return validChar.test(stringId);
 	
 }
 
 
 JSUtil.hideSelectElements =function(ishidden){
    var allsel = document.getElementsByTagName('select');
    for (var i=0;i<allsel.length;i++){
        if (ishidden)
           allsel[i].style.visibility='hidden';
        else
           allsel[i].style.visibility='visible';
    }
 };
 
 
JSUtil.setCheckBoxDisabled=function(isdisabled){
    var allsel = document.getElementsByTagName('checkbox');
    for (var i=0;i<allsel.length;i++){
        allsel[i].disabled=isdisabled;
    }
 };
 
 JSUtil.setButtonDisabled=function(isdisabled){
    var allsel = document.getElementsByTagName('button');
    for (var i=0;i<allsel.length;i++){
        allsel[i].disabled=isdisabled;
    }
 };
 
JSUtil.setRadioDisabled=function(isdisabled){
    var allsel = document.getElementsByTagName('radio');
    for (var i=0;i<allsel.length;i++){
        allsel[i].disabled=isdisabled;
    }
 };
 
 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];}
}
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];}}
}

JSUtil.splitText = function(string){
	var db='';
	var stringlen = 15;
	var array = new Array();
	if (string.split(' ').length==1){
		if (string.length >stringlen ){
			var cnt = 0;
			while (cnt<string.length){
				if (cnt+stringlen<string.length){
					db = db + string.substring(cnt, cnt+stringlen) + '-' + '<br>';
					cnt = cnt+stringlen;
				}
				else{
					return db + string.substring(cnt, string.length);
				}
			}
		}
		else{
			return string;
		}
	}
	else{
		return string;
	}
}
 
JSUtil.toggleFieldByMode = function(aMode){
	if (aMode=='C'){
		DWRUtil.removeAllOptions('acctType');
		$('acctType').disabled = true;
		$('bankName').disabled = true;
		$('routingNumber').disabled = true;
		$('accountNumber').disabled = true;
		$('address').disabled = false;
		DWRUtil.setValue('requiredAddress','*');
		DWRUtil.setValue('requiredAccountName','*');
		DWRUtil.setValue('requiredRoutingNumber','');
		DWRUtil.setValue('requiredAccountNumber','');
	}
	else{
		DWRUtil.removeAllOptions('acctType');
		$('acctType').options[0] = new Option('C', 'C');
		$('acctType').options[1] = new Option('S','S');
		$('acctType').disabled = false;
		$('bankName').disabled = false;
		$('routingNumber').disabled = false;
		$('accountNumber').disabled = false;
		$('address').disabled =true;
		DWRUtil.setValue('requiredAddress','');
		DWRUtil.setValue('requiredAccountName','');
		DWRUtil.setValue('requiredRoutingNumber','*');
		DWRUtil.setValue('requiredAccountNumber','*');
	}
}

JSUtil.clearFieldByMode = function(aMode){
	if (aMode=='C'){
		DWRUtil.setValue('bankName','');
		DWRUtil.setValue('routingNumber','');
		DWRUtil.setValue('accountNumber','');
	}
	else{
		DWRUtil.setValue('address','');
	}
}
 
 