(function(e){function q(a){e.fn.cycle.debug&&m(a)}function m(){window.console&&console.log&&console.log("[cycle] "+Array.prototype.join.call(arguments," "))}function r(a,c,d){var f=e(a).data("cycle.opts"),g=!!a.cyclePause;if(g&&f.paused)f.paused(a,f,c,d);else!g&&f.resumed&&f.resumed(a,f,c,d)}function D(a,c,d){function f(b,h,j){if(!b&&h===true){b=e(j).data("cycle.opts");if(!b){m("options not found, can not resume");return false}if(j.cycleTimeout){clearTimeout(j.cycleTimeout);j.cycleTimeout=0}s(b.elements,
b,1,!b.backwards)}}if(a.cycleStop==undefined)a.cycleStop=0;if(c===undefined||c===null)c={};if(c.constructor==String)switch(c){case "destroy":case "stop":d=e(a).data("cycle.opts");if(!d)return false;a.cycleStop++;a.cycleTimeout&&clearTimeout(a.cycleTimeout);a.cycleTimeout=0;d.elements&&e(d.elements).stop();e(a).removeData("cycle.opts");c=="destroy"&&E(d);return false;case "toggle":a.cyclePause=a.cyclePause===1?0:1;f(a.cyclePause,d,a);r(a);return false;case "pause":a.cyclePause=1;r(a);return false;
case "resume":a.cyclePause=0;f(false,d,a);r(a);return false;case "prev":case "next":d=e(a).data("cycle.opts");if(!d){m('options not found, "prev/next" ignored');return false}e.fn.cycle[c](d);return false;default:c={fx:c}}else if(c.constructor==Number){var g=c;c=e(a).data("cycle.opts");if(!c){m("options not found, can not advance slide");return false}if(g<0||g>=c.elements.length){m("invalid slide index: "+g);return false}c.nextSlide=g;if(a.cycleTimeout){clearTimeout(a.cycleTimeout);a.cycleTimeout=
0}if(typeof d=="string")c.oneTimeFx=d;s(c.elements,c,1,g>=c.currSlide);return false}return c}function y(a,c){if(!e.support.opacity&&c.cleartype&&a.style.filter)try{a.style.removeAttribute("filter")}catch(d){}}function E(a){a.next&&e(a.next).unbind(a.prevNextEvent);a.prev&&e(a.prev).unbind(a.prevNextEvent);if(a.pager||a.pagerAnchorBuilder)e.each(a.pagerAnchors||[],function(){this.unbind().remove()});a.pagerAnchors=null;a.destroy&&a.destroy(a)}function F(a,c,d,f,g){var b=e.extend({},e.fn.cycle.defaults,
f||{},e.metadata?a.metadata():e.meta?a.data():{}),h=e.isFunction(a.data)?a.data(b.metaAttr):null;if(h)b=e.extend(b,h);if(b.autostop)b.countdown=b.autostopCount||d.length;var j=a[0];a.data("cycle.opts",b);b.$cont=a;b.stopCount=j.cycleStop;b.elements=d;b.before=b.before?[b.before]:[];b.after=b.after?[b.after]:[];!e.support.opacity&&b.cleartype&&b.after.push(function(){y(this,b)});b.continuous&&b.after.push(function(){s(d,b,0,!b.backwards)});G(b);!e.support.opacity&&b.cleartype&&!b.cleartypeNoBg&&z(c);
a.css("position")=="static"&&a.css("position","relative");b.width&&a.width(b.width);b.height&&b.height!="auto"&&a.height(b.height);if(b.startingSlide)b.startingSlide=parseInt(b.startingSlide,10);else if(b.backwards)b.startingSlide=d.length-1;if(b.random){b.randomMap=[];for(h=0;h<d.length;h++)b.randomMap.push(h);b.randomMap.sort(function(){return Math.random()-0.5});b.randomIndex=1;b.startingSlide=b.randomMap[1]}else if(b.startingSlide>=d.length)b.startingSlide=0;b.currSlide=b.startingSlide||0;var k=
b.startingSlide;c.css({position:"absolute",top:0,left:0}).hide().each(function(i){i=b.backwards?k?i<=k?d.length+(i-k):k-i:d.length-i:k?i>=k?d.length-(i-k):k-i:d.length-i;e(this).css("z-index",i)});e(d[k]).css("opacity",1).show();y(d[k],b);if(b.fit)if(b.aspect)c.each(function(){var i=e(this),t=b.aspect===true?i.width()/i.height():b.aspect;if(b.width&&i.width()!=b.width){i.width(b.width);i.height(b.width/t)}if(b.height&&i.height()<b.height){i.height(b.height);i.width(b.height*t)}});else{b.width&&c.width(b.width);
b.height&&b.height!="auto"&&c.height(b.height)}if(b.center&&(!b.fit||b.aspect))c.each(function(){var i=e(this);i.css({"margin-left":b.width?(b.width-i.width())/2+"px":0,"margin-top":b.height?(b.height-i.height())/2+"px":0})});b.center&&!b.fit&&!b.slideResize&&c.each(function(){var i=e(this);i.css({"margin-left":b.width?(b.width-i.width())/2+"px":0,"margin-top":b.height?(b.height-i.height())/2+"px":0})});if(b.containerResize&&!a.innerHeight()){for(var l=h=0,n=0;n<d.length;n++){var o=e(d[n]),u=o[0],
v=o.outerWidth(),w=o.outerHeight();v||(v=u.offsetWidth||u.width||o.attr("width"));w||(w=u.offsetHeight||u.height||o.attr("height"));h=v>h?v:h;l=w>l?w:l}h>0&&l>0&&a.css({width:h+"px",height:l+"px"})}var A=false;b.pause&&a.hover(function(){A=true;this.cyclePause++;r(j,true)},function(){A&&this.cyclePause--;r(j,true)});if(H(b)===false)return false;var B=false;f.requeueAttempts=f.requeueAttempts||0;c.each(function(){var i=e(this);this.cycleH=b.fit&&b.height?b.height:i.height()||this.offsetHeight||this.height||
i.attr("height")||0;this.cycleW=b.fit&&b.width?b.width:i.width()||this.offsetWidth||this.width||i.attr("width")||0;if(i.is("img")){i=e.browser.mozilla&&this.cycleW==34&&this.cycleH==19&&!this.complete;var t=e.browser.opera&&(this.cycleW==42&&this.cycleH==19||this.cycleW==37&&this.cycleH==17)&&!this.complete,I=this.cycleH==0&&this.cycleW==0&&!this.complete;if(e.browser.msie&&this.cycleW==28&&this.cycleH==30&&!this.complete||i||t||I)if(g.s&&b.requeueOnImageNotLoaded&&++f.requeueAttempts<100){m(f.requeueAttempts,
" - img slide not loaded, requeuing slideshow: ",this.src,this.cycleW,this.cycleH);setTimeout(function(){e(g.s,g.c).cycle(f)},b.requeueTimeout);B=true;return false}else m("could not determine size of image: "+this.src,this.cycleW,this.cycleH)}return true});if(B)return false;b.cssBefore=b.cssBefore||{};b.cssAfter=b.cssAfter||{};b.cssFirst=b.cssFirst||{};b.animIn=b.animIn||{};b.animOut=b.animOut||{};c.not(":eq("+k+")").css(b.cssBefore);e(c[k]).css(b.cssFirst);if(b.timeout){b.timeout=parseInt(b.timeout,
10);if(b.speed.constructor==String)b.speed=e.fx.speeds[b.speed]||parseInt(b.speed,10);b.sync||(b.speed/=2);for(h=b.fx=="none"?0:b.fx=="shuffle"?500:250;b.timeout-b.speed<h;)b.timeout+=b.speed}if(b.easing)b.easeIn=b.easeOut=b.easing;if(!b.speedIn)b.speedIn=b.speed;if(!b.speedOut)b.speedOut=b.speed;b.slideCount=d.length;b.currSlide=b.lastSlide=k;if(b.random){if(++b.randomIndex==d.length)b.randomIndex=0;b.nextSlide=b.randomMap[b.randomIndex]}else b.nextSlide=b.backwards?b.startingSlide==0?d.length-1:
b.startingSlide-1:b.startingSlide>=d.length-1?0:b.startingSlide+1;if(!b.multiFx){h=e.fn.cycle.transitions[b.fx];if(e.isFunction(h))h(a,c,b);else if(b.fx!="custom"&&!b.multiFx){m("unknown transition: "+b.fx,"; slideshow terminating");return false}}a=c[k];if(!b.skipInitializationCallbacks){b.before.length&&b.before[0].apply(a,[a,a,b,true]);b.after.length&&b.after[0].apply(a,[a,a,b,true])}b.next&&e(b.next).bind(b.prevNextEvent,function(){return x(b,1)});b.prev&&e(b.prev).bind(b.prevNextEvent,function(){return x(b,
0)});if(b.pager||b.pagerAnchorBuilder)J(d,b);K(b,d);return b}function G(a){a.original={before:[],after:[]};a.original.cssBefore=e.extend({},a.cssBefore);a.original.cssAfter=e.extend({},a.cssAfter);a.original.animIn=e.extend({},a.animIn);a.original.animOut=e.extend({},a.animOut);e.each(a.before,function(){a.original.before.push(this)});e.each(a.after,function(){a.original.after.push(this)})}function H(a){var c,d,f=e.fn.cycle.transitions;if(a.fx.indexOf(",")>0){a.multiFx=true;a.fxs=a.fx.replace(/\s*/g,
"").split(",");for(c=0;c<a.fxs.length;c++){var g=a.fxs[c];d=f[g];if(!d||!f.hasOwnProperty(g)||!e.isFunction(d)){m("discarding unknown transition: ",g);a.fxs.splice(c,1);c--}}if(!a.fxs.length){m("No valid transitions named; slideshow terminating.");return false}}else if(a.fx=="all"){a.multiFx=true;a.fxs=[];for(p in f){d=f[p];f.hasOwnProperty(p)&&e.isFunction(d)&&a.fxs.push(p)}}if(a.multiFx&&a.randomizeEffects){d=Math.floor(Math.random()*20)+30;for(c=0;c<d;c++)a.fxs.push(a.fxs.splice(Math.floor(Math.random()*
a.fxs.length),1)[0]);q("randomized fx sequence: ",a.fxs)}return true}function K(a,c){a.addSlide=function(d,f){var g=e(d),b=g[0];a.autostopCount||a.countdown++;c[f?"unshift":"push"](b);if(a.els)a.els[f?"unshift":"push"](b);a.slideCount=c.length;g.css("position","absolute");g[f?"prependTo":"appendTo"](a.$cont);if(f){a.currSlide++;a.nextSlide++}!e.support.opacity&&a.cleartype&&!a.cleartypeNoBg&&z(g);a.fit&&a.width&&g.width(a.width);a.fit&&a.height&&a.height!="auto"&&g.height(a.height);b.cycleH=a.fit&&
a.height?a.height:g.height();b.cycleW=a.fit&&a.width?a.width:g.width();g.css(a.cssBefore);if(a.pager||a.pagerAnchorBuilder)e.fn.cycle.createPagerAnchor(c.length-1,b,e(a.pager),c,a);if(e.isFunction(a.onAddSlide))a.onAddSlide(g);else g.hide()}}function s(a,c,d,f){if(d&&c.busy&&c.manualTrump){q("manualTrump in go(), stopping active transition");e(a).stop(true,true);c.busy=0}if(c.busy)q("transition active, ignoring new tx request");else{var g=c.$cont[0],b=a[c.currSlide],h=a[c.nextSlide];if(!(g.cycleStop!=
c.stopCount||g.cycleTimeout===0&&!d))if(!d&&!g.cyclePause&&!c.bounce&&(c.autostop&&--c.countdown<=0||c.nowrap&&!c.random&&c.nextSlide<c.currSlide))c.end&&c.end(c);else{var j=false;if((d||!g.cyclePause)&&c.nextSlide!=c.currSlide){j=true;var k=c.fx;b.cycleH=b.cycleH||e(b).height();b.cycleW=b.cycleW||e(b).width();h.cycleH=h.cycleH||e(h).height();h.cycleW=h.cycleW||e(h).width();if(c.multiFx){if(f&&(c.lastFx==undefined||++c.lastFx>=c.fxs.length))c.lastFx=0;else if(!f&&(c.lastFx==undefined||--c.lastFx<
0))c.lastFx=c.fxs.length-1;k=c.fxs[c.lastFx]}if(c.oneTimeFx){k=c.oneTimeFx;c.oneTimeFx=null}e.fn.cycle.resetState(c,k);c.before.length&&e.each(c.before,function(n,o){g.cycleStop==c.stopCount&&o.apply(h,[b,h,c,f])});var l=function(){c.busy=0;e.each(c.after,function(n,o){g.cycleStop==c.stopCount&&o.apply(h,[b,h,c,f])})};q("tx firing("+k+"); currSlide: "+c.currSlide+"; nextSlide: "+c.nextSlide);c.busy=1;if(c.fxFn)c.fxFn(b,h,c,l,f,d&&c.fastOnEvent);else if(e.isFunction(e.fn.cycle[c.fx]))e.fn.cycle[c.fx](b,
h,c,l,f,d&&c.fastOnEvent);else e.fn.cycle.custom(b,h,c,l,f,d&&c.fastOnEvent)}if(j||c.nextSlide==c.currSlide){c.lastSlide=c.currSlide;if(c.random){c.currSlide=c.nextSlide;if(++c.randomIndex==a.length)c.randomIndex=0;c.nextSlide=c.randomMap[c.randomIndex];if(c.nextSlide==c.currSlide)c.nextSlide=c.currSlide==c.slideCount-1?0:c.currSlide+1}else if(c.backwards)if((d=c.nextSlide-1<0)&&c.bounce){c.backwards=!c.backwards;c.nextSlide=1;c.currSlide=0}else{c.nextSlide=d?a.length-1:c.nextSlide-1;c.currSlide=
d?0:c.nextSlide+1}else if((d=c.nextSlide+1==a.length)&&c.bounce){c.backwards=!c.backwards;c.nextSlide=a.length-2;c.currSlide=a.length-1}else{c.nextSlide=d?0:c.nextSlide+1;c.currSlide=d?a.length-1:c.nextSlide-1}}j&&c.pager&&c.updateActivePagerLink(c.pager,c.currSlide,c.activePagerClass);j=0;if(c.timeout&&!c.continuous)j=C(a[c.currSlide],a[c.nextSlide],c,f);else if(c.continuous&&g.cyclePause)j=10;if(j>0)g.cycleTimeout=setTimeout(function(){s(a,c,0,!c.backwards)},j)}}}function C(a,c,d,f){if(d.timeoutFn){for(a=
d.timeoutFn.call(a,a,c,d,f);d.fx!="none"&&a-d.speed<250;)a+=d.speed;q("calculated timeout: "+a+"; speed: "+d.speed);if(a!==false)return a}return d.timeout}function x(a,c){var d=c?1:-1,f=a.elements,g=a.$cont[0],b=g.cycleTimeout;if(b){clearTimeout(b);g.cycleTimeout=0}if(a.random&&d<0){a.randomIndex--;if(--a.randomIndex==-2)a.randomIndex=f.length-2;else if(a.randomIndex==-1)a.randomIndex=f.length-1;a.nextSlide=a.randomMap[a.randomIndex]}else if(a.random)a.nextSlide=a.randomMap[a.randomIndex];else{a.nextSlide=
a.currSlide+d;if(a.nextSlide<0){if(a.nowrap)return false;a.nextSlide=f.length-1}else if(a.nextSlide>=f.length){if(a.nowrap)return false;a.nextSlide=0}}g=a.onPrevNextEvent||a.prevNextClick;e.isFunction(g)&&g(d>0,a.nextSlide,f[a.nextSlide]);s(f,a,1,c);return false}function J(a,c){var d=e(c.pager);e.each(a,function(f,g){e.fn.cycle.createPagerAnchor(f,g,d,a,c)});c.updateActivePagerLink(c.pager,c.startingSlide,c.activePagerClass)}function z(a){function c(f){f=parseInt(f,10).toString(16);return f.length<
2?"0"+f:f}function d(f){for(;f&&f.nodeName.toLowerCase()!="html";f=f.parentNode){var g=e.css(f,"background-color");if(g&&g.indexOf("rgb")>=0){f=g.match(/\d+/g);return"#"+c(f[0])+c(f[1])+c(f[2])}if(g&&g!="transparent")return g}return"#ffffff"}q("applying clearType background-color hack");a.each(function(){e(this).css("background-color",d(this))})}if(e.support==undefined)e.support={opacity:!e.browser.msie};e.expr[":"].paused=function(a){return a.cyclePause};e.fn.cycle=function(a,c){var d={s:this.selector,
c:this.context};if(this.length===0&&a!="stop"){if(!e.isReady&&d.s){m("DOM not ready, queuing slideshow");e(function(){e(d.s,d.c).cycle(a,c)});return this}m("terminating; zero elements found by selector"+(e.isReady?"":" (DOM not ready)"));return this}return this.each(function(){var f=D(this,a,c);if(f!==false){f.updateActivePagerLink=f.updateActivePagerLink||e.fn.cycle.updateActivePagerLink;this.cycleTimeout&&clearTimeout(this.cycleTimeout);this.cycleTimeout=this.cyclePause=0;var g=e(this),b=f.slideExpr?
e(f.slideExpr,this):g.children(),h=b.get(),j=F(g,b,h,f,d);if(j!==false)if(h.length<2)m("terminating; too few slides: "+h.length);else if(g=j.continuous?10:C(h[j.currSlide],h[j.nextSlide],j,!j.backwards)){g+=j.delay||0;if(g<10)g=10;q("first timeout: "+g);this.cycleTimeout=setTimeout(function(){s(h,j,0,!f.backwards)},g)}}})};e.fn.cycle.resetState=function(a,c){c=c||a.fx;a.before=[];a.after=[];a.cssBefore=e.extend({},a.original.cssBefore);a.cssAfter=e.extend({},a.original.cssAfter);a.animIn=e.extend({},
a.original.animIn);a.animOut=e.extend({},a.original.animOut);a.fxFn=null;e.each(a.original.before,function(){a.before.push(this)});e.each(a.original.after,function(){a.after.push(this)});var d=e.fn.cycle.transitions[c];e.isFunction(d)&&d(a.$cont,e(a.elements),a)};e.fn.cycle.updateActivePagerLink=function(a,c,d){e(a).each(function(){e(this).children().removeClass(d).eq(c).addClass(d)})};e.fn.cycle.next=function(a){x(a,1)};e.fn.cycle.prev=function(a){x(a,0)};e.fn.cycle.createPagerAnchor=function(a,
c,d,f,g){if(e.isFunction(g.pagerAnchorBuilder)){c=g.pagerAnchorBuilder(a,c);q("pagerAnchorBuilder("+a+", el) returned: "+c)}else c='<a href="#">'+(a+1)+"</a>";if(c){var b=e(c);if(b.parents("body").length===0){var h=[];if(d.length>1){d.each(function(){var l=b.clone(true);e(this).append(l);h.push(l[0])});b=e(h)}else b.appendTo(d)}g.pagerAnchors=g.pagerAnchors||[];g.pagerAnchors.push(b);d=function(l){l.preventDefault();g.nextSlide=a;l=g.$cont[0];var n=l.cycleTimeout;if(n){clearTimeout(n);l.cycleTimeout=
0}l=g.onPagerEvent||g.pagerClick;e.isFunction(l)&&l(g.nextSlide,f[g.nextSlide]);s(f,g,1,g.currSlide<a)};/mouseenter|mouseover/i.test(g.pagerEvent)?b.hover(d,function(){}):b.bind(g.pagerEvent,d);!/^click/.test(g.pagerEvent)&&!g.allowPagerClickBubble&&b.bind("click.cycle",function(){return false});var j=g.$cont[0],k=false;g.pauseOnPagerHover&&b.hover(function(){k=true;j.cyclePause++;r(j,true,true)},function(){k&&j.cyclePause--;r(j,true,true)})}};e.fn.cycle.hopsFromLast=function(a,c){var d=a.lastSlide,
f=a.currSlide;return c?f>d?f-d:a.slideCount-d:f<d?d-f:d+a.slideCount-f};e.fn.cycle.commonReset=function(a,c,d,f,g,b){e(d.elements).not(a).hide();if(typeof d.cssBefore.opacity=="undefined")d.cssBefore.opacity=1;d.cssBefore.display="block";if(d.slideResize&&f!==false&&c.cycleW>0)d.cssBefore.width=c.cycleW;if(d.slideResize&&g!==false&&c.cycleH>0)d.cssBefore.height=c.cycleH;d.cssAfter=d.cssAfter||{};d.cssAfter.display="none";e(a).css("zIndex",d.slideCount+(b===true?1:0));e(c).css("zIndex",d.slideCount+
(b===true?0:1))};e.fn.cycle.custom=function(a,c,d,f,g,b){var h=e(a),j=e(c),k=d.speedIn;a=d.speedOut;var l=d.easeIn;c=d.easeOut;j.css(d.cssBefore);if(b){k=typeof b=="number"?a=b:a=1;l=c=null}var n=function(){j.animate(d.animIn,k,l,function(){f()})};h.animate(d.animOut,a,c,function(){h.css(d.cssAfter);d.sync||n()});d.sync&&n()};e.fn.cycle.transitions={fade:function(a,c,d){c.not(":eq("+d.currSlide+")").css("opacity",0);d.before.push(function(f,g,b){e.fn.cycle.commonReset(f,g,b);b.cssBefore.opacity=0});
d.animIn={opacity:1};d.animOut={opacity:0};d.cssBefore={top:0,left:0}}};e.fn.cycle.ver=function(){return"2.9995"};e.fn.cycle.defaults={activePagerClass:"activeSlide",after:null,allowPagerClickBubble:false,animIn:null,animOut:null,aspect:false,autostop:0,autostopCount:0,backwards:false,before:null,center:null,cleartype:!e.support.opacity,cleartypeNoBg:false,containerResize:1,continuous:0,cssAfter:null,cssBefore:null,delay:0,easeIn:null,easeOut:null,easing:null,end:null,fastOnEvent:0,fit:0,fx:"fade",
fxFn:null,height:"auto",manualTrump:true,metaAttr:"cycle",next:null,nowrap:0,onPagerEvent:null,onPrevNextEvent:null,pager:null,pagerAnchorBuilder:null,pagerEvent:"click.cycle",pause:0,pauseOnPagerHover:0,prev:null,prevNextEvent:"click.cycle",random:0,randomizeEffects:1,requeueOnImageNotLoaded:true,requeueTimeout:250,rev:0,shuffle:null,skipInitializationCallbacks:false,slideExpr:null,slideResize:1,speed:1E3,speedIn:null,speedOut:null,startingSlide:0,sync:1,timeout:4E3,timeoutFn:null,updateActivePagerLink:null,
width:null}})(jQuery);

	
var te = {};

