/*
 * General Site Script
 *
 */

/* carousellite */
eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('(6($){$.1g.1w=6(o){o=$.1f({r:n,x:n,N:n,17:q,J:n,L:1a,16:n,y:q,u:12,H:3,B:0,k:1,K:n,I:n},o||{});8 G.R(6(){p b=q,A=o.y?"15":"w",P=o.y?"t":"s";p c=$(G),9=$("9",c),E=$("10",9),W=E.Y(),v=o.H;7(o.u){9.1h(E.D(W-v-1+1).V()).1d(E.D(0,v).V());o.B+=v}p f=$("10",9),l=f.Y(),4=o.B;c.5("1c","H");f.5({U:"T",1b:o.y?"S":"w"});9.5({19:"0",18:"0",Q:"13","1v-1s-1r":"S","z-14":"1"});c.5({U:"T",Q:"13","z-14":"2",w:"1q"});p g=o.y?t(f):s(f);p h=g*l;p j=g*v;f.5({s:f.s(),t:f.t()});9.5(P,h+"C").5(A,-(4*g));c.5(P,j+"C");7(o.r)$(o.r).O(6(){8 m(4-o.k)});7(o.x)$(o.x).O(6(){8 m(4+o.k)});7(o.N)$.R(o.N,6(i,a){$(a).O(6(){8 m(o.u?o.H+i:i)})});7(o.17&&c.11)c.11(6(e,d){8 d>0?m(4-o.k):m(4+o.k)});7(o.J)1p(6(){m(4+o.k)},o.J+o.L);6 M(){8 f.D(4).D(0,v)};6 m(a){7(!b){7(o.K)o.K.Z(G,M());7(o.u){7(a<=o.B-v-1){9.5(A,-((l-(v*2))*g)+"C");4=a==o.B-v-1?l-(v*2)-1:l-(v*2)-o.k}F 7(a>=l-v+1){9.5(A,-((v)*g)+"C");4=a==l-v+1?v+1:v+o.k}F 4=a}F{7(a<0||a>l-v)8;F 4=a}b=12;9.1o(A=="w"?{w:-(4*g)}:{15:-(4*g)},o.L,o.16,6(){7(o.I)o.I.Z(G,M());b=q});7(!o.u){$(o.r+","+o.x).1n("X");$((4-o.k<0&&o.r)||(4+o.k>l-v&&o.x)||[]).1m("X")}}8 q}})};6 5(a,b){8 1l($.5(a[0],b))||0};6 s(a){8 a[0].1k+5(a,\'1j\')+5(a,\'1i\')};6 t(a){8 a[0].1t+5(a,\'1u\')+5(a,\'1e\')}})(1x);',62,96,'||||curr|css|function|if|return|ul|||||||||||scroll|itemLength|go|null||var|false|btnPrev|width|height|circular||left|btnNext|vertical||animCss|start|px|slice|tLi|else|this|visible|afterEnd|auto|beforeStart|speed|vis|btnGo|click|sizeCss|position|each|none|hidden|overflow|clone|tl|disabled|size|call|li|mousewheel|true|relative|index|top|easing|mouseWheel|padding|margin|200|float|visibility|append|marginBottom|extend|fn|prepend|marginRight|marginLeft|offsetWidth|parseInt|addClass|removeClass|animate|setInterval|0px|type|style|offsetHeight|marginTop|list|jCarouselLite|jQuery'.split('|'),0,{}));

