﻿var gsMonthNames = new Array(
'January',
'February',
'March',
'April',
'May',
'June',
'July',
'August',
'September',
'October',
'November',
'December'
);
var gsDayNames = new Array(
'Sunday',
'Monday',
'Tuesday',
'Wednesday',
'Thursday',
'Friday',
'Saturday'
);
Date.prototype.format = function(f){
    if (!this.valueOf())
        return '&nbsp;';
    var d = this;
    return f.replace(/(yyyy|mmmm|mmm|mm|dddd|ddd|dd|hh|nn|ss|a\/p)/gi,
        function($1){
            switch ($1.toLowerCase()){
            case 'yyyy': return d.getFullYear();
            case 'mmmm': return gsMonthNames[d.getMonth()];
            case 'mmm':  return gsMonthNames[d.getMonth()].substr(0, 3);
            case 'mm':   return (d.getMonth() + 1).zf(2);
            case 'dddd': return gsDayNames[d.getDay()];
            case 'ddd':  return gsDayNames[d.getDay()].substr(0, 3);
            case 'dd':   return d.getDate().zf(2);
            case 'hh':   return ((h = d.getHours() % 12) ? h : 12).zf(2);
            case 'nn':   return d.getMinutes().zf(2);
            case 'ss':   return d.getSeconds().zf(2);
            case 'a/p':  return d.getHours() < 12 ? 'a' : 'p';
            };
        }
    );
};

String.prototype.zf = function(l) { return '0'.string(l - this.length) + this;}
String.prototype.string = function(l) { var s = '', i = 0; while (i++ < l) { s += this; } return s; }
String.prototype.trim = function(){return this.replace(/^\s+|\s+$/, '');};
String.prototype.format = function(){
    var str = this;
    for(var i=0;i<arguments.length;i++){
        var re = new RegExp('\\{' + (i) + '\\}','gm');
        str = str.replace(re, arguments[i]);
    };
    return str;
};
Number.prototype.zf = function(l) { return this.toString().zf(l);}


/* Browser Bugs W/O */
// BWO_001 - SELECT onchange will not exec if selected item changes(via keyboard) in Gecko browser.
function BWO_001_ku(e){
if(e.keyCode && (e.keyCode == 1 || e.keyCode == 9 || e.keyCode == 16 || e.altKey || e.ctrlKey)) return true;if(e.target.onchange) e.target.onchange();return true;}
function BWO_001_ini(){
	var s = document.getElementsByTagName("SELECT");
	for(i=0; i<s.length; i++) s.item(i).addEventListener("keyup", BWO_001_ku, false);
	return true;
};
if(navigator.userAgent.indexOf("Gecko") != -1) window.addEventListener("load", BWO_001_ini, false);







 /* bsVariable ***********************************************************************************/
function bsCookie(){
this.remove= function(name){this.add(name,"",-1);};
this.read=function(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
};
this.add=function(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
};
};
var _bsCookie = new bsCookie();

 /* bsVariable ***********************************************************************************/
function bsVariable(){
this.CStr=function(v){return (v + "");};
this.CNum=function(v){v=this.CStr(v);if(v.indexOf(".") > 0){return parseFloat(v);}else{return parseInt(v);};};
this.CInt=function(v){v=this.CStr(v);return parseInt(v,10);};
this.CCur=function(v){v=this.CStr(v);return parseFloat(v);};
this.CDate=function(v){v=this.CStr(v);return new Date(v);};
this.CBool=function(v){v=this.CStr(v);v=v.toLowerCase();if(v=="false" || v=="no" || v=="0" || v==""){return false;};return true;};
this.convert=function(nt,v){if(!this.isSimpleVar(v)){return null;};v=this.CStr(v);v=v.toLowerCase();switch(nt){case "int":case "integer":return this.CInt(v);case "number":case "num":case "long":return this.CNum(v);case "string":case "char":case "varchar":return this.CStr(v);case "datetime":case "date":return this.CDate(v);case "float":case "money":case "cur":case "currency":return this.CCur(v);case "bool":case "boolean":return this.CBool(v);};return null;};
this.getFunctionName=function(f){
if(!f) return '?';
var tmp=f.toString();var re=/(\s*function\s+)(\w+)(\s*\()/m;re.exec(tmp);return RegExp.$2;};
this.getClassName=function(o){
if(!o) return '?';
if(o.nodeName) return (!o.type ? o.nodeName: o.nodeName + '(' + o.type + ')');
if(o._typeOf) return o._typeOf;
return this.getFunctionName(o.constructor);
};
this.getTypeName=function(o){
if(o instanceof Array){return "array";};
if(o instanceof Date){return "date";};
if(o instanceof String){return "string";};
if(o instanceof Boolean){return "boolean";};
if(this.isSimpleVar(o)){return typeof(o);};
return this.getClassName(o);};
this.getMembers=function(o){var nArr= new Array();var c=0;for(property in o){nArr[c]=property;c++;};return nArr;};
this.getDetails=function(o,divChar){
  var str= '::::::' + this.getClassName(o) + '::::::' + divChar;
  for(property in o){
    str +=property + ' = ' + (!o[property] ? 'Null': (!this.isObject(o[property])? o[property]:this.getClassName(o[property]))) + divChar;
  };
  str +=(divChar + divChar);
  return str;
};
this.isFunction=function(v){return typeof v=='function'};
this.isObject=function(v){return (v && typeof v=='object') || this.isFunction(v)};
this.isAlien=function(v){return this.isObject(v) && typeof v.constructor !='function'};
this.isArray=function(v){return this.isObject(v) && v.constructor==Array};
this.isBoolean=function(v){return typeof v=='boolean'};
this.isUndefined=function(v){return typeof v=='undefined'};
this.isEmpty=function(o){var i, v;if(this.isObject(o)){for (i in o){v=o[i];if(this.isUndefined(v) && this.isFunction(v)){return false;};};};return true;};
this.isNull=function(v){return typeof v == 'object' && !v};
this.isNumeric=function(v){if(!isNaN(v)){return true;};if(!v.length){return false;};var ValidChars = "0123456789.";var IsNumber=true;var Char;for(i = 0; i < v.length && IsNumber == true; i++){Char=v.charAt(i);if(ValidChars.indexOf(Char)==-1){IsNumber=false;};};return IsNumber;};
this.isMoney=function(v){
if(!v) return false;
var v = new String(v);
var ValidChars = "$0123456789.";var IsNumber=true;var Char;for(i = 0; i < v.length && IsNumber == true; i++){Char=v.charAt(i);if(ValidChars.indexOf(Char)==-1){IsNumber=false;};};return IsNumber;};
this.isString=function(v){return typeof v=='string';};
this.isSimpleVar=function(v){
var vt;
if(v instanceof Array){vt="array";};
if(v instanceof Date){vt="date";};
if(v instanceof String){vt="string";};
if(v instanceof Boolean){vt="boolean";};
if(!vt){vt=typeof(v);};
return this.isSimpleVarByName(vt);};
this.isSimpleVarByName=function(str){str=str.toLowerCase();switch(str){case "int":case "string":case "number":case "boolean":case "bool":case "dateTime":case "date":case "float":return true;};return false;};
this.isNothing=function(v){return (this.isUndefined(v) || v==null);}
this.isInteger=function(s){if(!isNaN(s)){return true;};var i;for(i = 0; i < s.length; i++){var c = s.charAt(i);if (((c < "0") || (c > "9"))) return false;};return true;};
this._isDate_dtCh= "/";
this._isDate_minYear=1900;
this._isDate_maxYear=2100;
this._isDate_SCIB=function(s, bag){var i;var returnString = "";for (i = 0; i < s.length; i++){var c = s.charAt(i);if(bag.indexOf(c) == -1) returnString += c;};return returnString;};
this._isDate_daysInFeb = function(year){return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );};
this._isDate_DaysArr = function(n){var arr = new Array(n);for(var i = 1; i <= n; i++){arr[i] = 31;if (i==4 || i==6 || i==9 || i==11) {arr[i] = 30};if (i==2) {arr[i] = 29};};return arr};
this.isDate=function(dtStr){var daysInMonth = this._isDate_DaysArr(12);var pos1=dtStr.indexOf(this._isDate_dtCh);var pos2=dtStr.indexOf(this._isDate_dtCh,pos1+1);var strMonth=dtStr.substring(0,pos1);var strDay=dtStr.substring(pos1+1,pos2);var strYear=dtStr.substring(pos2+1);strYr=strYear;if(strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1);if(strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1);for(var i = 1; i <= 3; i++){if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1);};month=parseInt(strMonth);day=parseInt(strDay);year=parseInt(strYr);if(pos1==-1 || pos2==-1){return false;};if(strMonth.length<1 || month<1 || month>12){return false;};if(strDay.length<1 || day<1 || day>31 || (month==2 && day>this._isDate_daysInFeb(year)) || day > daysInMonth[month]){return false;};if(strYear.length != 4 || year==0 || year<this._isDate_minYear || year>this._isDate_maxYear){return false;};if(dtStr.indexOf(this._isDate_dtCh,pos2+1)!=-1 || this.isInteger(this._isDate_SCIB(dtStr, this._isDate_dtCh))==false){return false;};return true;};
this.dateDiff=function(d1s,d2s){
     d1= Date.parse(d1s);
     d2= Date.parse(d2s);
     return ((d2-d1)/(24*60*60*1000));
};
this.clone=function(srcO){var t=_bsVariable.getTypeName(srcO);if(_bsVariable.isSimpleVarByName(t)){return srcO;};var ro;switch(t){case "array":ro=[];case "object":default:try{ro=eval("new "+ t + "()");}catch(e){ro=new Object();};break;};for(var name in srcO){var _t=_bsVariable.getTypeName(srcO[name]);if(name!='Base' && name!='inherits' && name!='_typeOf' && _t!='Function' && name!='_ESL'){ro[name]=this.clone(srcO[name]);};};return ro;};
};
var _bsVariable=new bsVariable();




