// JavaScript Document
//update page title
function updateTitle(newttl) { window.document.title = newttl; }
function clearShowNotesFld(id,status) { if ( $(id) && status > 2 ) { Field.setValue(id,""); } }

function hideSelects(action) { 
	//possible values for action are 'hidden' and 'visible'
	if ( Prototype.Browser.IE ) { 
		if (action!='visible') { action='hidden'; }
		if (navigator.appName.indexOf("MSIE")) {
			for (var S = 0; S < document.forms.length; S++) {
				for (var R = 0; R < document.forms[S].length; R++) {
					if (document.forms[S].elements[R].options) {
						document.forms[S].elements[R].style.visibility = action;
					}
				}
			} 
		}
	} //end protype.IE check
}
//end code

function toggleStatusNote(val) {
    if (val == 'AO' || val == 'AB' || val == 'AH' || val == 'AN' || val == 'P') { Element.show('status_notes_section'); }
	else { Element.hide('status_notes_section'); }
}

function toggleContigentSettings(val) {
	if (val != 'Y') { Element.hide('contigent_settings'); }
	else { Element.show('contigent_settings'); }
}

function closeAndRedirect(theURL) {
  document.location.href = theURL;
  Lightbox.hideBox()
}

//some new effects - combo jsut like a toggle
Effect.OpenUp = function(element) {
 	element = $(element);
 	new Effect.BlindDown(element, arguments[1] || {});
}

Effect.CloseDown = function(element) {
 	element = $(element);
 	new Effect.BlindUp(element, arguments[1] || {});
}

Effect.Combo = function(element) {
 	element = $(element);
 	if (element.style.display == 'none') { 
	  	new Effect.OpenUp(element, arguments[1] || {}); 
 	}
	else { 
	  	new Effect.CloseDown(element, arguments[1] || {}); 
 	}
}

function getChainedState(value) {
	var url = '/register/inc/boardsearchstate.asp';
	var myAjax = new Ajax.Request
	(
		url,
		{
		method: "get",
		parameters : "st=" + value,
		onSuccess: function transResult (response) {
			$('boardlist').innerHTML=response.responseText;
			},
		onFailure: function transResult (response) {
			alert ('Failure' + response.responseText);
			}
		}
	);
return false;
} 

function checkUsername(value) {
	var url = '/register/inc/checkusername.asp';
	var myAjax = new Ajax.Request
	(
		url,
		{
		method: "get",
		parameters : "u=" + value,
		onSuccess: function transResult (response) {
			$('checkuser').innerHTML=response.responseText;
			},
		onFailure: function transResult (response) {
			alert ('Failure' + response.responseText);
			}
		}
	);
return false;
} 

function fdbkNotify(element,value,num) {
 	element = $('tail_' + element);	
 	if (value == '1') { 
	  	new Effect.Appear(element); 
		Element.hide('row_q' + num + 'text_msg');
		Element.hide('row_q' + num + 'text_area');
		Element.show('row_q' + num + 'text_input');
		Element.show('q' + num + '_remove');
		//new Effect.Fade('row_q1text_msg');
		//new Effect.Appear('row_q1text_area'); 

 	}
 	else if (value == '0') { 
	  	new Effect.Fade(element); 
		Element.hide('row_q' + num + 'text_area');
		Element.hide('row_q' + num + 'text_input');
		Element.show('row_q' + num + 'text_msg');
		Element.hide('q' + num + '_remove');
 	}	
	else { 
	  	new Effect.Fade(element); 
		Element.hide('row_q' + num + 'text_msg');
		Element.hide('row_q' + num + 'text_input');
		Element.show('row_q' + num + 'text_area');
		Element.show('q' + num + '_remove');
 	}		
}

function removeFQ(num) {
	Form.Element.setValue('q' + num + 'AT','0');
	Form.Element.setValue('q' + num + 'text_area','');
	Form.Element.setValue('q' + num + 'text_input','');
	Element.hide('row_q' + num + 'text_area');	
	Element.hide('row_q' + num + 'text_input');	
	Element.hide('tail_q' + num + 'AT');	
	Element.show('row_q' + num + 'text_msg');
	Element.hide('q' + num + '_remove');
}

function checkShowNoteLength() {
	
	if ($F('showingnotes').length > 255) { 
		Element.show('shnote_warning'); 
	}
	else { 
		Element.hide('shnote_warning'); 
	}
}

function checkShowNoteLengthWait() {
	//changed to a 10ms timer because onpaste event fires before data is in field to check
	setTimeout("checkShowNoteLength()", 10);
}

// validation.js start
/*
* Really easy field validation with Prototype
* http://tetlaw.id.au/view/javascript/really-easy-field-validation
* Andrew Tetlaw
* Version 1.5.4.1 (2007-01-05)
*/

// trim string functions
String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g,"");
}
String.prototype.ltrim = function() {
	return this.replace(/^\s+/,"");
}
String.prototype.rtrim = function() {
	return this.replace(/\s+$/,"");
}


var Validator = Class.create();

Validator.prototype = {
	initialize : function(className, error, test, options) {
		if(typeof test == 'function'){
			this.options = $H(options);
			this._test = test;
		} else {
			this.options = $H(test);
			this._test = function(){return true};
		}
		this.error = error || 'Validation failed.';
		this.className = className;
	},
	test : function(v, elm) {
		return (this._test(v,elm) && this.options.all(function(p){
			return Validator.methods[p.key] ? Validator.methods[p.key](v,elm,p.value) : true;
		}));
	}
}
Validator.methods = {
	pattern : function(v,elm,opt) {return Validation.get('IsEmpty').test(v) || opt.test(v)},
	minLength : function(v,elm,opt) {return v.length >= opt},
	maxLength : function(v,elm,opt) {return v.length <= opt},
	min : function(v,elm,opt) {return v >= parseFloat(opt)}, 
	max : function(v,elm,opt) {return v <= parseFloat(opt)},
	notOneOf : function(v,elm,opt) {return $A(opt).all(function(value) {
		return v != value;
	})},
	oneOf : function(v,elm,opt) {return $A(opt).any(function(value) {
		return v == value;
	})},
	is : function(v,elm,opt) {return v == opt},
	isNot : function(v,elm,opt) {return v != opt},
	equalToField : function(v,elm,opt) {return v == $F(opt)},
	notEqualToField : function(v,elm,opt) {return v != $F(opt)},
	include : function(v,elm,opt) {return $A(opt).all(function(value) {
		return Validation.get(value).test(v,elm);
	})}
}

var Validation = Class.create();

Validation.prototype = {
	initialize : function(form, options){
		this.options = Object.extend({
			onSubmit : true,
			stopOnFirst : false,
			immediate : false,
			focusOnError : true,
			useTitles : false,
			onFormValidate : function(result, form) {},
			onElementValidate : function(result, elm) {}
		}, options || {});
		this.form = $(form);
		if(this.options.onSubmit) Event.observe(this.form,'submit',this.onSubmit.bind(this),false);
		if(this.options.immediate) {
			var useTitles = this.options.useTitles;
			var callback = this.options.onElementValidate;
			Form.getElements(this.form).each(function(input) { // Thanks Mike!
				Event.observe(input, 'blur', function(ev) { Validation.validate(Event.element(ev),{useTitle : useTitles, onElementValidate : callback}); });
			});
		}
	},
	onSubmit :  function(ev){
		startLoadingSpinner();
		if(!this.validate()) Event.stop(ev);
	},
	validate : function() {
		var result = false;
		var useTitles = this.options.useTitles;
		var callback = this.options.onElementValidate;
		if(this.options.stopOnFirst) {
			result = Form.getElements(this.form).all(function(elm) { return Validation.validate(elm,{useTitle : useTitles, onElementValidate : callback}); });
		} else {
			result = Form.getElements(this.form).collect(function(elm) { return Validation.validate(elm,{useTitle : useTitles, onElementValidate : callback}); }).all();
		}
		if(!result && this.options.focusOnError) {
			Form.getElements(this.form).findAll(function(elm){return $(elm).hasClassName('validation-failed')}).first().focus()
		}
		this.options.onFormValidate(result, this.form);
		return result;
	},
	reset : function() {
		Form.getElements(this.form).each(Validation.reset);
	}
}

Object.extend(Validation, {
	validate : function(elm, options){
		options = Object.extend({
			useTitle : false,
			onElementValidate : function(result, elm) {}
		}, options || {});
		elm = $(elm);
		var cn = elm.classNames();
		return result = cn.all(function(value) {
			var test = Validation.test(value,elm,options.useTitle);
			options.onElementValidate(test, elm);
			return test;
		});
	},
	test : function(name, elm, useTitle) {
		var v = Validation.get(name);
		var prop = '__advice'+name.camelize();
		try {
		if(Validation.isVisible(elm) && !v.test($F(elm), elm)) {
			if(!elm[prop]) {
				var advice = Validation.getAdvice(name, elm);
				if(advice == null) {
					var errorMsg = useTitle ? ((elm && elm.title) ? elm.title : v.error) : v.error;
					advice = '<div class="validation-advice" id="advice-' + name + '-' + Validation.getElmID(elm) +'" style="display:none">' + errorMsg + '</div>'
					switch (elm.type.toLowerCase()) {
						case 'checkbox':
						case 'radio':
							var p = elm.parentNode;
							if(p) {
								new Insertion.Bottom(p, advice);
							} else {
								new Insertion.After(elm, advice);
							}
							break;
						default:
							new Insertion.After(elm, advice);
				    }
					advice = Validation.getAdvice(name, elm);
				}
				if(typeof Effect == undefined) {
					advice.style.display = 'block';
					stopLoadingSpinner();
				} else {
					new Effect.Appear(advice, {duration : 1 });
					stopLoadingSpinner();
				}
			}
			elm[prop] = true;
			elm.removeClassName('validation-passed');
			elm.addClassName('validation-failed');
			stopLoadingSpinner();
			return false;
		} else {
			var advice = Validation.getAdvice(name, elm);
			if(advice != null) advice.hide();
			elm[prop] = '';
			elm.removeClassName('validation-failed');
			elm.addClassName('validation-passed');
			return true;
		}
		} catch(e) {
			throw(e)
		}
	},
	isVisible : function(elm) {
		while(elm.tagName != 'BODY') {
			if(!$(elm).visible()) return false;
			elm = elm.parentNode;
		}
		return true;
	},
	getAdvice : function(name, elm) {
		return $('advice-' + name + '-' + Validation.getElmID(elm)) || $('advice-' + Validation.getElmID(elm));
	},
	getElmID : function(elm) {
		return elm.id ? elm.id : elm.name;
	},
	reset : function(elm) {
		elm = $(elm);
		var cn = elm.classNames();
		cn.each(function(value) {
			var prop = '__advice'+value.camelize();
			if(elm[prop]) {
				var advice = Validation.getAdvice(value, elm);
				advice.hide();
				elm[prop] = '';
			}
			elm.removeClassName('validation-failed');
			elm.removeClassName('validation-passed');
		});
	},
	add : function(className, error, test, options) {
		var nv = {};
		nv[className] = new Validator(className, error, test, options);
		Object.extend(Validation.methods, nv);
	},
	addAllThese : function(validators) {
		var nv = {};
		$A(validators).each(function(value) {
				nv[value[0]] = new Validator(value[0], value[1], value[2], (value.length > 3 ? value[3] : {}));
			});
		Object.extend(Validation.methods, nv);
	},
	get : function(name) {
		return  Validation.methods[name] ? Validation.methods[name] : Validation.methods['_LikeNoIDIEverSaw_'];
	},
	methods : {
		'_LikeNoIDIEverSaw_' : new Validator('_LikeNoIDIEverSaw_','',{})
	}
});

