/*
 *
 *	JELLY JavaScript Library (c) 2008 Pete Boere --/ v.1+ /--
 *	last modified: 21/07/2008
 *
 */
var JELLY=function(){var G=function(I,K,H){var J=H.repeat||1;switch(K){case"sibling":do{do{I=I[H.type+"Sibling"]}while(I&&I.nodeType!==1)}while(I&&--J);break;case"child":if(H.type==="first"){I=I.firstChild;while(I&&I.nodeType!==1){I=I.nextSibling}}else{if(H.type==="last"){I=I.lastChild;while(I&&I.nodeType!==1){I=I.previousSibling}}}break;case"parent":do{I=I.parentNode}while(I&&--J)}return I},E=function(J){var K=J.length,H=[],I;for(I=0;I<K;I++){H[I]=J[I]}return H},D=function(H){return typeof H!=="undefined"},C=function(H){return H.constructor===Array},B=function(H){return typeof H==="string"},A=window.document,F=A.documentElement;return{addClass:function(H,I){H.className+=H.className?" "+I:I},removeClass:function(H,J){var I=new RegExp("(^|\\s|\\b)"+J+"(\\s|$)","g");H.className=H.className.replace(I," ").normalize()},hasClass:function(H,J){var I=new RegExp("(^|\\s)"+J+"(\\s|$)");return I.test(H.className)},toggleClass:function(H,I){if(JELLY.hasClass(H,I)){JELLY.removeClass(H,I)}else{JELLY.addClass(H,I)}},createElement:function(K,H){var J=A.createElement(K),I;for(I in H){switch(I){case"setHTML":J.innerHTML=H[I];break;case"setText":J.appendChild(A.createTextNode(H[I]));break;case"class":J.className=H[I];break;case"style":J.style.cssText=H[I];break;default:J.setAttribute(I,H[I])}}return J},insertElement:function(J,H,I){I=I||"bottom";switch(I){case"before":return H.parentNode.insertBefore(J,H);case"after":return H.parentNode.insertBefore(J,H.nextSibling);case"top":return H.insertBefore(J,H.firstChild);default:return H.appendChild(J)}},replaceElement:function(I,H){return I.parentNode.replaceChild(H,I)},removeElement:function(H){return H.parentNode.removeChild(H)},getFirst:function(H){return G(H,"child",{type:"first"})},getLast:function(H){return G(H,"child",{type:"last"})},getParent:function(H,I){return G(H,"parent",{repeat:I})},getNext:function(H,I){return G(H,"sibling",{type:"next",repeat:I})},getPrevious:function(H,I){return G(H,"sibling",{type:"previous",repeat:I})},getXY:function(H){var I=[0,0];do{I[0]+=H.offsetLeft;I[1]+=H.offsetTop}while(H=H.offsetParent);return I},getX:function(H){return JELLY.getXY(H)[0]},getY:function(H){return JELLY.getXY(H)[1]},setXY:function(H,K,J,I){I=I||"px";H.style.left=K+I;H.style.top=J+I},getStyle:function(I,K,H){K=JELLY.str.toCamelCase(K);var J;if(K==="opacity"){if(I.__opacity===undefined){I.__opacity=1}return I.__opacity}if(I.style[K]){J=I.style[K]}else{if("getComputedStyle" in window){J=window.getComputedStyle(I,null)[K]}else{if("currentStyle" in I){J=I.currentStyle[K]}}}return H===true?parseInt(J,10):J},setOpacity:function(H,I){if(H.filters){JELLY.setOpacity=function(J,K){if(J.__opacity===undefined){J.__opacity=1}J.style.filter=K===1?"":"alpha(opacity="+K*100+")";J.__opacity=K}}else{JELLY.setOpacity=function(J,K){if(J.__opacity===undefined){J.__opacity=1}J.style.opacity=J.__opacity=K}}JELLY.setOpacity(H,I)},dom:{getId:function(H){return A.getElementById(H.replace(/(\w+)?#/,""))},getTags:function(H,I){if(I===null){return I}return E((I||A).getElementsByTagName(H))},getClass:function(){if(D(A.getElementsByClassName)){return function(H,I){if(I===null){return I}return E((I||A).getElementsByClassName(H.replace(/(\w+)?\./,"")))}}return function(I,K){if(K===null){return K}var M=E((K||A).getElementsByTagName("*")),H=[],L=new RegExp("(^|\\s)"+I.replace(/(\w+)?\./,"")+"(\\s|$)"),N=M.length,J;for(J=0;J<N;J++){if(L.test(M[J].className)){H[H.length]=M[J]}}return H}}(),filterByClass:function(I,L){L=L||A.getElementsByTagName("*");var H=[],K=new RegExp("(^|\\s)"+I.replace(/(\w+)?\./,"")+"(\\s|$)"),M=L.length,J;for(J=0;J<M;J++){if(K.test(L[J].className)){H[H.length]=L[J]}}return H},filterByAttribute:function(L,P){if(!C(L)){L=E(L)}P=P.normalize();var N=function(){if(!D(L[0].hasAttibute)&&JELLY.browser.ie){return function(S,R){switch(true){case /for/i.test(R):return S.attributes[R].nodeValue;case /class/i.test(R):return S.attributes[R].nodeValue||null;case /href|src/i.test(R):return S.getAttribute(R,2);case /style/i.test(R):return S.getAttribute(R).cssText.toLowerCase()||null}return S.getAttribute(R)}}return function(S,R){return S.getAttribute(R)}}(),Q=[],M=L.length,J,H;if(/=/.test(P)){var I=/([^\^\$\*]+)((?:\^|\$|\*)?=)([^$]*)/.exec(P),K,O;switch(I[2]){case"=":K=K=new RegExp("^"+I[3]+"$");break;case"^=":K=new RegExp("^"+I[3]);break;case"$=":K=new RegExp(I[3]+"$");break;case"*=":K=new RegExp(I[3]);break}O=function(R,S){if(S!==null&&K.test(S)){Q[Q.length]=R}};for(J=0;J<M;J++){H=L[J];O(H,N(H,I[1]))}}else{for(J=0;J<M;J++){H=L[J];if(N(H,P)!==null){Q[Q.length]=H}}}return Q}},Q:function(T){var I=JELLY.dom.getId,U=JELLY.dom.getTags,R=JELLY.dom.getClass,O=JELLY.dom.filterByClass,V=JELLY.dom.filterByAttribute;if(!B(T)){return E(T)}var L=T.normalize().split(" ");switch(true){case /^(\w+)?#[^\s]+$/.test(T):return I(T);case /^\w+$/.test(T):return U(T);case /^\w+\.[^\s]+$/.test(T):return O(T,U(T.split(".")[0]));case /^\.[^\s]+$/.test(T):return R(T);case /^(\w+)?#[^\s]+\s\w+$/.test(T):return U(L[1],I(L[0]));case /^(\w+)?#[^\s]+\s\.[^\s]+$/.test(T):return R(L[1],I(L[0]));case /^(\w+)?#[^\s]+\s\w+\.[^\s]+$/.test(T):return O(L[1],U(L[1].split(".")[0],I(L[0])))}var N=[],Q=[],J,S,H,M,P,K;for(M=0;L.length>M;M++){H=L[M];S=[];if(/\[/.test(H)){J=H.split("[")[1].replace("]","");H=H.split("[")[0]}switch(true){case /^(\w+)?#[^\s]+$/.test(H):S=[I(H)];break;case /^\w+$/.test(H):if(M===0){S=U(H)}else{for(K=0;K<N.length;K++){P=U(H,N[K]);if(P[0]){S=S.concat(P)}}}break;case /^\.[^\s]+$/.test(H):if(M===0){S=R(H)}else{for(K=0;K<N.length;K++){P=R(H,N[K]);if(P[0]){S=S.concat(P)}}}break;case /^\w+\.[^\s]+$/.test(H):if(M===0){S=O(H,U(H.split(".")[0]))}else{for(K=0;K<N.length;K++){P=O(H,U(H.split(".")[0],N[K]));if(P[0]){S=S.concat(P)}}}break}if(J){S=V(S,J);J=null}if(!S[0]){return null}N=S}while(P=N.pop()){if(!P.__jelly){P.__jelly=true;Q[Q.length]=P}}for(M=0;Q.length>M;M++){Q[M].__jelly=undefined}return Q.reverse()},addEvent:function(K,M,N){var J=!!K.addEventListener,L=/mouseenter/.test(M),O=/mouseleave/.test(M),P=arguments.callee,H,I;P.log=P.log||[];if(!J){H=function(Q){Q=JELLY.fixEvent(Q);N.call(K,Q)}}if(L||O){H=function(Q){Q=JELLY.fixEvent(Q);if(!JELLY.mouseEnterLeave.call(K,Q)){return }N.call(K,Q)};M=L?"mouseover":"mouseout"}I=[K,M,H||N];P.log.push(I);if(J){K.addEventListener(M,H||N,false)}else{K.attachEvent("on"+M,H)}return I},removeEvent:function(H){if(H[0].removeEventListener){H[0].removeEventListener(H[1],H[2],false)}else{H[0].detachEvent("on"+H[1],H[2])}},purgeEventLog:function(){if(JELLY.addEvent.log.length>1){var H=JELLY.addEvent.log,I,J;for(I=0;H[I];I++){J=H[I];if(J[0]===window&&J[1]==="unload"){continue}JELLY.removeEvent(J)}}},fixEvent:function(H){H=H||window.event;if(window.event&&!window.opera){H.target=H.srcElement;H.relatedTarget=function(){switch(H.type){case"mouseover":return H.fromElement;case"mouseout":return H.toElement}}();H.stopPropagation=function(){H.cancelBubble=true};H.preventDefault=function(){H.returnValue=false};H.pageX=H.clientX+F.scrollLeft;H.pageY=H.clientY+F.scrollTop}return H},mouseEnterLeave:function(K){var J,I;if(K.relatedTarget){J=K.relatedTarget;if(J.nodeType!==1||J===this){return false}var H=this.getElementsByTagName("*");for(I=0;H[I];I++){if(J===H[I]){return false}}}return true},stopEvent:function(H){H=JELLY.fixEvent(H);H.stopPropagation();H.preventDefault()},getFlashVersion:function(){var I={major:null,build:null},L,H,K;if(navigator.plugins&&typeof navigator.plugins["Shockwave Flash"]==="object"){L=navigator.plugins["Shockwave Flash"].description;if(L!==null){H=L.replace(/^[^\d]+/,"");I.major=parseInt(H.replace(/^(.*)\..*$/,"$1"),10);I.build=parseInt(H.replace(/^.*r(.*)$/,"$1"),10)}}else{if(JELLY.browser.ie){try{K=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");L=K.GetVariable("$version");if(L!==null){H=L.replace(/^\S+\s+(.*)$/,"$1").split(",");I.major=parseInt(H[0],10);I.build=parseInt(H[2],10)}}catch(J){}}}return I},createFlashObject:function(I){var K=I.path,H=I.attributes||{},L=I.params||{};vars=I.vars||{},fallback=I.fallback||'<a href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif"alt="You need the latest Adobe Flash Player to view this content" /></a>',data=[],output="<object";if(JELLY.browser.ie){H.classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000";L.movie=K}else{H.data=K;H.type="application/x-shockwave-flash"}H.width=I.width;H.height=I.height;for(var J in H){output+=" "+J+'="'+H[J]+'"'}output+=">\n";for(var J in vars){data.push(J+"="+escape(vars[J]))}if(data.length>0){L.flashvars=data.join("&")}for(var J in L){output+='\t<param name="'+J+'" value="'+L[J]+'" />\n'}return output+fallback+"\n</object>"},str:{toCamelCase:function(H){return H.replace(/-\D/gi,function(I){return I.charAt(I.length-1).toUpperCase()})},toCssCase:function(H){return H.replace(/([A-Z])/g,"-$1").toLowerCase()},rgbToHex:function(L){var H=L.match(/[\d]{1,3}/g),J=[],I;for(I=0;I<3;I++){var K=(H[I]-0).toString(16);J.push(K.length===1?"0"+K:K)}return"#"+J.join("")},hexToRgb:function(K,L){var J=K.match(/^#([\w]{1,2})([\w]{1,2})([\w]{1,2})$/),H=[],I;for(I=1;I<J.length;I++){if(J[I].length===1){J[I]+=J[I]}H.push(parseInt(J[I],16))}return L?H:"rgb("+H.join(",")+")"},parseColour:function(N,M){var K=JELLY.str.rgbToHex,H=JELLY.str.hexToRgb,J=/^#/.test(N),L=[],I;switch(M){case"hex":if(J){return N}else{return K(N)}case"rgb":if(J){return H(N)}else{return N}case"rgb-array":if(J){return H(N,true)}else{I=N.replace(/rgb| |\(|\)/g,"").split(",");I.each(function(O){L.push(parseInt(O,10))});return L}}}},getCookie:function(I){var H=new RegExp(I+"=([^; ]+)").exec(A.cookie);if(!H){return null}return unescape(H[1])},setCookie:function(I,K,H,M,J,L){if(H){H=new Date(new Date().getTime()+((1000*60*60*24)*H)).toGMTString()}A.cookie=I+"="+escape(K)+(H?";expires="+H:"")+(M?";path="+M:"")+(J?";domain="+J:"")+(L?";secure":"")},removeCookie:function(H,J,I){if(JELLY.getCookie(H)){A.cookie=H+"="+(J?";path="+J:"")+(I?";domain="+I:"")+(";expires="+new Date(0))}},getViewport:function(){if(D(window.innerWidth)){return function(){return[window.innerWidth,window.innerHeight]}}if(D(F)&&D(F.clientWidth)&&F.clientWidth!==0){return function(){return[F.clientWidth,F.clientHeight]}}return function(){return[A.body.clientWidth||0,A.body.clientHeight||0]}}(),getWindowScroll:function(){if(D(window.pageYOffset)){return function(){return[window.pageXOffset,window.pageYOffset]}}return function(){if(D(F.scrollTop)&&(F.scrollTop>0||F.scrollLeft>0)){return[F.scrollLeft,F.scrollTop]}return[A.body.scrollLeft,A.body.scrollTop]}}(),parseQueryString:function(J){J=J||window;if(/\?/.test(J.href)){var H=J.href.split("?")[1].split("&"),I=H.length-1,K={},L;do{L=H[I].split("=");K[L[0]]=L[1]}while(I--);return K}return null},extend:function(K,J,H){for(var I in J){if(D(K[I])&&H===false){continue}K[I]=J[I]}return K},bind:function(){var H=E(arguments),J=H.shift(),I=H.shift();return function(){return I.apply(J,H)}},bindEventListener:function(){var H=E(arguments),J=H.shift(),I=H.shift();return function(K){return I.apply(J,[K].concat(H))}},toArray:function(H){return E(H)},isDefined:function(H){return D(H)},isArray:function(H){return C(H)},isString:function(H){return B(H)},browser:function(){var H=window.navigator,N="ActiveXObject" in window,L="XMLHttpRequest" in window,M="securityPolicy" in H,O="taintEnabled" in H,J=H.userAgent,P=/opera/i.test(J),K=/firefox/i.test(J),I=/webkit/i.test(J);return{ie:N,ie6:N&&!L,ie7:N&&L,opera:P,firefox:K||(M&&!N&&!P),webkit:I||(!O&&!N&&!P)}}(),trace:function(){if(window.console&&window.console.log){console.log(arguments)}},local:"for(var i in JELLY){if(i!='local')eval('var '+i+'=JELLY.'+i)};"}}();JELLY.addEvent(window,"unload",JELLY.purgeEventLog);(function(){var A=JELLY.browser,D=JELLY.addClass,F=document.documentElement,E="other";for(var C in A){if(A[C]){E=C}}if(/^ie\d/.test(E)){E+=" ie"}D(F,E);D(F,"js");if(A.ie6){try{document.execCommand("BackgroundImageCache",false,true)}catch(B){}}})();JELLY.extend(Array.prototype,{forEach:function(C,D){for(var B=0,A=this.length;B<A;B++){C.call(D,this[B],B,this)}}},false);Array.prototype.each=Array.prototype.forEach;JELLY.extend(String.prototype,{trim:function(){return this.replace(/^\s+|\s+$/g,"")},normalize:function(){return this.replace(/\s{2,}/g," ").trim()}});

JELLY.validateForm = function (form, validateFields) {
	
	JELLY.addEvent(form, 'submit', validate);
	var labels = form.getElementsByTagName('label');
	var trace = JELLY.trace;
	
	function validate (e) {
		var pass = true,
		    error_string = '';
		
		for (var i = 0; validateFields.length > i; i++) {
			var field = form[validateFields[i]];
			var current = validateFields[i];
			var assocLabel = JELLY.dom.filterByAttribute(labels, 'for=' + field.id)[0];
			if (!assocLabel) {
				alert('Developer Notice: \nCheck correct label for ' + field.name + ' field');
				return false;
			}
			var labelText = assocLabel.innerHTML.normalize().replace(/(:|-)$/, '');
			if (/^\s*$/.test(field.value)) {
				error_string += (labelText + ' is required \n'); 
				pass = false;
				continue;
			}
			if (/email/i.test(current)) {
				if (!(/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/.test(field.value))) {
					error_string += 'Please check your entered email address \n'; 
					pass = false;
				}
			} 
		} 
		if (error_string) {
			alert(error_string); 
		}
		error_string = '';
		if (!pass) {
			JELLY.stopEvent(e);
		}
	}
}