jQuery(document).ready(function($) {
	
	te.init();
	
	// HOME page
	if (te.elementExists('body#page_home .scrollable')){
		
		// slider & quotes
		te.homeSlider('#items');
		te.homeQuotes();
		
		// home page links
		$( '.home_box_nav' ).click(function() {
			var url = $(this).find('a').attr('href');
			window.location = url;
		});
		
		if (te.ie){
			$( '.home_box_nav' ).bind({
				mouseover: function (e) {
					$(this).css( 'cursor', 'pointer' );
				}
			});
		}
		
	}
	
	// ANSWERS page
	if (te.elementExists('#faq_wrapper')){
		te.faq();
	}
	
});

// generic functions
te.init = function(){
	
	$('link[rel=canonical]').attr('href',window.location);
	
	te.popup('a[rel=terms], map area[rel=terms]');

	if(jQuery().jFav) {	
		$('#content a.bookmark').jFav();
	}

	te.ie = $('html').hasClass('ie');
	te.ie_lte7 = $('html').hasClass('lte7');
	te.ie_lte8 = $('html').hasClass('lte8');
	
	if (te.ie_lte8) {
		$('.home_box_nav').append('<div class="ie" />');
	}
	
	// 
	// if (te.ie) {
	// 	te.buttonEnable();
	// }
	
	AXPShareIt.setup({ 
		message: "",
		linkOrder: [ "Facebook", "Twitter", "Digg"], 
		useHTTPCanonical: true 
	}); 
	AXPShareIt.links.Twitter.linktemplate = 'http://twitter.com/home?status=$msg$msgSfx$title $url';

};