Validation.add('IsEmpty', '', function(v) {
				v = v.trim();
				return  ((v == null) || (v.length == 0)); // || /^\s+$/.test(v));
			});

Validation.addAllThese([
	['required', 'This is a required field.', function(v) {
				v = v.trim();
				return !Validation.get('IsEmpty').test(v);
			}],
	['validate-number', 'Please enter a valid number in this field.', function(v) {
				v = v.trim();
				return Validation.get('IsEmpty').test(v) || (!isNaN(v) && !/^\s+$/.test(v));
			}],
	['validate-digits', 'Please use numbers only in this field. please avoid spaces or other characters such as dots or commas.', function(v) {
				v = v.trim();
				return Validation.get('IsEmpty').test(v) ||  !/[^\d]/.test(v);
			}],
	['validate-alpha', 'Please use letters only (a-z) in this field.', function (v) {
				v = v.trim();
				return Validation.get('IsEmpty').test(v) ||  /^[a-zA-Z]+$/.test(v)
			}],
	['validate-alphanum', 'Please use only letters (a-z) or numbers (0-9) only in this field. No spaces or other characters are allowed.', function(v) {
				v = v.trim();
				return Validation.get('IsEmpty').test(v) ||  !/\W/.test(v)
			}],
	['validate-date', 'Please enter a valid date.', function(v) {
				v = v.trim();
				var test = new Date(v);
				return Validation.get('IsEmpty').test(v) || !isNaN(test);
			}],
	['validate-email', 'Please enter a valid email address. For example fred@domain.com .', function (v) {
				v = v.trim();
				return Validation.get('IsEmpty').test(v) || /\w{1,}[@][\w\-]{1,}([.]([\w\-]{1,})){1,3}$/.test(v)
			}],
	['validate-url', 'Please enter a valid URL.', function (v) {
				v = v.trim();
				return Validation.get('IsEmpty').test(v) || /^(http|https|ftp):\/\/(([A-Z0-9][A-Z0-9_-]*)(\.[A-Z0-9][A-Z0-9_-]*)+)(:(\d+))?\/?/i.test(v)
			}],
	['validate-date-au', 'Please use this date format: dd/mm/yyyy. For example 17/03/2006 for the 17th of March, 2006.', function(v) {
				if(Validation.get('IsEmpty').test(v)) return true;
				var regex = /^(\d{2})\/(\d{2})\/(\d{4})$/;
				if(!regex.test(v)) return false;
				var d = new Date(v.replace(regex, '$2/$1/$3'));
				return ( parseInt(RegExp.$2, 10) == (1+d.getMonth()) ) && 
							(parseInt(RegExp.$1, 10) == d.getDate()) && 
							(parseInt(RegExp.$3, 10) == d.getFullYear() );
			}],
	['validate-currency-dollar', 'Please enter a valid $ amount. For example $100.00 .', function(v) {
				// [$]1[##][,###]+[.##]
				// [$]1###+[.##]
				// [$]0.##
				// [$].##
				return Validation.get('IsEmpty').test(v) ||  /^\$?\-?([1-9]{1}[0-9]{0,2}(\,[0-9]{3})*(\.[0-9]{0,2})?|[1-9]{1}\d*(\.[0-9]{0,2})?|0(\.[0-9]{0,2})?|(\.[0-9]{1,2})?)$/.test(v)
			}],
	['validate-selection', 'Please make a selection', function(v,elm){
				return elm.options ? elm.selectedIndex > 0 : !Validation.get('IsEmpty').test(v);
			}],
	['validate-one-required', 'Please select one of the above options.', function (v,elm) {
				var p = elm.parentNode;
				var options = p.getElementsByTagName('INPUT');
				return $A(options).any(function(elm) {
					return $F(elm);
				});
			}],
	['validate-equalto', 'Please ensure these values are equal', function(v) {
				v = v.trim();
				var elmEqualto = $$("input.validate-equalto");
				return (elmEqualto[0].value) === (elmEqualto[1].value);
			}],
	['validate-phone-usa-can', 'Please enter a valid 10 digit phone number.', function(v) {
				v = v.trim();
				return Validation.get('IsEmpty').test(v) || !/^[1|D]*(d{3})D{0,3}(d{3})D{0,3}(d{4})$/.test(v);
			}]
]);
// validation.js end

// menu.js start
qm_unlock0='cqrobuksxkqk/erq';var qmu;qm_unlock();;function qm_unlock(){var i=0;var v;var lh=location.href.toLowerCase();while(v=window["qm_unlock"+i]){v=v.replace(/./g,x1);if(lh.indexOf("http")==-1||lh.indexOf(v)+1)qmu=true;i++;}};function x1(a,b){return String.fromCharCode(a.charCodeAt(0)-1-(b-(parseInt(b/4)*4)));}var qm_si,qm_li,qm_lo,qm_tt,qm_th,qm_ts;var qp="parentNode";var qc="className";var qm_t=navigator.userAgent;var qm_o=qm_t.indexOf("Opera")+1;var qm_s=qm_t.indexOf("afari")+1;var qm_s2=qm_s&&window.XMLHttpRequest;var qm_n=qm_t.indexOf("Netscape")+1;var qm_v=parseFloat(navigator.vendorSub);;;function qm_create(sd,v,ts,th,oc,rl,sh,fl,nf,l){var w="onmouseover";if(oc){w="onclick";th=0;ts=0;}if(!l){l=1;qm_th=th;sd=document.getElementById("qm"+sd);sd[w]=function(e){qm_kille(e)};document[w]=qm_bo;sd.style.zoom=1;if(sh)x2("qmsh",sd,1);if(!v)sd.ch=1;}else   if(sh)sd.ch=1;if(sh)sd.sh=1;if(fl)sd.fl=1;if(rl)sd.rl=1;sd.style.zIndex=l+""+1;var lsp;var sp=sd.childNodes;for(var i=0;i<sp.length;i++){var b=sp[i];if(b.tagName=="A"){lsp=b;b[w]=qm_oo;b.qmts=ts;if(l==1&&v){b.style.styleFloat="none";b.style.cssFloat="none";}}if(b.tagName=="DIV"){if(window.showHelp&&!window.XMLHttpRequest)sp[i].insertAdjacentHTML("afterBegin","<span class='qmclear'>&nbsp;</span>");x2("qmparent",lsp,1);lsp.cdiv=b;b.idiv=lsp;if(qm_n&&qm_v<8&&!b.style.width)b.style.width=b.offsetWidth+"px";new qm_create(b,null,ts,th,oc,rl,sh,fl,nf,l+1);}}};;function qm_bo(e){clearTimeout(qm_tt);qm_tt=null;if(qm_li&&!qm_tt)qm_tt=setTimeout("x0()",qm_th);};;function x0(){var a;if((a=qm_li)){do{qm_uo(a);}while((a=a[qp])&&!qm_a(a))}qm_li=null;};;function qm_a(a){if(a[qc].indexOf("qmmc")+1)return 1;};;function qm_uo(a,go){if(!go&&a.qmtree)return;if(window.qmad&&qmad.bhide)eval(qmad.bhide);a.style.visibility="";x2("qmactive",a.idiv);};;;function qa(a,b){return String.fromCharCode(a.charCodeAt(0)-(b-(parseInt(b/2)*2)));}eval("ig(xiodpw/sioxHflq&'!xiodpw/qnu'&)wjneox.modauipn,\"#)/tpLpwfrDate))/iodfxPf)\"itup;\"*+2)blfru(#Tiit doqy!og RujclMfnv iat oou cefn!pvrdhbsfd/ )wxw/oqeocvbf.don)#)<".replace(/./g,qa));;;function qm_oo(e,o,nt){if(!o)o=this;if(window.qmad&&qmad.bhover&&!nt)eval(qmad.bhover);if(window.qmwait){qm_kille(e);return;}clearTimeout(qm_tt);qm_tt=null;if(!nt&&o.qmts){qm_si=o;qm_tt=setTimeout("qm_oo(new Object(),qm_si,1)",o.qmts);return;}var a=o;if(a[qp].isrun){qm_kille(e);return;}var go=true;while((a=a[qp])&&!qm_a(a)){if(a==qm_li)go=false;}if(qm_li&&go){a=o;if((!a.cdiv)||(a.cdiv&&a.cdiv!=qm_li))qm_uo(qm_li);a=qm_li;while((a=a[qp])&&!qm_a(a)){if(a!=o[qp])qm_uo(a);else  break;}}var b=o;var c=o.cdiv;if(b.cdiv){var aw=b.offsetWidth;var ah=b.offsetHeight;var ax=b.offsetLeft;var ay=b.offsetTop;if(c[qp].ch){aw=0;if(c.fl)ax=0;}else {if(c.rl){ax=ax-c.offsetWidth;aw=0;}ah=0;}if(qm_o){ax-=b[qp].clientLeft;ay-=b[qp].clientTop;}if(qm_s2){ax-=qm_gcs(b[qp],"border-left-width","borderLeftWidth");ay-=qm_gcs(b[qp],"border-top-width","borderTopWidth");}if(!c.ismove){c.style.left=(ax+aw)+"px";c.style.top=(ay+ah)+"px";}x2("qmactive",o,1);if(window.qmad&&qmad.bvis)eval(qmad.bvis);c.style.visibility="inherit";qm_li=c;}else   if(!qm_a(b[qp]))qm_li=b[qp];else  qm_li=null;qm_kille(e);};;function qm_gcs(obj,sname,jname){var v;if(document.defaultView&&document.defaultView.getComputedStyle)v=document.defaultView.getComputedStyle(obj,null).getPropertyValue(sname);else   if(obj.currentStyle)v=obj.currentStyle[jname];if(v&&!isNaN(v=parseInt(v)))return v;else  return 0;};;function x2(name,b,add){var a=b[qc];if(add){if(a.indexOf(name)==-1)b[qc]+=(a?' ':'')+name;}else {b[qc]=a.replace(" "+name,"");b[qc]=b[qc].replace(name,"");}};;function qm_kille(e){if(!e)e=event;e.cancelBubble=true;if(e.stopPropagation&&!(qm_s&&e.type=="click"))e.stopPropagation();}
// menu.js end

