

/*yepnope1.0.1|WTFPL*/(function(a,b,c){function H(){var a=z;a.loader={load:G,i:0};return a}function G(a,b,c){var e=b=="c"?r:q;i=0,b=b||"j",u(a)?F(e,a,b,this.i++,d,c):(h.splice(this.i++,0,a),h.length==1&&E());return this}function F(a,c,d,g,j,l){function q(){!o&&A(n.readyState)&&(p.r=o=1,!i&&B(),n.onload=n.onreadystatechange=null,e(function(){m.removeChild(n)},0))}var n=b.createElement(a),o=0,p={t:d,s:c,e:l};n.src=n.data=c,!k&&(n.style.display="none"),n.width=n.height="0",a!="object"&&(n.type=d),n.onload=n.onreadystatechange=q,a=="img"?n.onerror=q:a=="script"&&(n.onerror=function(){p.e=p.r=1,E()}),h.splice(g,0,p),m.insertBefore(n,k?null:f),e(function(){o||(m.removeChild(n),p.r=p.e=o=1,B())},z.errorTimeout)}function E(){var a=h.shift();i=1,a?a.t?e(function(){a.t=="c"?D(a):C(a)},0):(a(),B()):i=0}function D(a){var c=b.createElement("link"),d;c.href=a.s,c.rel="stylesheet",c.type="text/css",!a.e&&(o||j)?function g(a){e(function(){if(!d)try{a.sheet.cssRules.length?(d=1,B()):g(a)}catch(b){b.code==1e3||b.message=="security"||b.message=="denied"?(d=1,e(function(){B()},0)):g(a)}},0)}(c):(c.onload=function(){d||(d=1,e(function(){B()},0))},a.e&&c.onload()),e(function(){d||(d=1,B())},z.errorTimeout),!a.e&&f.parentNode.insertBefore(c,f)}function C(a){var c=b.createElement("script"),d;c.src=a.s,c.onreadystatechange=c.onload=function(){!d&&A(c.readyState)&&(d=1,B(),c.onload=c.onreadystatechange=null)},e(function(){d||(d=1,B())},z.errorTimeout),a.e?c.onload():f.parentNode.insertBefore(c,f)}function B(){var a=1,b=-1;while(h.length- ++b)if(h[b].s&&!(a=h[b].r))break;a&&E()}function A(a){return!a||a=="loaded"||a=="complete"}var d=b.documentElement,e=a.setTimeout,f=b.getElementsByTagName("script")[0],g=({}).toString,h=[],i=0,j="MozAppearance"in d.style,k=j&&!!b.createRange().compareNode,l=j&&!k,m=k?d:f.parentNode,n=a.opera&&g.call(a.opera)=="[object Opera]",o="webkitAppearance"in d.style,p=o&&"async"in b.createElement("script"),q=j?"object":n||p?"img":"script",r=o?"img":q,s=Array.isArray||function(a){return g.call(a)=="[object Array]"},t=function(a){return typeof a=="object"},u=function(a){return typeof a=="string"},v=function(a){return g.call(a)=="[object Function]"},w=[],x={},y,z;z=function(a){function h(a,b){function i(a){if(u(a))g(a,f,b,0,c);else if(t(a))for(h in a)a.hasOwnProperty(h)&&g(a[h],f,b,h,c)}var c=!!a.test,d=c?a.yep:a.nope,e=a.load||a.both,f=a.callback,h;i(d),i(e),a.complete&&b.load(a.complete)}function g(a,b,d,e,g){var h=f(a),i=h.autoCallback;if(!h.bypass){b&&(b=v(b)?b:b[a]||b[e]||b[a.split("/").pop().split("?")[0]]);if(h.instead)return h.instead(a,b,d,e,g);d.load(h.url,h.forceCSS||!h.forceJS&&/css$/.test(h.url)?"c":c,h.noexec),(v(b)||v(i))&&d.load(function(){H(),b&&b(h.origUrl,g,e),i&&i(h.origUrl,g,e)})}}function f(a){var b=a.split("!"),c=w.length,d=b.pop(),e=b.length,f={url:d,origUrl:d,prefixes:b},g,h;for(h=0;h<e;h++)g=x[b[h]],g&&(f=g(f));for(h=0;h<c;h++)f=w[h](f);return f}var b,d,e=this.yepnope.loader;if(u(a))g(a,0,e,0);else if(s(a))for(b=0;b<a.length;b++)d=a[b],u(d)?g(d,0,e,0):s(d)?z(d):t(d)&&h(d,e);else t(a)&&h(a,e)},z.addPrefix=function(a,b){x[a]=b},z.addFilter=function(a){w.push(a)},z.errorTimeout=1e4,b.readyState==null&&b.addEventListener&&(b.readyState="loading",b.addEventListener("DOMContentLoaded",y=function(){b.removeEventListener("DOMContentLoaded",y,0),b.readyState="complete"},0)),a.yepnope=H()})(this,this.document);

