var p = window.location.pathname.split( "/" );
if( p[ p.length - 1 ].substr( -1 ) !== "/" ) {
	p[ p.length - 1 ] = "";
};
var relative_path = p.join( "/" );

/*
	@Class:		moopop 1.1
	@Author:		copyright (c) 2007-2008 by gonchuki - http://blog.gonchuki.com
	@License:		This work is licensed under a Creative Commons Attribution-Share Alike 3.0 License. http://creativecommons.org/licenses/by-sa/3.0/
	@Brief:		Unobtrusive javascript popups via late binding
	@Example: 	<a href="print.cfm" rel="popup[765, 600]">Print This</a>
	@Requirements:	Mootools 1.2
*/

var moopop={width:0,height:0,captureByRel:function(attrVal,parent){this.capture((parent||document).getElements('a[rel*='+(attrVal||'popup')+']'));},capture:function(el,width,height){if($defined(width)&&$defined(height)){this.width=width;this.height=height;}
switch($type(el)){case'string':el=$$(el);case'element':case'array':$splat(el).each(this.add_pop_to,this);}
this.width=null;this.height=null;},add_pop_to:function(el){el.addEvent('click',function(e){e.stop();this.popup(el);}.bind(this));var size=el.get('rel').match(/\[(\d+),\s*(\d+)/)||['',this.width,this.height];var resizable=el.get('rel').match(/,(r)/)||[];if(size[1])el.store('popupprops','top=0, left=0, scrollbars=yes, width='+size[1]+', height='+size[2]+(resizable[1]?', scrollbars=yes, resizable=yes':''));},popup:function(el){window.open(el.get('href'),el.get('name')||'',el.retrieve('popupprops')||'');}};window.addEvent('domready',function(){moopop.captureByRel('popup');});


/*
	mediaboxAdvanced v1.2.0 - The ultimate extension of Slimbox and Mediabox; an all-media script
	updated 2010.01.24
	(c) 2007-2009 John Einselen <http://iaian7.com>
		based on
	Slimbox v1.64 - The ultimate lightweight Lightbox clone
	(c) 2007-2008 Christophe Beyls <http://www.digitalia.be>
	MIT-style license.
*/
var Mediabox;(function(){var A,h,P,H,O,n,F,l,m,k,J,y,t,z=new Image(),V=new Image(),r=false,w=false,S,b,j,c,U,E,M,T,W,e,D,Q,G,x,B,o,i="none",f,d="mediaBox",C;window.addEvent("domready",function(){$(document.body).adopt($$([S=new Element("div",{id:"mbOverlay"}).addEvent("click",N),b=new Element("div",{id:"mbCenter"})]).setStyle("display","none"));j=new Element("div",{id:"mbImage"}).injectInside(b);c=new Element("div",{id:"mbBottom"}).injectInside(b).adopt(new Element("a",{id:"mbCloseLink",href:"#"}).addEvent("click",N),e=new Element("a",{id:"mbNextLink",href:"#"}).addEvent("click",g),T=new Element("a",{id:"mbPrevLink",href:"#"}).addEvent("click",K),E=new Element("div",{id:"mbTitle"}),W=new Element("div",{id:"mbNumber"}),M=new Element("div",{id:"mbCaption"}));y={overlay:new Fx.Tween(S,{property:"opacity",duration:360}).set(0),image:new Fx.Tween(j,{property:"opacity",duration:360,onComplete:I}),bottom:new Fx.Tween(c,{property:"opacity",duration:240}).set(0)}});Mediabox={close:function(){N()},open:function(Z,Y,X){A=$extend({loop:false,stopKey:true,overlayOpacity:0.6,resizeOpening:true,resizeDuration:240,resizeTransition:false,initialWidth:320,initialHeight:180,defaultWidth:640,defaultHeight:360,showCaption:true,showCounter:true,counterText:"({x} of {y})",imgBackground:false,imgPadding:70,scriptaccess:"true",fullscreen:"true",fullscreenNum:"1",autoplay:"true",autoplayNum:"1",autoplayYes:"yes",volume:"100",medialoop:"true",bgcolor:"#000000",wmode:"opaque",useNB:true,playerpath:"/js/NonverBlaster.swf",controlColor:"0xFFFFFF",controlBackColor:"0x000000",showTimecode:"false",JWplayerpath:"/js/player.swf",backcolor:"000000",frontcolor:"999999",lightcolor:"000000",screencolor:"000000",controlbar:"over",controller:"true",flInfo:"true",revverID:"187866",revverFullscreen:"true",revverBack:"000000",revverFront:"ffffff",revverGrad:"000000",usViewers:"true",ytBorder:"0",ytColor1:"000000",ytColor2:"333333",ytQuality:"&ap=%2526fmt%3D18",ytRel:"0",ytInfo:"1",ytSearch:"0",vuPlayer:"basic",vmTitle:"1",vmByline:"1",vmPortrait:"1",vmColor:"ffffff"},X||{});if((Browser.Engine.gecko)&&(Browser.Engine.version<19)){r=true;A.overlayOpacity=1;S.className="mbOverlayFF"}if(typeof Z=="string"){Z=[[Z,Y,X]];Y=0}h=Z;A.loop=A.loop&&(h.length>1);if((Browser.Engine.trident)&&(Browser.Engine.version<5)){w=true;S.className="mbOverlayIE";S.setStyle("position","absolute");L()}q();s(true);n=window.getScrollTop()+(window.getHeight()/2);l=window.getScrollLeft()+(window.getWidth()/2);y.resize=new Fx.Morph(b,$extend({duration:A.resizeDuration,onComplete:R},A.resizeTransition?{transition:A.resizeTransition}:{}));b.setStyles({top:n,left:l,width:A.initialWidth,height:A.initialHeight,marginTop:-(A.initialHeight/2),marginLeft:-(A.initialWidth/2),display:""});y.overlay.start(A.overlayOpacity);return a(Y)}};Element.implement({mediabox:function(X,Y){$$(this).mediabox(X,Y);return this}});Elements.implement({mediabox:function(X,aa,Z){aa=aa||function(ab){x=ab.rel.split(/[\[\]]/);x=x[1];return[ab.href,ab.title,x]};Z=Z||function(){return true};var Y=this;Y.addEvent("contextmenu",function(ab){if(this.toString().match(/\.gif|\.jpg|\.png/i)){ab.stop()}});Y.removeEvents("click").addEvent("click",function(){var ac=Y.filter(Z,this);var ad=[];var ab=[];ac.each(function(af,ae){if(ab.indexOf(af.toString())<0){ad.include(ac[ae]);ab.include(ac[ae].toString())}});return Mediabox.open(ad.map(aa),ab.indexOf(this.toString()),X)});return Y}});function L(){S.setStyles({top:window.getScrollTop(),left:window.getScrollLeft()})}function q(){k=window.getWidth();J=window.getHeight();S.setStyles({width:k,height:J})}function s(X){["object",window.ie?"select":"embed"].forEach(function(Z){Array.forEach(document.getElementsByTagName(Z),function(aa){if(X){aa._mediabox=aa.style.visibility}aa.style.visibility=X?"hidden":aa._mediabox})});S.style.display=X?"":"none";var Y=X?"addEvent":"removeEvent";if(w){window[Y]("scroll",L)}window[Y]("resize",q);document[Y]("keydown",u)}function u(X){switch(X.code){case 27:case 88:case 67:N();break;case 37:case 80:K();break;case 39:case 78:g()}if(A.stopKey){return false}}function K(){return a(H)}function g(){return a(O)}function a(X){if(X>=0){j.set("html","");P=X;H=((P||!A.loop)?P:h.length)-1;O=P+1;if(O==h.length){O=A.loop?0:-1}v();b.className="mbLoading";if(!h[X][2]){h[X][2]=""}Q=h[X][2].split(" ");G=Q.length;if(G>1){B=(Q[G-2].match("%"))?(window.getWidth()*((Q[G-2].replace("%",""))*0.01))+"px":Q[G-2]+"px";o=(Q[G-1].match("%"))?(window.getHeight()*((Q[G-1].replace("%",""))*0.01))+"px":Q[G-1]+"px"}else{B="";o=""}D=h[X][0];D=encodeURI(D).replace("(","%28").replace(")","%29");U=h[P][1].split("::");if(D.match(/quietube\.com/i)){f=D.split("v.php/");D=f[1]}else{if(D.match(/\/\/yfrog/i)){i=(D.substring(D.length-1));if(i.match(/b|g|j|p|t/i)){i="image"}if(i=="s"){i="flash"}if(i.match(/f|z/i)){i="video"}D=D+":iphone"}}if(D.match(/\.gif|\.jpg|\.png|twitpic\.com/i)||i=="image"){i="img";D=D.replace(/twitpic\.com/i,"twitpic.com/show/full");t=new Image();t.onload=p;t.src=D}else{if(D.match(/\.flv|\.mp4/i)||i=="video"){i="obj";B=B||A.defaultWidth;o=o||A.defaultHeight;if(A.useNB){t=new Swiff(""+A.playerpath+"?mediaURL="+D+"&allowSmoothing=true&autoPlay="+A.autoplay+"&buffer=6&showTimecode="+A.showTimecode+"&loop="+A.medialoop+"&controlColor="+A.controlColor+"&controlBackColor="+A.controlBackColor+"&defaultVolume="+A.volume+"&scaleIfFullScreen=true&showScalingButton=true&crop=false",{id:"MediaboxSWF",width:B,height:o,params:{wmode:A.wmode,bgcolor:A.bgcolor,allowscriptaccess:A.scriptaccess,allowfullscreen:A.fullscreen}})}else{t=new Swiff(""+A.JWplayerpath+"?file="+D+"&backcolor="+A.backcolor+"&frontcolor="+A.frontcolor+"&lightcolor="+A.lightcolor+"&screencolor="+A.screencolor+"&autostart="+A.autoplay+"&controlbar="+A.controlbar,{id:"MediaboxSWF",width:B,height:o,params:{wmode:A.wmode,bgcolor:A.bgcolor,allowscriptaccess:A.scriptaccess,allowfullscreen:A.fullscreen}})}p()}else{if(D.match(/\.mp3|\.aac|tweetmic\.com|tmic\.fm/i)||i=="audio"){i="obj";B=B||A.defaultWidth;o=o||"20px";if(D.match(/tweetmic\.com|tmic\.fm/i)){D=D.split("/");D[4]=D[4]||D[3];D="http://media4.fjarnet.net/tweet/tweetmicapp-"+D[4]+".mp3"}if(A.useNB){t=new Swiff(""+A.playerpath+"?mediaURL="+D+"&allowSmoothing=true&autoPlay="+A.autoplay+"&buffer=6&showTimecode="+A.showTimecode+"&loop="+A.medialoop+"&controlColor="+A.controlColor+"&controlBackColor="+A.controlBackColor+"&defaultVolume="+A.volume+"&scaleIfFullScreen=true&showScalingButton=true&crop=false",{id:"MediaboxSWF",width:B,height:o,params:{wmode:A.wmode,bgcolor:A.bgcolor,allowscriptaccess:A.scriptaccess,allowfullscreen:A.fullscreen}})}else{t=new Swiff(""+A.JWplayerpath+"?file="+D+"&backcolor="+A.backcolor+"&frontcolor="+A.frontcolor+"&lightcolor="+A.lightcolor+"&screencolor="+A.screencolor+"&autostart="+A.autoplay,{id:"MediaboxSWF",width:B,height:o,params:{wmode:A.wmode,bgcolor:A.bgcolor,allowscriptaccess:A.scriptaccess,allowfullscreen:A.fullscreen}})}p()}else{if(D.match(/\.swf/i)||i=="flash"){i="obj";B=B||A.defaultWidth;o=o||A.defaultHeight;t=new Swiff(D,{id:"MediaboxSWF",width:B,height:o,params:{wmode:A.wmode,bgcolor:A.bgcolor,allowscriptaccess:A.scriptaccess,allowfullscreen:A.fullscreen}});p()}else{if(D.match(/\.mov|\.m4v|\.m4a|\.aiff|\.avi|\.caf|\.dv|\.mid|\.m3u|\.mp3|\.mp2|\.mp4|\.qtz/i)||i=="qt"){i="qt";B=B||A.defaultWidth;o=(parseInt(o)+16)+"px"||A.defaultHeight;t=new Quickie(D,{id:"MediaboxQT",width:B,height:o,container:"mbImage",attributes:{controller:A.controller,autoplay:A.autoplay,volume:A.volume,loop:A.medialoop,bgcolor:A.bgcolor}});p()}else{if(D.match(/\#mb_/i)){i="inline";B=B||A.defaultWidth;o=o||A.defaultHeight;URLsplit=D.split("#");t=$(URLsplit[1]).get("html");p()}else{A.showCaption=false;A.showCounter=false;i="url";B=B||A.defaultWidth;o=o||A.defaultHeight;d="mediaId_"+new Date().getTime();t=new Element("iframe",{src:D,id:d,width:B,height:o,frameborder:0});p()}}}}}}}return false}function p(){if(i=="img"){B=t.width;o=t.height;if(A.imgBackground){j.setStyles({backgroundImage:"url("+D+")",display:""})}else{if(o>=J-A.imgPadding&&(o/J)>=(B/k)){o=J-A.imgPadding;B=t.width=parseInt((o/t.height)*B);t.height=o}else{if(B>=k-A.imgPadding&&(o/J)<(B/k)){B=k-A.imgPadding;o=t.height=parseInt((B/t.width)*o);t.width=B}}if(Browser.Engine.trident){t=$(t)}t.addEvent("mousedown",function(X){X.stop()}).addEvent("contextmenu",function(X){X.stop()});j.setStyles({backgroundImage:"none",display:""});t.inject(j)}}else{if(i=="obj"){if(Browser.Plugins.Flash.version<8){j.setStyles({backgroundImage:"none",display:""});j.set("html",'<div id="mbError"><b>Error</b><br/>Adobe Flash is either not installed or not up to date, please visit <a href="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" title="Get Flash" target="_new">Adobe.com</a> to download the free player.</div>');B=A.DefaultWidth;o=A.DefaultHeight}else{j.setStyles({backgroundImage:"none",display:""});t.inject(j)}}else{if(i=="qt"){j.setStyles({backgroundImage:"none",display:""});t}else{if(i=="inline"){j.setStyles({backgroundImage:"none",display:""});j.set("html",t)}else{if(i=="url"){j.setStyles({backgroundImage:"none",display:""});t.inject(j)}else{j.setStyles({backgroundImage:"none",display:""});j.set("html",'<div id="mbError"><b>Error</b><br/>A file type error has occoured, please visit <a href="iaian7.com/webcode/mediaboxAdvanced" title="mediaboxAdvanced" target="_new">iaian7.com</a> or contact the website author for more information.</div>');B=A.defaultWidth;o=A.defaultHeight}}}}}j.setStyles({width:B,height:o});E.set("html",(A.showCaption)?U[0]:"");M.set("html",(A.showCaption&&(U.length>1))?U[1]:"");W.set("html",(A.showCounter&&(h.length>1))?A.counterText.replace(/{x}/,P+1).replace(/{y}/,h.length):"");if((H>=0)&&(h[H][0].match(/\.gif|\.jpg|\.png|twitpic\.com/i))){z.src=h[H][0].replace(/twitpic\.com/i,"twitpic.com/show/full")}if((O>=0)&&(h[O][0].match(/\.gif|\.jpg|\.png|twitpic\.com/i))){V.src=h[O][0].replace(/twitpic\.com/i,"twitpic.com/show/full")}B=j.offsetWidth;o=j.offsetHeight+c.offsetHeight;if(o>=n+n-10){F=-(n-10)}else{F=-(o/2)}if(B>=l+l-10){m=-(l-10)}else{m=-(B/2)}if(A.resizeOpening){y.resize.start({width:B,height:o,marginTop:F,marginLeft:m})}else{b.setStyles({width:B,height:o,marginTop:F,marginLeft:m});R()}}function R(){y.image.start(1)}function I(){b.className="";if(i!="url"){if(H>=0){T.style.display=""}if(O>=0){e.style.display=""}}else{T.style.display="none";e.style.display="none"}y.bottom.start(1)}function v(){if(t){t.onload=$empty}y.resize.cancel();y.image.cancel().set(0);y.bottom.cancel().set(0);$$(T,e).setStyle("display","none")}function N(){if(P>=0){t.onload=$empty;j.set("html","");for(var X in y){y[X].cancel()}b.setStyle("display","none");y.overlay.chain(s).start(0)}return false}})();Mediabox.scanPage=function(){var a=$$("a").filter(function(b){return b.rel&&b.rel.test(/^lightbox/i)});$$(a).mediabox({},null,function(c){var b=this.rel.replace(/[[]|]/gi," ");var d=b.split(" ");return(this==c)||((this.rel.length>8)&&c.rel.match(d[1]))})};window.addEvent("domready",Mediabox.scanPage);

/*

	@Class:		InputClearAndReplace
	@Author:		Brandon Gray for O3 World 2008
	@Brief:		Loops through all inputs/textareas with a class name of 'clear_replace' and clears the default text when focused
				when focus is lost it checks to see if the field is blank (no new data entered), if value is blank the default text is placed back in
	@Example: 	<input type="text" name="firstname" id="firstname" value="" class="clear_replace" />
	@Requirements:	Mootools 1.2
			
*/
var InputClearAndReplace = new Class ({
	options: {
		InputElement: '.clear_replace'
	},
	initialize: function()  {
		var inputElementList = $$( this.options.InputElement );
		var originalValue = new Array();
		inputElementList.each( function( element, i ) {
			originalValue.push( inputElementList[ i ].value );
			element.onfocus = function() {
				if( this.value == originalValue[ i ] ) this.value = '';
			},
			element.onblur = function() {
				if( this.value == '' ) this.value = originalValue[ i ];
			}
		});
	}
});

/*

	@Class:		FeaturedProgram
	@Author:		Brandon Gray for O3 World 2010
	@Brief:		Controls the display of content in the "featured" section on the home page.
	@Requirements:	Mootools 1.2, Mootools "More" Asset class
			
*/
var FeaturedProgram = new Class ({
	
	initialize: function()  {
		
		// Preload images
		var images = new Asset.images([
			'img/fpo/home_feature_1.jpg',
			'img/fpo/home_feature_2.jpg',
			'img/fpo/home_feature_3.jpg',
			'img/fpo/home_feature_4.jpg',
			'img/fpo/home_feature_5.jpg',
			'img/fpo/home_feature_6.jpg',
			'img/fpo/home_feature_7.jpg'
		]);
		
		this.menuLinks 	= $$( '#feat ul a.solution' );
		this.contentDivs	= $$( '#feat div.feat' );
		this.pos			= 0;
		this.total		= this.menuLinks.length;
		this.isPaused 		= false;
		this.timer		= this.updateCount.bind( this ).periodical( 9100 );
		this.timerImg 		= $( 'timer' );
		
		for ( var i = 0; i < this.menuLinks.length; i++ ) this.menuLinks[ i ].addEvent( 'click', this.setMenu.bindWithEvent( this, [ i ] ) );
				
	},
	
	updateCount: function() {
		
		( this.pos != ( this.total - 1 ) ) ? this.pos++ : this.pos = 0;
		
		this.setMenu( null, this.pos );
		this.setContent( this.pos );
		
	},
	
	setMenu: function( event, i ) {
		
		if( event ) {
			
			event.stop();
			$clear( this.timer );
			this.timer = null;
			this.isPaused = true;
			this.timerImg.setStyle( 'display', 'none' );
			
		}
		
		this.pos = i;
		
		for ( var j = 0; j < this.menuLinks.length; j++ ) {
			
			this.menuLinks[ j ].getParent( 'li' ).removeClass( 'active' );
			this.menuLinks[ j ].getParent( 'li' ).addClass( 'rule' );
			
		}
		
		this.menuLinks[ i ].getParent( 'li' ).removeClass( 'rule' );
		this.menuLinks[ i ].getParent( 'li' ).addClass( 'active' );
		
		this.setContent( i );
		
	},
	
	setContent: function( i ) {
		
		for ( var k = 0; k < this.contentDivs.length; k++ ) {
			
			this.contentDivs[ k ].setStyle( 'display', 'none' );
			this.contentDivs[ k ].setStyle( 'opacity', '0' );
			
		}
		
		this.contentDivs[ i ].setStyle( 'display', 'block' );
		this.contentDivs[ i ].fade( '1' );
		
	}
	
});


/*
	@Class:		TestimonialCallout
	@Author:		Andrew Regis for O3 World 2011
	@Brief:		Controls the AJAX powered roataion of Testimonial Callouts.			
*/
var TestimonialCallout = new Class ({
	
	Implements: [ Chain, Options ],
	
	options: {
		
		Webroot:		'/',
		Container:	'testimonial_callout',
		RotationTime:	10					// in seconds
		
	},
	
	initialize: function()  {
		
		this.Webroot			= this.options.Webroot;
		this.Container			= $( this.options.Container );
		this.RotationTime		= this.options.RotationTime * 1000;
		this.RequestResponse	= '';
		
		this.MyFx				= new Fx.Tween( this.Container, { durration: 1000 } );
		this.TheChain			= new Chain();
		
		this.MyRequest			= new Request({
								method:		'get',
								url:			this.Webroot + 'ajax_processing.cfm?AJAXRequest=testimonial_callout',
								noCache :		true,
								onSuccess:	function( response ){
												this.RequestResponse = response;
												this.TheChain.chain(
													function(){ this.MyFx.start( 'opacity', 1, 0 ); }.bind( this ),
													function(){
														this.Container.set( 'html', this.RequestResponse );
														if( typeof( Cufon ) != 'undefined' ) {
															Cufon.replace( '#side h4' );
														};
														//alert( response + '\n\n' + this.RequestResponse );
													}.bind( this ),
													function(){ this.MyFx.start( 'opacity', 0, 1 ); }.bind( this )
												);
												this.TheChain.callChain();
												this.TheChain.callChain.delay( 1000, this.TheChain );
												this.TheChain.callChain.delay( 250, this.TheChain );
											}.bind( this ),
								initialDelay:	this.RotationTime,
								delay: 		this.RotationTime,
								limit: 		30000
		}).startTimer();
		
	}
	
});
TestimonialCallout.implement( new Options );


function navSlide() {
	var navLists = $$( '#nav > li' );
	navLists.each( function( navItem ){
		var navItemChild = navItem.getFirst( 'div' );
		if( !navItemChild ) return;
		navItemChild.set({ 
			'styles': {
				'top': -navItemChild.getCoordinates().height + 48,
				'visibility': 'visible'
			},
			'tween': {
				property: 'top',
				duration: 500,
				unit: 'px',
				link: 'cancel',
				transition: Fx.Transitions.Quart.easeInOut
			}
		});
		navItem.addEvents({
			'mouseenter': function() {
				navItemChild.tween( 48 );
			},
			'mouseleave': function() {
				navItemChild.tween( -navItemChild.getCoordinates().height + 48 );
			}
		});
	});
}

// Drop down display fix for IE6 - typical
function ie6NavFix() {
	var navLists = $$( '#head_wrap li' );
	for( var i = 0; i < navLists.length; i++ ) {
		if( navLists[i].getChildren( 'form' ).length > 0 ) {
			navLists[i].addEvent( 'mouseenter', function() {
				this.getChildren( 'form' )[ 0 ].setStyle( 'display', 'block' );
			});
			navLists[i].addEvent( 'mouseleave', function() {
				this.getChildren( 'form' )[ 0 ].setStyle( 'display', 'none' );
			});
		};
	};
};


function checkEmail( FormElement ) {
	if ( !( /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test( FormElement.value ) ) ) {
		return false;	
	} else {
		return true;
	};
};

function validateForm( ID ) {
	if( $$( '#Form_' + ID + '.required' ) ) {
		var i		= 0;
		var Valid		= 1;
		var Fields	= $$( "#" + ID + ' .required' );
		if( Fields.length ) {
			for( i = 0; i < Fields.length; i++ ) {
				if( Fields[i].id.split( '_' )[0] == 'mmmultiple' ) {
					var OneChecked = false;
					var NumItems	= Fields[i].id.split( '_' )[1];
					for( var j = 0; j < NumItems; j++ ) {
						if( $( Fields[i].name + '_' + j ).checked == true ) {
							OneChecked = true;
							break;
						};
					};
					if( !OneChecked ) {
						alert( 'The ' + Fields[i].name.replace( /_/g, ' ' ) + ' field is a required field.' );
						$( Fields[i].name + '_0' ).focus();
						Valid = 0;
						break;
					};
				} else if( Fields[i].getProperty( 'min' ) != null && Fields[i].value.length < parseInt( Fields[i].getProperty( 'min' ) ) ) {
					alert( 'The ' + Fields[i].id.replace( '_', ' ' ) + ' field is a requires at least a ' + Fields[i].getProperty( 'min' ) + ' character minimum.' );
					Fields[i].focus();
					Valid = 0;
					break;
				} else if( Fields[i].value == '' || Fields[i].value == Fields[i].name || ( Fields[i].name.toLowerCase().indexOf( 'email', 0 ) != -1 && !checkEmail( Fields[i] ) ) ) {
					alert( 'The ' + Fields[i].id.replace( '_', ' ' ) + ' field is a required field.' );
					Fields[i].focus();
					Valid = 0;
					break;
				};
			};
		};
	} else {
		Valid = 0;
	};
	return Valid;
};

function ValidateBlogComment( ) {	
	// Validate input
	if( $( 'Name' ).value == "" || $( 'Name' ).value == "Name" ) {
		alert( 'Please enter your name.' );
		$( 'Name' ).focus();
		return false;
	} else if( !checkEmail( document.BlogCommentForm.Email ) ) {
		alert( 'Please enter your valid email address.' );
		$( 'Email' ).focus();
		return false;
	} else if( $( 'Comment' ).value == "" || $( 'Comment' ).value == "Comment" ) {
		alert( 'Please enter a comment.' );
		$( 'Comment' ).focus();
		return false;
	} else if( $( 'THP' ).value == "" ) {
		// Create new FX's
		var FormFx = new Fx.Tween( $( 'BlogCommentForm' ), { duration: '500', link: 'chain' } );
		if( $( 'comment_form' ) ) { FormFx.start( 'opacity', '1', '1' ); };
		var ProcessingFx = new Fx.Tween( $( 'comment_processing' ), { duration: '500', link: 'chain' } );
		if( $( 'comment_processing' ) ) { ProcessingFx.start( 'opacity', '0', '0' ); };
		var CompleteFx = new Fx.Tween( $( 'comment_complete' ), { duration: '500', link: 'chain' } );
		if( $( 'comment_complete' ) ) { CompleteFx.start( 'opacity', '0', '0' ); };
		// Begin responce
		new Request({
			method:		'post',
			url:			'ajax_processing.cfm?AJAXRequest=blog_comment',
			link:		'cancel',
			onRequest:	function() {
							FormFx.start( 'opacity', '1', '0' );
							FormFx.start( 'display', 'block', 'none' );
							ProcessingFx.start( 'opacity', '0', '1' );
							//CompleteFx.start( 'opacity', '0', '0' );
						},
			onFailure:	function() {
							//FormFx.start( 'opacity', '0', '0' );
							ProcessingFx.start( 'opacity', '1', '0' );
							$( 'comment_complete' ).set( 'html', '<p>There was an error processing your comment.<br /><br />Please try again.</p>' );
							CompleteFx.start( 'opacity', '0', '1' );
							$( 'Name' ).value		= "Name";
							$( 'Email' ).value		= "Email (Will Not Display)";
							$( 'Link' ).value		= "Website";
							$( 'Comment' ).value	= "Comment";
						},
			onSuccess:	function() {
							//FormFx.start( 'opacity', '0', '0' );
							ProcessingFx.start( 'opacity', '1', '0' );
							$( 'comment_complete' ).set( 'html', '<p>Comment submitted successfully!<br /><br />Your comment will appear pending approval.</p>' );
							CompleteFx.start( 'opacity', '0', '1' );
							$( 'Name' ).value		= "Name";
							$( 'Email' ).value		= "Email (Will Not Display)";
							$( 'Link' ).value		= "Website";
							$( 'Comment' ).value	= "Comment";
						}
		}).send( $( 'BlogCommentForm' ) );
		return false;
	};
};

function executeSubmitForm( ) {
	var AllForms = $$( 'form.ContentForm' );
	if( AllForms.length ) {
		AllForms.each( function( item, index ) {
			item.removeEvents( 'submit' );
			$( item.id ).addEvent( 'submit', function( event ) {
				if( validateForm( item.id ) ) {
					var MyRequest = new Request( {
						method:		'post',
						url:			relative_path + 'ajax_processing.cfm',
						onRequest: 	function( ) {
							$( item.id + '_Submit' ).addClass( 'hide' );
							$( item.id + '_Wait' ).removeClass( 'hide' );
							$( item.id + '_Fields' ).tween( 'opacity', '0.3' );
						},
						onSuccess: 	function( html ){
							if( html.indexOf( "There was an error" ) > -1 ){
								// an error occured, so reshow form and scroll to error message
								$( item.id + '_Response' ).set( 'html', html );
								$( item.id + '_Submit' ).removeClass( 'hide' );
								$( item.id + '_Wait' ).addClass( 'hide' );
								$( item.id + '_Fields' ).tween( 'opacity', '1' );
								var myFx = new Fx.Scroll( window ).toElement( item.id + '_Response' );
							} else {
								// form submitted properly, so show response
								$( item.id + '_Response' ).removeClass( 'hide' );
								$( item.id + '_Response' ).set( 'html', html );
								$( item.id + '_Submit' ).addClass( 'hide' );
								$( item.id + '_Wait' ).addClass( 'hide' );
								$( item.id + '_Fields' ).addClass( 'hide' );
								var myFx = new Fx.Scroll( window ).toElement( item.id + '_Response' );
							};
						},
						onFailure: 	function( ){
							alert( 'Something went wrong... we couldn\'t submit this form. Please try again.' );
							$( item.id + '_Response' ).addClass( 'hide' );
							$( item.id + '_Submit' ).removeClass( 'hide' );
							$( item.id + '_Wait' ).addClass( 'hide' );
							$( item.id + '_Fields' ).removeClass( 'hide' );
							$( item.id + '_Fields' ).tween( 'opacity', '1' );
						}
					} ).send( { data: $( item.id ) } );
					event.stop();
				};
			} );
		} );
	};
};

function validateSendToAFriend() {
	$( 'SendToAFriend_Form' ).removeEvents( 'submit' );
	$( 'SendToAFriend_Form' ).addEvent( 'submit', function( event ) {
		if( $( 'Name' ).value == "" ) {
			alert( 'Please enter your name.' );
			$( 'Name' ).focus();
		} else if( !checkEmail( $( 'Email' ) ) ) {
			alert( 'Please enter your valid email address.' );
			$( 'Email' ).focus();
		} else if( $( 'FriendName' ).value == "" ) {
			alert( 'Please enter your friend\'s name.' );
			$( 'FriendName' ).focus();
		} else if( !checkEmail( $( 'FriendEmail' ) ) ) {
			alert( 'Please enter your friend\'s valid email address.' );
			$( 'FriendEmail' ).focus();
		} else if( $( 'TheField' ).value == "" ) {
			var MyRequest = new Request( {
				method:		'post',
				url:			relative_path + 'ajax_processing.cfm',
				onRequest: 	function() {
					$( 'SendToAFriend_Wait' ).removeClass( 'hide' );
					$( 'SendToAFriend_Submit' ).addClass( 'hide' );
					$( 'SendToAFriend_Wrapper' ).tween( 'opacity', '0.3' );
				},
				onComplete:	function() {
					$( 'SendToAFriend_Wait' ).addClass( 'hide' );
					$( 'SendToAFriend_Wrapper' ).addClass( 'hide' );
					$( 'SendToAFriend_Response' ).removeClass( 'hide' );
				}
			} ).send( { data: $( 'SendToAFriend_Form' ) } );
		};
		event.stop();
	} );
};

function ValidateBlogSearch() {
	$( 'blog_search' ).removeEvents( 'submit' );
	$( 'blog_search' ).addEvent( 'submit', function( event ) {	
		var ThisInput = $$( "#blog_search #searchString" )[0];
		var x = ThisInput.value;
		ThisInput.value = x.replace(/[^0-9A-Z\x20\x2d]+/gi,"");
		if( ThisInput.value == "" || ThisInput.value == "Submit Search Term" ) {
			alert( 'Please enter your search terms.' );
			ThisInput.focus();
		} else {
			$( item.id ).submit();
		};
		event.stop();
	} );
};

function initialize(){
	
	executeSubmitForm();
	
};

/*

	@Class:		FooterClients
	@Author:		Brandon Gray for O3 World 2010
	@Brief:		Creates a basic fade out, fade in slide show of images.
	@Requirements:	Mootools 1.2
			
*/
var FooterClients = new Class({

	initialize: function() {
	
		this.images 	= $$( '#client_slide img' );
		this.pos 		= 0;
		this.total	= this.images.length;
		this.timer;
		
		if ( this.total != 1 ) {

			this.timer = this.fadeOut.bind( this ).periodical( 4000 );

			this.images.each( function( item ) {
							  
				item.set( 'morph', {
					duration: 750
				});
				
			});
			
		};
		
	},
	
	fadeOut: function() {
		
		this.timer = $clear( this.timer );
		
		this.images[ this.pos ].morph({
		
			opacity: 0,
			onComplete: function() {
				
				( this.pos != ( this.total - 1 ) ) ? this.pos++ : this.pos = 0;
				this.fadeIn();
				
			}.bind( this )
		
		});
		
	},
	
	fadeIn: function() {
		
		this.images[ this.pos ].morph({
		
			opacity: 1,
			onComplete: function(){
				
				this.timer = this.fadeOut.bind( this ).periodical( 4000 );
				
			}.bind( this )
		
		});
		
	}

});

window.addEvent( 'domready', function() {

	initialize();

	if ( Browser.Engine.trident4 ) ie6NavFix();
	if( $( 'feat' ) ) var featProg = new FeaturedProgram();
	if ( $( 'client_slide' ) ) var clientSlide = new FooterClients();
	
	var InputList = new InputClearAndReplace();
		
	navSlide();

	if( $( 'SendToAFriend_Form' ) ) { validateSendToAFriend(); };

	if( $( 'blog_search' ) ) { ValidateBlogSearch() };

} );