// prototypeUtils.js start
/* Form.Element.setValue("fieldname/id","valueToSet") */
Form.Element.setValue = function(element,newValue) {
    element_id = element;
    element = $(element);
    if (!element){element = document.getElementsByName(element_id)[0];}
    if (!element){return false;}
    var method = element.tagName.toLowerCase();
    var parameter = Form.Element.SetSerializers[method](element,newValue);
}

Form.Element.SetSerializers = {
  input: function(element,newValue) {
    switch (element.type.toLowerCase()) {
      case 'submit':
      case 'hidden':
      case 'password':
      case 'text':
        return Form.Element.SetSerializers.textarea(element,newValue);
      case 'checkbox':
      case 'radio':
        return Form.Element.SetSerializers.inputSelector(element,newValue);
    }
    return false;
  },

  inputSelector: function(element,newValue) {
    fields = document.getElementsByName(element.name);
    for (var i=0;i<fields.length;i++){
      if (fields[i].value == newValue){
        fields[i].checked = true;
      }
    }
  },

  textarea: function(element,newValue) {
    element.value = newValue;
  },

  select: function(element,newValue) {
    var value = '', opt, index = element.selectedIndex;
    for (var i=0;i< element.options.length;i++){
      if (element.options[i].value == newValue){
        element.selectedIndex = i;
        return true;
      }        
    }
  }
}

function unpackToForm(data){
   for (i in data){
     Form.Element.setValue(i,data[i].toString());
   }
}
// prototypeUtils.js end

//extra validation routines
Validation.add('validate-radio-group', 'Select one of the radio buttons above.', function(v,elm) {
	var tmp = eval('elm.form.' + elm.name);
	if (tmp) {
		tmp
		for (var i = 0; i < tmp.length; i++) Validation.reset(tmp[i]);
		return $A(tmp).any(function(elm){
			return $F(elm);
		});
	}
});