/* checkbox */
(function($){var i=function(e){if(!e)var e=window.event;e.cancelBubble=true;if(e.stopPropagation)e.stopPropagation()};$.fn.checkbox=function(f){try{document.execCommand('BackgroundImageCache',false,true)}catch(e){}var g={cls:'jquery-checkbox',empty:'empty.png'};g=$.extend(g,f||{});var h=function(a){var b=a.checked;var c=a.disabled;var d=$(a);if(a.stateInterval)clearInterval(a.stateInterval);a.stateInterval=setInterval(function(){if(a.disabled!=c)d.trigger((c=!!a.disabled)?'disable':'enable');if(a.checked!=b)d.trigger((b=!!a.checked)?'check':'uncheck')},10);return d};return this.each(function(){var a=this;var b=h(a);if(a.wrapper)a.wrapper.remove();a.wrapper=$('<span class="'+g.cls+'"><span class="mark"><img src="'+g.empty+'" /></span></span>');a.wrapperInner=a.wrapper.children('span:eq(0)');a.wrapper.hover(function(e){a.wrapperInner.addClass(g.cls+'-hover');i(e)},function(e){a.wrapperInner.removeClass(g.cls+'-hover');i(e)});b.css({position:'absolute',zIndex:-1,visibility:'hidden'}).after(a.wrapper);var c=false;if(b.attr('id')){c=$('label[for='+b.attr('id')+']');if(!c.length)c=false}if(!c){c=b.closest?b.closest('label'):b.parents('label:eq(0)');if(!c.length)c=false}if(c){c.hover(function(e){a.wrapper.trigger('mouseover',[e])},function(e){a.wrapper.trigger('mouseout',[e])});c.click(function(e){b.trigger('click',[e]);i(e);return false})}a.wrapper.click(function(e){b.trigger('click',[e]);i(e);return false});b.click(function(e){i(e)});b.bind('disable',function(){a.wrapperInner.addClass(g.cls+'-disabled')}).bind('enable',function(){a.wrapperInner.removeClass(g.cls+'-disabled')});b.bind('check',function(){a.wrapper.addClass(g.cls+'-checked')}).bind('uncheck',function(){a.wrapper.removeClass(g.cls+'-checked')});$('img',a.wrapper).bind('dragstart',function(){return false}).bind('mousedown',function(){return false});if(window.getSelection)a.wrapper.css('MozUserSelect','none');if(a.checked)a.wrapper.addClass(g.cls+'-checked');if(a.disabled)a.wrapperInner.addClass(g.cls+'-disabled')})}})(jQuery);

/*
jQuery(function(){
	jQuery('.hidden').removeClass('hidden');
    $("#footerCarousel").jCarouselLite({
        btnNext: ".carouselNext",
        btnPrev: ".prev",
        visible:4,
        speed: 400,
        scroll: 2
    });
});
*/

/*
$(document).ready(function(){
 
	$("form.signup input")
		.bind("focus.labelFx", function(){
			$(this).prev().hide();
		})
		.bind("blur.labelFx", function(){
			$(this).prev()[!this.value ? "show" : "hide"]();
		})
		.trigger("blur.labelFx");
 
});
*/

var labels = function(){
	
	this.id = '';
	this.text = '';
	this.className = '';
	
	this.run = function(){
				
		if ( jQuery(this.id).val() ==  '') {
			jQuery(this.id).val(this.text).addClass(this.className);
		}
		
		var that = this;
		jQuery(this.id).bind('dblclick' , function(){
			jQuery(that.id).val('');
			jQuery(that.id).removeClass(that.className);
		});
		jQuery(this.id).bind('focus' , function(){
			if (jQuery(that.id).val() == that.text){
				jQuery(that.id).val('').removeClass(that.className);
			}
		});
		jQuery(this.id).bind('blur' , function(){
			if (jQuery(that.id).val() == ''){
				jQuery(that.id).val(that.text).addClass(that.className);			
			}
		});
		
	};

};

/*

var rotator = {
	objCount :	0,
	counter	:	0,
	obj		:	'#homepageRotator',
	child	:	'LI',
	opacity	:	0.5,
	objItems	:	null,
	timer 	:	 null,
	time	: 	3000,
	fadeTime :	450,
	init	:	function(){
		this.objItems = jQuery(this.obj).children(this.child);
		this.objCount = this.objItems.length;
		jQuery(this.objItems).css({opacity : 0});
		this.run();
	},
	
	run	:	function(){
		this.fade(this.counter);
		this.counter ++;
		if (this.counter >= this.objCount) {
			this.counter = 0;
		}
		
		var that = this;
		clearTimeout(this.timer);
		this.timer = setTimeout(function(){that.run();} , that.time);
	},
	
	fade : function(count) {
		jQuery(this.objItems).fadeTo(this.fadeTime , this.opacity);
		jQuery(this.objItems[count]).fadeTo(this.fadeTime , 1);
	}		
};

*/