yepnope([
	{
		load:'//ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js',
		callback:function(u,r,k)
		{
			if(!window.jQuery)
			{
				yepnope('/cr/js/jquery.js');
			}
		}
	},{
		load:	'/cr/js/libs/jqui.js'	+
				',libs/jq-easing.js'	+
				',libs/jq-cycle.js'		+
				',libs/jq-valid.js'		+
				',libs/jq-hover.js'		+
				',libs/jq-fancy.js'		+
				'.p-2011050201.js',
		callback:function(u,r,k)
		{
			jQuery(function(){
				// URI Segments. Namaste.
				var currentURI = location.pathname;
				var uriSegments = currentURI.replace('/^\//','').replace('/\/$/','').split('/');

				// External Links in New Windows
				$.expr[':'].external = function(o) {
					return !o.href.match(/^mailto\:/) && (o.hostname !== location.hostname);
				};
				$('a:external').attr('target','_blank').addClass('external');

				// LiveChat Polling
				if ($('#live-chat').length)
				{
					var lcPing = function () {
						//$.ajaxSetup({"error":function(){}});
						$.getJSON('/cr/php/lc-ping.php',function(d){
							$('#live-chat').attr('class',d['status']);
							setTimeout(function() {
								lcPing();
							},30000);
						});
					};
					lcPing();
					$('#live-chat').click(function(){
						window.open($(this).attr('href'),'lchat','status=no,toolbar=no,width=280,height=420');
						_gaq.push(['_trackEvent','Chat','Start',uriSegments[1]+'/'+uriSegments[2],1,true]);
						return false;
					});
				}

				// Sidebar Test
				if ( $('#connect-sidebar').length )
				{
					var qForm = '<h2>Ask a Question</h2>\
								<form action="/cr/processor/question/" id="question" method="post">\
									<p>Have questions for us? Ask away!</p>\
									<label>\
										<span class="title">Name</span>\
										<input type="text" name="name" id="question-name">\
										<input type="text" name="first_name" id="question-first_name" class="honeypot">\
									</label>\
									<label>\
										<span class="title">Email</span>\
										<input type="email" name="email" id="question-email">\
									</label>\
									<label>\
										<span class="title">Question / Comment</span>\
										<textarea name="q" id="question-q"></textarea>\
									</label>\
									<button id="em-sub-submit" class="submit"><span>  Send &raquo; </span></button>\
								</form>';
					var qFormVal = {
						debug:true,
						rules: {
							name:'required',
							email: {
								required:true,
								email:true
							},
							q:'required'
						},
						errorClass:'invalid',
						highlight:function(e,ec) {
							$(e).addClass(ec);
						},
						unhighlight:function(e,ec) {
							$(e).removeClass(ec);
						},
						submitHandler:function(f) {
							formHide(f);
							$.ajax({
								type:'POST',
								url:$(f).attr('action'),
								dataType:'json',
								data:{
									action:'question',
									jssub:'1',
									direct:($('input#question-direct').length)?$('input#question-direct').val():'',
									name:$('input#question-name',f).val(),
									email:$('input#question-email',f).val(),
									first_name:$('input#question-first_name',f).val(),
									q:$('textarea#question-q',f).val()
								},
								success:function(json) {
									var m = '';
									if (json.success) {
										m = '<p class="message">'+json.message+'</p> \
											<!-- Google Code for Successful Contact Conversion Page --> \
											<script type="text/javascript"> \
											/* <![CDATA[ */ \
											var google_conversion_id = 1018188931; \
											var google_conversion_language = "en"; \
											var google_conversion_format = "3"; \
											var google_conversion_color = "ffffff"; \
											var google_conversion_label = "zMR5CJXfnwIQg6nB5QM"; \
											var google_conversion_value = 0; \
											/* ]]> */ \
											</script> \
											<script type="text/javascript" src="http://www.googleadservices.com/pagead/conversion.js"> \
											</script> \
											<noscript> \
											<div style="display:inline;"> \
											<img height="1" width="1" style="border-style:none;" alt="" src="http://www.googleadservices.com/pagead/conversion/1018188931/?label=zMR5CJXfnwIQg6nB5QM&amp;guid=ON&amp;script=0"/> \
											</div> \
											</noscript>';
										_gaq.push(['_trackEvent','Forms','Form Submitted','question']);
									} else {
										m = '<p class="message">'+json.message+'</p>';
										_gaq.push(['_trackEvent','Forms','Form Error','question, json error']);
									}
									formShow(f,m,false,100);
								},
								error:function(x,t,e) {
									var m = '<p class="message">There was a problem subscribing.</p>';
									formShow(f,m,true);
									_gaq.push(['_trackEvent','Forms','Form Error','question']);
								}
							});
						},
						invalidHandler: function(f,v) {
						},
						errorPlacement: function(err,el) {
						}
					}
					var emForm = '<h2>Newsletter Sign-up</h2>\
								<form action="/cr/processor/em-sub/" id="em-sub" method="post">\
									<p>Sign up for our newsletter.</p>\
									<label>\
										<span class="title">First Name</span>\
										<input type="text" name="fname" id="em-sub-fname">\
										<input type="text" name="first_name" id="em-sub-first_name" class="honeypot">\
									</label>\
									<label>\
										<span class="title">Last Name</span>\
										<input type="text" name="lname" id="em-sub-lname">\
									</label>\
									<label>\
										<span class="title">Email</span>\
										<input type="email" name="email" id="em-sub-email">\
									</label>\
									<button id="em-sub-submit" class="submit"><span> Sign-up &raquo; </span></button>\
								</form>';
					var emFormVal = {
						debug:true,
						rules: {
							fname:'required',
							lname:'required',
							email: {
								required:true,
								email:true
							}
						},
						errorClass:'invalid',
						highlight:function(e,ec) {
							$(e).addClass(ec);
						},
						unhighlight:function(e,ec) {
							$(e).removeClass(ec);
						},
						submitHandler:function(f) {
							formHide(f);
							$.ajax({
								type:'POST',
								url:$(f).attr('action'),
								dataType:'json',
								data:{
									action:'em-sub',
									jssub:'1',
									fname:$('input#em-sub-fname',f).val(),
									lname:$('input#em-sub-lname',f).val(),
									email:$('input#em-sub-email',f).val(),
									first_name:$('input#em-sub-first_name',f).val(),
									'em-sub':'1'
								},
								success:function(json) {
									var m = '';
									if (json.success) {
										m = '<p class="message">'+json.message+'</p>';
										_gaq.push(['_trackEvent','Forms','Form Submitted','em-sub']);
									} else {
										m = '<p class="message">'+json.message+'</p>';
										_gaq.push(['_trackEvent','Forms','Form Error','em-sub, json error']);
									}
									formShow(f,m,false,100);
								},
								error:function(x,t,e) {
									var m = '<p class="message">There was a problem subscribing.</p>';
									formShow(f,m,true);
									_gaq.push(['_trackEvent','Forms','Form Error','em-sub']);
								}
							});
						},
						invalidHandler: function(f,v) {
						},
						errorPlacement: function(err,el) {
						}
					}
					$('.employee-detail .contact-link a').click(function(){
						var linkWidth = $(this).width() + 16;
						$('.employee-detail .contact-link .pop-wrap').remove();
						$('<div class="pop-wrap" style="left:'+linkWidth+'px;bottom:-22px;font-size:1.5em;"><div class="pop">'+qForm+'</div><div class="pop-arrow"></div><div class="pop-close"></div></div>').appendTo('.employee-detail .contact-link');
						$('<input type="hidden" name="direct" id="question-direct" value="'+uriSegments[3]+'">').appendTo('.employee-detail .contact-link #question');
						$('.pop-wrap #question').validate(qFormVal);
						$('.contact-link .pop input:first').focus();
						// To Make Buttons Submit Forms (IE <= 7 Only)
						// And I'm putting this at the bottom because IE doesn't even know some of the forms exist yet.
						if ($.browser.msie && parseFloat($.browser.version) <= 7) {
							$('form button').click(function() {
								$(this).parents('form').submit();
							});
						}
						return false;
					});
					$('#connect-sidebar .button').has('a[href=#newsletter-form],a[href=#question-form]').click(function() {
						var sidebarHeight = $('#connect-sidebar').height();
						var buttonPosition = $(this).position();
						var buttonFromBottom = (sidebarHeight - (buttonPosition.top + $(this).height()));
						var currentForm = {};
						if ( $(this).has('a[href=#newsletter-form]').length )
						{
							currentForm.id = 'em-sub';
							currentForm.html = emForm;
							currentForm.valCfg = emFormVal;

						}
						if ( $(this).has('a[href=#question-form]').length )
						{
							currentForm.id = 'question';
							currentForm.html = qForm;
							currentForm.valCfg = qFormVal;
						}
						$('#connect-sidebar .pop-wrap').remove();
						
						/*
						$('#page-header').css('z-index','250');
						$('#page-body').css('z-index','1500');
						*/
						
						$('<div class="pop-wrap" style="bottom:'+buttonFromBottom+'px"><div class="pop">'+currentForm.html+'</div><div class="pop-arrow"></div><div class="pop-close"></div></div>').appendTo('#connect-sidebar');
						$('#'+currentForm.id).validate(currentForm.valCfg);
						$('#connect-sidebar .pop input:first').focus();
						
						// To Make Buttons Submit Forms (IE <= 7 Only)
						// And I'm putting this at the bottom because IE doesn't even know some of the forms exist yet.
						if ($.browser.msie && parseFloat($.browser.version) <= 7) {
							$('form button').click(function() {
								$(this).parents('form').submit();
							});
						}
						
						return false;
					});
					$('.pop-wrap .pop-close').live('click',function(){
						$('.pop-wrap').remove();
						
						/*
						$('#page-header').css('z-index','500');
						$('#page-body').css('z-index','250');
						*/
					});
				}

				// Slideshow. Better than ViewMaster
				if ($('#slideshow').length)
				{
					$('#slides').cycle({
						timeout:6000,
						fx:'scrollLeft',
						easeIn:'easeInQuint',
						pager:'#ctrl',
						cleartypeNoBg:true,
						pagerAnchorBuilder:function(i,s){ return '<li><a href="#"></a></li>'; },
						before:function(c,n){ (! $.browser.msie)? $('.image',c).fadeOut(100): $('.image',c).hide(); },
						after:function(c,n){ (! $.browser.msie)? $('.image',n).fadeIn(600): $('.image',n).show(); }
						});
					$('#slideshow').css('background','transparent');
				}

				// Primary Nav Menus
				$('#primary-nav > ul > li').each(function(){
					//$(this).css('position:relative')
					$(this).hoverIntent({
						timeout:300,
						over:function(){ $(this).addClass('hov') },
						out:function(){ $(this).removeClass('hov') }
					});
					if (uriSegments[1] == 'conversations')
					{
						$('#nav-full-conversations').addClass('active');
					}
					// Utilization Login Hack
					$('#nav-full-utilization-reports-log-in a,#nav-sub-utilization-reports-log-in a,a.utilization-reports-log-in').attr('target','_blank').addClass('external');
					// Conversations Link Rewrites
					$('#nav-full-social-media-feeds a').attr('href','/conversations/#social-media-tab');
					$('#nav-full-news-releases a').attr('href','/conversations/#news-releases-tab');
					
					
				});
				// Uptime Addition
				$('#nav-full-stimulus-award').after('<li class="last" id="nav-full-uptime"><a href="/uptime/">Uptime</a></li>');

				// Sidebar Nav Menu Tweaks
				if ($('#sub-nav').length)
				{
					$('#sub-nav li').each(function(){
						if ($('ul',this).length) { $(this).addClass('has-children'); }
					})
				}

				// Super PopBox
				if ( $('a.pop-box').length )
				{
					// var popHeight = ($(this).is('.virtual-office'))? 520: 480;
					$('a.pop-box').fancybox({
						type:'iframe',
						scrolling:'no',
						autoDimensions:false,
						width:720,
						height:520
					});
				}
				
				if ( $('a.pop-box-map').length )
				{
					$('a.pop-box-map').fancybox({
						type:'ajax',
						scrolling:'no',
						autoDimensions:false,
						width:720,
						height:520
					});
				}
				if ( $('a.pop-map').length )
				{
					$('a.pop-map').click(function(){
						window.open($(this).attr('href'),'_blank','width=720,height=520');
						return false;
					});
				}

				// VO PopBox


				// VO InfoBoxes
				if ( $('.vo-spot').length )
				{

					$('.vo-spot').click(function(){
						var spotPos = $(this).position();
						var spotDim = [$(this).width(),$(this).height()];
						var spotCenter = [Math.round(spotDim[0] / 2),Math.round(spotDim[1] / 2)];
						var spotCSS = ((spotPos.top + spotCenter[0]) > 235)?
										'bottom:'+(470 - spotDim[1] - spotPos.top)+'px;':
										'top:'+spotPos.top+'px;';
						spotCSS += ((spotPos.left + spotCenter[1]) > 360)?
										'right:'+(720 - spotPos.left)+'px;':
										'left:'+(spotPos.left + spotDim[0])+'px;';
						var spotContent = $(this).html();
						$('#vo-map .pop-wrap').remove();
						$('<div class="pop-wrap" style="'+spotCSS+'"><div class="pop">'+spotContent+'</div><div class="pop-close"></div></div>').appendTo('#vo-map');
					});
					$('#vo-map .pop-close').live('click',function(){
						$('#vo-map .pop-wrap').remove();
					});
				}

				// Super PopUps
				if ( $('a.pop-up').length )
				{
					$('a.pop-up').fancybox({
						type:'iframe',
						scrolling:'no',
						autoDimensions:false,
						width:720
					});
					$('a.pop-up[href$=jpg],a.pop-up[href$=png],a.pop-up[href$=gif]').fancybox();
				}

				// Section List MAGIC
				if ($('#section-list').length)
				{

					// Center & Fade In
					var sectOffset = (960 - ($('#section-list li').length * 120)) / 2;
					$('#section-list ul').css('paddingLeft',sectOffset+'px')
					// IE is funny. FUNNY.
					if ( ! $.support.opacity)
					{
						$('#section-list li').css({opacity:1,filter:''});
					}
					else
					{
						$('#section-list li').animate({opacity:1},400);
					}
					//$('#section-list li').css('zIndex','99').animate({opacity:1},400);

					var aWidth = ($('#section-list ul li').length + 1) * 940;
					$('#section-descriptions .article-wrap').css({width:aWidth+'px',height:'200px'});
					$('#section-list ul li').hoverIntent({
						over:function(){
							var mTop = ($('#section-list li').index(this) + 1) * 940;
							//if ( $.browser.msie ) mTop = mTop - 240;
							$('#section-descriptions .article-wrap').stop().animate({marginLeft:'-'+mTop+'px'},400,'easeInOutQuart');
							if ( ! $.browser.msie )
							{
								$('#section-list ul li .sel').fadeOut(100,function(){$(this).remove();});
								$('<span class="sel" />').hide().appendTo(this).fadeIn(400);
							}
							else
							{
								$('#section-list ul li .sel').remove();
								$('<span class="sel" />').hide().appendTo(this).show();
							}
							$('#page-body').addClass('set');
						},
						out:function(){}
						});
					$('#section-list ul').hoverIntent({
						over:function(){},
						out:function(){
							if ( ! $('#page-body.set').length)
							{
								$('#section-descriptions .article-wrap').stop().animate({marginLeft:'0px'},200,'easeInOutQuart');
							}
						}
					});
					$('#page-body').hoverIntent({
						over:function(){},
						out:function(){
							$(this).removeClass('set');
							$('#section-descriptions .article-wrap').stop().animate({marginLeft:'0px'},200,'easeInOutQuart');
							if ( ! $.browser.msie )
							{
								$('#section-list ul li .sel').fadeOut(100,function(){$(this).remove();});
							}
							else
							{
								$('#section-list ul li .sel').remove();
							}
						}
					});
				}

				// Tabbed Content. Nothing witty.
				if ($('#content-tabs').length)
				{
					$('#content-tabs').tabs();

					// Hanchorin' for some Anchors
					var ankh = window.location.href.split('#')[1];
					var selTab = false;
					if (ankh !== undefined && ankh != '')
					{
						if ( $('#'+ankh+'-tab').length )
						{
							selTab = ankh+'-tab';
							$('#content-tabs').tabs('select',selTab)
						}
						$('#tab-nav a[href=#testimonials-tab]').click(function(){
							_gaq.push(['_trackEvent','Testimonial Tab','View',currentURI,1,1]);
						});
					}
				}
				
				// Resource PDF File Tracking
				if ($('#resources-tab .resource-list li.pdf a').length) {
					$('#resources-tab .resource-list li.pdf a').click(function() {
						gaTrackEvent('Resource PDF','View',$(this).attr('href'));
						return false;
					});
				}

				// Buckets Click-a-billy
				if ($('#page-footer .buckets').length)
				{
					var flipIcon = function(){
						var img = [$('.icon',this).attr('src'),$('.icon',this).attr('hov')];
						if (img[1] != '') { $('.icon',this).attr('src',img[1]).attr('hov',img[0]); }
					}
					$('#page-footer .buckets li').hover(flipIcon,flipIcon);
					$('#page-footer .buckets a').click(function(){
						_gaq.push(['_trackEvent','Bucket','Click',$(this).attr('id'),1,1]);
					});
				}

				// FAQ Expand-o-matic.
				if ($('.faq-list').length)
				{
					$('.faq-list dd').each(function(){ $(this).css("height",$(this).height()).slideUp(100); });
					$('.faq-list dt').click(function(){
						if ($(this).is('.active'))
						{
							$(this).removeClass('active').next('dd').slideToggle(200);
						}
						else
						{
							$(this).addClass('active').next('dd').slideToggle(400,'easeInOutQuart');
						}
					});
				}

				// Employee Directory Expand-o-matic.
				if ($('.staff-category').length)
				{
					$('.staff-category h2').click(function(){
						var p = $(this).parents('.staff-category');
						if ($(p).is('.staff-active'))
						{
							$(p).removeClass('staff-active').children('.staff').slideToggle(200);
						}
						else
						{
							$(p).addClass('staff-active').children('.staff').slideToggle(400,'easeInOutQuart');
						}
					});
					$('.staff-featured h2').unbind('click').css('cursor','default');
				}

				/* /// FORM SUBMISSIONS /// */

				// Track Form Loads on GA
				if ($('form').length) {
					$('form').each(function() {
						var id = $(this).attr('id');
						if (id !== '') {
							id = (id == 'petition')? id + ' - ' + $('#petition-id').val(): id;
							_gaq.push(['_trackEvent','Forms','Form Loaded',id,1,1]);
						}
					});
				}

				// emSub Form Submission

				// Question Form Submission

				// Contact Form Submission
				if ($('form#contact').length)
				{
					var cFormVal = {
						debug:true,
						rules: {
							fname:'required',
							lname:'required',
							email: {
								required:true,
								email:true
							},
							comment:'required'
						},
						errorClass:'invalid',
						highlight:function(e,ec) {
							$(e).addClass(ec);
						},
						unhighlight:function(e,ec) {
							$(e).removeClass(ec);
						},
						submitHandler:function(f) {
							formHide(f);
							$.ajax({
								type:'POST',
								url:$(f).attr('action'),
								dataType:'json',
								data:{
									action:'contact',
									jssub:'1',
									subject:$('select#contact-subject',f).val(),
									fname:$('input#contact-fname',f).val(),
									lname:$('input#contact-lname',f).val(),
									email:$('input#contact-email',f).val(),
									address:$('input#contact-address',f).val(),
									city:$('input#contact-city',f).val(),
									state:$('input#contact-state',f).val(),
									zip:$('input#contact-zip',f).val(),
									phone:$('input#contact-phone',f).val(),
									comment:$('textarea#contact-comment',f).val(),
									first_name:$('input#contact-first_name',f).val()
								},
								success:function(json) {
									var m = '';
									if (json.success) {
										m = '<p class="message">'+json.message+'</p> \
											<!-- Google Code for Successful Contact Conversion Page --> \
											<script type="text/javascript"> \
											/* <![CDATA[ */ \
											var google_conversion_id = 1018188931; \
											var google_conversion_language = "en"; \
											var google_conversion_format = "3"; \
											var google_conversion_color = "ffffff"; \
											var google_conversion_label = "zMR5CJXfnwIQg6nB5QM"; \
											var google_conversion_value = 0; \
											/* ]]> */ \
											</script> \
											<script type="text/javascript" src="http://www.googleadservices.com/pagead/conversion.js"> \
											</script> \
											<noscript> \
											<div style="display:inline;"> \
											<img height="1" width="1" style="border-style:none;" alt="" src="http://www.googleadservices.com/pagead/conversion/1018188931/?label=zMR5CJXfnwIQg6nB5QM&amp;guid=ON&amp;script=0"/> \
											</div> \
											</noscript>';
										_gaq.push(['_trackEvent','Forms','Form Submitted','contact']);
									} else {
										m = '<p class="message">'+json.message+'</p>';
										_gaq.push(['_trackEvent','Forms','Form Error','contact, json error']);
									}
									$('.ie7 #interior-content').css('margin-right','-10px');
									formShow(f,m,false,100);
								},
								error:function(x,t,e) {
									var m = '<p class="message">There was a problem subscribing.</p>';
									formShow(f,m,true);
									$('.ie7 #interior-content').css('margin-right','-10px');
									_gaq.push(['_trackEvent','Forms','Form Error','contact']);
								}
							});
						},
						invalidHandler: function(f,v) {
						},
						errorPlacement: function(err,el) {
						}
					}
					$('form#contact').validate(cFormVal);
					// To Make Buttons Submit Forms (IE <= 7 Only)
					// And I'm putting this at the bottom because IE doesn't even know some of the forms exist yet.
					if ($.browser.msie && parseFloat($.browser.version) <= 7) {
						$('form button').click(function() {
							$(this).parents('form').submit();
						});
					}
				}
				
				// Contact Form Submission
				if ($('form#generic').length)
				{
					var cFormVal = {
						debug:true,
						rules: {
							name:'required',
							company:'required',
							email: {
								required:true,
								email:true
							},
							zip:'required'
						},
						errorClass:'invalid',
						highlight:function(e,ec) {
							$(e).addClass(ec);
						},
						unhighlight:function(e,ec) {
							$(e).removeClass(ec);
						},
						submitHandler:function(f) {
							formHide(f);
							var fName = $('input#generic-form',f).val();
							$.ajax({
								type:'POST',
								url:$(f).attr('action'),
								dataType:'json',
								data:{
									action:'generic',
									jssub:'1',
									form:fName,
									name:$('input#generic-name',f).val(),
									company:$('input#generic-company',f).val(),
									email:$('input#generic-email',f).val(),
									zip:$('input#generic-zip',f).val(),
									mobile:$('input#generic-mobile',f).val(),
									first_name:$('input#generic-first_name',f).val()
								},
								success:function(json) {
									var isLP = $('body.lp').length;
									var m = '';
									if (json.success) {
										m = '<p class="message">'+json.message+'</p> \
											<!-- Google Code for Successful Contact Conversion Page --> \
											<script type="text/javascript"> \
											/* <![CDATA[ */ \
											var google_conversion_id = 1018188931; \
											var google_conversion_language = "en"; \
											var google_conversion_format = "3"; \
											var google_conversion_color = "ffffff"; \
											var google_conversion_label = "zMR5CJXfnwIQg6nB5QM"; \
											var google_conversion_value = 0; \
											/* ]]> */ \
											</script> \
											<script type="text/javascript" src="http://www.googleadservices.com/pagead/conversion.js"> \
											</script> \
											<noscript> \
											<div style="display:inline;"> \
											<img height="1" width="1" style="border-style:none;" alt="" src="http://www.googleadservices.com/pagead/conversion/1018188931/?label=zMR5CJXfnwIQg6nB5QM&amp;guid=ON&amp;script=0"/> \
											</div> \
											</noscript>';
										m = '<p class="message">'+json.message+'</p>';
										_gaq.push(['_trackEvent','Forms','Form Submitted','generic-'+fName]);
									} else {
										m = '<p class="message">'+json.message+'</p>';
										_gaq.push(['_trackEvent','Forms','Form Error','generic-'+fName+', json error']);
									}
									$('.ie7 #interior-content').css('margin-right','-10px');
									
									if (isLP) {
										$('.pre-content').fadeOut(200,function(){
											$('body').removeClass('lp');
											$('#lp-foot-suppress').css('display','block');
											$('#section-descriptions').css('height','600px');
											$('.post-content').fadeIn(200,function(){
												$('.post-content .cc').load('/lp/cc/'+uriSegments[3]);
											});
										});
									} else { formShow(f,m,false,100); }
									
								},
								error:function(x,t,e) {
									var m = '<p class="message">There was a problem subscribing.</p>';
									formShow(f,m,true);
									$('.ie7 #interior-content').css('margin-right','-10px');
									_gaq.push(['_trackEvent','Forms','Form Error','generic'+fName]);
								}
							});
						},
						invalidHandler: function(f,v) {
						},
						errorPlacement: function(err,el) {
						}
					}
					$('form#generic').validate(cFormVal);
					// To Make Buttons Submit Forms (IE <= 7 Only)
					// And I'm putting this at the bottom because IE doesn't even know some of the forms exist yet.
					if ($.browser.msie && parseFloat($.browser.version) <= 7) {
						$('form button').click(function() {
							$(this).parents('form').submit();
						});
					}
				}
				
				if ($('.ie8,.ie9'))
				{
					$('body').css('background-image','url(/cr/images/body-bg.png)');
				}
				
				
				function gaTrackEvent(c,a,l) {
					_gaq.push(['_trackEvent',c,a,l,1,1]);
					window.setTimeout("window.location.href='" + l + "'", 500);
				}
				

				function formHide(f) {
					var fw = $(f).innerWidth();
					var fh = $(f).innerHeight();
					var fid = $(f).attr('id');
					$(f).parent('.fwrap').remove();
					$(f).wrap(function() {
						return '<div class="fwrap '+ fid +'" style="width:'+ fw +'px;height:'+ fh +'px" />';
					});
					$(f).fadeOut(400,function() {
						if ( ! $('div.fwrap.finished').length) $('div.fwrap.'+ fid).css('background','transparent url(/cr/images/spinner.gif) no-repeat center center');
					});
				}
				function formShow(f,m,r,h) {
					$(f).parent('.fwrap').prepend(m).addClass('finished').css('background','none');
					r = typeof(r) != 'undefined' ? r : false;
					if (r) $(f).show();
					h = typeof(h) != 'undefined' ? h : false;
					if (h && !r) $(f).parent('.fwrap').animate({height:h+'px'},200);
				}
			});
		}
	}
]);