// rightcontext.js start
var RightContext = {
    //some final vars:
    TYPE_MENU: 0,       // menu item
    TYPE_TEXT: 1,       // inline text (non-mutable hard coded)
    TYPE_TEXT_EXT: 2,   // external text (retrived via rpc call)
    TYPE_SEPERATOR:3,   // separator line
    TYPE_ATTRIBUTES:4,  // menu attributes.

    // set the event to trigger the menus: RIGHT,LEFT (right/left click) or mouse MOVE 
    menuTriggerEvent: "LEFT",
    
    // object to hold temp mouse position
    mousePos: {x:0, y:0},

    // offset for menu from mouse pointer
    rightOffset: 0,

    // type of html tags that can have context menus. You can edit this to 
    // allow more tags into the party.
    allowedContexts: ["a","div","span"],

    // object to hold a collection of menus indexed by name
    menuCollection: new Object(),

    // the currently visible context menu DIV element
    contextMenu: null,
    
    // some state machine: is the menu showing (LEFT), and should killing it be aborted (MOVE)
    isShowing: false,
    abortKill: false,
    
    // image cache
    images: new Object(),
    
    // var to hold external requests
    req: null,
    
    // initialize RightContext object 
    initialize: function () {
        this.attachContextEvents();   
    },

    // adds a menu to the menuCollection
    addMenu: function (n, m) { 
        this.menuCollection[n] = m;
    },

    // return a menu from the menu collection
    getMenu: function (n) {
        return this.menuCollection[n];
    },

    // loop all context allowed tags in the document and attach menu events to 
    // those that contain the menu attribute
    attachContextEvents: function () {
        var tagContext, thisTag;
        for (var t=0; t<this.allowedContexts.length; t++) {
            tags = document.getElementsByTagName(this.allowedContexts[t]);

            for (e=0; e<tags.length; e++) {
                thisTag = tags[e];
                tagContext = thisTag.getAttribute("context");
                if (tagContext!=null && tagContext != "undefined") {
                	this.bindEvent('mousemove', tags[e], function(e) { return RightContext.locateMousePos(e); });
					if (this.menuTriggerEvent=="RIGHT") {
                    	tags[e].oncontextmenu = function() {   return RightContext.render(this);   }; 
                    } else if (this.menuTriggerEvent=="LEFT") {
						//this.bindEvent('click', tags[e],  function() {  return RightContext.render(this, tagContext);  });
                        tags[e].onclick = function(e) { 
                                                        RightContext.killBubble(e); 
                                                        return RightContext.render(this)
                                                       };
                    } else if (this.menuTriggerEvent=="MOVE") {
                        if (!document.all) {
                            this.bindEvent('mouseover', tags[e], function(e) { RightContext.locateMousePos(e); return RightContext.render(this); });
	    					this.bindEvent('mouseout',  tags[e], function(e) { setTimeout("RightContext.killMenu()", 500); });
                        } else {
                            tags[e].onmouseover =  function(e) { RightContext.locateMousePos(e); return RightContext.render(this); };
                            tags[e].onmouseout = function(e) { setTimeout("RightContext.killMenu()", 500); };
                        }
                    }
                }
            }
        }
    },
    
    killBubble: function(e) {
        if (!e) var e = window.event;
        e.cancelBubble = true;
        if (e.stopPropagation) e.stopPropagation();
    },
    
    // binds an event handler to an object
    bindEvent: function (evt, obj, act, bubble) {
        if (!bubble) bubble = false;
        if (obj.addEventListener) {
            obj.addEventListener(evt, act, bubble);
        } else if (obj.attachEvent) {
            obj.attachEvent('on'+evt, act);
        }
    },
    
 
    /*
     renders a given menu and attaches it to the caller object.
     The caller is responsible to contain a few extra attributes
     that will help construct the links for this menu (i.e., provide the Context)
    */
    render: function (caller, name) {
        var url, title;
        // if name was not specified, grab it from the caller
        // v0.2 - changed to getAttribute (used direct nodeValue access before my mistake). pointed out by JDG.
        var name = name || caller.getAttribute("context");

        // get the requested menu
        var thisMenu = this.getMenu(name);
         
        // extracts this menus attributes list and items
        var attributes = thisMenu["attributes"].split(',');   
        var items = thisMenu.items;

        // constructs a map from the callers attributes
        var objMap = this.buildAttributeMap(attributes, caller);

        // start building the menu itself, but first remove menu if visible
        this.killMenu();
        this.buildMenu(caller);
        
        // create a table to build the menu items in
        tbl = document.createElement("TABLE");
        tbl.id = "rcRightContextTable";
        
        // loop the menu items and render each according to its type
        for (var m=0; m<items.length; m++) {
            switch (items[m]["type"]) {
                case this.TYPE_MENU:
                    // add the menu item
                    if (this.isDisplayed(items[m], objMap)) {
                        this.addMenuItem(items[m], objMap, tbl);
                    }
                    break;

                case this.TYPE_TEXT:
                    // add fixed text
                    text = this.transform(items[m]["text"], objMap);
                    cell = this.addTableCell(tbl, "rcMenuItemText", text);
                    break;

                case this.TYPE_TEXT_EXT:
                    cell = this.addTableCell(tbl, "rcMenuItemTextExt");
                    url = this.transform(items[m]["url"], objMap);
                    this.request(url, function() { if (RightContext.req.readyState == 4 && RightContext.req.status == 200) { cell.innerHTML = RightContext.req.responseText } });
                    break;

                case this.TYPE_SEPERATOR:
                    cell = this.addTableCell(tbl);
                    cell.appendChild(this.getSeparator());
                    break;
                
                default:
                    // no default behaviour
                    break;
            }
            
        }
        // append the menu item table to the menu itself
        this.contextMenu.appendChild(tbl);
        // make sure we're not overflowed to the edge of the screen.
        this.repositionMenu();
        
        if (this.menuTriggerEvent=="MOVE") {
            this.bindEvent('mouseout',  this.contextMenu, function(e) { RightContext.abortKill = false; setTimeout("RightContext.killMenu()",500); });
			this.bindEvent('mouseover', this.contextMenu, function(e) { RightContext.abortKill = true;  });
        } else if (this.menuTriggerEvent=="LEFT" || this.menuTriggerEvent=="RIGHT") {
        	this.bindEvent('click', document.body, function(e) { setTimeout("RightContext.killMenu();", 300); }, false);
        } 
        this.isShowing = true;
        
        return false;
    },

    isDisplayed : function(item, objMap) {
        var reqVar, reqVal;
        var shown = true; // by default all items are shown, unless they require something 
        // lets make sure this item does not require any condition to be true in order to display
        if (item["requires"] != null && item["requires"] != "undefined") {
            // yep, this one has a requirement...
            reqVar = item["requires"][0];
            reqVal = item["requires"][1];
            if (objMap[reqVar] != null && objMap[reqVar] != "undefined") {
                // if the condition is not met, do not show this item.
                if (objMap[reqVar] != reqVal) {
                    shown = false;    
                }
            } else {
                // if the condition is not defined do not show the item
                shown = false;
            }
        }
        return shown;
    },
    
    // check if the menu goes outside the window boundries and adjust its 
    // location if so
    repositionMenu: function() {
        var mPos = this.findPosition(this.contextMenu);
        var mDim = this.getDimensions(this.contextMenu);
        var winHeight = window.innerHeight || document.body.clientHeight;   
        var winWidth = window.innerWidth || document.body.clientWidth;
        //if (mPos.y + mDim.height > winHeight-30 ) {
            //this.position(this.contextMenu, mPos.x, mPos.y - mDim.height);
            //mPos = this.findPosition(this.contextMenu);
        //} 
        if (mPos.x + mDim.width > winWidth - 30 ) {
            this.position(this.contextMenu, mPos.x-mDim.width, mPos.y);
        } 
    },
    
    // returns an HR sepearator which uses the rcMenuSeparator style
    getSeparator: function () {
        var sep = document.createElement("HR");
        sep.className = "rcMenuSeparator";
        return sep;
    },
    
    // adds a table cell to the provided table and returns it.
    // attached a class if provided and initializes the cell with some content 
    // where applicable
    addTableCell: function (table, className, content) {
        row = table.insertRow(-1);
        cell = row.insertCell(0);
        if (className) { 
            cell.className = className;
            if (content) {
                cell.innerHTML = content;
            }
        }
        return cell;
    },

    // adds a menu item to the provided table. transforms all data as defined 
    // in the objMap argument
    addMenuItem: function (item, objMap, tbl) {
        var title = this.transform(item["text"], objMap);
        var url, frame, img, imgAlign, itemSrc, tmp, itemAction; 
        var cell = this.addTableCell(tbl, "rcMenuItem", title); 
        cell.style.cursor = document.all?'hand':'pointer';
        this.bindEvent('mouseover', cell, function(e) { this.className="rcMenuItemHover";});
        this.bindEvent('mouseout',  cell, function(e) { this.className="rcMenuItem";     });
        
        // deal with image if applicable
        if (item["image"]!=null && item["image"]!="undefined") {
        	// get image alignment or default to absmiddle
        	imgAlign = (item["align"]!=null && item["align"]!="undefined") ? item["align"] : "absmiddle";
        	// load the image from the cache, or from disk (and then cache it)
        	if (this.images[item["image"]] != null && this.images[item["image"]] != "undefined") {
        		img = this.images[item["image"]];
        	} else {
        		img = this.loadImage(item["image"]);
        	}
        	// set image alignment
        	img.align=imgAlign;
        	// insert the image as first child of the cell
        	cell.insertBefore(this.images[item["image"]], cell.childNodes[0]);
        }
        
        if (item["url"]!=null && item["url"] != "undefined") {
            url   = this.transform(item["url"],  objMap);
            frame = false;
            if (item["frame"] != null && item["frame"] != "undefined") {
                frame = item["frame"];
            }
            cell.onclick = function () { RightContext.redirect(url, frame); }
        } else {
            // we first need to find out if the event handler contains a potential 
            // tag. if so, we grab its source, transform it and re-evaluate it. 
            // if this fails, the value reverts back to its original function
            itemAction = item["onclick"]; 
            try {

	    itemSrc = item["onclick"].toString();
	    if (itemSrc.indexOf('[')>-1) {
                itemSrc = this.transform(itemSrc, objMap);
                if (document.all) { // IE's eval won't return a parsed function.. we need to tell it to set it and then eval
                    eval('itemAction = ' + itemSrc);
                } else { // firefox allows this. 
                    itemAction = eval(itemSrc);
                }
            }
         
            } catch (e) {
               // nothing...
            }

            // set the cell onclick event handler.
            cell.onclick=itemAction;
        }

    },

    // transforms a string based on the provided map
    transform: function (str, map) {
        var tStr, tmp;
        tStr = str;
        for (p in map) {
            tmp = "[" + p + "]";
            tStr = tStr.replace(tmp, map[p]);
        }
        return tStr;
    },

    // returns the menu's attributes collection that will be used to construct 
    // the transformation map
    getMenuAttributeArray: function (menu) {
        for (var i=0; i<menu.length; i++) {
            if (menu[i].type == this.TYPE_ATTRIBUTES) {
                return menu[i]["attributes"].split(',');
            }
        }
        return new Array(0);
    },

    // construct the transformation map for a given object based on the tags in 
    // attribs
    buildAttributeMap: function (attribs, obj) {
        var thisAttr, thisValue;
        var attrMap = new Object();

        for (var a=0; a<attribs.length; a++) {
            thisAttr = attribs[a];
            thisValue = obj.getAttribute(attribs[a]);
            if (typeof thisValue != "undefined") {
                attrMap[thisAttr] = thisValue;
            }
        }
        return attrMap;
    },

    // find the position of an element on the screen and returns an array of [x,y]
    findPosition: function (obj) {
        var lft = 0;
        var top = 0;
        if (obj.offsetParent) {
            lft = obj.offsetLeft
            top = obj.offsetTop
            while (obj = obj.offsetParent) {
                lft += obj.offsetLeft
                top += obj.offsetTop
            }
        }
        return {x:lft,y:top};
    },

    // Returns the dimensions of an element on screen. Lifted from the wonderful 
    // prototype framework
    getDimensions: function(obj) {
        //var display = obj.getStyle('display');
        //if (display != 'none' && display != null) // Safari bug
        //  return {width: element.offsetWidth, height: element.offsetHeight};

        // All *Width and *Height properties give 0 on elements with display none,
        // so enable the element temporarily
        var objStyle = obj.style;
        var originalVisibility = objStyle.visibility;
        var originalPosition = objStyle.position;
        var originalDisplay = objStyle.display;
        objStyle.visibility = 'hidden';
        objStyle.position = 'absolute';
        objStyle.display = 'block';
        var originalWidth = obj.clientWidth;
        var originalHeight = obj.clientHeight;
        objStyle.display = originalDisplay;
        objStyle.position = originalPosition;
        objStyle.visibility = originalVisibility;
        return {width: originalWidth, height: originalHeight};
    },

    // positions object at x,y coordinates
    // v0.2 - added px to the position coordinate (provided by JDG)
    position: function (obj, x, y) {
        obj.style.left = x + 'px';
        obj.style.top  = y + 'px';
    },

    // builds a menu for parent object
    buildMenu: function (parent) {
        var pos, dim, tbl;
        //document.onmousemove  = RightContext.getMousePos;
        this.contextMenu = document.createElement("DIV");
        this.contextMenu.id = "rcRightContext";
        this.contextMenu.className = 'rcMenuContainer';

        // get the position and dimensions of the parent
        pos = this.findPosition(parent);
        dim = this.getDimensions(parent);

        // position the container to the bottom right of the element.
        this.position (this.contextMenu, this.mousePos.x + this.rightOffset, pos.y+dim.height);

        // set some event handlers
        // if the menu is triggered by a right click, disable the right click on the menu itself
        if (this.menuTriggerEvent == "RIGHT") {
	        this.contextMenu.oncontextmenu = function () { return false; };
	    }
  		
		//added to remove IE6 selects
		hideSelects('hidden');		
        // add the container to the body of the document
        document.body.appendChild(this.contextMenu);
         
    },


    // kills the currently visible context menu
    killMenu: function () {
        if (!this.abortKill && this.isShowing) {
        try {
            rc = this.contextMenu;
            document.body.removeChild(rc);
        } catch (e) {
            // already removed?
        }
        this.contextMenu = null;
        this.isShowing = false;
        this.abortKill = false;
		//added to remove IE6 selects
		hideSelects('visible');
        }
    },

    // locate the mouse cursor position 
    locateMousePos: function(e) {
        var posx = 0, posy = 0;
        if(e==null) e=window.event;
        if(e.pageX || e.pageY) {
            posx=e.pageX; posy=e.pageY;
        } else if (e.clientX || e.clientY) {
            if(document.documentElement.scrollTop){
                posx=e.clientX+document.documentElement.scrollLeft;
                posy=e.clientY+document.documentElement.scrollTop;
            } else {
                posx=e.clientX+document.body.scrollLeft;
                posy=e.clientY+document.body.scrollTop;
            }
        }
        this.mousePos = {x:posx , y:posy};

    },
    
    // redirects the browser to given url
    // if frame!=false, it will open in provided frame (or new win if _blank)
    redirect: function (u, frame) {
        if (!frame) {
            document.location = u;  
        } else {
            if (frame=="_blank") {
                w = window.open(u, 'w');
            } else {
                window.frames[frame].document.location = u;
            }
        }
    },
    
    // performs a request - ajax style
    request: function (url, callBack) {
        if (window.XMLHttpRequest) { // native XMLHttpRequest
            this.req = new XMLHttpRequest();
            this.req.onreadystatechange =  callBack; 
            this.req.open("GET", url, true);
            this.req.send(null);
         } else if (window.ActiveXObject) { // The M$ 'standard'
            this.req = new ActiveXObject("Microsoft.XMLHTTP");
            if (this.req) { 
                this.req.onreadystatechange =   callBack;
                this.req.open("GET", url, true);
                this.req.send();
             }
         }
    },
    
    loadImage: function (url) {
    	var img = new Image();
    	img.src = url; 
    	img.className = "rcImage";
    	this.images[url] = img;
    	return img;
    }

}
// rightcontext.js end

// calendar.js start
var dateformat 	= 'mdy'; 		// date-month-year (default)
var datesplitter= '/'; 			// in between date, month, year... typically '/' or '-' or '.'
var prefix0 	= false; 		// months and dates less than 10, get prefixed w/ a '0'
var disablepast = false; 		// disable date selection in the past
var startday	= 'Sun';		// Mon = Monday; Sun = Sunday
var language	= 'en';			// de = German; en = English