Array.prototype.inArray = function (value) {
	var i;
	for (i=0; i < this.length; i++) {
		if (this[i] === value) {
			return true;
		}
	}
	return false;
};




/* General Functions ***********************************************************************************/
function pauseExec(ms){if(!ms || ms==0){return;};var d = new Date();var cd = null;do {cd = new Date(); } while(cd-d < ms);}; 

/* bsRegExp ************************************************************************************/
function bsDebug(){
var _self=this;
this._el;
    this.cls=function(){
      if(!_self._el) return;
      this._el.innerHTML='';
    };
    this.print=function(text){
	    if(!_self._el){
		    _self._el=document.createElement('DIV');
		    _self._el.setAttribute('id','divSGDebug');
		    _self._el.style.width='100%';
		    _self._el.style.height=400;
		    _self._el.style.bgColor='#847D84';
		    _self._el.style.overflow='scroll';
		    _self._el.style.border='1px solid black';
		    _self._el.style.font='10px verdana'
		    _bsEvents.add(_self._el,'dblclick',function(){_self.cls();});
		    
		    document.body.appendChild(_self._el);
	    };
	    
	    if(_self._el.innerHTML.length){_self._el.innerHTML+='<br/>';};
	    _self._el.innerHTML+='> ' + text;  	
    };
};
var _bsDebug = new bsDebug();


/* bsRegExp ************************************************************************************/
function bsRegExp(){
  this.expEmail = /^([0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,9})$/;
  this.expSingleLetter = /^[a-zA-Z]$/;
  this.expWhitespace = /^\s+$/;
  this.expAlphabetic = /^[a-zA-Z]+$/;
  this.expSingleDigit = /^\d$/;
  this.expSingleLetterOrDigit = /^([a-zA-Z]|\d)$/;
  this.expAlphanumeric = /^[a-zA-Z0-9]+$/;
  this.expInteger = /^\d+$/;
  this.expPhone_US = /^((\+\d{1,3}(-| )?\(?\d\)?(-| )?\d{1,3})|(\(?\d{2,3}\)?))(-| )?(\d{3,4})(-| )?(\d{4})(( x| ext)\d{1,5}){0,1}$/;
  this.test=function(str,exp){
     return str.match(exp);
  };
};

var _bsRegExp = new bsRegExp();


/* bsEffects ***********************************************************************************/
function bsEffects(){
this.addHover=function(v,cssOver,cssOut){var el=_bsElement.getRef(v);if(!el)return;el.hover_css_over=cssOver;el.hover_css_out=cssOut;_bsEvents.add(el,'mouseover',this._hoverMouseOver,false);_bsEvents.add(el,'mouseout',this._hoverMouseOut,false);};
this.removeHover=function(el){_bsEvents.remove(el,'mouseover',this._hoverMouseOver,false);_bsEvents.remove(el,'mouseout',this._hoverMouseOut,false);};
this._hoverMouseOver=function(e){var el=_bsEvents.getElement(e);_bsElement.setClass(el,el.hover_css_over);};
this._hoverMouseOut=function(e){var el=_bsEvents.getElement(e);_bsElement.setClass(el,el.hover_css_out);};
};
var _bsEffects=new bsEffects();

/* bsEvents ***********************************************************************************/
function bsEvents(){
var oThis=this;
this._cache;
this.getElement=function(e){e = (e) ? e:((window.event) ? window.event:"");if(e){var el;if(e.target){el=(e.target.nodeType == 3) ? e.target.parentNode : e.target;}else{el=e.srcElement;};};return el;};
this.add=function(el,eventName,fn,useCapture){
  if(!useCapture) useCapture=false;
  var r;
  if(el.addEventListener){
     if(eventName.substring(0, 2) == "on") eventName=_bsString.Mid(eventName,2);
     el.addEventListener(eventName,fn,useCapture);
     r=true;
  }else if(el.attachEvent){
     if(eventName.substring(0, 2) != "on") eventName="on" + eventName;
     r=el.attachEvent(eventName,fn);
  }else{
     if(eventName.substring(0, 2) != "on") eventName="on" + eventName;
     eval('document.getElementById("' + el.id + '").' + eventName)=fn;
  };
  if(!this._cache){
     this._cache=new Array();
     this.add(window,'unload',this.removeAll);
  };
  this._cache.push(arguments);
  return r;
  };
this.remove=function(el,eventName,fn,useCapture){
if(!useCapture) useCapture=false;
try
{
if(el.removeEventListener){
   el.removeEventListener(eventName, fn, useCapture);
   return true;
}else if(el.detachEvent){
   var r = el.detachEvent("on" + eventName, fn);
   return r;
};
}
catch(err){};
};
this.removeAll=function(){for(var i=0;i<oThis._cache.length; i++){var item=oThis._cache[i];oThis.remove(item[0],item[1],item[2],item[3]);oThis._cache[i]=null;};oThis._cache=null;};
};
var _bsEvents=new bsEvents();


/* bsWindow ***********************************************************************************/
function bsWindow(){
this.loadJSFile=function(url){
   var e = document.createElement("script");
   e.src = url;
   e.type="text/javascript";
   document.getElementsByTagName("head")[0].appendChild(e); 
}
this.isInIFrame=function(){
  return ((parent.window.location != window.location) && parent.window._bsWindow);
};
this.getDocumentObject=function(useCallerWindow){//Obsolete
  if(!useCallerWindow) useCallerWindow=false;
  if(this.isInIFrame() && useCallerWindow == false) return parent.window._bsWindow.getDocumentObject();
  return document;
};
this.createElement=function(code,useCallerWindow){
  if(!useCallerWindow) useCallerWindow=false;
  if(this.isInIFrame() && useCallerWindow == false) return parent.window._bsWindow.createElement(code);
  return document.createElement(code);
}
this.appendChild=function(node,useCallerWindow){
  if(!useCallerWindow) useCallerWindow=false;
  if(this.isInIFrame() && useCallerWindow == false){
    parent.window._bsWindow.appendChild(node);
    return;
  }
  document.body.appendChild(node);
}
this.getScrollX=function(useCallerWindow){if(!useCallerWindow) useCallerWindow=false;if(this.isInIFrame() && useCallerWindow == false) return parent.window._bsWindow.getScrollX();return window.pageXOffset||this.getPVal("scrollLeft");};
this.getScrollY=function(useCallerWindow){if(!useCallerWindow) useCallerWindow=false;if(this.isInIFrame() && useCallerWindow == false) return parent.window._bsWindow.getScrollY();return window.pageYOffset||this.getPVal("scrollTop");};

this.getInnerHeight=function(useCallerWindow){
if(!useCallerWindow) useCallerWindow=false;
if(this.isInIFrame() && useCallerWindow == false) return parent.window._bsWindow.getInnerHeight();
var s = document.body.scrollHeight;
var o = document.body.offsetHeight;
if (s > o) return document.body.scrollHeight;
else return document.body.offsetHeight;
};

this.getInnerWidth=function(useCallerWindow){
if(!useCallerWindow) useCallerWindow=false;
if(this.isInIFrame() && useCallerWindow == false) return parent.window._bsWindow.getInnerWidth();
var s = document.body.scrollWidth;
var o = document.body.offsetWidth
if (s > o) return document.body.scrollWidth;
else return document.body.offsetWidth;
};

this.getHeight=function(useCallerWindow){
if(!useCallerWindow) useCallerWindow=false;
if(this.isInIFrame() && useCallerWindow == false) return parent.window._bsWindow.getHeight();

if (self.innerHeight) return self.innerHeight;
else if (document.documentElement && document.documentElement.clientHeight) return document.documentElement.clientHeight;
else if (document.body) return document.body.clientHeight;
};
this.getWidth=function(useCallerWindow){
if(!useCallerWindow) useCallerWindow=false;
if(this.isInIFrame() && useCallerWindow == false) return parent.window._bsWindow.getWidth();
if (self.innerWidth) return self.innerWidth;
else if (document.documentElement && document.documentElement.clientWidth) return document.documentElement.clientWidth;
else if (document.body) return document.body.clientWidth;
};
this.getPVal=function(p){
var d=document.documentElement;
var b=document.body;
if(d&&d[p]) return d[p];
else
  if(b&&b[p]) return b[p];
  return 0;
};


this.inheritSize=function(v){
  _bsElement.setHeight(v,this.getHeight());
  _bsElement.setWidth(v,this.getWidth());
};

this.get_pageFileName=function(){
  var sPath = window.location.pathname;
  return sPath.substring(sPath.lastIndexOf('/') + 1);
}
this.reload=function(args,useCallerWindow,pathOnly){
if(!pathOnly) pathOnly=false;
if(!useCallerWindow) useCallerWindow=false;
if(this.isInIFrame() && useCallerWindow == false) return parent.window._bsWindow.reload(args,null,pathOnly);

  var url = pathOnly?window.location.pathname:window.location.href;
  if(!args) url += ((url.indexOf("?") == -1 )?"?":"&") + args;
  
  this.navigateTo(url);
}
this.navigateTo=function(sURL,t){
 if(!t) t='';
 switch (t){
   case '_top':
     top.window.location.replace(sURL);
     break;
   case '_parent':
     parent.window.location.replace(sURL);
     break;
   case '_blank':
     window.open(sURL,t);
     break;
   default:
      if(parent.frames[t]){
         parent.frames[t].location.replace(sURL);
         return;
      }
      window.location.replace(sURL);
      break;
 };
};
this.getIframeWindow=function(iframe){
  return iframe.contentWindow;
};
this.getIFrameDocument=function(iframe){
  if (iframe.contentDocument){
    return iframe.contentDocument; 
  }else if (iframe.contentWindow) {
    return iframe.contentWindow.document;
  }else if (iframe.document){
    return iframe.document;
  };
};

this.getScrollerWidth=function(){
  /* Note: Does not work with IE */
    var scr = null;
    var inn = null;
    var wNoScroll = 0;
    var wScroll = 0;

    // Outer scrolling div
    scr = document.createElement('div');
    scr.style.position = 'absolute';
    scr.style.top = '-1000px';
    scr.style.left = '-1000px';
    scr.style.width = '100px';
    scr.style.height = '50px';
    // Start with no scrollbar
    scr.style.overflow = 'hidden';

    // Inner content div
    inn = document.createElement('div');
    inn.style.width = '100%';
    inn.style.height = '200px';

    // Put the inner div in the scrolling div
    scr.appendChild(inn);
    // Append the scrolling div to the doc
    document.body.appendChild(scr);

    // Width of the inner div sans scrollbar
    wNoScroll = inn.offsetWidth;
    // Add the scrollbar
    scr.style.overflow = 'auto';
    // Width of the inner div width scrollbar
    wScroll = inn.offsetWidth;

    // Remove the scrolling div from the doc
    document.body.removeChild(document.body.lastChild);

    // Pixel width of the scroller
    return (wNoScroll - wScroll);
};

};
var _bsWindow = new bsWindow();

 /* bsMouse ***********************************************************************************/