var featureImage = function() {
	
	this.imageList = null;
	this.featureObj = null;
	this.featureLen = null;
	this.autoTime = 2500;
	this.featureCount = 0;
	this.featureLen = null;
	this.fadeSpeed = 450;
	this.zindex = 1;

	this.load = function (container){
		
	jQuery( container ).hide();
	this.imageList = jQuery( container );
	this.featureLen = (this.imageList).length;
	this.set();
		
		// imageOff hides all features. This is removed from them all when first image has faded in.
		setTimeout(function(){ jQuery( container ).removeClass('imageOff') }, this.fadeSpeed);
	};
	
	this.set = function  (){
		
		this.featurObj = this.imageList[this.featureCount];
		jQuery(this.featurObj).css({'position' : 'absolute' ,  'z-index' : this.zindex }).hide();
		jQuery(this.featurObj).fadeIn(this.fadeSpeed);
		this.increment();
		
		// once images have rotated once, reset the z-index to 1 to prevent images overlapping anything else.
		if (this.featureCount == 0){
			jQuery(this.imageList).css('z-index' , 1);
			this.zindex = 1;
		}
		this.zindex = this.zindex+1;
		
		var that = this; // 'this' is out of scope in setTimeout
		setTimeout(function(){ that.set() } , this.autoTime);
	};
	
	this.increment = function (){
		if (this.featureCount >= this.featureLen-1){
			this.featureCount = 0;
		} else {
			this.featureCount++;
		}
	};
};

function bindHelperPopup(){
	
jQuery(".helperPopup a").hover( 
	function(){
			helperPopupIn(this); 
		} , 
	function(){
			helperPopupOut(this); 
		}
	);	
}

function helperPopupIn(obj){
	
	var parentObjPos = jQuery(obj).offset();
	
	jQuery(obj).next(".helperText").clone().attr('id' , 'popuphelper').prependTo(document.body);
	jQuery('#popuphelper').css('top' , (parentObjPos.top + 15) + 'px').css('left' , (parentObjPos.left - 5) + 'px').fadeIn('fast');
}
function helperPopupOut(obj){
	
	if (jQuery('#popuphelper')) {
		//jQuery('#popuphelper').fadeOut('fast' , function(){ jQuery('#popuphelper').remove(); });	
		jQuery('#popuphelper').remove();	
	}
	
	//jQuery(obj).next(".helperText").fadeOut('fast');
	
}


jQuery(function($){
	
	
	jQuery('#signup').bind('submit' , function(){
		var children = jQuery('#signup').find(':submit');
		jQuery(children).bind('click' , function(){
			return false;
			}).css('opacity' , 0.5);
	});
	
	bindHelperPopup();
	
	
	jQuery('h4.faq').bind('click' , function(){
		var obj = jQuery(this);
		if (jQuery(this).hasClass('faqOver')) {
			jQuery(this).removeClass('faqOver');
			obj.next().slideUp(100);
		} else {
			
			jQuery('h4.faq').removeClass('faqOver');
			obj.addClass('faqOver');
			jQuery('div.answer').hide();
			obj.next().slideDown(150);			
		}		
	});
	
	
	jQuery('.helpLink').bind('click' , function(){  
		jQuery(document.body).prepend('<div id="searchHelp"></div>');
		jQuery('#searchHelp').hide();
		jQuery.ajax({
			url : this.href,
			success : function(content){
				jQuery('#searchHelp').html(content).dialog({
					title : 'Search Help',
					width : 500,
					height: 340,
					position: 'center',
					modal: true ,
					resizable : false,
					closeText : 'Close',
					'close' : function(){jQuery('#searchHelp').remove();}		
				});
			}
		});

		return false;
	});
	jQuery('.standardButton').bind('mouseover', function(){jQuery(this).addClass('standardButtonOver');});
	jQuery('.standardButton').bind('mouseout', function(){jQuery(this).removeClass('standardButtonOver');});
	
	
	/* inline tabs function scroller */
	$(function() {
		$("ul.tabs").tabs("div.panes > div");
	});
	
	
	/* form script */
	$(document).ready(function(){
	  $("#form-application label").inFieldLabels();
	});

	
	$('.wpcf7-response-output').mouseenter(function() {
	  $(this).fadeOut();
	});
	
});