te.elementExists = function(el){
	
	if (jQuery(el).length){
		return true;
	}
	return false;
	
};

te.homeQuotes = function(){

	var template = '<p><span class="quote_mark">“</span><span class="quote_text">{text}</span>&hellip;”</p><cite><b><span class="quote_name">{name}</span>, <span class="quote_location">{location}</span></b></cite>';
	var container = $(".home_rewardstories blockquote");
	$.ajaxSetup({
		cache: true
	});
	
	$.getJSON("./assets/inc/json/quotes.json", function(data) {
		var quotes_total = data.quotes.length;
		var random = Math.floor(quotes_total*Math.random());
		container.html($.nano(template, data.quotes[random]));
	});
	
};

te.homeSlider = function(el){
	
	jQuery(el).cycle({ 
		timeout: 8000,
		delay: -2000,
		fx: 'custom', 
		height: 'auto',
		speed:  600,
		pager:  '.slidetabs',
		activePagerClass: 'current',
		pagerAnchorBuilder: function(idx, slide) { 
                return '<a href="#">&bull;</a>';
        },
		cssBefore:{  
			left: 951,   
			top: 0,  
			display: 'block',
			opacity: 0
		}, 
		animIn: { opacity: 1, left: 0 },
		animOut: { left: -951 }
	});
	
	if (te.ie_lte7) { 
    // $('#content #items').click(function() {
    //       alert('x');
    // });
	}
	
	
};