function bsMouse(){
this.getLeft=function(e){
var pos=0;if(!e){e=window.event;};
   if(e.pageX){
     pos=e.pageX;
   }else if(e.clientX){
     pos=e.clientX;
   };
   return pos;
};
this.getTop=function(e){
   var pos=0;if(!e){e=window.event;};
   if(e.pageY){
     pos = e.pageY;
   }else if(e.clientY){
     pos = e.clientY;
   };
   return pos;};
};
var _bsMouse=new bsMouse();


 /* bsString ***********************************************************************************/
function bsString(){
this.repeat=function(str,num){
   var r = '';
   for(i = 1; i < num; i++) r +=str;
   return r
};
this.length=function(str){
  if(!str) return 0;
  if(_bsVariable.isString(str)) return str.length;
  var s = new String(str);
  return s.length;
};
this.encodeSpecial=function(str){var nStr=str;nStr=nStr.replace(/\'/g,"\\'");nStr=nStr.replace(/\"/g,'\\"');nStr=nStr.replace(/\n/g,'\\n');nStr=nStr.replace(/\r/g,'\\r');nStr=nStr.replace(/\t/g,'\\t');nStr=nStr.replace(/\f/g,'\\f');return nStr;};
this.inStr=function(str1,str2){if(!str1 || !str2){return false;};return !(str1.indexOf(str2) == -1);};
this.Left=function(str,n){if(n <= 0){return "";}else if(n > String(str).length){return str;}else{return String(str).substring(0,n);};};
this.Right=function(str,n){if(n <= 0){return "";}else if(n > String(str).length){return str;}else{var iLen = String(str).length;return String(str).substring(iLen,iLen - n);};};
this.Mid=function(str, s, len){if(!len){len = String(str).length;};if (s < 0 || len < 0){return ""};var e, iLen = String(str).length;if(s + len > iLen){e=iLen;}else{e=s + len;};return String(str).substring(s,e);};
this.format=function(str){
  for(i = 1; i < arguments.length; i++)
    str = str.replace('{' + (i - 1) + '}', arguments[i]);
  return str;
}

this.removeInvalidChar=function(invalidList,str){
     // Loop through the string 
     var strReturn='';
     for(i=0;i< str.length;i++){
          // Get this character
          chr = str.substr(i,1);
          // Is this a number
          if(invalidList.indexOf(chr) > -1){
              strReturn += chr;
          };
     };
     return strReturn;
};
this.formatPhoneNumber=function(str,cc){
    if(!str) return '';
    if(str.length==0) return '';
    if(!cc) cc=1;
    cc=parseInt(cc);
    var strNum;
    
    switch(cc){
      case 1: //
        strNum = this.removeInvalidChar("1234567890",str);
        if(strNum.length !=10) return "?";  /* Min 10 numbers */
        return this.format("({0}) {1}-{2}", strNum.substring(0, 3), strNum.substring(3, 6), strNum.substring(6));
        break;
    };
    
     return str;
};

  this._formatDate_addZero=function(vNumber){ 
    return ((vNumber < 10) ? "0" : "") + vNumber 
  } 
        
 this.formatDate=function(vDate, vFormat){ 
    var vDay = this._formatDate_addZero(vDate.getDate()); 
    var vMonth = this._formatDate_addZero(vDate.getMonth()+1); 
    var vYearLong = this._formatDate_addZero(vDate.getFullYear()); 
    var vYearShort = this._formatDate_addZero(vDate.getFullYear().toString().substring(3,4)); 
    var vYear = (vFormat.indexOf("yyyy")>-1?vYearLong:vYearShort) 
    var vHour = this._formatDate_addZero(vDate.getHours()); 
    var vMinute = this._formatDate_addZero(vDate.getMinutes()); 
    var vSecond = this._formatDate_addZero(vDate.getSeconds()); 
    var vDateString = vFormat.replace(/dd/g, vDay).replace(/MM/g, vMonth).replace(/y{1,4}/g, vYear) 
    vDateString = vDateString.replace(/hh/g, vHour).replace(/mm/g, vMinute).replace(/ss/g, vSecond) 
    return vDateString 
  } 

this.encodeHTML=function(s){
    var str = new String(s);
    str = str.replace(/&/g, "&amp;");
    str = str.replace(/</g, "&lt;");
    str = str.replace(/>/g, "&gt;");
    str = str.replace(/"/g, "&quot;");
  return str;
}
this.Replace=function(Expression, Find, Replace){
	var temp = Expression;
	var a = 0;
	for (var i = 0; i < Expression.length; i++) 
	{
		a = temp.indexOf(Find);
		if (a == -1)
			break
		else
			temp = temp.substring(0, a) + Replace + temp.substring((a + Find.length));
	}
	return temp;
}
this.Chr=function(chrCode){return String.fromCharCode(chrCode)};
this.isValidCreditCard = function(type, ccnum) {
   if (type == "Visa") {
      // Visa: length 16, prefix 4, dashes optional.
      var re = /^4\d{3}-?\d{4}-?\d{4}-?\d{4}$/;
   } else if (type == "MC") {
      // Mastercard: length 16, prefix 51-55, dashes optional.
      var re = /^5[1-5]\d{2}-?\d{4}-?\d{4}-?\d{4}$/;
   } else if (type == "Disc") {
      // Discover: length 16, prefix 6011, dashes optional.
      var re = /^6011-?\d{4}-?\d{4}-?\d{4}$/;
   } else if (type == "AmEx") {
      // American Express: length 15, prefix 34 or 37.
      var re = /^3[4,7]\d{13}$/;
   } else if (type == "Diners") {
      // Diners: length 14, prefix 30, 36, or 38.
      var re = /^3[0,6,8]\d{12}$/;
   }
   if (!re.test(ccnum)) return false;
   // Remove all dashes for the checksum checks to eliminate negative numbers
   ccnum = ccnum.split("-").join("");
   // Checksum ("Mod 10")
   // Add even digits in even length strings or odd digits in odd length strings.
   var checksum = 0;
   for (var i=(2-(ccnum.length % 2)); i<=ccnum.length; i+=2) {
      checksum += parseInt(ccnum.charAt(i-1));
   }
   // Analyze odd digits in even length strings or even digits in odd length strings.
   for (var i=(ccnum.length % 2) + 1; i<ccnum.length; i+=2) {
      var digit = parseInt(ccnum.charAt(i-1)) * 2;
      if (digit < 10) { checksum += digit; } else { checksum += (digit-9); }
   }
   if ((checksum % 10) == 0) return true; else return false;
}
};
var _bsString=new bsString();




 /* bsNumber ***********************************************************************************/
function bsNumber(){
  this.isOdd=function(n){if(n==0) return false;if(n%2) return true;return false;};
};
var _bsNumber=new bsNumber();




 /* bsElement ***********************************************************************************/
function bsElement(){
/*<Deprecated>*/
// Use getVisible
this.isVisible=function(el){return this.getVisible(el)}
//Use toggleVisible
this.toggleDisplay=function(el){this.toggleVisible(el);}
//Use getVisible
this.getDisplay=function(el){return this.getVisible(el)};
//Use getBounds
this.getTop=function(v){return this.getOffset(v,'offsetTop')};
//Use getBounds
this.getRight=function(v){return this.getLeft(v)+this.getWidth(v);};
//Use getBounds
this.getBottom=function(v){return this.getTop(v)+this.getHeight(v);};
//Use getBounds
this.getLeft=function(v){return this.getOffset(v,'offsetLeft')};
//Use getBounds
this.getOffset=function(v,osp){
var el=this.getRef(v);
if(!el)return;
if(_bsBrowser.isNav4){return el.pageX;};
var x=0;
while(el.offsetParent&&el.offsetParent!=document.documentElement){
    x+=el[osp];
    el=el.offsetParent
};
return x;
};
//Use getBounds
this.getHeight=function(v){var el=this.getRef(v);if(!el)return;return parseInt(el.offsetHeight)};
// use $get
this.getRef=function(v){return this.$get(v)};
/*</Deprecated>*/

this.installTextLimit=function(el,maxLen,dispEl,format,fnOnTextChange){
  var oThis=this;
  var el=this.getRef(el);if(!el) return;
  var fn=function(){
     oThis.textLimit(el, maxLen, dispEl,format);
     var val = new String(_bsElement.getValue(el));
     var hasText = val.length > 0;
     if(fnOnTextChange) fnOnTextChange(hasText);
  };
  _bsEvents.add(el,'keyup',fn);
  _bsEvents.add(el,'blur',fn);
  _bsEvents.add(window,'load',fn);
  
};
this.textLimit=function(el, maxLen, dispEl,format){
var val = new String(_bsElement.getValue(el));
if(val.length > maxLen) el.value = val.substring(0, maxLen);

if(dispEl){
  if(!format) format="{0}/{1}";
  val = new String(_bsElement.getValue(el));
  _bsElement.setValue(dispEl,_bsString.format(format,val.length,maxLen));
};
}

this.setStyleFloat=function(v,value){
  var el=this.getRef(v);if(!el) return;
  if(typeof el.style.styleFloat != 'undefined') el.style.styleFloat=value;else if(typeof el.style.cssFloat != 'undefined') el.style.cssFloat=value;
}
this.setOpacity=function(v,value){
var el=this.getRef(v);
if(!el) return;
if(typeof el.style.opacity != 'undefined') el.style.opacity=value/100;
else if(typeof el.style.MozOpacity != 'undefined') el.style.MozOpacity=value/100;
else if(typeof el.style.filter != 'undefined') el.style.filter='alpha(opacity=' + value + ')'; 
}
this.createTextBox=function(id,defaultValue,cssClass){var el = document.createElement('input');el.setAttribute('id',id);el.setAttribute('autocomplete','off');el.setAttribute('type','text');if(defaultValue) el.value=defaultValue;if(cssClass) this.setClass(el,cssClass);return el;};
this.createSpan=function(id,text,cssClass){var el = document.createElement('span');el.setAttribute('id',id);if(cssClass) this.setClass(el,cssClass);if(text) el.innerHTML=text;return el;return el;};
this.createDropDown=function(id,selValue,cssClass,src,fnItemFormat){
   var el = document.createElement('select');
       el.setAttribute('id',id);
       el.setAttribute('autocomplete','off');
   if(cssClass) this.setClass(el,cssClass);
   this.loadDropDown(el,src,selValue,fnItemFormat);
   return el;
};  
this.loadDropDownFromArray=function(v,arr,textField,valueField,clear){
    if(clear==null) clear=true;
    var el=this.getRef(v);if(!el)return;
    var selValue=this.getValue(el);
     if(clear) while(el.firstChild) el.removeChild(el.firstChild);
     for(var i = 0; i < arr.length; i++){
          var opt = document.createElement('option');
              opt.setAttribute("value",arr[i][valueField]);
              opt.innerHTML=arr[i][textField];
              if(selValue==arr[i][textField] || selValue==arr[i][valueField]) opt.setAttribute("selected","selected");
        if(document.all && !window.opera){
           el.appendChild(opt); 
        }else{
           el.appendChild(opt,null); 
        }
      };
}
this.loadDropDownFromXML=function(v,xml,textField, valueField, selValue){
        var node;
        if(_bsVariable.isString(xml)){
          doc = _bsXML.getDoc(xml);
          if(!doc.childNodes[0]){
            alert('Invalid xml data: ' + xml);
            return null;
          };
          node = (doc.childNodes[0].nodeName=='xml')?doc.childNodes[1]:doc.childNodes[0];
        }else if(_bsVariable.isObject(xml_node)){
          node = xml_node;
        }else{
          alert('ERROR: [XItem::loadXML] - Invalid Parameter value (' + xml_node + ').');
        };
        
     for(var i = 0; i < node.childNodes.length; i++){
        var text = node.childNodes[i].attributes.getNamedItem(textField).nodeValue;
        var value = node.childNodes[i].attributes.getNamedItem(valueField).nodeValue;
        this.dropDownAddItem(v,value,text,(value==selValue?true:false),node.childNodes[i].attributes);
      };
};
this.loadDropDown=function(v,src,selValue,fnItemFormat){
var el=this.getRef(v);if(!el)return;
if(!src) return;
   var defaultSet=false;
     for(var i=0;i<src.count(); i++){
         var itemText=fnItemFormat?fnItemFormat(src.item(i)):src.item(i).text;
         var itemSelected=false;
             if((src.item(i).text==selValue || src.item(i).value==selValue) && defaultSet==false){
               defaultSet=true;
               itemSelected=true;
             };
         this.dropDownAddItem(el,src.item(i).value,itemText,itemSelected);
     };
};

this.dropDownAddItem=function(v,value,text,selected,attrList){
  var el=this.getRef(v);if(!el)return;
  var opt = document.createElement('option');
      opt.setAttribute("value",value);
      opt.innerHTML=text;
      /* Load all attributes */
      if(attrList){
          opt.tag = new bsCollection();
          for (var i=0;i < attrList.length;i++){
            var nObj = new bsObject();
            opt.tag.add(new bsObject(attrList[i].nodeName,attrList[i].nodeValue));
          }
      }
      if(selected==true) opt.setAttribute("selected","selected");
        if(document.all && !window.opera){
           el.appendChild(opt); 
        }else{
           el.appendChild(opt,null); 
        }
};
this.basicGUID=function(){
return new Date().getTime();
}  
this.generateGUID=function(prefix){
if((parent.window.location != window.location) && parent.window._bsElement){
  return parent.window._bsElement.generateGUID(prefix);
}
prefix += (((1+Math.random())*0x10000)|0).toString(16).substring(1);
var cnt=0;
while(document.getElementById(prefix+(++cnt))!=null);
return prefix+cnt;
};
this.getClass=function(v){var el=this.getRef(v);if(!el)return;return el.className;};
this.getDetails=function(v){
var el=this.getRef(v);
if(!el) return;
var isVisible = this.getVisible(el);
if (!isVisible) this.setDisplay(el,true);

var d=new Object();
if(_bsBrowser.isNav4){
d.left = el.pageX;
d.top = el.pageY;
};
d.width=parseInt(_bsBrowser.isIE ? el.offsetWidth : el.clientWidth);
d.height=parseInt(_bsBrowser.isIE ? el.offsetHeight:el.clientHeight);
d.left=parseInt(el.offsetLeft);
d.top=parseInt(el.offsetTop);
var elP=el.offsetParent;
while(elP!=null){
  d.left+=parseInt(elP.offsetLeft);
  d.top+=parseInt(elP.offsetTop);
    if(elP.tagName=="DIV"){
       d.left-=parseInt(elP.scrollLeft);
       d.top-=parseInt(elP.scrollTop);
     };
    elP=elP.offsetParent;
};
 this.setDisplay(el,isVisible);
return d;
};
this.getElementType=function(v){var el=this.getRef(v);if(!el) return;var t;if(el.length)t=el[0].type;if(!t) t=el.type;if(!t) t=el.tagName;if(!t) return;return new String(t).toLocaleLowerCase();}
this.getDisabled=function(v){var el=this.getRef(v);if(!el)return;return el.disabled;}; 
this.$get=function(v){if(!v) return null;if (typeof v!='string') return v;var el;if(document.getElementById) el=document.getElementById(v);else if(document.all) el=document.all[v];else if(document.layers) el=(!document.layers[v]?this.$getLow('document',v):document.layers[v]);return el};
this.$getLow=function(obj,name){var x=obj.layers;var l;for(var i=0;i<x.length;i++){if(x[i].id==name)return x[i];else if(x[i].layers.length){var tmp=this.$getLow(x[i],name);if(tmp)return tmp;}};return null};
this.getBounds=function(el,includeScrolls){
var b = new Sys.UI.Bounds(0,0,0,0);
var el=this.getRef(el);
if(!el)return b;

b.height=(el.offsetHeight || 0);
b.width=(el.offsetWidth || 0);


// ************* Following code will be needed if calculating element from outside of iframe.
//  if(typeof(window.pageYOffset)=='number'){
//    //Netscape compliant
//    y=window.pageYOffset;
//    x=window.pageXOffset;
//  }else if(document.body && (document.body.scrollLeft || document.body.scrollTop)){
//    //DOM compliant
//    y=document.body.scrollTop;
//    x=document.body.scrollLeft;
//  }else if(document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop)){
//    //IE6 standards compliant mode
//    y=document.documentElement.scrollTop;
//    y=document.documentElement.scrollLeft;
//  }


if(document.layers){
    b.x=(el.pageY || 0);
    b.x=(el.pageX || 0);
}else{
    while(el.offsetParent&&el.offsetParent!=document.documentElement){
        b.x += (el.offsetLeft || 0);
        b.y += (el.offsetTop || 0);
        if(includeScrolls){
            if(el.tagName !== 'BODY'){
               b.x-=(el.scrollLeft || 0);
               b.y-=(el.scrollTop || 0);
            }
        }
        el=el.offsetParent;
    }
}
return b;


//this.getTop=function(v){return this.getOffset(v,'offsetTop')};
////Use getBounds
//this.getRight=function(v){return this.getLeft(v)+this.getWidth(v);};
////Use getBounds
//this.getBottom=function(v){return this.getTop(v)+this.getHeight(v);};
////Use getBounds
//this.getLeft=function(v){return this.getOffset(v,'offsetLeft')};
////Use getBounds
//this.getOffset=function(v,osp){
//var el=this.getRef(v);
//if(!el)return;
//if(_bsBrowser.isNav4){return el.pageX;};
//var x=0;
//while(el.offsetParent&&el.offsetParent!=document.documentElement){
//    x+=el[osp];
//    el=el.offsetParent
//};

};
this.getCumulativeScrollXY=function(el) {
  var x=0,y=0;
  if(typeof(window.pageYOffset)=='number'){
    //Netscape compliant
    y=window.pageYOffset;
    x=window.pageXOffset;
  }else if(document.body && (document.body.scrollLeft || document.body.scrollTop)){
    //DOM compliant
    y=document.body.scrollTop;
    x=document.body.scrollLeft;
  }else if(document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop)){
    //IE6 standards compliant mode
    y=document.documentElement.scrollTop;
    y=document.documentElement.scrollLeft;
  }
 
var el=el.parentNode;
var curStyle;
while(el!=null){
    curStyle = Sys.UI.DomElement._getCurrentStyle(el);
    if(el.tagName !== 'BODY'){
       if(el.scrollLeft) x+=el.scrollLeft;
       if(el.scrollTop) y+=el.scrollTop;
    }
    el=el.parentNode;
};
  return new Sys.UI.Point(x,y);
}

this.getTopParent=function(v){var el=this.getRef(v);if(!el)return;var elP=el.parentNode;while(elP){elP=elP.parentNode;};return elP;};
this.getValueIIF=function(v,default_val,str_before,str_after){
  var el=this.getRef(v);
  if(!el){return ''};
  str_before=(!str_before)?'':str_before;
  str_after=(!str_after)?'':str_after;
  
   switch(this.getElementType(el)){
     case 'select-one':
     case 'select':
       if(el.selectedIndex==-1){return default_val;}
       return (el.options[el.selectedIndex].value!='') ? (str_before + el.options[el.selectedIndex].text + str_after):default_val;
       break;
     case 'text':
       return (el.value!='') ? (str_before + el.value + str_after):default_val;
       break;
    };
};
this.isChecked=function(v){
var el=this.getRef(v);
if(!el) return;
return el.checked;
};
this.getValue=function(v,returnText){
var el=this.getRef(v);
if(!el) return;
switch(this.getElementType(el)){
case 'undefined': return;
case 'span':
case 'div':
return el.innerHTML;
case 'radio':
for(var i=0; i < el.length; i++){
   if(el[i].checked == true) return el[i].value;
};

case 'select-multiple':var _arr=new Array();
for(var i=0; i < el.length; i++){if(el[i].selected == true){_arr[_arr.length]=el[i].value;};};
return _arr;

case 'checkbox': 
return el.checked;
case "select-one":
case "select":return ((el.selectedIndex >= 0)?(returnText==true?el.options[el.selectedIndex].text:el.options[el.selectedIndex].value):-1);
case "hidden":
case "text":
return el.value;
default:
return el.value;
};

};
this.getWidth=function(v){var el=this.getRef(v);if(!el)return;return parseInt(el.offsetWidth);};
this.getZIndex=function(v){var el=this.getRef(v);var zi=0;while(el){if(_bsBrowser.isNav4){zi=el.zIndex ? el.zIndex : 0;}else{zi=el.style ? (el.style.zIndex ? el.style.zIndex:0):0;};if(zi){el=null;}else{el=el.parentNode;};};return zi;};
this.isChildOf=function(c,p){c=this.getRef(c);p=this.getRef(p);if(!c || !p) return false;;var el=c;while(el.parentNode){if(el.parentNode==p) return true;el=el.parentNode;};return false;};
this.removeFromParent=function(v){
  var el=this.getRef(v);if(!el)return;
  el.parentNode.removeChild(el);
}

this.getVisible=function(el){
var el=this.getRef(el);
if(!el) return null;
if(_bsBrowser.isNav4) return el.style.visibility=='show';
else return el.style.display!='none';
}
this.setAntiHighLight=function(){
if(_bsBrowser.isIE){var omit=["input","textarea", "select"];
if(!document.onselectstart) _bsEvents.add(document,'selectstart',new Function("return false"),false);

for(var i=0; i<omit.length; i++){
var ElList = document.getElementsByTagName(omit[i]);
for(var ii=0;ii<ElList.length;ii++){
if(!ElList[ii].onselectstart) _bsEvents.add(ElList[ii],'selectstart',new Function("event.cancelBubble=true;"),false);};};};

};
this.setClass=function(v,c){var el=this.getRef(v);if(!el)return;if (!c){c='';};if(c && (el.className != c)){el.className=c;};};
this.setCursor=function(v,c){var el=this.getRef(v);if(!el)return;el.style.cursor=c;};
this.setDisplay=function(el,value){
    this.setVisible(el,value);
};
this.setVisible=function(el,value){
    var el=this.getRef(el);
    if(!el) return;
        if (value) {
            if (el.style.removeAttribute) el.style.removeAttribute('display');
            else el.style.removeProperty('display');
        }
        if(_bsBrowser.isNav4) el.style.visibility = value ? 'show':'hide';
        else{
            el.style.visibility=value?'visible':'hidden';
            el.style.display=value?'':'none';
        };
}

this.setDisabled=function(v,disabled){var el=this.getRef(v);if(!el)return;el.disabled=disabled;}; 
this.setFocus=function(v){var el=this.getRef(v);if(!el)return;try{el.focus();}catch(err){return err.description};};
this.setHeight=function(v,n){if(n < 0) return;var el=this.getRef(v);if(!el)return;el.style.height=n;};
this.setLeft=function(v,pos){var el=this.getRef(v);if(!el)return;el.style.left=pos;};
this.setPosition=function(v,xh,yv){
var el=this.getRef(v);
if(!el)return;
if(!yv) yv='m';
if(!xh) xh='c';

var sY=_bsWindow.getScrollY();
var sX=_bsWindow.getScrollX();
var eH=parseInt(this.getHeight(el));
var wH=parseInt(_bsWindow.getHeight());
var eW=parseInt(this.getWidth(el));
var wW=parseInt(_bsWindow.getWidth());

if(_bsVariable.isString(yv)) yv=yv.toLowerCase();
if(_bsVariable.isString(xh)) xh=xh.toLowerCase();

if(yv=="top" || yv=='t') yv=1;
if(yv=="bottom" || yv=='b') yv=wH-eH;
if(yv=="middle" || yv=='mid' || yv=='m' || yv=='center' || yv=='c') yv=(parseInt(wH/2)-parseInt(eH/2)) + (sY==0?0:sY);
//if(yv<1) yv=1;

if(xh=="left" || xh=='l') xh=1;
if(xh=="right") xh=wW-eW;
if(xh=="middle" || xh=='mid' || xh=='m' || xh=='center' || xh=='c') xh=(parseInt(wW/2)-parseInt(eW/2)) + (sX==0?0:sX);
//if(xh<1) xh=1;

if(xh < 0) xh=0;
if(yv < 0) yv=0;
el.style.left=_bsVariable.isNumeric(xh)?xh+'px':xh;
el.style.top=_bsVariable.isNumeric(yv)?yv+'px':yv;
};


this.setTop=function(v,pos){var el=this.getRef(v);if(!el)return;el.style.top=pos;};
this.setValue=function(v,v2){
/* TODO: COMPLETE THIS */
 var el=this.getRef(v);if(!el)return;
 var val="";
if(_bsVariable.isObject(v2)==true){
  val=_bsVariable.isString(v2)?v2:this.getValue(v2);
}else{
  val=v2;
}
 switch(this.getElementType(el)){
 case 'undefined': return;
 case 'radio':
 for(var i=0; i < el.length; i++){
   if(el[i].value == val) el[i].checked=true;
 };
 break;
 case 'select-multiple':
 var valt=_bsVariable.getTypeName(val);
 

 for(var i=0; i < el.options.length; i++){
     el.options[i].selected=false;
     if(valt=='array'){
        for(var ii=0; ii < val.length; ii++){
         if( _bsVariable.CStr(el.options[i].value) == _bsVariable.CStr(val[ii])){
           el.options[i].selected=true;
         };
        };
     }else{
        if(_bsString.inStr(val,el.options[i].value)!=-1){
          el.options[i].selected=true;
        };
     };
 };
 case 'checkbox':
   if(_bsVariable.isString(val)){
    el.checked = (val != 'false' && val != '0' && val !='');
   }else if (_bsVariable.isNumeric(val)) el.checked = val != 0;
    else el.checked=val;
   break;
 case "select-one":
 case "select":
    for(var i=0; i < el.options.length; i++){
    if( _bsVariable.CStr(el.options[i].value)== _bsVariable.CStr(val)){
    try{
      el.options[i].selected=true;
    }catch(err){
      el.selectedIndex=i;
    }
    
    break;
    };};break;
 case "span":
 case "div":
    if(!el.firstChild) el.appendChild(document.createTextNode(''));
    el.firstChild.nodeValue=val;
 break;
 default:
   el.value=val;
 break;
 };

 if(el.onchange) el.onchange();
};
this.setWidth=function(v,n){if(n < 0) return;var el=this.getRef(v);if(!el)return;el.style.width=n;};
this.ZIndexMax=9999;
this.setZIndexTop=function(v,useCallerWindow){
if(!useCallerWindow) useCallerWindow=true;
if(useCallerWindow==true){
    if((parent.window.location != window.location) && parent.window._bsElement){
    parent.window._bsElement.setZIndexTop(v);
    return;
    }
}
var el=this.getRef(v);
if(!el)return;
this.setZIndex(el,this.ZIndexMax);
this.ZIndexMax+=1;
};
this.setZIndex=function(v,z){var el=this.getRef(v);if(!el)return;if(_bsBrowser.isNav4){el.zIndex=z;}else{el.style.zIndex=z;};};
this.toggleVisible=function(el){this.setVisible(el,!this.getVisible(el))};
this.toggleCss=function(v,css1,css2){var el=this.getRef(v);if(!el)return;var curCss=this.getClass(el);curCss=(curCss==css1) ? css2:css1;this.setClass(el,curCss)};
};
var _bsElement=new bsElement();




 /* bsBrowser ***********************************************************************************/
function bsBrowser(){
this.ua=navigator.userAgent.toLowerCase();
this.major=parseInt(navigator.appVersion);
this.minor=parseFloat(navigator.appVersion);
this.isIE=((this.ua.indexOf("msie") != -1) && (this.ua.indexOf("opera") == -1));
this.isIE3=(this.isIE && (this.major < 4));
this.isIE4=(this.isIE && (this.major == 4) && (this.ua.indexOf("msie 4")!=-1) );
this.isIE5=(this.isIE && (this.major == 4) && (this.ua.indexOf("msie 5.0")!=-1) );
this.isIE55=(this.isIE && (this.major == 4) && (this.ua.indexOf("msie 5.5") !=-1));
this.isIE6=(this.isIE && (this.major == 4) && (this.ua.indexOf("msie 6")!=-1) );
this.isIE6up=(this.isIE && !this.isIE3 && !this.isIE4 && !this.isIE5 && !this.isIE55 && !this.isIE6);
this.isNav=((this.ua.indexOf('mozilla')!=-1) && (this.ua.indexOf('spoofer')==-1) && (this.ua.indexOf('compatible') == -1) && (this.ua.indexOf('opera')==-1) && (this.ua.indexOf('webtv')==-1) && (this.ua.indexOf('hotjava')==-1));
this.isNav2=(this.isNav && (this.major == 2));
this.isNav3=(this.isNav && (this.major == 3));
this.isNav4=(this.isNav && (this.major == 4));
this.isNav4up=(this.isNav && (this.major >= 4));
this.isNav6=(this.isNav && (this.major == 5));
this.isNav6up=(this.isNav && (this.major >= 5));
this.isNavOnly=(this.isNav && ((this.ua.indexOf(";nav") != -1) || (this.ua.indexOf("; nav") != -1)));      
this.isFirefox=(this.isNav && (this.ua.indexOf("firefox") != -1));
};
var _bsBrowser=new bsBrowser();




/* bsXML *******************************************************************************************/
function bsXML(){
this.getDoc=function(strXml){var d =null;if(_bsBrowser.isIE){d=new ActiveXObject("Msxml2.DOMDocument.3.0");d.loadXML(strXml);}else{var p=new DOMParser();d=p.parseFromString(strXml, "text/xml");};return d;};
this.encodeAttribute=function(str){if(!str){return '';};str=new String(str);str=str.replace('&','&amp;');str=str.replace('<','&lt;');str=str.replace('"','&quot;');return str;};
this.encodeValue=function(str){

if(!_bsVariable.isString(str)){
    if(str==null) return '';
    str=new String(str);
};
if(str.length && str=='0') return '0';
if(str=='') return '';
if(!str) return '';

str=new String(str);str=str.replace('&','&amp;');str=str.replace('<','&lt;');str=str.replace('"','&quot;');return str;};

this.isSimpleType=function(str){
  switch(str){
    case "xsd:int":
    case "xsd:float":
    case "xsd:double":
    case "xsd:decimal":
    case "xsd:string":
    case "xsd:boolean":
    case "xsd:dateTime":
    case "xsd:timeInstant":
    case "int":
    case "float":
    case "double":
    case "decimal":
    case "string":
    case "boolean":
    case "dateTime":
    case "timeInstant":
      return true;
      break;
    default:
      return false;
  };
};
this.CType=function(xsi_type,value){
  switch(xsi_type){
    case "xsd:int":
      return parseInt(value);
    case "xsd:float":
    case "xsd:double":
    case "xsd:decimal":
      return parseFloat(value);
    case "xsd:string":
      return new String(value);
    case "xsd:boolean":
      return new Boolean(value);
    case "xsd:dateTime":
    case "xsd:timeInstant":
      return new Date(value);
  };
};
this.deserialize=function(v,o){

if(!v){return null};
  
var node;
var doc;

if(_bsVariable.isString(v)){
  var doc=this.getDoc(v);
  if(!doc.childNodes[0]){return null;};
  if(doc.childNodes[0].nodeName=='xml'){
    if(!doc.childNodes[1]){return null;};
    node=doc.childNodes[1]
  }else{
    node=doc.childNodes[0];
  };
   
}else if(_bsVariable.isObject(v)){
   node=v;
}else{
  alert('ERROR: [SRC:bsSerialize.deserialize] - This page contains functionality that is not currently supported by your current browser.');
  return null;
};

var node_name=node.nodeName;
 // <ArrayOfAnyType>
 if(node_name=="ArrayOfAnyType"){
    if(!o){o=[];};
     for(var i = 0; i < node.childNodes.length; i++){
        o[i]=this.deserialize(node.childNodes[i]);
      };
      return o;
 };
 // <ArrayOfAnyType>

    // Simple types indicated by xsi:type
    var node_xsi;
    if(node.attributes && node.attributes.getNamedItem("xsi:type")){
      node_xsi=node.attributes.getNamedItem("xsi:type").nodeValue;
      if(node_xsi){
        if(this.isSimpleType(node_xsi)){ // type is a simple type. i.e. string
          return (node.firstChild ? this.CType(node_xsi,node.firstChild.nodeValue):null);
        };
      };
    };
    
    // Simple types indicated by name
    if(this.isSimpleType(node_name)){ // type is a simple type. i.e. string
      return this.CType(node_name,node.firstChild.nodeValue);
    };
    
    if(!o){
      if(node.attributes && node.attributes.getNamedItem("js_Type")){
          try{
            o=eval("new " + node.attributes.getNamedItem("js_Type").nodeValue + "()"); // Custom Object
          }catch(e){
            o=new Object(); // Custom Object Not Found
          };
      };
    };
    
    
    //<Attributes>
    if(!o){
     return null;
    };
    if(o._xml_attributes){
      var atts_t=_bsVariable.getTypeName(o._xml_attributes);
      var atts_arr;
      if(atts_t=='string'){
         if(o._xml_attributes.indexOf(',')==-1){
           atts_arr=new Array();
           atts_arr[0]=o._xml_attributes;
         }else{
           atts_arr=o._xml_attributes.split(',');
         };
       }else if(atts_t=='array'){
         atts_arr=o._xml_attributes;
       };
       if(atts_arr){
         for(var i=0;i<atts_arr.length; i++){
           if(node.attributes && node.attributes.getNamedItem(atts_arr[i])){
             o[atts_arr[i]]=node.attributes.getNamedItem(atts_arr[i]).nodeValue;
           };
         };
        };
     };
    //</Attributes>
    
    //<Elements>
      if(o._xml_elements){
        var els_t=_bsVariable.getTypeName(o._xml_elements);
        var els_arr;
        if(els_t=='string'){
           if(o._xml_elements.indexOf(',')==-1){
             els_arr=new Array();
             els_arr[0]=o._xml_elements;
           }else{
             els_arr=o._xml_elements.split(',');
           };
         }else if(els_t=='array'){
           els_arr=o._xml_elements;
         };
             if(els_arr){
                   for(var i=0;i<els_arr.length; i++){
                     var el_name=els_arr[i];
                     var el_type=null;

                      if(el_name.indexOf('/')!=-1){
                        var el_name_part = el_name.split('/');
                        el_name=el_name_part[0];
                        el_type=(el_name_part[1]=='?') ? null:el_name_part[1]; // this element value is unknown include xsi.
                       };
                         if(el_type){
                          try{
                            o[el_name]=eval("new " + el_type + "()"); // Custom Object
                          }catch(e){};
                         };
                       var el_node_index=-1;
                       for(var i=0; i < node.childNodes.length; i++){
                         if(node.childNodes[i].nodeName==el_name){
                          if(o[el_name]){
                            this.deserialize(node.childNodes[i],o[el_name]);
                          }else{
                            o[el_name]=this.deserialize(node.childNodes[i]);
                          };
                          break;
                         };
                       };
                   };
              };
       };
     //</Elements>         
                
     if(o._isCol && node.childNodes.length){
       for(var i=0; i < node.childNodes.length; i++){
         o.add(this.deserialize(node.childNodes[i]));
       };
     };

    
    return o;
};

this.serialize=function(v,root,use_xsi,use_xml_details){


  if(!v){return null};
  
  var t=_bsVariable.getTypeName(v);
  var isST=_bsVariable.isSimpleVarByName(t);

      var xml='';
      var atts='';
      var els='';
      var xsi='';
      
      switch(t){
        case "array":
          root=(!root)?'ArrayOfAnyType':root;
           for(var i=0;i<v.length; i++){
             if(v[i].serialize){
               els += v[i].serialize(v[i],'anyType',true);
             }else{
               els += this.serialize(v[i],'anyType',true);
             };
           };
          break;
        case "number":
          if(use_xsi){
            xsi=(parseInt(v)==parseFloat(v)) ? 'xsd:int':'xsd:float';
          };
            if(!root){
             root=(parseInt(v)==parseFloat(v)) ? 'int':'float';
            };
          els=v;
          break;
        case "date":
          if(use_xsi){
            xsi='xsd:dateTime';
          };
          root=(!root)?'dateTime':root;
          els=v.toLocaleString(); 
          break;
        case "string":
        case "boolean":
          if(use_xsi){
            xsi='xsd:' + t;
          };
          root=(!root)?t:root;
         if(t=='string'){
           els=this.encodeValue(v);
         }else{
           els=v.toString();
         };  
      break;
      default:
          
          if(v._isSerializable=true){// Serializeable Objects
             if(use_xsi){xsi=v._xml_xsi_type;};
               root=(!root)?v._xml_root:root;
              // <Atributes>
                if(v._xml_attributes){
                  var atts_t=_bsVariable.getTypeName(v._xml_attributes);
                  var atts_arr;
                  if(atts_t=='string'){
                     if(v._xml_attributes.indexOf(',')==-1){
                       atts_arr=new Array();
                       atts_arr[0]=v._xml_attributes;
                     }else{
                       atts_arr=v._xml_attributes.split(',');
                     };
                   }else if(atts_t=='array'){
                     atts_arr=v._xml_attributes;
                   };
                   if(atts_arr){
                     for(var i=0;i<atts_arr.length; i++){
                       atts+=' ' + atts_arr[i] + '="' + _bsXML.encodeAttribute(v[atts_arr[i]]) + '"';
                     };
                  };
                };
                if(!v._isCol){
                  atts+=' js_Type="' + t + '"';
                };
              // </Atributes>
              
                // <elements>
                
                if(v._xml_elements){
                var els_t=_bsVariable.getTypeName(v._xml_elements);
                var els_arr;
                if(els_t=='string'){
                   if(v._xml_elements.indexOf(',')==-1){
                     els_arr=new Array();
                     els_arr[0]=v._xml_elements;
                   }else{
                     els_arr=v._xml_elements.split(',');
                   };
                 }else if(els_t=='array'){
                   els_arr=v._xml_elements;
                 };
                     if(els_arr){
                           for(var i=0;i<els_arr.length; i++){
                             var el_name=els_arr[i];
                             var el_show_type=null;
 
                              if(el_name.indexOf('/')!=-1){
                                var el_name_part = el_name.split('/');
                                el_name=el_name_part[0];
                                el_show_type=(el_name_part[1]=='?') ? true:false; // this element value is unknown include xsi.
                               };
                                  if(v[el_name]){
                                   els+=_bsXML.serialize(v[el_name],el_name,el_show_type);
                                  };
                           };
                      };
                 };
                // </elements>
                // <_items>
                 if(v._items){
                    for(var i=0;i<v._items.length; i++){
                      els+=_bsXML.serialize(v._items[i],null,false);
                    };
                 };
                // <_items>
      
          }else{
            root=(!root)?t:root;
            if(use_xsi){xsi=t;};
              for(var name in v){
                var _t=_bsVariable.getTypeName(v[name]);
                var _fc=_bsString.Left(name,1);
                if(_fc!='_' && _t!='Function'){
                    els += this.serialize(v[name],name,true);
                };
              };
          };
      break;
      };
      
      
    if(xsi.length){xsi=' xsi:type="' + xsi + '"';};
    
    var xmlns='';
    if(use_xml_details){
      xml += '<?xml version="1.0" encoding="utf-16"?>';
      xmlns = ' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"';
    };
    
      if(els.length>0){
          xml +='<' + root + atts + xsi + xmlns + '>';
          xml +=els;
          xml +='</' + root + '>';
      }else{
          xml +='<' + root + atts + xsi + xmlns + ' />';
      };
      
      return xml;
      
  };


};

var _bsXML=new bsXML();


/* bsFile ***********************************************************************************/
function bsFile(){
   this._iframe;
   this.url;
   this.id=_bsElement.generateGUID('bsFile');
   this.downloadFromUrl=function(url,debug){
   if(!debug) debug=false;
     var oThis=this;
     if(url) this.url=url;
     if(!this._iframe){
       this._iframe=document.createElement('IFRAME');
       this._iframe.setAttribute('id','_hi_dl_file');
       this._iframe.setAttribute('name','_hi_dl_file');   
       if(!debug) _bsElement.setDisplay(this._iframe,false);
       this._iframe.style.position="absolute";
       //TODO: Implement... downloading file modal frame.
       _bsEvents.add(this._iframe,'readystatechange',function(){},false);
       document.body.appendChild(this._iframe);
     };
     this._iframe.src = this.url;
   };
};

var _bsFile=new bsFile();


 /* Object Inheritance ******************************************************************************/
 Function.prototype.inherits = function(baseClass){
 this.prototype=new baseClass;
 this.prototype._base=baseClass.prototype;
 this.prototype.constructor=this.constructor;
 this.prototype._typeOf=_bsVariable.getFunctionName(this.toString());
 };
 
 function bsObject(key,value){
   this.key=key;
   this.value=value;
   this.clone=function(){return _bsVariable.clone(this); /*Note: cloning may need a revision due to the _refCount feature.*/};
 };bsObject.inherits(Object);
 

 /* bsCollection ***********************************************************************************/
function bsCollection(cClass){
this._items=null;
this.cClass=!cClass?'bsObject':cClass;
this.keyCounter=0;
this.count=function(){if(!this._items){return 0;};return this._items.length;};
this.onItemRemoved;
this.itemByProperty=function(prop,value){
  var _list = new Array();
    for(var j=0;j<this._items.length;j++){
      if(!value){
        if(eval('this._items[j].'+ prop)){
           _list[_list.length]=this._items[j];
        };
      }else{
        if(eval('this._items[j].'+ prop + '==value')){
           _list[_list.length]=this._items[j];
        };
      };
    };
   return _list;
};
this.getXML=function(eName){
  if(!eName) eName='Items';
  var xml = '<' + eName;
      xml += ' arrayOf="' + this.cClass + '"';
      xml += this._items ? '>':'/>';
        if(this._items){
            for(var j=0;j<this._items.length;j++){
              if(this._items[j].getXML) xml += this._items[j].getXML();
            };
        };
      if(this._items) xml += '</' + eName + '>';
   return xml;
}
this.add=function(o){
   return this._add(o);
};
this._add=function(o){
  var ro=false;
  if(!o && this.cClass){ 
     ro=true;eval('o=new ' + this.cClass + '();')
  };
  if(_bsVariable.isArray(o) && this.cClass){
    var oo;
    eval('oo=new ' + this.cClass + '();')
    if(oo.iniProp) oo.iniProp(o);
    o=oo;
  }
  
  if(!o) return -1;
  if(o.addRef) o.addRef();
  if(!this._items) this._items=new Array();
  
  if(!o.key || o.key==''){o.key='k'+this.keyCounter;this.keyCounter+=1;};
  o._oParent=this;
  this._items[(this._items.length)]=o;
return ro?o:this._items.length;
};

this.clear=function(dispose){
if(!this._items) return;
    for(var j=0;j<this._items.length;j++){
      if(this._items[j].dispose) this._items[j].dispose();
      this._items[j]=null;
    };
  this._items=null;
  if(this.onItemRemoved) this.onItemRemoved();
};

this.getIndexByKey=function(key){
   for(var j=0;j<this._items.length; j++){
      if(this._items[j].key==key) return j
   }
};
this.item=function(indexKey){
if(!this._items){return null;};
if(isNaN(indexKey)){for(var j=0;j<this._items.length; j++){
if(this._items[j].key==indexKey){
return this._items[j]};};}else{return this._items[indexKey]};};
this.removeList=function(list){
 if(!list) return;
   for(var j=0;j<list.length;j++){
     this.remove(list[j]);
   };
     list=null;  
};
this.remove=function(indexKey,dispose){
if(_bsVariable.isObject(indexKey)){
   if(indexKey.key) this.remove(indexKey.key,dispose);
}else if(isNaN(indexKey)){
   for(var j=0;j<this._items.length; j++){
      if(this._items[j].key==indexKey || this._items[j]==indexKey){
         if(this._items[j].dispose) this._items[j].dispose();
         this._items.splice(j,1);
      }
   }
 }else{
    if(this._items[indexKey].dispose) this._items[indexKey].dispose();
    this._items.splice(indexKey,1);
  };
  if(this.onItemRemoved) this.onItemRemoved();
};
this.clone=function(){return _bsVariable.clone(this);};
};bsCollection.inherits(bsObject);


/* bsAntiOverlap ******************************************************************************** */

function bsAntiOverlap(){
var _self = this;
this.divs=new bsCollection();
this.exec=function(){
  if(!_bsBrowser.isIE) return;
  if(_self.divs.count() == 0) return;
  var _selects=document.getElementsByTagName("SELECT");
  if(!_selects.length) return;

  for(var i=0;i<_selects.length;i++){
      var sel_show=true;
      var sd=_bsElement.getDetails(_selects[i]);
      for(var ii=0;ii<_self.divs._items.length;ii++){
        if(sel_show){
           var dd=_bsElement.getDetails(_self.divs._items[ii]);
           sel_show = !((sd.left+sd.width>dd.left && sd.left<dd.left+dd.width && sd.top+sd.height>dd.top && sd.top<dd.top+dd.height)?true:false);
        };
      };
     _bsElement.setDisplay(_selects[i],sel_show); // Show/Hide
   };
};
};bsAntiOverlap.inherits(bsObject);

var _bsAntiOverlap = new bsAntiOverlap();


 /* bsListItem ***********************************************************************************/
function bsLItem(key,text,value){
  this.key=key;
  this.text=text;
  this.value=value;
};bsLItem.inherits(Object);

function bsListItem(){
   for(var i=0; i<arguments.length; i++){
      switch (i){
        case 0: this.key = _bsVariable.isNumeric(arguments[i])?'K' + arguments[i]:arguments[i];
                this.value = arguments[i];
                if(arguments.length==1) this.text=arguments[i];
                break;
        case 1: this.text = arguments[i];break;
        default: eval('this.P' + (i-1) + '=arguments[i]');break;
      };
   };
};

var AjaxGlobalStatus=0; // (Required by XLoader)

function ExecJS(code){
  eval(code);
};


/*
Rules.
Private properties start with _ (underscore).
Object names' first character is Uppercase.
Function names' first character is Lowercase.
No ; (semicolon) when when (return [value]})
*/



/*
// Initializes a new instance of the StringBuilder class
// and appends the given value if supplied
function StringBuilder(value){
this.strings = new Array("");
this.append(value);
this.append=function(value){if(value)this.strings.push(value);return this;}
this.clear=function(){this.strings.length=1;}
this.toString=function (){return this.strings.join("")}
};bsLItem.inherits(Object);
*/



/*
  Dependencies: bslib.js
                bslib_msgbox.js
                
  TODO: Feature (field hyperlink): allow to set a hyperlink that will focus on the failing field (i.e.) Edit pen, that when click will focus on element. Also, add a OnPreElementFocus that when set will be called prior to focus element (This is important when a field is located under another tab that needs to be selected prior to displaying the field).
        Feature: (field hyperlink - Function) This function will trigger before the failing field is focused (See field hyperlink).
  
  Other validation controls, such as bsValNumeric, bsValDate, bsValPhoneNumber, bsValZipCode, bsValNumericRange
*/
function bsValidation(){ 
    this.pageGUID;
    this.sectionGUID;
    this.sectionText; // i.e. tab name
    this.groupGUID;
    this.groupText; // i.e. Addresses
    this.itemGUID;
    this.itemText; // i.e. Address
    this.itemDistinctTextFn;
    this._cssLabelOld;
    this.cssLabelFail;
    this.confirmValidateFn; //When available; this method it executed (returns true|false) to determine if validation is to be performed.
    this.customValidateFn; //When available; this method returns (true or false) indicating the result of a custom validation.
    this.reset=function(){
          // Restore label css
          if(this._cssLabelOld){
              if(this.labelElement){
                _bsElement.setClass(this.labelElement,this._cssLabelOld);
              };
              this._cssLabelOld=null;
           };
    }
    this.validate=function(){
          // Restore label css
          if(this._cssLabelOld){
              if(this.labelElement){
                _bsElement.setClass(this.labelElement,this._cssLabelOld);
              };
              this._cssLabelOld=null;
           };
           
           // Check if validation is required
           if(this.confirmValidateFn){
              var _doValidation = this.confirmValidateFn();
              if (_doValidation == false) return true;
           };
           
           if(this.customValidateFn){
             if(!this.customValidateFn()) return false;
           };
           
           
           var _valid = (this._validate?this._validate():true);
           
           return _valid;
           
    };
};bsValidation.inherits(bsObject);



function bsValRegExp(key,
                     elementToValidate,
                     labelElement,
                     errorMessage,
                     regExp){
                       
this.key=key;
this.elementToValidate=_bsElement.getRef(elementToValidate);
this.labelElement=_bsElement.getRef(labelElement);
this.errorMessage=errorMessage;
this.regExp=regExp;
this._validate=function(){
   if(!this.regExp) return true;
   var _value = _bsElement.getValue(this.elementToValidate);
   if(_value==''){
     if(this.onValidation) this.onValidation(true,this);
     return true;
   };
   // validate
   if(!_bsRegExp.test(_value,this.regExp)){
     if(this.onValidation) this.onValidation(false,this);
     return false;
   };
    if(this.onValidation) this.onValidation(true,this);
    return true;
};
};bsValRegExp.inherits(bsValidation);



function bsValRequired(key,
                       elementToValidate,
                       labelElement,
                       errorMessage,
                       confirmValidateFn){
                       
this.indicatorElement;
this.key=key;
this.elementToValidate=_bsElement.getRef(elementToValidate);
this.labelElement=_bsElement.getRef(labelElement);
this.errorMessage=errorMessage;
this.confirmValidateFn=confirmValidateFn;
this.drawRequired=function(){
   var _show = !this.confirmValidateFn?true:this.confirmValidateFn();
     this.indicatorElement.innerHTML=_show?'*':'';   
};
this._validate=function(){
    if(this.elementToValidate.disabled){
      if(this.onValidation) this.onValidation(true,this);
      return true;
    };
    
   var _value = _bsElement.getValue(this.elementToValidate);
   // validate
   if (_value == '' || _value==0){
      if(!this.errorMessage){
        if(this.labelElement){ // Get label text.
          this.errorMessage=new String(this.labelElement.innerHTML);
          this.errorMessage=this.errorMessage.replace(':','');
          this.errorMessage +=' required.';
        }else{
          this.errorMessage='Field required.'; // Use Generic text.
        };
      };
      
     if(this.onValidation) this.onValidation(false,this);
     return false;
   };
    if(this.onValidation) this.onValidation(true,this);
    return true;
};
};bsValRequired.inherits(bsValidation);


function bsValCustom(fn,
                     labelElement,
                     errorMessage){
this.customValidateFn=fn;
this.labelElement=_bsElement.getRef(labelElement);
this.errorMessage=errorMessage;
};bsValCustom.inherits(bsValidation);

function bsValidator(){
this.cssLabelFail='labelError';
this.cssSection='popup_section';
this.cssGroup='popup_group';
this.cssItem='popup_item';
this.headerText='Please correct/complete the following item(s)before proceeding:';
this.displayElement;
this.title='Attention!';
this.subTitle='Attention!';
this.useMsgBox=true;
this.clearByItemGUID=function(itemGUID){
    if(!this._items) return;
      var _list = this.itemByProperty('itemGUID',itemGUID);
      this.removeList(_list);      
      if(this.onItemRemoved) this.onItemRemoved();
};
this.clearByGroupGUID=function(groupGUID){
    if(!this._items) return;
        for(var i=0;i<this._items.length;i++){
          if(this._items[i].groupGUID==groupGUID){
             this.remove(i);
          };
        };
      if(this.onItemRemoved) this.onItemRemoved();
};
this.displayError=function(str){
    if(this.displayElement){
      this.displayElement = _bsElement.getRef(this.displayElement);
      this.displayElement.innerHTML=str;
      _bsElement.setDisplay(this.displayElement,true);
    }else{
      if(this.useMsgBox){
        var msgBox = new bsMsgBox();
            msgBox.isModal=true;
            msgBox.width='500px';
            msgBox.height='250px';
            msgBox.show(str,this.title,'ok',1,this.subTitle);
      }else{
        alert(str);
      };
    };
};
this.validateByItemGUID=function(itemGUID){
  return this.validate('itemGUID',itemGUID);
};
this.reset=function(){
  if(!this._items) return;
  for(var i=0;i<this._items.length; i++){
     this.item(i).reset();
  }
}
this.validate=function(prop,value){
if(!this._items) return true;

 var _valid=true;
 var r_header = this.headerText;
 var r_items = (!this.displayElement && !this.useMsgBox) ? '\n':'<br/><br/>';
 var r_divider = (!this.displayElement && !this.useMsgBox) ? '\u00A0\u00A0\u00A0':'&nbsp;&nbsp;&nbsp;';
  // Reset Label (css Class)
  
  

  var cur_sec_text;
  var cur_group_text;
  var cur_item_text;
  var cur_indent=0;
  
  var lastGroup='';
  for(var i=0;i<this._items.length; i++){
   if (!prop || (eval('this.item(i).' + prop + '==value'))){
    if(!this.item(i).validate()){
       if(_valid) _bsElement.setFocus(this.item(i).elementToValidate); // Focus
       
       var r_item='';

       if (this.item(i).sectionText != cur_sec_text){ // New Section
         cur_sec_text=this.item(i).sectionText ;
         cur_indent=2;
         var sec_text = (!this.displayElement && !this.useMsgBox)? cur_sec_text:'<span class="' + this.cssSection + '">' + cur_sec_text + '</span>';
         r_item+=_bsString.repeat(r_divider,cur_indent) + '• ' + sec_text + ((!this.displayElement && !this.useMsgBox)? '\n':'<br/>');
         cur_group_text=null;
         cur_item_text=null;
       };
       
       if (this.item(i).groupText != cur_group_text){ // New group
         cur_group_text=this.item(i).groupText;
         cur_indent=(!cur_sec_text ? 2:3);
         var sec_group = (!this.displayElement && !this.useMsgBox)? cur_group_text:'<span class="' + this.cssGroup + '">' + cur_group_text + '</span>';
         r_item+=_bsString.repeat(r_divider,cur_indent) + '• ' + sec_group + ((!this.displayElement && !this.useMsgBox) ? '\n':'<br/>');
         cur_item_text=null;
       };
       
       var item_dt = this.item(i).itemDistinctTextFn?this.item(i).itemDistinctTextFn():'';
       var item_text = this.item(i).itemText?this.item(i).itemText + item_dt:null;
       
       if (item_text != cur_item_text){ // New item
         cur_item_text=this.item(i).itemText + item_dt;
         var item_text = (!this.displayElement && !this.useMsgBox)? cur_group_text:'<span class="' + this.cssItem + '">' + cur_item_text + '</span>';
         if(lastGroup != cur_item_text && lastGroup.length!=0) r_item+='<br/>';
         cur_indent=(!cur_sec_text && !cur_group_text)?2:((!cur_sec_text && cur_group_text) || (cur_sec_text && !cur_group_text))?3:4;
         r_item+=_bsString.repeat(r_divider,cur_indent) + '• ' + item_text + '';
         r_item +=((!this.displayElement && !this.useMsgBox)? '\n':'<br/>');
         hasItems=true;
         lastGroup=cur_item_text;
       };
       
       
       
       r_item += _bsString.repeat(r_divider,cur_indent+1)
       r_item += ' - ';
       r_item += this.item(i).errorMessage;
       r_items +=r_item;
       r_items += (!this.displayElement && !this.useMsgBox) ? '\n':'<br/>';
         
       if(this.item(i).labelElement){
          var _cssVal = (!this.item(i).cssLabelFail?this.cssLabelFail:this.item(i).cssLabelFail);
           if(_cssVal){
             this.item(i)._cssLabelOld=_bsElement.getClass(this.item(i).labelElement);
             _bsElement.setClass(this.item(i).labelElement,_cssVal);
           };
       };
       _focus=false;
       _valid=false;
       
      };
    }; /* for */
    
  };
  
  if(!_valid) this.displayError(r_header + r_items);
  return _valid;
};
};bsValidator.inherits(bsCollection);


var _bsValidator = new bsValidator();


