/***************************************************************
Copyright 2008 Mandogroup Ltd
Modules: Flash Text,Form Validation,Date,
Notes: 
***************************************************************/


/**************************************************************

	Script		: Flash Text (sIFR)
	Version		: 2.0.2
	Authors		: Shaun Inman, Mike Davidson
	Desc		: Replaces html text with flash text.

**************************************************************/

/*	sIFR v2.0.5
	Copyright 2004 - 2007 Mark Wubben and Mike Davidson. Prior contributions by Shaun Inman and Tomas Jogin.
	
	This software is licensed under the CC-GNU LGPL <http://creativecommons.org/licenses/LGPL/2.1/>
*/

var hasFlash=function(){var a=6;if(navigator.appVersion.indexOf("MSIE")!=-1&&navigator.appVersion.indexOf("Windows")>-1){document.write('<script language="VBScript"\> \non error resume next \nhasFlash = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & '+a+'))) \n</script\> \n');if(window.hasFlash!=null)return window.hasFlash}if(navigator.mimeTypes&&navigator.mimeTypes["application/x-shockwave-flash"]&&navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin){var b=(navigator.plugins["Shockwave Flash 2.0"]||navigator.plugins["Shockwave Flash"]).description;return parseInt(b.charAt(b.indexOf(".")-1))>=a}return false}();String.prototype.normalize=function(){return this.replace(/\s+/g," ")};if(Array.prototype.push==null){Array.prototype.push=function(){var i=0,a=this.length,b=arguments.length;while(i<b){this[a++]=arguments[i++]}return this.length}}if(!Function.prototype.apply){Function.prototype.apply=function(a,b){var c=[];var d,e;if(!a)a=window;if(!b)b=[];for(var i=0;i<b.length;i++){c[i]="b["+i+"]"}e="a.__applyTemp__("+c.join(",")+");";a.__applyTemp__=this;d=eval(e);a.__applyTemp__=null;return d}}function named(a){return new named.Arguments(a)}named.Arguments=function(a){this.oArgs=a};named.Arguments.prototype.constructor=named.Arguments;named.extract=function(a,b){var c,d;var i=a.length;while(i--){d=a[i];if(d!=null&&d.constructor!=null&&d.constructor==named.Arguments){c=a[i].oArgs;break}}if(c==null)return;for(e in c)if(b[e]!=null)b[e](c[e]);return};var parseSelector=function(){var a=/^([^#.>`]*)(#|\.|\>|\`)(.+)$/;function r(s,t){var u=s.split(/\s*\,\s*/);var v=[];for(var i=0;i<u.length;i++)v=v.concat(b(u[i],t));return v}function b(c,d,e){c=c.normalize().replace(" ","`");var f=c.match(a);var g,h,i,j,k,n;var l=[];if(f==null)f=[c,c];if(f[1]=="")f[1]="*";if(e==null)e="`";if(d==null)d=document;switch(f[2]){case "#":k=f[3].match(a);if(k==null)k=[null,f[3]];g=document.getElementById(k[1]);if(g==null||(f[1]!="*"&&!o(g,f[1])))return l;if(k.length==2){l.push(g);return l}return b(k[3],g,k[2]);case ".":if(e!=">")h=m(d,f[1]);else h=d.childNodes;for(i=0,n=h.length;i<n;i++){g=h[i];if(g.nodeType!=1)continue;k=f[3].match(a);if(k!=null){if(g.className==null||g.className.match("(\\s|^)"+k[1]+"(\\s|$)")==null)continue;j=b(k[3],g,k[2]);l=l.concat(j)}else if(g.className!=null&&g.className.match("(\\s|^)"+f[3]+"(\\s|$)")!=null)l.push(g)}return l;case ">":if(e!=">")h=m(d,f[1]);else h=d.childNodes;for(i=0,n=h.length;i<n;i++){g=h[i];if(g.nodeType!=1)continue;if(!o(g,f[1]))continue;j=b(f[3],g,">");l=l.concat(j)}return l;case "`":h=m(d,f[1]);for(i=0,n=h.length;i<n;i++){g=h[i];j=b(f[3],g,"`");l=l.concat(j)}return l;default:if(e!=">")h=m(d,f[1]);else h=d.childNodes;for(i=0,n=h.length;i<n;i++){g=h[i];if(g.nodeType!=1)continue;if(!o(g,f[1]))continue;l.push(g)}return l}}function m(d,o){if(o=="*"&&d.all!=null)return d.all;return d.getElementsByTagName(o)}function o(p,q){return q=="*"?true:p.nodeName.toLowerCase().replace("html:", "")==q.toLowerCase()}return r}();var sIFR=function(){var a="http://www.w3.org/1999/xhtml";var b=false;var c=false;var d;var ah=[];var al=document;var ak=al.documentElement;var am=window;var au=al.addEventListener;var av=am.addEventListener;var f=function(){var g=navigator.userAgent.toLowerCase();var f={a:g.indexOf("applewebkit")>-1,b:g.indexOf("safari")>-1,c:navigator.product!=null&&navigator.product.toLowerCase().indexOf("konqueror")>-1,d:g.indexOf("opera")>-1,e:al.contentType!=null&&al.contentType.indexOf("xml")>-1,f:true,g:true,h:null,i:null,j:null,k:null};f.l=f.a||f.c;f.m=!f.a&&navigator.product!=null&&navigator.product.toLowerCase()=="gecko";if(f.m&&g.match(/.*gecko\/(\d{8}).*/))f.j=new Number(g.match(/.*gecko\/(\d{8}).*/)[1]);f.n=g.indexOf("msie")>-1&&!f.d&&!f.l&&!f.m;f.o=f.n&&g.match(/.*mac.*/)!=null;if(f.d&&g.match(/.*opera(\s|\/)(\d+\.\d+)/))f.i=new Number(g.match(/.*opera(\s|\/)(\d+\.\d+)/)[2]);if(f.n||(f.d&&f.i<7.6))f.g=false;if(f.a&&g.match(/.*applewebkit\/(\d+).*/))f.k=new Number(g.match(/.*applewebkit\/(\d+).*/)[1]);if(am.hasFlash&&(!f.n||f.o)){var aj=(navigator.plugins["Shockwave Flash 2.0"]||navigator.plugins["Shockwave Flash"]).description;f.h=parseInt(aj.charAt(aj.indexOf(".")-1))}if(g.match(/.*(windows|mac).*/)==null||f.o||f.c||(f.d&&(g.match(/.*mac.*/)!=null||f.i<7.6))||(f.b&&f.h<7)||(!f.b&&f.a&&f.k<312)||(f.m&&f.j<20020523))f.f=false;if(!f.o&&!f.m&&al.createElementNS)try{al.createElementNS(a,"i").innerHTML=""}catch(e){f.e=true}f.p=f.c||(f.a&&f.k<312);return f}();function at(){return{bIsWebKit:f.a,bIsSafari:f.b,bIsKonq:f.c,bIsOpera:f.d,bIsXML:f.e,bHasTransparencySupport:f.f,bUseDOM:f.g,nFlashVersion:f.h,nOperaVersion:f.i,nGeckoBuildDate:f.j,nWebKitVersion:f.k,bIsKHTML:f.l,bIsGecko:f.m,bIsIE:f.n,bIsIEMac:f.o,bUseInnerHTMLHack:f.p}}if(am.hasFlash==false||!al.getElementsByTagName||!al.getElementById||(f.e&&(f.p||f.n)))return{UA:at()};function af(e){if((!k.bAutoInit&&(am.event||e)!=null)||!l(e))return;b=true;for(var i=0,h=ah.length;i<h;i++)j.apply(null,ah[i]);ah=[]}var k=af;function l(e){if(c==false||k.bIsDisabled==true||((f.e&&f.m||f.l)&&e==null&&b==false)||al.getElementsByTagName("body").length==0)return false;return true}function m(n){if(f.n)return n.replace(new RegExp("%\d{0}","g"),"%25");return n.replace(new RegExp("%(?!\d)","g"),"%25")}function as(p,q){return q=="*"?true:p.nodeName.toLowerCase().replace("html:", "")==q.toLowerCase()}function o(p,q,r,s,t){var u="";var v=p.firstChild;var w,x,y,z;if(s==null)s=0;if(t==null)t="";while(v){if(v.nodeType==3){z=v.nodeValue.replace("<","&lt;");switch(r){case "lower":u+=z.toLowerCase();break;case "upper":u+=z.toUpperCase();break;default:u+=z}}else if(v.nodeType==1){if(as(v,"a")&&!v.getAttribute("href")==false){if(v.getAttribute("target"))t+="&sifr_url_"+s+"_target="+v.getAttribute("target");t+="&sifr_url_"+s+"="+m(v.getAttribute("href")).replace(/&/g,"%26");u+='<a href="asfunction:_root.launchURL,'+s+'">';s++}else if(as(v,"br"))u+="<br/>";if(v.hasChildNodes()){y=o(v,null,r,s,t);u+=y.u;s=y.s;t=y.t}if(as(v,"a"))u+="</a>"}w=v;v=v.nextSibling;if(q!=null){x=w.parentNode.removeChild(w);q.appendChild(x)}}return{"u":u,"s":s,"t":t}}function A(B){if(al.createElementNS&&f.g)return al.createElementNS(a,B);return al.createElement(B)}function C(D,E,z){var p=A("param");p.setAttribute("name",E);p.setAttribute("value",z);D.appendChild(p)}function F(p,G){var H=p.className;if(H==null)H=G;else H=H.normalize()+(H==""?"":" ")+G;p.className=H}function aq(ar){var a=ak;if(k.bHideBrowserText==false)a=al.getElementsByTagName("body")[0];if((k.bHideBrowserText==false||ar)&&a)if(a.className==null||a.className.match(/\bsIFR\-hasFlash\b/)==null)F(a, "sIFR-hasFlash")}function j(I,J,K,L,M,N,O,P,Q,R,S,r,T){if(!l())return ah.push(arguments);aq();named.extract(arguments,{sSelector:function(ap){I=ap},sFlashSrc:function(ap){J=ap},sColor:function(ap){K=ap},sLinkColor:function(ap){L=ap},sHoverColor:function(ap){M=ap},sBgColor:function(ap){N=ap},nPaddingTop:function(ap){O=ap},nPaddingRight:function(ap){P=ap},nPaddingBottom:function(ap){Q=ap},nPaddingLeft:function(ap){R=ap},sFlashVars:function(ap){S=ap},sCase:function(ap){r=ap},sWmode:function(ap){T=ap}});var U=parseSelector(I);if(U.length==0)return false;if(S!=null)S="&"+S.normalize();else S="";if(K!=null)S+="&textcolor="+K;if(M!=null)S+="&hovercolor="+M;if(M!=null||L!=null)S+="&linkcolor="+(L||K);if(O==null)O=0;if(P==null)P=0;if(Q==null)Q=0;if(R==null)R=0;if(N==null)N="#FFFFFF";if(T=="transparent")if(!f.f)T="opaque";else N="transparent";if(T==null)T="";var p,V,W,X,Y,Z,aa,ab,ac;var ad=null;for(var i=0,h=U.length;i<h;i++){p=U[i];if(p.className!=null&&p.className.match(/\bsIFR\-replaced\b/)!=null)continue;V=p.offsetWidth-R-P;W=p.offsetHeight-O-Q;aa=A("span");aa.className="sIFR-alternate";ac=o(p,aa,r);Z="txt="+m(ac.u).replace(/\+/g,"%2B").replace(/&/g,"%26").replace(/\"/g, "%22").normalize() + S + "&w=" + V + "&h=" + W + ac.t;F(p,"sIFR-replaced");if(ad==null||!f.g){if(!f.g){if(!f.n)p.innerHTML=['<embed class="sIFR-flash" type="application/x-shockwave-flash" src="',J,'" quality="best" wmode="',T,'" bgcolor="',N,'" flashvars="',Z,'" width="',V,'" height="',W,'" sifr="true"></embed>'].join("");else p.innerHTML=['<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" sifr="true" width="',V,'" height="',W,'" class="sIFR-flash"><param name="movie" value="',J,'"></param><param name="flashvars" value="',Z,'"></param><param name="quality" value="best"></param><param name="wmode" value="',T,'"></param><param name="bgcolor" value="',N,'"></param> </object>'].join('')}else{if(f.d){ab=A("object");ab.setAttribute("data",J);C(ab,"quality","best");C(ab,"wmode",T);C(ab,"bgcolor",N)}else{ab=A("embed");ab.setAttribute("src",J);ab.setAttribute("quality","best");ab.setAttribute("flashvars",Z);ab.setAttribute("wmode",T);ab.setAttribute("bgcolor",N)}ab.setAttribute("sifr","true");ab.setAttribute("type","application/x-shockwave-flash");ab.className="sIFR-flash";if(!f.l||!f.e)ad=ab.cloneNode(true)}}else ab=ad.cloneNode(true);if(f.g){if(f.d)C(ab,"flashvars",Z);else ab.setAttribute("flashvars",Z);ab.setAttribute("width",V);ab.setAttribute("height",W);ab.style.width=V+"px";ab.style.height=W+"px";p.appendChild(ab)}p.appendChild(aa);if(f.p)p.innerHTML+=""}if(f.n&&k.bFixFragIdBug)setTimeout(function(){al.title=d},0)}function ai(){d=al.title}function ae(){if(k.bIsDisabled==true)return;c=true;if(k.bHideBrowserText)aq(true);if(am.attachEvent)am.attachEvent("onload",af);else if(!f.c&&(al.addEventListener||am.addEventListener)){if(f.a&&f.k>=132&&am.addEventListener)am.addEventListener("load",function(){setTimeout("sIFR({})",1)},false);else{if(al.addEventListener)al.addEventListener("load",af,false);if(am.addEventListener)am.addEventListener("load",af,false)}}else if(typeof am.onload=="function"){var ag=am.onload;am.onload=function(){ag();af()}}else am.onload=af;if(!f.n||am.location.hash=="")k.bFixFragIdBug=false;else ai()}k.UA=at();k.bAutoInit=true;k.bFixFragIdBug=true;k.replaceElement=j;k.updateDocumentTitle=ai;k.appendToClassName=F;k.setup=ae;k.debug=function(){aq(true)};k.debug.replaceNow=function(){ae();k()};k.bIsDisabled=false;k.bHideBrowserText=true;return k}();

if(typeof sIFR == "function" && !sIFR.UA.bIsIEMac && (!sIFR.UA.bIsWebKit || sIFR.UA.nWebKitVersion >= 100)){
	sIFR.setup();
};

/*	sIFR 2.0.1 Official Add-ons 1.2
	Copyright 2005 Mark Wubben

	This software is licensed under the CC-GNU LGPL <http://creativecommons.org/licenses/LGPL/2.1/>
*/

if(typeof sIFR=="function")(function(){var j=document;var h=j.documentElement;sIFR.removeDecoyClasses=function(){function a(b){if(b&&b.className!=null)b.className=b.className.replace(/\bsIFR-hasFlash\b/,"")}return function(){a(h);a(j.getElementsByTagName("body")[0])}}();sIFR.preferenceManager={storage:{sCookieId:"sifr",set:function(a){var b=new Date();b.setFullYear(b.getFullYear()+3);j.cookie=[this.sCookieId,"=",a,";expires=",b.toGMTString(),";path=/"].join("")},get:function(){var a=j.cookie.match(new RegExp(";?"+this.sCookieId+"=([^;]+);?"));if(a!=null&&a[1]=="false")return false;else return true},reset:function(){var a=new Date();a.setFullYear(a.getFullYear()-1);j.cookie=[this.sCookieId,"=true;expires=",a.toGMTString(),";path=/"].join("")}},disable:function(){this.storage.set(false)},enable:function(){this.storage.set(true)},test:function(){return this.storage.get()}};if(sIFR.preferenceManager.test()==false){sIFR.bIsDisabled=true;sIFR.removeDecoyClasses()}sIFR.rollback=function(){function a(b){var c,d,e,f,g,h;var l=parseSelector(b);var i=l.length-1;var m=false;while(i>=0){c=l[i];l.length--;d=c.parentNode;if(c.getAttribute("sifr")=="true"){h=0;while(h<d.childNodes.length){c=d.childNodes[h];if(c.className=="sIFR-alternate"){e=c;h++;continue}d.removeChild(c)}if(e!=null){f=e.firstChild;while(f!=null){g=f.nextSibling;d.appendChild(e.removeChild(f));f=g}d.removeChild(e)}if(!sIFR.UA.bIsXML&&sIFR.UA.bUseInnerHTMLHack)d.innerHTML+="";d.className=d.className.replace(/\bsIFR\-replaced\b/,"")};m=true;i--}return m}return function(k){named.extract(arguments,{sSelector:function(a){k=a}});if(k==null)k="";else k+=">";sIFR.removeDecoyClasses();sIFR.bHideBrowserText=false;if(a(k+"embed")==false)a(k+"object")}}()})()


function doSIFR(){
	if(typeof sIFR == "function"){
		
		sIFR.replaceElement(named({
			sSelector:"div.main h2", 
			sFlashSrc:"/_common/swf/gotham.swf", 
			sColor:"#e81a22", 
			sBgColor:"#FFFFFF" ,
			sWmode: 'transparent'
		}));	
		sIFR.replaceElement(named({
			sSelector:"div#form-content h1", 
			sFlashSrc:"/_common/swf/gotham.swf", 
			sColor:"#e81a22", 
			sBgColor:"#FFFFFF" ,
			sWmode: 'transparent'
		}));
		sIFR.replaceElement(named({
			sSelector:"div.main-content h2", 
			sFlashSrc:"/_common/swf/gotham.swf", 
			sColor:"#118ece", 
			sBgColor:"#FFFFFF" ,
			sWmode: 'transparent'
		}));		
	    sIFR.replaceElement(named({
			sSelector:"div.details-box div.content-box h2", 
			sFlashSrc:"/_common/swf/gotham.swf", 
			sColor:"#212121", 
			sBgColor:"#FFFFFF" ,
			sWmode: 'transparent'
		}));
		sIFR.replaceElement(named({
			sSelector:"div.heading div.content-box p", 
			sFlashSrc:"/_common/swf/gotham.swf", 
			sColor:"#212121", 
			sBgColor:"#FFFFFF" ,
			sWmode: 'transparent'
		}));
		sIFR.replaceElement(named({
			sSelector:"div.testimonial p", 
			sFlashSrc:"/_common/swf/gothamitalic.swf", 
			sColor:"#212121", 
			sBgColor:"#FFFFFF" ,
			sWmode: 'transparent'
		}));
		sIFR.replaceElement(named({
			sSelector:"div.form-content h3", 
			sFlashSrc:"/_common/swf/gotham.swf", 
			sColor:"#da151c", 
			sBgColor:"#FFFFFF" ,
			sWmode: 'transparent'
		}));
	
		sIFR.replaceElement(named({
			sSelector:"div.green-box div.content-box strong", 
			sFlashSrc:"/_common/swf/gotham.swf", 
			sColor:"#c2ff72", 
			sBgColor:"#FFFFFF" ,
			sWmode: 'transparent'
		}));
		sIFR.replaceElement(named({
			sSelector:"div.content-box h3", 
			sFlashSrc:"/_common/swf/gotham.swf", 
			sColor:"#1574a5", 
			sBgColor:"#FFFFFF" ,
			sWmode: 'transparent'
		}));
		sIFR.replaceElement(named({
			sSelector:"div.blue-box div.content-box strong", 
			sFlashSrc:"/_common/swf/gotham.swf", 
			sColor:"#ffffff", 
			sBgColor:"#000000" ,
			sWmode: 'transparent'
		}));
		sIFR.replaceElement(named({
			sSelector:"div.education-box div.content-box h2", 
			sFlashSrc:"/_common/swf/gotham.swf", 
			sColor:"#ffffff", 
			sBgColor:"#FFFFFF" ,
			sWmode: 'transparent'
		}));
	
		sIFR.replaceElement(named({
			sSelector:"h1", 
			sFlashSrc:"/_common/swf/gotham.swf", 
			sColor:"#da151c", 
			sBgColor:"#FFFFFF" ,
			sWmode: 'transparent'
		}));
		
		sIFR.replaceElement(named({
			sSelector:"h2", 
			sFlashSrc:"/_common/swf/gotham.swf", 
			sColor:"#da151c", 
			sBgColor:"#FFFFFF" ,
			sWmode: 'transparent'
		}));
	
	};
}

function resetSIFR(){
	sIFR.rollback();
	doSIFR();
}


/*************************************************************/



/**************************************************************

	Script		: Validate
	Version		: 1.2
	Authors		: Samuel Birch
	Desc		: Form validation

**************************************************************/

var Validate = new Class({

	initialize: function(myForm,options){
		options = Object.extend({
			custom: false,
			messageBox: false,
			dateFormat: false,
			fieldClass: false,
			showList:  true
		}, options || {});
		
		this.form = $(myForm);
		this.myElements = $$('#'+this.form.id+' .required');
		this.form.myElements = this.myElements;
		options.messageBox = $(options.messageBox);
		this.form.messageBox = options.messageBox;
		
		if(options.messageBox){
		this.formAnchor = new Element('a').setProperties({name: this.form.id+'Anchor'}).injectInside(options.messageBox);
		this.form.formAnchor = this.formAnchor;
		}
		
		options.list = new Element('ul').setProperty('id', 'errorList')
		if(options.messageBox && options.showList){
			options.list.injectInside(options.messageBox);
		}
		
		this.myElements.each(function(el,i){
			
			el.validate = function(){
				//TEXTBOX
				if(el.type == 'text'){
					if(el.value != ''){
						if(el.hasClass('email')){
							var regEmail = /^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/;
							if(el.value.toUpperCase().match(regEmail)){
								if($('errorListItem'+el.id)){$('errorListItem'+el.id).remove();}
								el.removeClass(options.fieldClass);
								el.getPrevious().removeClass(options.fieldClass);
								return(true);
							}else{
								if(!$('errorListItem'+el.id)){
									new Element('li').setProperty('id','errorListItem'+el.id).injectInside(options.list).setHTML(el.title);
								}
								el.addClass(options.fieldClass);
								el.getPrevious().addClass(options.fieldClass);
								return(false);
							}
							
						}else if(el.hasClass('number')){
							var regNum = /[-+]?[0-9]*\.?[0-9]+/;
							if(el.value.match(regNum)){
								if($('errorListItem'+el.id)){$('errorListItem'+el.id).remove();}
								el.removeClass(options.fieldClass);
								el.getPrevious().removeClass(options.fieldClass);
								return(true);
							}else{
								if(!$('errorListItem'+el.id)){
									new Element('li').setProperty('id','errorListItem'+el.id).injectInside(options.list).setHTML(el.title);
								}
								el.addClass(options.fieldClass);
								el.getPrevious().addClass(options.fieldClass);
								return(false);
							}
						}else if(el.hasClass('postcode')){
							var regPC = /^([Gg][Ii][Rr] 0[Aa]{2})|((([A-Za-z][0-9]{1,2})|(([A-Za-z][A-Ha-hJ-Yj-y][0-9]{1,2})|(([A-Za-z][0-9][A-Za-z])|([A-Za-z][A-Ha-hJ-Yj-y][0-9]?[A-Za-z])))) [0-9][A-Za-z]{2})$/
							if(el.value.match(regPC)){
								if($('errorListItem'+el.id)){$('errorListItem'+el.id).remove();}
								el.removeClass(options.fieldClass);
								el.getPrevious().removeClass(options.fieldClass);
								return(true);
							}else{
								if(!$('errorListItem'+el.id)){
									new Element('li').setProperty('id','errorListItem'+el.id).injectInside(options.list).setHTML(el.title);
								}
								el.addClass(options.fieldClass);
								el.getPrevious().addClass(options.fieldClass);
								return(false);
							}
							
						}else if(el.hasClass('date')){
							if(Date.isValid(el.value, options.dateFormat)){
								if($('errorListItem'+el.id)){$('errorListItem'+el.id).remove();}
								el.removeClass(options.fieldClass);
								el.getPrevious().removeClass(options.fieldClass);
								return(true);
							}else{
								if(!$('errorListItem'+el.id)){
									new Element('li').setProperty('id','errorListItem'+el.id).injectInside(options.list).setHTML(el.title);
								}
								el.addClass(options.fieldClass);
								el.getPrevious().addClass(options.fieldClass);
								return(false);
							}
							
						}else{
							if($('errorListItem'+el.id)){$('errorListItem'+el.id).remove();}
							el.removeClass(options.fieldClass);
							el.getPrevious().removeClass(options.fieldClass);
							return(true);
						}
					}else{
						if(!$('errorListItem'+el.id)){
							new Element('li').setProperty('id','errorListItem'+el.id).injectInside(options.list).setHTML(el.title);
						}
						el.addClass(options.fieldClass);
						el.getPrevious().addClass(options.fieldClass);
						return(false);	
					}
				}
				//TEXTAREA
				if(el.type == 'textarea'){
					if(el.value == ''){
						if(!$('errorListItem'+el.id)){
							new Element('li').setProperty('id','errorListItem'+el.id).injectInside(options.list).setHTML(el.title);
						}
						el.addClass(options.fieldClass);
						el.getPrevious().addClass(options.fieldClass);
						return(false);
					}else{
						if($('errorListItem'+el.id)){$('errorListItem'+el.id).remove();}
						el.removeClass(options.fieldClass);
						el.getPrevious().removeClass(options.fieldClass);
						return(true);
					}
				}
				//CHECKBOX
				if(el.type == 'checkbox'){
					if(!el.checked){
						if(!$('errorListItem'+el.id)){
							new Element('li').setProperty('id','errorListItem'+el.id).injectInside(options.list).setHTML(el.title);
						}
						el.addClass(options.fieldClass);
						el.getPrevious().addClass(options.fieldClass);
						return(false);
					}else{
						if($('errorListItem'+el.id)){$('errorListItem'+el.id).remove();}
						el.removeClass(options.fieldClass);
						el.getPrevious().removeClass(options.fieldClass);
						return(true);
					}
				}
				//DROPDOWN
				if(el.type == 'select-one'){
					if(el.value == ''){
						if(!$('errorListItem'+el.id)){
							new Element('li').setProperty('id','errorListItem'+el.id).injectInside(options.list).setHTML(el.title);
						}
						el.addClass(options.fieldClass);
						el.getPrevious().addClass(options.fieldClass);
						return(false);
					}else{
						if($('errorListItem'+el.id)){$('errorListItem'+el.id).remove();}
						el.removeClass(options.fieldClass);
						el.getPrevious().removeClass(options.fieldClass);
						return(true);
					}
				}
				//RADIO
				if(el.type == 'radio'){
					var rad = $A(this.form[el.name]);
					var ok = false;
					rad.each(function(e,j){
						if(e.checked){
							ok = true;
						}
					});
					if(!ok){
						if(options.list.getLast().innerHTML != rad[0].title){
							if(!$('errorListItem'+el.id)){
								new Element('li').setProperty('id','errorListItem'+el.id).injectInside(options.list).setHTML(rad[0].title);
							}
						}
						
						rad.each(function(e,j){
							e.addClass(options.fieldClass);
							if(el.getPrevious()){
								el.getPrevious().addClass(options.fieldClass);
							}
						});
						return(false);
					}else{
						if($('errorListItem'+el.id)){$('errorListItem'+el.id).remove();}
						rad.each(function(e,j){
							e.removeClass(options.fieldClass);
							if(el.getPrevious()){
								el.getPrevious().removeClass(options.fieldClass);
							}
						});
						return(true);
					}
				}
			}
		});
		
		this.form.onsubmit = function(){
			var valid = true;
			this.myElements.each(function(el,i){
				if(!el.validate()){valid=false};
			});
			if(options.custom != false){
				validC = options.custom(options.list);
				if(valid && !validC){valid = false};
			}
			
			if(this.messageBox){
			if(!valid){
				this.messageBox.setStyle('display','block');
				document.location = '#'+this.formAnchor.name;
			}else{
				this.messageBox.setStyle('display','none');
			}
			}
			
			return(valid);
		}
	}

});


/*************************************************************/


/**************************************************************

	Script		: Date
	Version		: 1.02
	Authors		: Matt Kruse
	Desc		: Extends the <Date> prototype.

**************************************************************/


Date.$VERSION = 1.02;

// Utility function to append a 0 to single-digit numbers
Date.LZ = function(x) {return(x<0||x>9?"":"0")+x};
// Full month names. Change this for local month names
Date.monthNames = new Array('January','February','March','April','May','June','July','August','September','October','November','December');
// Month abbreviations. Change this for local month names
Date.monthAbbreviations = new Array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
// Full day names. Change this for local month names
Date.dayNames = new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
// Day abbreviations. Change this for local month names
Date.dayAbbreviations = new Array('Sun','Mon','Tue','Wed','Thu','Fri','Sat');
// Used for parsing ambiguous dates like 1/2/2000 - default to preferring 'American' format meaning Jan 2.
// Set to false to prefer 'European' format meaning Feb 1
Date.preferAmericanFormat = false;

// If the getFullYear() method is not defined, create it
if (!Date.prototype.getFullYear) { 
	Date.prototype.getFullYear = function() { var yy=this.getYear(); return (yy<1900?yy+1900:yy); } 
} 

// Parse a string and convert it to a Date object.
// If no format is passed, try a list of common formats.
// If string cannot be parsed, return null.
// Avoids regular expressions to be more portable.
Date.parseString = function(val, format) {
	// If no format is specified, try a few common formats
	if (typeof(format)=="undefined" || format==null || format=="") {
		var generalFormats=new Array('y-M-d','MMM d, y','MMM d,y','y-MMM-d','d-MMM-y','MMM d','MMM-d','d-MMM');
		var monthFirst=new Array('M/d/y','M-d-y','M.d.y','M/d','M-d');
		var dateFirst =new Array('d/M/y','d-M-y','d.M.y','d/M','d-M');
		var checkList=new Array(generalFormats,Date.preferAmericanFormat?monthFirst:dateFirst,Date.preferAmericanFormat?dateFirst:monthFirst);
		for (var i=0; i<checkList.length; i++) {
			var l=checkList[i];
			for (var j=0; j<l.length; j++) {
				var d=Date.parseString(val,l[j]);
				if (d!=null) { 
					return d; 
				}
			}
		}
		return null;
	}

	this.isInteger = function(val) {
		for (var i=0; i < val.length; i++) {
			if ("1234567890".indexOf(val.charAt(i))==-1) { 
				return false; 
			}
		}
		return true;
	};
	this.getInt = function(str,i,minlength,maxlength) {
		for (var x=maxlength; x>=minlength; x--) {
			var token=str.substring(i,i+x);
			if (token.length < minlength) { 
				return null; 
			}
			if (this.isInteger(token)) { 
				return token; 
			}
		}
	return null;
	};
	val=val+"";
	format=format+"";
	var i_val=0;
	var i_format=0;
	var c="";
	var token="";
	var token2="";
	var x,y;
	var year=new Date().getFullYear();
	var month=1;
	var date=1;
	var hh=0;
	var mm=0;
	var ss=0;
	var ampm="";
	while (i_format < format.length) {
		// Get next token from format string
		c=format.charAt(i_format);
		token="";
		while ((format.charAt(i_format)==c) && (i_format < format.length)) {
			token += format.charAt(i_format++);
		}
		// Extract contents of value based on format token
		if (token=="yyyy" || token=="yy" || token=="y") {
			if (token=="yyyy") { 
				x=4;y=4; 
			}
			if (token=="yy") { 
				x=2;y=2; 
			}
			if (token=="y") { 
				x=2;y=4; 
			}
			year=this.getInt(val,i_val,x,y);
			if (year==null) { 
				return null; 
			}
			i_val += year.length;
			if (year.length==2) {
				if (year > 70) { 
					year=1900+(year-0); 
				}
				else { 
					year=2000+(year-0); 
				}
			}
		}
		else if (token=="MMM" || token=="NNN"){
			month=0;
			var names = (token=="MMM"?(Date.monthNames.concat(Date.monthAbbreviations)):Date.monthAbbreviations);
			for (var i=0; i<names.length; i++) {
				var month_name=names[i];
				if (val.substring(i_val,i_val+month_name.length).toLowerCase()==month_name.toLowerCase()) {
					month=(i%12)+1;
					i_val += month_name.length;
					break;
				}
			}
			if ((month < 1)||(month>12)){
				return null;
			}
		}
		else if (token=="EE"||token=="E"){
			var names = (token=="EE"?Date.dayNames:Date.dayAbbreviations);
			for (var i=0; i<names.length; i++) {
				var day_name=names[i];
				if (val.substring(i_val,i_val+day_name.length).toLowerCase()==day_name.toLowerCase()) {
					i_val += day_name.length;
					break;
				}
			}
		}
		else if (token=="MM"||token=="M") {
			month=this.getInt(val,i_val,token.length,2);
			if(month==null||(month<1)||(month>12)){
				return null;
			}
			i_val+=month.length;
		}
		else if (token=="dd"||token=="d") {
			date=this.getInt(val,i_val,token.length,2);
			if(date==null||(date<1)||(date>31)){
				return null;
			}
			i_val+=date.length;
		}
		else if (token=="hh"||token=="h") {
			hh=this.getInt(val,i_val,token.length,2);
			if(hh==null||(hh<1)||(hh>12)){
				return null;
			}
			i_val+=hh.length;
		}
		else if (token=="HH"||token=="H") {
			hh=this.getInt(val,i_val,token.length,2);
			if(hh==null||(hh<0)||(hh>23)){
				return null;
			}
			i_val+=hh.length;
		}
		else if (token=="KK"||token=="K") {
			hh=this.getInt(val,i_val,token.length,2);
			if(hh==null||(hh<0)||(hh>11)){
				return null;
			}
			i_val+=hh.length;
			hh++;
		}
		else if (token=="kk"||token=="k") {
			hh=this.getInt(val,i_val,token.length,2);
			if(hh==null||(hh<1)||(hh>24)){
				return null;
			}
			i_val+=hh.length;
			hh--;
		}
		else if (token=="mm"||token=="m") {
			mm=this.getInt(val,i_val,token.length,2);
			if(mm==null||(mm<0)||(mm>59)){
				return null;
			}
			i_val+=mm.length;
		}
		else if (token=="ss"||token=="s") {
			ss=this.getInt(val,i_val,token.length,2);
			if(ss==null||(ss<0)||(ss>59)){
				return null;
			}
			i_val+=ss.length;
		}
		else if (token=="a") {
			if (val.substring(i_val,i_val+2).toLowerCase()=="am") {
				ampm="AM";
			}
			else if (val.substring(i_val,i_val+2).toLowerCase()=="pm") {
				ampm="PM";
			}
			else {
				return null;
			}
			i_val+=2;
		}
		else {
			if (val.substring(i_val,i_val+token.length)!=token) {
				return null;
			}
			else {
				i_val+=token.length;
			}
		}
	}
	// If there are any trailing characters left in the value, it doesn't match
	if (i_val != val.length) { 
		return null; 
	}
	// Is date valid for month?
	if (month==2) {
		// Check for leap year
		if ( ( (year%4==0)&&(year%100 != 0) ) || (year%400==0) ) { // leap year
			if (date > 29){ 
				return null; 
			}
		}
		else { 
			if (date > 28) { 
				return null; 
			} 
		}
	}
	if ((month==4)||(month==6)||(month==9)||(month==11)) {
		if (date > 30) { 
			return null; 
		}
	}
	// Correct hours value
	if (hh<12 && ampm=="PM") {
		hh=hh-0+12; 
	}
	else if (hh>11 && ampm=="AM") { 
		hh-=12; 
	}
	return new Date(year,month-1,date,hh,mm,ss);
}

// Check if a date string is valid
Date.isValid = function(val,format) {
	return (Date.parseString(val,format) != null);
}

// Check if a date object is before another date object
Date.prototype.isBefore = function(date2) {
	if (date2==null) { 
		return false; 
	}
	return (this.getTime()<date2.getTime());
}

// Check if a date object is after another date object
Date.prototype.isAfter = function(date2) {
	if (date2==null) { 
		return false; 
	}
	return (this.getTime()>date2.getTime());
}

// Check if two date objects have equal dates and times
Date.prototype.equals = function(date2) {
	if (date2==null) { 
		return false; 
	}
	return (this.getTime()==date2.getTime());
}

// Check if two date objects have equal dates, disregarding times
Date.prototype.equalsIgnoreTime = function(date2) {
	if (date2==null) { 
		return false; 
	}
	var d1 = new Date(this.getTime()).clearTime();
	var d2 = new Date(date2.getTime()).clearTime();
	return (d1.getTime()==d2.getTime());
}

// Format a date into a string using a given format string
Date.prototype.format = function(format) {
	format=format+"";
	var result="";
	var i_format=0;
	var c="";
	var token="";
	var y=this.getYear()+"";
	var M=this.getMonth()+1;
	var d=this.getDate();
	var E=this.getDay();
	var H=this.getHours();
	var m=this.getMinutes();
	var s=this.getSeconds();
	var yyyy,yy,MMM,MM,dd,hh,h,mm,ss,ampm,HH,H,KK,K,kk,k;
	// Convert real date parts into formatted versions
	var value=new Object();
	if (y.length < 4) {
		y=""+(+y+1900);
	}
	value["y"]=""+y;
	value["yyyy"]=y;
	value["yy"]=y.substring(2,4);
	value["M"]=M;
	value["MM"]=Date.LZ(M);
	value["MMM"]=Date.monthNames[M-1];
	value["NNN"]=Date.monthAbbreviations[M-1];
	value["d"]=d;
	value["dd"]=Date.LZ(d);
	value["E"]=Date.dayAbbreviations[E];
	value["EE"]=Date.dayNames[E];
	value["H"]=H;
	value["HH"]=Date.LZ(H);
	if (H==0){
		value["h"]=12;
	}
	else if (H>12){
		value["h"]=H-12;
	}
	else {
		value["h"]=H;
	}
	value["hh"]=Date.LZ(value["h"]);
	value["K"]=value["h"]-1;
	value["k"]=value["H"]+1;
	value["KK"]=Date.LZ(value["K"]);
	value["kk"]=Date.LZ(value["k"]);
	if (H > 11) { 
		value["a"]="PM"; 
	}
	else { 
		value["a"]="AM"; 
	}
	value["m"]=m;
	value["mm"]=Date.LZ(m);
	value["s"]=s;
	value["ss"]=Date.LZ(s);
	while (i_format < format.length) {
		c=format.charAt(i_format);
		token="";
		while ((format.charAt(i_format)==c) && (i_format < format.length)) {
			token += format.charAt(i_format++);
		}
		if (typeof(value[token])!="undefined") { 
			result=result + value[token]; 
		}
		else { 
			result=result + token; 
		}
	}
	return result;
}

// Get the full name of the day for a date
Date.prototype.getDayName = function() { 
	return Date.dayNames[this.getDay()];
}

// Get the abbreviation of the day for a date
Date.prototype.getDayAbbreviation = function() { 
	return Date.dayAbbreviations[this.getDay()];
}

// Get the full name of the month for a date
Date.prototype.getMonthName = function() {
	return Date.monthNames[this.getMonth()];
}

// Get the abbreviation of the month for a date
Date.prototype.getMonthAbbreviation = function() { 
	return Date.monthAbbreviations[this.getMonth()];
}

// Clear all time information in a date object
Date.prototype.clearTime = function() {
  this.setHours(0); 
  this.setMinutes(0);
  this.setSeconds(0); 
  this.setMilliseconds(0);
  return this;
}

// Add an amount of time to a date. Negative numbers can be passed to subtract time.
Date.prototype.add = function(interval, number) {
	if (typeof(interval)=="undefined" || interval==null || typeof(number)=="undefined" || number==null) { 
		return this; 
	}
	number = +number;
	if (interval=='y') { // year
		this.setFullYear(this.getFullYear()+number);
	}
	else if (interval=='M') { // Month
		this.setMonth(this.getMonth()+number);
	}
	else if (interval=='d') { // Day
		this.setDate(this.getDate()+number);
	}
	else if (interval=='w') { // Weekday
		var step = (number>0)?1:-1;
		while (number!=0) {
			this.add('d',step);
			while(this.getDay()==0 || this.getDay()==6) { 
				this.add('d',step);
			}
			number -= step;
		}
	}
	else if (interval=='h') { // Hour
		this.setHours(this.getHours() + number);
	}
	else if (interval=='m') { // Minute
		this.setMinutes(this.getMinutes() + number);
	}
	else if (interval=='s') { // Second
		this.setSeconds(this.getSeconds() + number);
	}
	return this;
}


/*************************************************************/

/**************************************************************

	Script		: Text Resize Detector
	Version		: 1.0
	Authors		: Samuel birch
	Desc		: Captures when the text is resized.

**************************************************************/

var TextResizeDetector = new Class({
	getOptions: function(){
		return {
			delay: 200,
			onChange: Class.empty
		};
	},
	
	initialize: function(options){
		this.setOptions(this.getOptions(), options);
		
		this.element = new Element('span').setProperty('id','textResizeControl').setStyles({position: 'absolute', left: '-9999px'}).setHTML('&nbsp;').injectInside(document.body);
		this.oldSize = this.element.getStyle('height').toInt();
		this.start();
	},
	
	check: function(){
		if(this.oldSize != this.element.getStyle('height').toInt()){
			this.oldSize = this.element.getStyle('height').toInt();
			this.options.onChange();
		}
	},
	
	start: function(){
		this.timer = this.check.periodical(this.options.delay, this);
	},
	
	stop: function(){
		$clear(this.timer);
	}
});
TextResizeDetector.implement(new Events);
TextResizeDetector.implement(new Options);

/*************************************************************/


/*****
	Floating summary
*****/

window.addEvent('domready', function(){

	if($('summary')){
		var el = $('summary');
		var pos = el.getCoordinates();
		el.injectInside(document.body);
		el.setStyles({
			'position': 'absolute',
			'top': pos.top,
			'left': '50%',
			'margin-left': 183
		});
		
		window.addEvent('scroll', function(){
			var px = window.getScrollTop()+20;
			if(px < pos.top){
				px = pos.top;
			}
			if(px+pos.height+20 > $('footer').getCoordinates().top){
				px = $('footer').getCoordinates().top - pos.height - 20;
			}
			el.setStyle('top', px);
		});
		
	}
});