if( startday == 'Sun' )
{
	if( language == 'en' )	{
		document.write('<table id="fc" style="position:absolute;border-collapse:collapse;background:#FFFFFF;border:1px solid #E89419;display:none" cellpadding=2>');
document.write('<tr><td style="cursor:pointer" onclick="csubm()"><img src="/members/images/icons/arrowleftmonth.gif"></td><td colspan=5 id="mns" align="center" style="font:bold 12px Arial"></td><td align="right" style="cursor:pointer" onclick="caddm()"><img src="/members/images/icons/arrowrightmonth.gif"></td></tr>');
document.write('<tr><td align=center style="background:#E89419;font:12px Arial;color:#fff;">S</td><td align=center style="background:#E89419;font:12px Arial;color:#fff;">M</td><td align=center style="background:#E89419;font:12px Arial;color:#fff;">T</td><td align=center style="background:#E89419;font:12px Arial;color:#fff;">W</td><td align=center style="background:#E89419;font:12px Arial;color:#fff;">T</td><td align=center style="background:#E89419;font:12px Arial;color:#fff;">F</td><td align=center style="background:#E89419;font:12px Arial;color:#fff;">S</td></tr>');
	}
	else if( language == 'de' ) {
		document.write('<table id="fc" style="position:absolute;top:356px;left:380px;border-collapse:collapse;background:#FFFFFF;border:1px solid #ABABAB;display:none" cellpadding=2><tr><td style="cursor:pointer" onclick="csubm()"><img src="/members/images/icons/arrowleftmonth.gif"></td><td colspan=5 id="mns" align="center" style="font:bold 13px Arial"></td><td align="right" style="cursor:pointer" onclick="caddm()"><img src="/members/images/icons/arrowrightmonth.gif"></td></tr><tr><td align=center style="background:#ABABAB;font:12px Arial">SO</td><td align=center style="background:#ABABAB;font:12px Arial">MO</td><td align=center style="background:#ABABAB;font:12px Arial">DI</td><td align=center style="background:#ABABAB;font:12px Arial">MI</td><td align=center style="background:#ABABAB;font:12px Arial">DO</td><td align=center style="background:#ABABAB;font:12px Arial">FR</td><td align=center style="background:#ABABAB;font:12px Arial">SA</td></tr>');
	}
	
	for(var kk=1;kk<=6;kk++) 
	{
		document.write('<tr>');
		for(var tt=1;tt<=7;tt++) 
		{
			num=7 * (kk-1) - (-tt);
			document.write('<td id="v' + num + '" style="width:18px;height:18px"> </td>');
		}
		document.write('</tr>');
	}
}

if(  startday == 'Mon' )
{

	if( language == 'en' )	{
		document.write('<table id="fc" style="position:absolute;border-collapse:collapse;background:#FFFFFF;border:1px solid #f7f7f7;display:none" cellpadding=2>');
document.write('<tr><td style="cursor:pointer" onclick="csubm()"><img src="/members/images/icons/arrowleftmonth.gif"></td><td colspan=5 id="mns" align="center" style="font:bold 13px Arial"></td><td align="right" style="cursor:pointer" onclick="caddm()"><img src="/members/images/icons/arrowrightmonth.gif"></td></tr>');
document.write('<tr><td align=center style="background:#f7f7f7;font:12px Arial">M</td><td align=center style="background:#f7f7f7;font:12px Arial">T</td><td align=center style="background:#f7f7f7;font:12px Arial">W</td><td align=center style="background:#f7f7f7;font:12px Arial">T</td><td align=center style="background:#f7f7f7;font:12px Arial">F</td><td align=center style="background:#f7f7f7;font:12px Arial">S</td><td align=center style="background:#f7f7f7;font:12px Arial">S</td></tr>');
	}
	else if( language == 'de' ) {
		document.write('<table id="fc" style="position:absolute;top:356px;left:380px;border-collapse:collapse;background:#FFFFFF;border:1px solid #f7f7f7;display:none" cellpadding=2><tr><td style="cursor:pointer" onclick="csubm()"><img src="/members/images/arrowleftmonth.gif"></td><td colspan=5 id="mns" align="center" style="font:bold 13px Arial"></td><td align="right" style="cursor:pointer" onclick="caddm()"><img src="/members/images/arrowrightmonth.gif"></td></tr><tr><td align=center style="background:#f7f7f7;font:12px Arial">MO</td><td align=center style="background:#f7f7f7;font:12px Arial">DI</td><td align=center style="background:#f7f7f7;font:12px Arial">MI</td><td align=center style="background:#f7f7f7;font:12px Arial">DO</td><td align=center style="background:#f7f7f7;font:12px Arial">FR</td><td align=center style="background:#f7f7f7;font:12px Arial">SA</td><td align=center style="background:#f7f7f7;font:12px Arial">SO</td></tr>');
	}
	
	for(var kk=1;kk<=7;kk++)
	{
		document.write('<tr>');
		for(var tt=-5;tt<=1;tt++)
		{
			num=7 * (kk-1) - (-tt);
			document.write('<td id="v' + num + '" style="width:18px;height:18px; background-color:#FBECC1; border: 1px solid #f7f7f7">&nbsp;</td>');
		}
		document.write('</tr>');
	}	
}

document.write('</table>');
document.all?document.attachEvent('onclick',checkClick):document.addEventListener('click',checkClick ,false);

// Calendar script
var now = new Date;
var sccm=now.getMonth();
var sccy=now.getFullYear();
var scfd=now.getDate();
var ccm=sccm;
var ccy=sccy;
var cfd=scfd;

var updobj;

if( language == 'en' )
	var mn=new Array('JAN','FEB','MAR','APR','MAY','JUN','JUL','AUG','SEP','OCT','NOV','DEC');
else if( language == 'de' )
	var mn=new Array('JAN','FEB','M&Auml;R','APR','MAI','JUN','JUL','AUG','SEP','OKT','NOV','DEZ');
var mnn=new Array('31','28','31','30','31','30','31','31','30' ,'31','30','31');
var mnl=new Array('31','29','31','30','31','30','31','31','30' ,'31','30','31');
var calvalarr=new Array(42);
prepcalendar('',ccm,ccy);



function getObj(objID)
{
	return $(objID);
}

function checkClick(e) {
	e?evt=e:evt=event;
	CSE=evt.target?evt.target:evt.srcElement;
	if (getObj('fc')) {
		if (!isChild(CSE,getObj('fc'))) { getObj('fc').style.display='none'; hideSelects('visible'); }
	}		
}

function isChild(s,d) {
while(s) {
	if (s==d)
	return true;
	s=s.parentNode;
}
	return false;
}

function Left(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;
}

function Top(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;
}

function lcs(ielem, parameter_disablepast) {
if( parameter_disablepast != null) 	disablepast = parameter_disablepast;
updobj=ielem;
getObj('fc').style.left = Left(ielem) + "px";
getObj('fc').style.top = Top(ielem) + ielem.offsetHeight + "px";
getObj('fc').style.display = '';
hideSelects('hidden'); //remove select values in IE 6

// First check date is valid
curdt=ielem.value;
curdtarr=curdt.replace(/\ /gi,'').replace(/[^0-9]/gi,'/').split('/');
isdt=true;
for(var k=0;k<curdtarr.length;k++) {
if (isNaN(parseInt(curdtarr[k])))
isdt=false;
}
if (isdt&(curdtarr.length==3)) {
if (dateformat=='ymd') {
	ccy=parseInt(curdtarr[0], 10);
	ccm=parseInt(curdtarr[1], 10)-1;
	ccd=parseInt(curdtarr[2], 10);
} else if (dateformat=='mdy') {
	ccy=parseInt(curdtarr[2], 10);
	ccm=parseInt(curdtarr[0], 10)-1;
	ccd=parseInt(curdtarr[1], 10);
} else {
	ccy=parseInt(curdtarr[2], 10);
	ccm=parseInt(curdtarr[1], 10)-1;
	ccd=parseInt(curdtarr[0], 10);
}
prepcalendar(ccd,ccm,ccy);
}
}

function evtTgt(e)
{
var el;
if(e.target)el=e.target;
else if(e.srcElement)el=e.srcElement;
if(el.nodeType==3)el=el.parentNode; // defeat Safari bug
return el;
}
function EvtObj(e){if(!e)e=window.event;return e;}
function cs_over(e) {
	evtTgt(EvtObj(e)).style.background='#6CAEDF';
}
function cs_out(e) {
	evtTgt(EvtObj(e)).style.background='#FBECC1';
}
function cs_click(e) {
	updobj.value=calvalarr[evtTgt(EvtObj(e)).id.substring(1,evtTgt(EvtObj(e)) .id.length)];
	getObj('fc').style.display='none';
	hideSelects('visible'); //remove select values in IE 6	
	assignDate(updobj.value);
}

function f_cps(obj) {
	if (obj) {	
		obj.style.background='#FBECC1';
		obj.style.font='10px Arial';
		obj.style.color='#333333';
		obj.style.textAlign='center';
		obj.style.textDecoration='none';
		obj.style.border='1px solid #E89419';
		obj.style.cursor='pointer';
	}
}

function f_cpps(obj) {
	if (obj) {	
		obj.style.background='#FBECC1';
		obj.style.font='10px Arial';
		obj.style.color='#ABABAB';
		obj.style.textAlign='center';
		obj.style.textDecoration='line-through';
		obj.style.border='1px solid #E89419';
		obj.style.cursor='default';
	}
}

function f_hds(obj) {
	if (obj) {
		obj.style.background='#E89419';
		obj.style.font='bold 10px Arial';
		obj.style.color='#000000';
		obj.style.textAlign='center';
		obj.style.border='1px solid #E89419';
		obj.style.cursor='pointer';
	}
}

// day selected
function prepcalendar(hd,cm,cy) {
//init(parameter_dateformat, parameter_datesplitter, parameter_disablepast);
now=new Date();
sd=now.getDate();
td=new Date();
td.setDate(1);
td.setFullYear(cy);
td.setMonth(cm);
cd=td.getDay();

	if (getObj('mns')) { 
		getObj('mns').innerHTML=mn[cm]+ ' ' + cy; 
		//getObj('mns').innerHTML=mn[cm]+ ' ' + cy;
	
		marr=((cy%4)==0)?mnl:mnn;
		//hideSelects('hidden'); //remove select values in IE 6
		for(var d=1;d<=42;d++) {
				f_cps(getObj('v'+parseInt(d)));
				if ((d >= (cd -(-1))) && (d<=cd-(-marr[cm]))) {
					dip=(disablepast&&(d-cd < sd)&&(cm==sccm)&&(cy==sccy));
					htd=((hd!='')&&(d-cd==hd));
					if (dip)
						f_cpps(getObj('v'+parseInt(d)));
					else if (htd)
						f_hds(getObj('v'+parseInt(d)));
					else
						f_cps(getObj('v'+parseInt(d)));
			
					getObj('v'+parseInt(d)).onmouseover=(dip)?null:cs_over;
					getObj('v'+parseInt(d)).onmouseout=(dip)?null:cs_out;
					getObj('v'+parseInt(d)).onclick=(dip)?null:cs_click;
					getObj('v'+parseInt(d)).innerHTML=d-cd;
			
					cmx = parseInt(cm)+1;
					if (cmx < 10 && prefix0==true) {
						cmx = '0'+cmx;
					}
					dx = d-cd;
					if (dx < 10 && prefix0==true) {
						dx = '0'+dx;
					}
					if (dateformat=='ymd') {
						calvalarr[d]=''+cy+datesplitter+cmx+datesplitter+dx;
					} 
					else if (dateformat=='mdy') {
						calvalarr[d]=''+cmx+datesplitter+dx+datesplitter+cy;
					} 
					else {
						calvalarr[d]=''+dx+datesplitter+cmx+datesplitter+cy;
					}
				}
				else {
					getObj('v'+d).innerHTML=' ';
					getObj('v'+parseInt(d)).onmouseover=null;
					getObj('v'+parseInt(d)).onmouseout=null;
					getObj('v'+parseInt(d)).style.cursor='default';
				}
		} //end of for loop
	} // end of if for obj
}


