﻿function openWindow(theURL,winName,features) {	if (winName.window) winName.focus;	popupWin = window.open(theURL,winName,features)	popupWin.focus;}function deleteConfirm(what,formName,theURL) {	if (confirm("Are you sure you want to delete "+ what +"? ")) {		if (formName != null) {			formName.submit()		} else {			window.location.href = theURL		}	}}//MENUvar cssdropdown={disappeardelay: 250,disablemenuclick: false,enableswipe: 1,enableiframeshim: 1,dropmenuobj: null, ie: document.all, firefox: document.getElementById&&!document.all, swipetimer: undefined, bottomclip:0,getposOffset:function(what, offsettype){var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;var parentEl=what.offsetParent;while (parentEl!=null){totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;parentEl=parentEl.offsetParent;}return totaloffset;},swipeeffect:function(){if (this.bottomclip<parseInt(this.dropmenuobj.offsetHeight)){this.bottomclip+=10+(this.bottomclip/10)this.dropmenuobj.style.clip="rect(0 auto "+this.bottomclip+"px 0)"}elsereturnthis.swipetimer=setTimeout("cssdropdown.swipeeffect()", 10)},showhide:function(obj, e){if (this.ie || this.firefox)this.dropmenuobj.style.left=this.dropmenuobj.style.top="-500px"if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover"){if (this.enableswipe==1){if (typeof this.swipetimer!="undefined")clearTimeout(this.swipetimer)obj.clip="rect(0 auto 0 0)"this.bottomclip=0this.swipeeffect()}obj.visibility="visible"setTimeout("cssdropdown.dropmenuobj.style.overflow='hidden'",500)}else if (e.type=="click")obj.visibility="hidden"},iecompattest:function(){return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body},clearbrowseredge:function(obj, whichedge){var edgeoffset=0if (whichedge=="rightedge"){var windowedge=this.ie && !window.opera? this.iecompattest().scrollLeft+this.iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15this.dropmenuobj.contentmeasure=this.dropmenuobj.offsetWidthif (windowedge-this.dropmenuobj.x < this.dropmenuobj.contentmeasure)edgeoffset=this.dropmenuobj.contentmeasure-obj.offsetWidth}else{var topedge=this.ie && !window.opera? this.iecompattest().scrollTop : window.pageYOffsetvar windowedge=this.ie && !window.opera? this.iecompattest().scrollTop+this.iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18this.dropmenuobj.contentmeasure=this.dropmenuobj.offsetHeightif (windowedge-this.dropmenuobj.y < this.dropmenuobj.contentmeasure){edgeoffset=this.dropmenuobj.contentmeasure+obj.offsetHeightif ((this.dropmenuobj.y-topedge)<this.dropmenuobj.contentmeasure)edgeoffset=this.dropmenuobj.y+obj.offsetHeight-topedge}}return edgeoffset},dropit:function(obj, e, dropmenuID){if (this.dropmenuobj!=null){this.dropmenuobj.style.overflow="hidden"this.dropmenuobj.style.visibility="hidden"}this.clearhidemenu()if (this.ie||this.firefox){obj.onmouseout=function(){cssdropdown.delayhidemenu()}obj.onclick=function(){return !cssdropdown.disablemenuclick}this.dropmenuobj=document.getElementById(dropmenuID)this.dropmenuobj.onmouseover=function(){cssdropdown.clearhidemenu()}this.dropmenuobj.onmouseout=function(e){cssdropdown.dynamichide(e)}this.dropmenuobj.onclick=function(){cssdropdown.delayhidemenu()}this.showhide(this.dropmenuobj.style, e)this.dropmenuobj.x=this.getposOffset(obj, "left")this.dropmenuobj.y=this.getposOffset(obj, "top")this.dropmenuobj.style.left=this.dropmenuobj.x-this.clearbrowseredge(obj, "rightedge")+"px"this.dropmenuobj.style.top=this.dropmenuobj.y-this.clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+1+"px"this.positionshim()}},positionshim:function(){if (this.enableiframeshim && typeof this.shimobject!="undefined"){if (this.dropmenuobj.style.visibility=="visible"){this.shimobject.style.width=this.dropmenuobj.offsetWidth+"px"this.shimobject.style.height=this.dropmenuobj.offsetHeight+"px"this.shimobject.style.left=this.dropmenuobj.style.leftthis.shimobject.style.top=this.dropmenuobj.style.top}this.shimobject.style.display=(this.dropmenuobj.style.visibility=="visible")? "block" : "none"}},hideshim:function(){if (this.enableiframeshim && typeof this.shimobject!="undefined")this.shimobject.style.display='none'},contains_firefox:function(a, b) {while (b.parentNode)if ((b = b.parentNode) == a)return true;return false;},dynamichide:function(e){var evtobj=window.event? window.event : eif (this.ie&&!this.dropmenuobj.contains(evtobj.toElement))this.delayhidemenu()else if (this.firefox&&e.currentTarget!= evtobj.relatedTarget&& !this.contains_firefox(evtobj.currentTarget, evtobj.relatedTarget))this.delayhidemenu()},delayhidemenu:function(){this.delayhide=setTimeout("cssdropdown.dropmenuobj.style.overflow='hidden';cssdropdown.dropmenuobj.style.visibility='hidden'; cssdropdown.hideshim()",this.disappeardelay)},clearhidemenu:function(){if (this.delayhide!="undefined")clearTimeout(this.delayhide)},startmenu:function(){for (var ids=0; ids<arguments.length; ids++){var menuitems=document.getElementById(arguments[ids]).getElementsByTagName("a")for (var i=0; i<menuitems.length; i++){if (menuitems[i].getAttribute("rel")){var relvalue=menuitems[i].getAttribute("rel")menuitems[i].onmouseover=function(e){var event=typeof e!="undefined"? e : window.eventcssdropdown.dropit(this,event,this.getAttribute("rel"))}}}}if (window.createPopup && !window.XmlHttpRequest){document.write('<IFRAME id="iframeshim"  src="" style="display: none; left: 0; top: 0; z-index: 90; position: absolute; filter: progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)" frameBorder="0" scrolling="no"></IFRAME>')this.shimobject=document.getElementById("iframeshim")}}}// VALIDATION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){		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';				} else {					new Effect.Appear(advice, {duration : 1 });				}			}			elm[prop] = true;			elm.removeClassName('validation-passed');			elm.addClassName('validation-failed');			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) {				return  ((v == null) || (v.length == 0)); // || /^\s+$/.test(v));			});Validation.addAllThese([	['required', 'This is a required field.', function(v) {				return !Validation.get('IsEmpty').test(v);			}],	['validate-number', 'Please enter a valid number in this field.', function(v) {				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) {				return Validation.get('IsEmpty').test(v) ||  !/[^\d]/.test(v);			}],	['validate-phone-us', 'Please enter a valid Phone Number. For example XXX-XXX-XXXX', function(v) {			    return Validation.get('IsEmpty').test(v) || /^[01]?[- .]?(\([2-9]\d{2}\)|[2-9]\d{2})[- .]?\d{3}[- .]?\d{4}$/.test(v);    		}],	['validate-alpha', 'Please use letters only (a-z) in this field.', function (v) {				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) {				return Validation.get('IsEmpty').test(v) ||  !/\W/.test(v)			}],	['validate-date', 'Please enter a valid date.', function(v) {				var test = new Date(v);				return Validation.get('IsEmpty').test(v) || !isNaN(test);			}],	['validate-email', 'Please enter a valid email address. For example you@domain.com.', function (v) {				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) {				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);				});			}]]);