te.popup = function(el){

	$( el ).click(function(e) {
		var width=465; 
		if ( $.browser.msie ) { width=466; }
		window.open($(this).attr( 'href' ),'','width='+width+',height=500,scrollbars=yes,menubar=0,location=0');
		return false;
	});

};

te.faq = function(){
	
	// add tabindex # dynamically to answers
	var i = 9;
	$( '#faq_panes dt' )
		.attr('tabindex', 
			function(){
				return i++;
			}
		)
		.keydown(function (e){
			var code = e.charCode || e.keyCode;
			//RETURN key
			if (code === 13) {
				te.toggleFAQanswer($(this));
			}
		});
	
	jQuery( 'ul.tabs' ).tabs( '#faq_panes > div' );
	
	var hash = location.hash;
	
	if (hash) { te.openFAQ(hash); }
	
	// Bind an event handler.
	// jQuery(window).hashchange( function(e) {
	// openFAQ(hash);
	// });
	
	$( 'dt' ).bind( 'click' , function() {
		
		var faq = jQuery(this);
		
		te.toggleFAQanswer(faq);

	});
	
};

te.toggleFAQanswer = function(faq){
	
	if (faq.hasClass( 'open' )) {
		
		faq.removeClass( 'open' )
		   .find( 'span' )
		   .text( '+' )
		   .parent().next( 'dd' )
		   .slideToggle( 'fast' );
		
		// location.hash = '#';
		
	}
	else
	{
		
		faq.addClass( 'open' )
		   .find( 'span' )
		   .text( '–' )
		   .parent().next( 'dd' )
		   .slideToggle( 'fast' );
		
		deeplink = faq.closest( 'dt' ).attr( 'id' );
		// if (deeplink) { location.hash = '#'+deeplink; }
	
		
	}	
	
	
};

te.openFAQ = function(hash){
	
	hash = hash.replace( '#', '' );
	
	var faq = $( 'dt[id='+hash+']' );
	var tabs_api = jQuery( 'ul.tabs' ).data( 'tabs' );
	var tabbed_content = faq.closest( 'div' );
	
	tabbed_content.show();
	// tabs_api.click(3);
	tabs_api.click( '#'+tabbed_content.attr( 'id' ));
	faq.addClass( 'open' );
	faq.find( 'span' ).text( '–' ).parent().next( 'dd' ).show();
	
	return false;
	
};

// custom easing called "custom"
$.easing.custom = function (x, t, b, c, d) {
		if ((t/=d/2) < 1) { return c/2*t*t*t*t*t + b; }
		return c/2*((t-=2)*t*t*t*t + 2) + b;
};

/* Nano Templates (Tomasz Mazur, Jacek Becela) */

(function($){
  $.nano = function(template, data) {
    return template.replace(/\{([\w\.]*)\}/g, function (str, key) {
      var keys = key.split("."), value = data[keys.shift()];
      $.each(keys, function () { value = value[this]; });
      return (value === null || value === undefined) ? "" : value;
    });
  };
})(jQuery);