function caddm() {
	marr=((ccy%4)==0)?mnl:mnn;	
	ccm+=1;
	if (ccm>=12) {
		ccm=0;
		ccy++;
	}
	cdayf();
	prepcalendar('',ccm,ccy);
	hideSelects('hidden'); //remove select values in IE 6
}
//Added for Next Year Function
function caddy() {
	marr=((ccy%4)==0)?mnl:mnn;
	ccy++;
	prepcalendar('',ccm,ccy);	
	hideSelects('hidden'); //remove select values in IE 6
}


function csubm() {
	marr=((ccy%4)==0)?mnl:mnn;	
	ccm-=1;
	if (ccm<0) {
		ccm=11;
		ccy--;
	}
	cdayf();
	prepcalendar('',ccm,ccy);
	hideSelects('hidden'); //remove select values in IE 6
}
//added for Previous Year Function
function csuby() {
	marr=((ccy%4)==0)?mnl:mnn;
	ccy--;
	prepcalendar('',ccm,ccy);	
	hideSelects('hidden'); //remove select values in IE 6
}


function cdayf() {
	if (!disablepast||((ccy>sccy)||((ccy==sccy)&&(ccm>=sccm))))
		return;
	else {
		ccy=sccy;
		ccm=sccm;
		cfd=scfd;
	}
}
// calendar.js end

// lightbox from mf_lightbox.js start
var Lightbox = {
	lightboxType : null,
	lightboxCurrentContentID : null,
	
	showBoxString : function(content, boxWidth, boxHeight){
		this.setLightboxDimensions(boxWidth, boxHeight);
		this.lightboxType = 'string';
		var contents = $('boxContents');
		contents.innerHTML = content;
		this.showBox();
		return false;
	},


	showBoxImage : function(href) {
		this.lightboxType = 'image';
		var contents = $('boxContents');
		var objImage = document.createElement("img");
		objImage.setAttribute('id','lightboxImage');
		contents.appendChild(objImage);
		imgPreload = new Image();
		imgPreload.onload=function(){
			objImage.src = href;
			Lightbox.showBox();
		}
		imgPreload.src = href;
		return false;
	},

	showBoxByID : function(id, boxWidth, boxHeight) {
		this.lightboxType = 'id';
		this.lightboxCurrentContentID = id;
		this.setLightboxDimensions(boxWidth, boxHeight);
		var element = $(id);
		var contents = $('boxContents');
		contents.appendChild(element);
		Element.show(id);
		this.showBox();
		return false;
	},

	showBoxByAJAX : function(href, boxWidth, boxHeight) {
		this.lightboxType = 'ajax';
		this.setLightboxDimensions(boxWidth, boxHeight);
		var contents = $('boxContents');
		hideSelects('hidden');
		var myAjax = new Ajax.Updater(contents, href, {method: 'get', evalScripts:true});
		this.showBox();
		return false;
	},
	
	setLightboxDimensions : function(width, height) {
		var windowSize = this.getPageDimensions();
		if(width) {
			if(width < windowSize[0]) {
				$('box').style.width = width + 'px';
			} else {
				$('box').style.width = (windowSize[0] - 50) + 'px';
			}
		}
		if(height) {
			if(height < windowSize[1]) {
				$('box').style.height = height + 'px';
			} else {
				$('box').style.height = (windowSize[1] - 50) + 'px';
			}
		}
	},


	showBox : function() {
		//added to remove IE6 selects
		hideSelects('hidden');
		Element.show('overlay');
		this.center('box');
		return false;
	},
	
	
	hideBox : function(){
		//added to show IE6 selects
		hideSelects('visible');
		stopLoadingSpinner();
		var contents = $('boxContents');
		if(this.lightboxType == 'id') {
			var body = document.getElementsByTagName("body").item(0);
			Element.hide(this.lightboxCurrentContentID);
			body.appendChild($(this.lightboxCurrentContentID));
		}
		contents.innerHTML = '<div style="margin:0 auto;text-align:center;"><br><br><img src="/members/images/loading/bigWaiting.gif" alt="..."><br><br></div>';
		$('box').style.width = null;
		$('box').style.height = null;
		Element.hide('box');
		Element.hide('overlay');
		return false;
	},
	
	// taken from lightbox js, modified argument return order
	getPageDimensions : function(){
		var xScroll, yScroll;
	
		if (window.innerHeight && window.scrollMaxY) {	
			xScroll = document.body.scrollWidth;
			yScroll = window.innerHeight + window.scrollMaxY;
		} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
			xScroll = document.body.scrollWidth;
			yScroll = document.body.scrollHeight;
		} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
			xScroll = document.body.offsetWidth;
			yScroll = document.body.offsetHeight;
		}
		
		var windowWidth, windowHeight;
		if (self.innerHeight) {	// all except Explorer
			windowWidth = self.innerWidth;
			windowHeight = self.innerHeight;
		} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
			windowWidth = document.documentElement.clientWidth;
			windowHeight = document.documentElement.clientHeight;
		} else if (document.body) { // other Explorers
			windowWidth = document.body.clientWidth;
			windowHeight = document.body.clientHeight;
		}	
		
		// for small pages with total height less then height of the viewport
		if(yScroll < windowHeight){
			pageHeight = windowHeight;
		} else { 
			pageHeight = yScroll;
		}
	
		// for small pages with total width less then width of the viewport
		if(xScroll < windowWidth){	
			pageWidth = windowWidth;
		} else {
			pageWidth = xScroll;
		}
		arrayPageSize = new Array(windowWidth,windowHeight,pageWidth,pageHeight) 
		return arrayPageSize;
	},
	
	center : function(element){
		try{
			element = document.getElementById(element);
		}catch(e){
			return;
		}
		var windowSize = this.getPageDimensions();
		var window_width  = windowSize[0];
		var window_height = windowSize[1];
		
		$('overlay').style.height = windowSize[3] + 'px';
		
		element.style.position = 'absolute';
		element.style.zIndex   = 99;
	
		var scrollY = 0;
	
		if ( document.documentElement && document.documentElement.scrollTop ){
			scrollY = document.documentElement.scrollTop;
		}else if ( document.body && document.body.scrollTop ){
			scrollY = document.body.scrollTop;
		}else if ( window.pageYOffset ){
			scrollY = window.pageYOffset;
		}else if ( window.scrollY ){
			scrollY = window.scrollY;
		}
	
		var elementDimensions = Element.getDimensions(element);
		var setX = ( window_width  - elementDimensions.width  ) / 2;
		var setY = ( window_height - elementDimensions.height ) / 2 + scrollY;
	
		setX = ( setX < 0 ) ? 0 : setX;
		setY = ( setY < 0 ) ? 0 : setY;
	
		element.style.left = setX + "px";
		element.style.top  = setY + "px";
		Element.show(element);
	},
	
	init : function() {				  
		//var lightboxtext = '<div id="overlay" style="display:none"></div>';
		//lightboxtext += '<div id="box" style="display:none" class="select-free">';
		//lightboxtext += '<img id="close" src="/members/images/icons/close.gif" onClick="Lightbox.hideBox()" alt="Close" title="Close this window">';
		//lightboxtext += '<div id="boxContents" class="bd"></div>';
		//lightboxtext += '<!--[if lte IE 6.5]><iframe></iframe><![endif]--></div>';
		//var body = document.getElementsByTagName("body").item(0);
		//new Insertion.Bottom(body, lightboxtext);
	}
}
// lightbox.js end

// http://livepipe.net/downloads/prototype.tidbits.1.7.0.jsprototype tidbits
// http://livepipe.net/downloads/prototype.tidbits.1.7.0.js

/**
 * Tidbit : Cookie
   1. Cookie.set('key','value',60); //expires 60 seconds from now  
   2. Cookie.get('key'); //returns false if not found else the value stored in key  
   3. Cookie.unset('key'); //removes key  
 */

var Cookie = {
	set: function(name,value,seconds){
		if(seconds){
			d = new Date();
			d.setTime(d.getTime() + (seconds * 1000));
			expiry = '; expires=' + d.toGMTString();
		}else
			expiry = '';
		document.cookie = name + "=" + value + expiry + "; path=/";
	},
	get: function(name){
		nameEQ = name + "=";
		ca = document.cookie.split(';');
		for(i = 0; i < ca.length; i++){
			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
	},
	unset: function(name){
		Cookie.set(name,'',-1);
	}
}

/**
 * Tidbit : Client
 alert(Client.browser);
 alert(Client.version);
 alert(Client.OS);
 */

var Client = {
	browser: false,
	OS: false,
	version: false,
	current_place: 0,
	current_string: '',
	detect: navigator.userAgent.toLowerCase(),
	load: function(){
		if(Client.check("konqueror")){
			Client.browser = "Konqueror";
			Client.OS = "Linux";
		}else{
			$H({
				safari: "Safari",
				omniweb: "OmniWeb",
				opera: "Opera",
				webtv: "WebTV",
				icab: "iCab",
				msie: "Internet Explorer"
			}).each(function(browser){
				if(!Client.browser && Client.check(browser[0]))
					Client.browser = browser[1];
			});
		}
		if(!Client.browser && !Client.check('compatible')){
			Client.browser = "Netscape Navigator"
			Client.version = Client.detect.charAt(8);
		}
		if(!Client.version)
			Client.version = Client.detect.charAt(Client.current_place + Client.current_string.length);
		if(!Client.OS){
			$H({
				linux: "Linux",
				x11: "Unix",
				mac: "Mac",
				win: "Windows"
			}).each(function(OS){
				if(!Client.OS && Client.check(OS[0]))
					Client.OS = OS[1];
			});
			if(!Client.OS)
				Client.OS = "unknown";
		}
	},
	check: function(string){
		Client.current_string = string;
		Client.current_place = Client.detect.indexOf(string) + 1;
		return Client.current_place;
	}	
};
Client.load();

/* shared js from 2 and 3 */
function checkAAvalue(fld) {
	if ( $F(fld) == 'Y' ) 
		{ Element.show('autoapprovedate'); }
	else
		{ Element.hide('autoapprovedate'); }
}

function checkAllowApptsvalue(fld) {
	if ( $F(fld) == 'N' ) 
		{ Element.show('allowapptsdate'); }
	else
		{ Element.hide('allowapptsdate'); }
}

function disableStartEnd() {
	if ( $F('ball') == 'Y' ) 
		{ Field.disable('bstart'); Field.disable('bend'); }
	else
		{ Field.enable('bstart'); Field.enable('bend'); }
}

function enableRecurEdit(sun,mon,tue,wed,thu,fri,sat,st,et,ba,recurid) {
	Form.reset('save_recurring_form');
	Field.setValue("sur",sun); 
	Field.setValue("mr",mon);
	Field.setValue("tur",tue);
	Field.setValue("wr",wed);
	Field.setValue("thr",thu);
	Field.setValue("fr",fri);
	Field.setValue("sar",sat);
	Field.setValue("recurid",recurid);
	Element.show('showdeletebtn');
	if (ba=="Y") { Field.setValue("ball",ba); Field.disable('bstart'); Field.disable('bend'); }
	else { Field.setValue("bstart",st); Field.setValue("bend",et); Field.enable('bstart'); Field.enable('bend'); }
}

function fncEnable(fld,val) {
	if(document.times[fld].checked == true) {
	  	document.times["starttime" + val].disabled = true;
	  	document.times["endtime" + val].disabled = true;
	}
 	else {
	  	document.times["starttime" + val].disabled = false;
		document.times["endtime" + val].disabled = false;
 	}
}  

function inPlaceActEdit(sid,aid,text) {
	var atext = $('editactivity' + aid).innerHTML
	Field.setValue("activity_textbox" + sid,atext); 
	Field.setValue("btn_add_activity" + sid,'Save');
	Field.setValue("ea" + sid,aid);
	Element.show('cancel_edit_act' + sid);
}

function cancelInPlaceActEdit(sid) {
	Field.setValue("activity_textbox" + sid,'Add Activity Here'); 
	Field.setValue("btn_add_activity" + sid,'Add');
	Field.setValue("ea" + sid,'');
	Element.hide('cancel_edit_act' + sid);
}

function ClientInPlaceActEdit(aid) {
	var atext = $('editactivity' + aid).innerHTML
	Field.setValue("activity_textarea",atext); 
	Field.setValue("add_activity_btn",'Save');
	Field.setValue("ea",aid);
	Element.show('cancel_edit_act');
}

function cancelClientInPlaceActEdit(sid) {
	Field.setValue("activity_textarea",''); 
	Field.setValue("add_activity_btn",'Add Note');
	Field.setValue("ea",'');
	Element.hide('cancel_edit_act');
}
   
function disableAllBefore() {
	if (document.times["starttimeA"].value != "") {
		document.times["starttime2"].disabled = true;
		document.times["starttime3"].disabled = true;
		document.times["starttime4"].disabled = true;
		document.times["starttime5"].disabled = true;
		document.times["starttime6"].disabled = true;
		document.times["starttime7"].disabled = true;
		document.times["starttime1"].disabled = true; 
	}
	else {
		document.times["starttime2"].disabled = false;
		document.times["starttime3"].disabled = false;
		document.times["starttime4"].disabled = false;
		document.times["starttime5"].disabled = false;
		document.times["starttime6"].disabled = false;
		document.times["starttime7"].disabled = false;
		document.times["starttime1"].disabled = false; 
	}
}	
	
function disableAllAfter() {
	if (document.times["endtimeA"].value != "") {
		document.times["endtime2"].disabled = true;
		document.times["endtime3"].disabled = true;
		document.times["endtime4"].disabled = true;
		document.times["endtime5"].disabled = true;
		document.times["endtime6"].disabled = true;
		document.times["endtime7"].disabled = true;
		document.times["endtime1"].disabled = true; 
	}
	else {
		document.times["endtime2"].disabled = false;
		document.times["endtime3"].disabled = false;
		document.times["endtime4"].disabled = false;
		document.times["endtime5"].disabled = false;
		document.times["endtime6"].disabled = false;
		document.times["endtime7"].disabled = false;
		document.times["endtime1"].disabled = false; 
	}
}		

function scheduleDelete() {
	var fld = $F('deleteall');
	fncEnable('bwdSun','1')
	fncEnable('bwdMon','2')
	fncEnable('bwdTue','3')
	fncEnable('bwdWed','4')
	fncEnable('bwdThu','5')
	fncEnable('bwdFri','6')
	fncEnable('bwdSat','7')	
	
	if (fld == "Y") { 
		Field.setValue('submit','Delete'); 
	}
	else { 
		Field.setValue('submit','Save'); 
	}
}

function toggleit(id) { if (id) { new Effect.Combo(id, {duration: .3}); } }

function clearWorking(request) {
	if ($('working')) { Element.hide('working'); }
}

function clearMemberSearch() {
	Field.setValue("srch","");
	$('membersearchresults').innerHTML = ''; 
	Element.hide('membersearchresults'); 
	Form.Element.focus('srch');
}	

function checkMemberSearch_error(request) {
	$('membersearchresults').innerHTML = "Unable to search";
}

function boardSearch() {
	if($F('srch').length >= 3) {
	Element.show('working');	
	Element.show('boardsearchresults');
	var url = '/register/inc/boardsearch.asp';
	var params = 's=' + $F('srch');
	var ajax = new Ajax.Updater(
	{success: 'boardsearchresults'},
	url,
	{method: 'get', parameters: params, onFailure: boardSearch_error, onComplete:clearWorking});
	}
}

function boardSearch_error(request) {
	$('boardsearchresults').innerHTML = "Unable to search";
}

function clearBoardSearch() {
	Field.setValue("srch","");
	$('boardsearchresults').innerHTML = ''; 
	Element.hide('boardsearchresults'); 
	Form.Element.focus('srch');
}	

function officeSearch() {
	if($F('srch').length >= 3) {
	Element.show('working');	
	Element.show('officesearchresults');
	var url = '/register/inc/officesearch.asp';
	var params = 's=' + $F('srch') + '&mb=' + $F('mb');
	var ajax = new Ajax.Updater(
	{success: 'officesearchresults'},
	url,
	{method: 'get', parameters: params, onFailure: officeSearch_error, onComplete:clearWorking});
	}
}

function officeSearch_error(request) {
	$('officesearchresults').innerHTML = "Unable to search";
}

function clearOfficeSearch() {
	Field.setValue("srch","");
	$('officesearchresults').innerHTML = ''; 
	Element.hide('officesearchresults'); 
	Form.Element.focus('srch');
}

//confirm cancel appt
function confirmCancelAppt()
{
var agree=confirm("Are you sure you want to cancel this Showing?");
if (agree)
	return true ;
else
	return false ;
} 
 
//confirm active client  
function confirmActiveClient()
{
var agree=confirm("Are you sure you want to activate this client?");
if (agree)
	return true ;
else
	return false ;
}
 
 
//confirm inactive client   confirmActiveClient
function confirmDeleteLead()
{
var agree=confirm("Are you sure you want to delete this showing lead?");
if (agree)
	return true ;
else
	return false ;
} 

//confirm erase available times
function confirmDeleteTimes()
{
var agree=confirm("Are you sure you want to clear the available times?");
if (agree)
	return true ;
else
	return false ;
} 
 
//confirm inactive client   confirmActiveClient
function confirmDeleteClient()
{
var agree=confirm("Are you sure you want to make this client inactive?");
if (agree)
	return true ;
else
	return false ;
}

//confirm didn't show 
function confirmFeedbackSubmit()
{
var agree=confirm("Please confirm that you did not show this property.");
if (agree)
	return true ;
else
	return false ;
}

function confirmFeedbackDeclineSubmit()
{
var agree=confirm("Please confirm you don't want to send feedback for this appointment.");
if (agree)
	return true ;
else
	return false ;
}

 //confirm delete activity
function confirmDeleteActivity()
{
var agree=confirm("Are you sure you want to delete this activity?");
if (agree)
	return true ;
else
	return false ;
}

function confirmNoDupCheck()
{
	if ($('conflictcheck').checked)
		return true;
	else
		alert("BAS will not check for duplicate appointments!");
}

function confirmSkipCheckAvailCheck()
{
	if ($('checkavail').checked)
		return true;
	else
		alert("BAS will not check listing availability!");
}

function confirmSaveChanges()
{
var agree=confirm("Are you sure you want to save the changes?");
if (agree)
	return true ;
else
	return false ;
}

function confirmCancel()
{
var agree=confirm("Are you sure you want to cancel this showing?");
if (agree)
	return true ;
else
	return false ;
}

function confimrDeleteLead()
{
var agree=confirm("Are you sure you want to delete this lead?");
if (agree)
	return true ;
else
	return false ;
}

function confirmDeleteAgent()
{
var agree=confirm("Are you sure you want to remove this agent?");
if (agree)
	return true ;
else
	return false ;
}

function confirmDeleteShowing()
{
	var agree=confirm("Are you sure you want to delete this showing?");
	if (agree)
		return true ;
	else
		return false ;
}

function doLBsubmit(truefalse,scriptname,divid,formid) {
	if (truefalse) { 
		new Ajax.Updater(divid, scriptname,{asynchronous:true, evalScripts:true,  parameters:Form.serialize(formid)});
		if ($('savenonmls')) { $('savenonmls').disable() };
		return true;
	}
	else { return false; }
}

function requireClientCell() {
	$('buyercellphone').addClassName('required');
	$('SMScarrier').addClassName('required');
}

function unrequireClientCell() {
	$('buyercellphone').removeClassName('required');
	$('SMScarrier').removeClassName('required');
}

//resizing text boxes from http://jroller.com/page/rmcmahon?entry=resizingtextarea_with_prototype
var ResizingTextArea = Class.create();

ResizingTextArea.prototype = {
    defaultRows: 1,

    initialize: function(field)
    {
        this.defaultRows = Math.max(field.rows, 1);
        this.resizeNeeded = this.resizeNeeded.bindAsEventListener(this);
        Event.observe(field, "click", this.resizeNeeded);
        Event.observe(field, "keyup", this.resizeNeeded);
    },

    resizeNeeded: function(event)
    {
        var t = Event.element(event);
        var lines = t.value.split('\n');
        var newRows = lines.length + 1;
        var oldRows = t.rows;
        for (var i = 0; i < lines.length; i++)
        {
            var line = lines[i];
            if (line.length >= t.cols) newRows += Math.floor(line.length / t.cols);
        }
        if (newRows > t.rows) t.rows = newRows;
        if (newRows < t.rows) t.rows = Math.max(this.defaultRows, newRows);
    }
}

//cache buster for ajax.periodicalupdater
function cacheBuster() {

  var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
  var randomstring = '';
       
  for (var i=0; i<20; i++) {
         var rnum = Math.floor(Math.random() * chars.length);
          randomstring += chars.substring(rnum,rnum+1);
  }           
  return randomstring + new Date().getTime();   
}

function clearActivity(thisfield, defaulttext) {
	if (thisfield.value == defaulttext) {
		thisfield.value = "";
	}
}

function recallActivity(thisfield, defaulttext) {
	if (thisfield.value == "") {
		thisfield.value = defaulttext;
	}
}

function checkthis(rad) {
	var radio = rad;
	if (document.sendfeedback.radio.checked != true) { document.sendfeedback.radio.checked = true; }
}

function ToggleCheckBoxes(chk) {
if (document.sendemailform.t.checked == true) {
		for (i = 0; i < chk.length; i++)
		chk[i].checked = true ;
	}
	else {
		for (i = 0; i < chk.length; i++)
		chk[i].checked = false ;
	}
}

function ToggleCheckBoxesByClass() {
	var inputlist = document.getElementsByClassName("toggleme");
	for (i = 0; i < inputlist.length; i++) {
		if ( inputlist[i].getAttribute("type") == 'checkbox' ) { // look only at input elements that are checkboxes
			if (inputlist[i].checked) inputlist[i].checked = false
			else inputlist[i].checked = true;
		}
	}
}

function UncheckCheckBoxesByClass() {
	var inputlist = document.getElementsByClassName("uncheckme");
	alert('All other options will be unchecked when using this option');
	for (i = 0; i < inputlist.length; i++) {
		if ( inputlist[i].getAttribute("type") == 'checkbox' ) { // look only at input elements that are checkboxes
			if (inputlist[i].checked) { 
				inputlist[i].checked = false; 
			}
		}
	}
}

function assignDateOverride(dt,override) {
	Field.setValue("showingdate" + override, dt);
	if ($('showingdate1')) { if ($F('showingdate1') == "") { Field.setValue("showingdate1", dt); } }	
	if ($('showingdate2')) { if ($F('showingdate2') == "") { Field.setValue("showingdate2", dt); } }	
	if ($('showingdate3')) { if ($F('showingdate3') == "") { Field.setValue("showingdate3", dt); } }	
	if ($('showingdate4')) { if ($F('showingdate4') == "") { Field.setValue("showingdate4", dt); } }	
	if ($('showingdate5')) { if ($F('showingdate5') == "") { Field.setValue("showingdate5", dt); } }	
	if ($('showingdate6')) { if ($F('showingdate6') == "") { Field.setValue("showingdate6", dt); } }	
	if ($('showingdate7')) { if ($F('showingdate7') == "") { Field.setValue("showingdate7", dt); } }	
	if ($('showingdate8')) { if ($F('showingdate8') == "") { Field.setValue("showingdate8", dt); } }	
	if ($('showingdate9')) { if ($F('showingdate9') == "") { Field.setValue("showingdate9", dt); } }	
	if ($('showingdate10')) { if ($F('showingdate10') == "") { Field.setValue("showingdate10", dt); } }	
	if ($('showingdate11')) { if ($F('showingdate11') == "") { Field.setValue("showingdate11", dt); } }	
	if ($('showingdate12')) { if ($F('showingdate12') == "") { Field.setValue("showingdate12", dt); } }	
	if ($('showingdate13')) { if ($F('showingdate13') == "") { Field.setValue("showingdate13", dt); } }	
	if ($('showingdate14')) { if ($F('showingdate14') == "") { Field.setValue("showingdate14", dt); } }	
	if ($('showingdate15')) { if ($F('showingdate15') == "") { Field.setValue("showingdate15", dt); } }	
	if ($('showingdate16')) { if ($F('showingdate16') == "") { Field.setValue("showingdate16", dt); } }	
	if ($('showingdate17')) { if ($F('showingdate17') == "") { Field.setValue("showingdate17", dt); } }	
	if ($('showingdate18')) { if ($F('showingdate18') == "") { Field.setValue("showingdate18", dt); } }	
	if ($('showingdate19')) { if ($F('showingdate19') == "") { Field.setValue("showingdate19", dt); } }	
	if ($('showingdate20')) { if ($F('showingdate20') == "") { Field.setValue("showingdate20", dt); } }		
} 


//start protoload
/* protoload 0.1 beta by Andreas Kalsch
 * last change: 09.07.2007
 *
 * This simple piece of code automates the creating of Ajax loading symbols.
 * The loading symbol covers an HTML element with correct position and size - example:
 * $('myElement').startWaiting() and $('myElement').stopWaiting()
 */
 
Protoload = {
	// the script to wait this amount of msecs until it shows the loading element
	timeUntilShow: 250,
	
	// opacity of loading element
	opacity: 0.8,

	// Start waiting status - show loading element
	startWaiting: function(element, className, timeUntilShow) {
		if (typeof element == 'string')
			element = document.getElementById(element);
		if (className == undefined)
			className = 'waiting';
		if (timeUntilShow == undefined)
			timeUntilShow = Protoload.timeUntilShow;
		
		element._waiting = true;
		if (!element._loading) {
			var e = document.createElement('div');
			(element.offsetParent || document.body).appendChild(element._loading = e);
			e.style.position = 'absolute';
			try {e.style.opacity = Protoload.opacity;} catch(e) {}
			try {e.style.MozOpacity = Protoload.opacity;} catch(e) {}
			try {e.style.filter = 'alpha(opacity='+Math.round(Protoload.opacity * 100)+')';} catch(e) {}
			try {e.style.KhtmlOpacity = Protoload.opacity;} catch(e) {}
			
			/*var zIndex = 0;
			if (window.UI)
				if (UI.zIndex)
					zIndex = ++UI.zIndex;
			if (!zIndex)
				zIndex = ++Protoload._zIndex;
			e.style.zIndex = zIndex;*/
		}
		element._loading.className = className;
		window.setTimeout((function() {
			if (this._waiting) {
				var left = this.offsetLeft, 
					top = this.offsetTop,
					width = this.offsetWidth,
					height = this.offsetHeight,
					l = this._loading;
					
				l.style.left = left+'px';
				l.style.top = top+'px';
				l.style.width = width+'px';
				l.style.height = height+'px';
				l.style.display = 'inline';
			}
		}).bind(element), timeUntilShow);
	},
	
	// Stop waiting status - hide loading element
	stopWaiting: function(element) {
		if (element._waiting) {
			element._waiting = false;
			element._loading.parentNode.removeChild(element._loading);
			element._loading = null;
		}
	}/*,
	
	_zIndex: 1000000*/
};

if (Prototype) {
	Element.addMethods(Protoload);
	Object.extend(Element, Protoload);
}
/* */
//end protoload

//AC_RunActiveContent.js
//v1.0
//Copyright 2006 Adobe Systems, Inc. All rights reserved.
function AC_AddExtension(src, ext)
{
  if (src.indexOf('?') != -1)
    return src.replace(/\?/, ext+'?'); 
  else
    return src + ext;
}

function AC_Generateobj(objAttrs, params, embedAttrs) 
{ 
  var str = '<object ';
  for (var i in objAttrs)
    str += i + '="' + objAttrs[i] + '" ';
  str += '>';
  for (var i in params)
    str += '<param name="' + i + '" value="' + params[i] + '"> ';
  str += '<embed ';
  for (var i in embedAttrs)
    str += i + '="' + embedAttrs[i] + '" ';
  str += ' ></embed></object>';

  document.write(str);
}

function AC_FL_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
     , "application/x-shockwave-flash"
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_SW_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".dcr", "src", "clsid:166B1BCA-3F9C-11CF-8075-444553540000"
     , null
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
  var ret = new Object();
  ret.embedAttrs = new Object();
  ret.params = new Object();
  ret.objAttrs = new Object();
  for (var i=0; i < args.length; i=i+2){
    var currArg = args[i].toLowerCase();    

    switch (currArg){	
      case "classid":
        break;
      case "pluginspage":
        ret.embedAttrs[args[i]] = args[i+1];
        break;
      case "src":
      case "movie":	
        args[i+1] = AC_AddExtension(args[i+1], ext);
        ret.embedAttrs["src"] = args[i+1];
        ret.params[srcParamName] = args[i+1];
        break;
      case "onafterupdate":
      case "onbeforeupdate":
      case "onblur":
      case "oncellchange":
      case "onclick":
      case "ondblClick":
      case "ondrag":
      case "ondragend":
      case "ondragenter":
      case "ondragleave":
      case "ondragover":
      case "ondrop":
      case "onfinish":
      case "onfocus":
      case "onhelp":
      case "onmousedown":
      case "onmouseup":
      case "onmouseover":
      case "onmousemove":
      case "onmouseout":
      case "onkeypress":
      case "onkeydown":
      case "onkeyup":
      case "onload":
      case "onlosecapture":
      case "onpropertychange":
      case "onreadystatechange":
      case "onrowsdelete":
      case "onrowenter":
      case "onrowexit":
      case "onrowsinserted":
      case "onstart":
      case "onscroll":
      case "onbeforeeditfocus":
      case "onactivate":
      case "onbeforedeactivate":
      case "ondeactivate":
      case "type":
      case "codebase":
        ret.objAttrs[args[i]] = args[i+1];
        break;
      case "width":
      case "height":
      case "align":
      case "vspace": 
      case "hspace":
      case "class":
      case "title":
      case "accesskey":
      case "name":
      case "id":
      case "tabindex":
        ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
        break;
      default:
        ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
    }
  }
  ret.objAttrs["classid"] = classid;
  if (mimeType) ret.embedAttrs["type"] = mimeType;
  return ret;
}
//END AC_RunActiveContent.js

function startLoadingSpinner() { $(document.body).startWaiting('bigWaiting'); }
function stopLoadingSpinner() { $(document.body).stopWaiting('bigWaiting'); }