	$(document).ready(function() {  
		

		//if submit button is clicked
		$('#submit').click(function () {
			
			//remove any error boxes
			$('.error, .done').remove();
			$('input, textarea').removeClass('hightlight');	
			$('input, textarea').focus(function(){
				$(this).removeClass('hightlight');
				$(this).parent().find('.error').remove();
			});		
			
			//Get the data from all the fields
			var name = $('input[name=name]');
			var email = $('input[name=email]');
			var subject = $('input[name=subject]');
			var checking = $('input[name=checking]');
			var comment = $('textarea[name=comment]');
			var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
	
			//Simple validation to make sure user entered something
			//If error found, add hightlight class to the text field
			if (name.val()=='') {
				name.addClass('hightlight')
				.parent().append('<span class="error">You forgot to enter your Name.</span>');
				return false;
			} else name.removeClass('hightlight');
			
			if (email.val()=='') {
				email.addClass('hightlight')
				.parent().append('<span class="error">You forgot to enter your Email.</span>');
				return false;
			} else if (!emailReg.test(email.val())){
				email.addClass('hightlight')
				.parent().append('<span class="error">Enter a valid Email.</span>');
				return false;
			} else email.removeClass('hightlight');
			
			if (comment.val()=='') {
				comment.addClass('hightlight')
				.parent().append('<span class="error">You forgot to enter your Comment.</span>');
				return false;
			} else comment.removeClass('hightlight');
			
			if (checking.val()!='') {
				$('.loading').text('Are you Human??? Please try again.').show();
				return false;
			}
			
			//organize the data properly
			var data = 'name=' + name.val() + '&email=' + email.val() + 'checking=' + checking.val() + '&subject=' + 
			subject.val() + '&comment='  + encodeURIComponent(comment.val());
			
			//disabled all the text fields
			//$('.text').attr('disabled','true');
			
			//show the loading sign
			$('.loading').text('Sending.....').show();
			$('.left').append('<div class="done"> <b>Thank you !</b> I have received your message.</div>');

			//start the ajax
			$.ajax({
				//this is the php file that processes the data and send mail
				url: "../process.php",	
				
				//GET method is used
				type: "GET",
	
				//pass the data			
				data: data,		
				
				//Do not cache the page
				cache: false,
				
				//success
				success: function (html) {				
					//if process.php returned 1/true (send mail success)
					if (html==1) {					
						//hide the form
						//$('.form').fadeOut('slow');					
						
						//show the success message
						$('.done').fadeIn('slow');
						$('.loading').hide();
						
					//if process.php returned 0/false (send mail failed)
					} else alert('Sorry, unexpected error. Please try again later.');				
				}		
			});
			
			//cancel the submit button default behaviours
			return false;
		});	
		
		//Background Slide
		$('a.link').click(function () {  
			$('#wrapper').scrollTo($(this).attr('href'), 800);
			setPosition($(this).attr('href'), '#cloud1', '0px', '400px', '800px', '1200px')
			setPosition($(this).attr('href'), '#cloud2', '0px', '800px', '1600px', '2400px')
			$('a.link').removeClass('selected');  
			$(this).addClass('selected');
			return false;  
		});  
		
		//Position avatar so links work in IE7 and below
		var content = $('#avatar');
		var offset = content.offset();
		var tWidth = content.width();
		var tLeft = offset.left;
		var tTop = offset.top;
		var me = $("#me");
		
		me.prependTo('body');
		me.css({'top':tTop,'left':tLeft + tWidth - 150});
		
		//Create speechbubble
		getTip = function() {
			var tTip = 
				"<div id='speechBubble'>"
			return tTip;
		}
		me.append(getTip());
		
		//Speechbubble pop out
		var speechBubble = $('#speechBubble');
		var tooltipOut = {    
			over: hoverOn,  
			out: hoveOut 
		};
		
		function hoverOn() {
			// Needs to be here for hoverIntent to work
		};
			
		function hoveOut() {
			speechBubble.fadeOut('fast');
		};
		
		$('#social').hoverIntent(tooltipOut);
		
		$('.tooltip').each(function(){
					
			var $this = $(this);
			var tTitle = (this.rel);
			
			var tooltipOn = {    
				 over: hoverOn,  
				 out: hoveOut 
			};
			
			function hoverOn() {
				speechBubble.html(tTitle)
				.fadeIn();
			};
			
			function hoveOut() {
				// Needs to be here for hoverIntent to work
			};
					
			$this.hoverIntent(tooltipOn);	
						
		});
				
		//Cycle activate
		$('#portfolio-slide')
		.before('<div id="portfolio-nav"></div>') 
		.cycle({
			fx: 'blindX' ,
			pager: '#portfolio-nav'
		});
		
		$('#testimonials-slide')
		.before('<div id="portfolio-prev"></div><div id="portfolio-next"></div>') 
		.cycle({
			fx: 'scrollVert',
			timeout: 7000,
			cleartype: true,
			cleartypeNoBg: true,
			prev: '#portfolio-prev',
			next: '#portfolio-next'
		});
		
		//Check what tab page is on when loading then place active class on correct menu item
		var portfolioLink = $('.portfolio a');
		var menuLink = $('a.link');
		
		if (location.href.match(/\#box2/)) {
        	menuLink.removeClass('selected');  
			portfolioLink.addClass('selected');  
		} else if (location.href.match(/\#box4/)) {
        	menuLink.removeClass('selected');  
			portfolioLink.addClass('selected'); 
		}

	});
	
	//Slide function 
	function setPosition(check, div, p1, p2, p3, p4) {
	if(check==='#box1')
		{
			$(div).scrollTo(p1, 800);
		}
	else if(check==='#box2')
		{
			$(div).scrollTo(p2, 800);
		}
	else if(check==='#box3')
		{
			$(div).scrollTo(p3, 800);
		}
	else
		{
			$(div).scrollTo(p4, 800);
		}
	}; 
	
	
/**
* hoverIntent r6 // 2011.02.26 // jQuery 1.5.1+
* <http://cherne.net/brian/resources/jquery.hoverIntent.html>
* 
* @param  f  onMouseOver function || An object with configuration options
* @param  g  onMouseOut function  || Nothing (use configuration options object)
* @author    Brian Cherne brian(at)cherne(dot)net
*/
(function($){$.fn.hoverIntent=function(f,g){var cfg={sensitivity:7,interval:100,timeout:0};cfg=$.extend(cfg,g?{over:f,out:g}:f);var cX,cY,pX,pY;var track=function(ev){cX=ev.pageX;cY=ev.pageY};var compare=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);if((Math.abs(pX-cX)+Math.abs(pY-cY))<cfg.sensitivity){$(ob).unbind("mousemove",track);ob.hoverIntent_s=1;return cfg.over.apply(ob,[ev])}else{pX=cX;pY=cY;ob.hoverIntent_t=setTimeout(function(){compare(ev,ob)},cfg.interval)}};var delay=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);ob.hoverIntent_s=0;return cfg.out.apply(ob,[ev])};var handleHover=function(e){var ev=jQuery.extend({},e);var ob=this;if(ob.hoverIntent_t){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t)}if(e.type=="mouseenter"){pX=ev.pageX;pY=ev.pageY;$(ob).bind("mousemove",track);if(ob.hoverIntent_s!=1){ob.hoverIntent_t=setTimeout(function(){compare(ev,ob)},cfg.interval)}}else{$(ob).unbind("mousemove",track);if(ob.hoverIntent_s==1){ob.hoverIntent_t=setTimeout(function(){delay(ev,ob)},cfg.timeout)}}};return this.bind('mouseenter',handleHover).bind('mouseleave',handleHover)}})(jQuery);
	
	
/**
 * jQuery.ScrollTo - Easy element scrolling using jQuery.
 * Copyright (c) 2007-2009 Ariel Flesler - aflesler(at)gmail(dot)com | http://flesler.blogspot.com
 * Dual licensed under MIT and GPL.
 * Date: 5/25/2009
 * @author Ariel Flesler
 * @version 1.4.2
 *
 * http://flesler.blogspot.com/2007/10/jqueryscrollto.html
 */
;(function(d){var k=d.scrollTo=function(a,i,e){d(window).scrollTo(a,i,e)};k.defaults={axis:'xy',duration:parseFloat(d.fn.jquery)>=1.3?0:1};k.window=function(a){return d(window)._scrollable()};d.fn._scrollable=function(){return this.map(function(){var a=this,i=!a.nodeName||d.inArray(a.nodeName.toLowerCase(),['iframe','#document','html','body'])!=-1;if(!i)return a;var e=(a.contentWindow||a).document||a.ownerDocument||a;return d.browser.safari||e.compatMode=='BackCompat'?e.body:e.documentElement})};d.fn.scrollTo=function(n,j,b){if(typeof j=='object'){b=j;j=0}if(typeof b=='function')b={onAfter:b};if(n=='max')n=9e9;b=d.extend({},k.defaults,b);j=j||b.speed||b.duration;b.queue=b.queue&&b.axis.length>1;if(b.queue)j/=2;b.offset=p(b.offset);b.over=p(b.over);return this._scrollable().each(function(){var q=this,r=d(q),f=n,s,g={},u=r.is('html,body');switch(typeof f){case'number':case'string':if(/^([+-]=)?\d+(\.\d+)?(px|%)?$/.test(f)){f=p(f);break}f=d(f,this);case'object':if(f.is||f.style)s=(f=d(f)).offset()}d.each(b.axis.split(''),function(a,i){var e=i=='x'?'Left':'Top',h=e.toLowerCase(),c='scroll'+e,l=q[c],m=k.max(q,i);if(s){g[c]=s[h]+(u?0:l-r.offset()[h]);if(b.margin){g[c]-=parseInt(f.css('margin'+e))||0;g[c]-=parseInt(f.css('border'+e+'Width'))||0}g[c]+=b.offset[h]||0;if(b.over[h])g[c]+=f[i=='x'?'width':'height']()*b.over[h]}else{var o=f[h];g[c]=o.slice&&o.slice(-1)=='%'?parseFloat(o)/100*m:o}if(/^\d+$/.test(g[c]))g[c]=g[c]<=0?0:Math.min(g[c],m);if(!a&&b.queue){if(l!=g[c])t(b.onAfterFirst);delete g[c]}});t(b.onAfter);function t(a){r.animate(g,j,b.easing,a&&function(){a.call(this,n,b)})}}).end()};k.max=function(a,i){var e=i=='x'?'Width':'Height',h='scroll'+e;if(!d(a).is('html,body'))return a[h]-d(a)[e.toLowerCase()]();var c='client'+e,l=a.ownerDocument.documentElement,m=a.ownerDocument.body;return Math.max(l[h],m[h])-Math.min(l[c],m[c])};function p(a){return typeof a=='object'?a:{top:a,left:a}}})(jQuery);


/*!
 * jQuery Cycle Plugin (with Transition Definitions)
 * Examples and documentation at: http://jquery.malsup.com/cycle/
 * Copyright (c) 2007-2010 M. Alsup
 * Version: 2.9995 (09-AUG-2011)
 * Dual licensed under the MIT and GPL licenses.
 * http://jquery.malsup.com/license.html
 * Requires: jQuery v1.3.2 or later
 */
(function(a){var n="click.cycle",m="none",o="absolute",j="auto",l="position",d=true,c=null,g="cycle.opts",b=false,A="2.9995";if(a.support==undefined)a.support={opacity:!a.browser.msie};function f(b){a.fn.cycle.debug&&e(b)}function e(){window.console&&console.log&&console.log("[cycle] "+Array.prototype.join.call(arguments," "))}a.expr[":"].paused=function(a){return a.cyclePause};a.fn.cycle=function(g,h){var c=this,d={s:c.selector,c:c.context};if(c.length===0&&g!="stop"){if(!a.isReady&&d.s){e("DOM not ready, queuing slideshow");a(function(){a(d.s,d.c).cycle(g,h)});return c}e("terminating; zero elements found by selector"+(a.isReady?"":" (DOM not ready)"));return c}return c.each(function(){var c=this,k=v(c,g,h);if(k===b)return;k.updateActivePagerLink=k.updateActivePagerLink||a.fn.cycle.updateActivePagerLink;c.cycleTimeout&&clearTimeout(c.cycleTimeout);c.cycleTimeout=c.cyclePause=0;var o=a(c),n=k.slideExpr?a(k.slideExpr,c):o.children(),m=n.get(),j=x(o,n,m,k,d);if(j===b)return;if(m.length<2){e("terminating; too few slides: "+m.length);return}var l=j.continuous?10:s(m[j.currSlide],m[j.nextSlide],j,!j.backwards);if(l){l+=j.delay||0;if(l<10)l=10;f("first timeout: "+l);c.cycleTimeout=setTimeout(function(){i(m,j,0,!k.backwards)},l)}})};function h(c,d,e){var b=a(c).data(g),f=!!c.cyclePause;if(f&&b.paused)b.paused(c,b,d,e);else!f&&b.resumed&&b.resumed(c,b,d,e)}function v(f,j,m){if(f.cycleStop==undefined)f.cycleStop=0;if(j===undefined||j===c)j={};if(j.constructor==String){switch(j){case"destroy":case"stop":var k=a(f).data(g);if(!k)return b;f.cycleStop++;f.cycleTimeout&&clearTimeout(f.cycleTimeout);f.cycleTimeout=0;k.elements&&a(k.elements).stop();a(f).removeData(g);j=="destroy"&&z(k);return b;case"toggle":f.cyclePause=f.cyclePause===1?0:1;n(f.cyclePause,m,f);h(f);return b;case"pause":f.cyclePause=1;h(f);return b;case"resume":f.cyclePause=0;n(b,m,f);h(f);return b;case"prev":case"next":var k=a(f).data(g);if(!k){e('options not found, "prev/next" ignored');return b}a.fn.cycle[j](k);return b;default:j={fx:j}}return j}else if(j.constructor==Number){var l=j;j=a(f).data(g);if(!j){e("options not found, can not advance slide");return b}if(l<0||l>=j.elements.length){e("invalid slide index: "+l);return b}j.nextSlide=l;if(f.cycleTimeout){clearTimeout(f.cycleTimeout);f.cycleTimeout=0}if(typeof m=="string")j.oneTimeFx=m;i(j.elements,j,1,l>=j.currSlide);return b}return j;function n(h,j,f){if(!h&&j===d){var c=a(f).data(g);if(!c){e("options not found, can not resume");return b}if(f.cycleTimeout){clearTimeout(f.cycleTimeout);f.cycleTimeout=0}i(c.elements,c,1,!c.backwards)}}}function r(b,c){if(!a.support.opacity&&c.cleartype&&b.style.filter)try{b.style.removeAttribute("filter")}catch(d){}}function z(b){b.next&&a(b.next).unbind(b.prevNextEvent);b.prev&&a(b.prev).unbind(b.prevNextEvent);(b.pager||b.pagerAnchorBuilder)&&a.each(b.pagerAnchors||[],function(){this.unbind().remove()});b.pagerAnchors=c;b.destroy&&b.destroy(b)}function x(p,v,n,z,K){var x="px",f=a.extend({},a.fn.cycle.defaults,z||{},a.metadata?p.metadata():a.meta?p.data():{}),O=a.isFunction(p.data)?p.data(f.metaAttr):c;if(O)f=a.extend(f,O);if(f.autostop)f.countdown=f.autostopCount||n.length;var H=p[0];p.data(g,f);f.$cont=p;f.stopCount=H.cycleStop;f.elements=n;f.before=f.before?[f.before]:[];f.after=f.after?[f.after]:[];!a.support.opacity&&f.cleartype&&f.after.push(function(){r(this,f)});f.continuous&&f.after.push(function(){i(n,f,0,!f.backwards)});u(f);!a.support.opacity&&f.cleartype&&!f.cleartypeNoBg&&q(v);p.css(l)=="static"&&p.css(l,"relative");f.width&&p.width(f.width);f.height&&f.height!=j&&p.height(f.height);if(f.startingSlide)f.startingSlide=parseInt(f.startingSlide,10);else if(f.backwards)f.startingSlide=n.length-1;if(f.random){f.randomMap=[];for(var I=0;I<n.length;I++)f.randomMap.push(I);f.randomMap.sort(function(){return Math.random()-.5});f.randomIndex=1;f.startingSlide=f.randomMap[1]}else if(f.startingSlide>=n.length)f.startingSlide=0;f.currSlide=f.startingSlide||0;var s=f.startingSlide;v.css({position:o,top:0,left:0}).hide().each(function(b){var c;if(f.backwards)c=s?b<=s?n.length+(b-s):s-b:n.length-b;else c=s?b>=s?n.length-(b-s):s-b:n.length-b;a(this).css("z-index",c)});a(n[s]).css("opacity",1).show();r(n[s],f);if(f.fit)if(!f.aspect){f.width&&v.width(f.width);f.height&&f.height!=j&&v.height(f.height)}else v.each(function(){var b=a(this),c=f.aspect===d?b.width()/b.height():f.aspect;if(f.width&&b.width()!=f.width){b.width(f.width);b.height(f.width/c)}if(f.height&&b.height()<f.height){b.height(f.height);b.width(f.height*c)}});f.center&&(!f.fit||f.aspect)&&v.each(function(){var b=a(this);b.css({"margin-left":f.width?(f.width-b.width())/2+x:0,"margin-top":f.height?(f.height-b.height())/2+x:0})});f.center&&!f.fit&&!f.slideResize&&v.each(function(){var b=a(this);b.css({"margin-left":f.width?(f.width-b.width())/2+x:0,"margin-top":f.height?(f.height-b.height())/2+x:0})});var P=f.containerResize&&!p.innerHeight();if(P){for(var C=0,B=0,J=0;J<n.length;J++){var D=a(n[J]),E=D[0],G=D.outerWidth(),F=D.outerHeight();if(!G)G=E.offsetWidth||E.width||D.attr("width");if(!F)F=E.offsetHeight||E.height||D.attr("height");C=G>C?G:C;B=F>B?F:B}C>0&&B>0&&p.css({width:C+x,height:B+x})}var L=b;f.pause&&p.hover(function(){L=d;this.cyclePause++;h(H,d)},function(){L&&this.cyclePause--;h(H,d)});if(t(f)===b)return b;var M=b;z.requeueAttempts=z.requeueAttempts||0;v.each(function(){var c=this,g=a(c);c.cycleH=f.fit&&f.height?f.height:g.height()||c.offsetHeight||c.height||g.attr("height")||0;c.cycleW=f.fit&&f.width?f.width:g.width()||c.offsetWidth||c.width||g.attr("width")||0;if(g.is("img")){var j=a.browser.msie&&c.cycleW==28&&c.cycleH==30&&!c.complete,i=a.browser.mozilla&&c.cycleW==34&&c.cycleH==19&&!c.complete,k=a.browser.opera&&(c.cycleW==42&&c.cycleH==19||c.cycleW==37&&c.cycleH==17)&&!c.complete,h=c.cycleH==0&&c.cycleW==0&&!c.complete;if(j||i||k||h)if(K.s&&f.requeueOnImageNotLoaded&&++z.requeueAttempts<100){e(z.requeueAttempts," - img slide not loaded, requeuing slideshow: ",c.src,c.cycleW,c.cycleH);setTimeout(function(){a(K.s,K.c).cycle(z)},f.requeueTimeout);M=d;return b}else e("could not determine size of image: "+c.src,c.cycleW,c.cycleH)}return d});if(M)return b;f.cssBefore=f.cssBefore||{};f.cssAfter=f.cssAfter||{};f.cssFirst=f.cssFirst||{};f.animIn=f.animIn||{};f.animOut=f.animOut||{};v.not(":eq("+s+")").css(f.cssBefore);a(v[s]).css(f.cssFirst);if(f.timeout){f.timeout=parseInt(f.timeout,10);if(f.speed.constructor==String)f.speed=a.fx.speeds[f.speed]||parseInt(f.speed,10);if(!f.sync)f.speed=f.speed/2;var Q=f.fx==m?0:f.fx=="shuffle"?500:250;while(f.timeout-f.speed<Q)f.timeout+=f.speed}if(f.easing)f.easeIn=f.easeOut=f.easing;if(!f.speedIn)f.speedIn=f.speed;if(!f.speedOut)f.speedOut=f.speed;f.slideCount=n.length;f.currSlide=f.lastSlide=s;if(f.random){if(++f.randomIndex==n.length)f.randomIndex=0;f.nextSlide=f.randomMap[f.randomIndex]}else if(f.backwards)f.nextSlide=f.startingSlide==0?n.length-1:f.startingSlide-1;else f.nextSlide=f.startingSlide>=n.length-1?0:f.startingSlide+1;if(!f.multiFx){var N=a.fn.cycle.transitions[f.fx];if(a.isFunction(N))N(p,v,f);else if(f.fx!="custom"&&!f.multiFx){e("unknown transition: "+f.fx,"; slideshow terminating");return b}}var A=v[s];if(!f.skipInitializationCallbacks){f.before.length&&f.before[0].apply(A,[A,A,f,d]);f.after.length&&f.after[0].apply(A,[A,A,f,d])}f.next&&a(f.next).bind(f.prevNextEvent,function(){return k(f,1)});f.prev&&a(f.prev).bind(f.prevNextEvent,function(){return k(f,0)});(f.pager||f.pagerAnchorBuilder)&&y(n,f);w(f,n);return f}function u(b){b.original={before:[],after:[]};b.original.cssBefore=a.extend({},b.cssBefore);b.original.cssAfter=a.extend({},b.cssAfter);b.original.animIn=a.extend({},b.animIn);b.original.animOut=a.extend({},b.animOut);a.each(b.before,function(){b.original.before.push(this)});a.each(b.after,function(){b.original.after.push(this)})}function t(c){var g,i,h=a.fn.cycle.transitions;if(c.fx.indexOf(",")>0){c.multiFx=d;c.fxs=c.fx.replace(/\s*/g,"").split(",");for(g=0;g<c.fxs.length;g++){var j=c.fxs[g];i=h[j];if(!i||!h.hasOwnProperty(j)||!a.isFunction(i)){e("discarding unknown transition: ",j);c.fxs.splice(g,1);g--}}if(!c.fxs.length){e("No valid transitions named; slideshow terminating.");return b}}else if(c.fx=="all"){c.multiFx=d;c.fxs=[];for(p in h){i=h[p];h.hasOwnProperty(p)&&a.isFunction(i)&&c.fxs.push(p)}}if(c.multiFx&&c.randomizeEffects){var k=Math.floor(Math.random()*20)+30;for(g=0;g<k;g++){var l=Math.floor(Math.random()*c.fxs.length);c.fxs.push(c.fxs.splice(l,1)[0])}f("randomized fx sequence: ",c.fxs)}return d}function w(b,c){b.addSlide=function(g,f){var d=a(g),e=d[0];if(!b.autostopCount)b.countdown++;c[f?"unshift":"push"](e);b.els&&b.els[f?"unshift":"push"](e);b.slideCount=c.length;d.css(l,o);d[f?"prependTo":"appendTo"](b.$cont);if(f){b.currSlide++;b.nextSlide++}!a.support.opacity&&b.cleartype&&!b.cleartypeNoBg&&q(d);b.fit&&b.width&&d.width(b.width);b.fit&&b.height&&b.height!=j&&d.height(b.height);e.cycleH=b.fit&&b.height?b.height:d.height();e.cycleW=b.fit&&b.width?b.width:d.width();d.css(b.cssBefore);(b.pager||b.pagerAnchorBuilder)&&a.fn.cycle.createPagerAnchor(c.length-1,e,a(b.pager),c,b);if(a.isFunction(b.onAddSlide))b.onAddSlide(d);else d.hide()}}a.fn.cycle.resetState=function(b,d){d=d||b.fx;b.before=[];b.after=[];b.cssBefore=a.extend({},b.original.cssBefore);b.cssAfter=a.extend({},b.original.cssAfter);b.animIn=a.extend({},b.original.animIn);b.animOut=a.extend({},b.original.animOut);b.fxFn=c;a.each(b.original.before,function(){b.before.push(this)});a.each(b.original.after,function(){b.after.push(this)});var e=a.fn.cycle.transitions[d];a.isFunction(e)&&e(b.$cont,a(b.elements),b)};function i(h,e,m,k){if(m&&e.busy&&e.manualTrump){f("manualTrump in go(), stopping active transition");a(h).stop(d,d);e.busy=0}if(e.busy){f("transition active, ignoring new tx request");return}var l=e.$cont[0],j=h[e.currSlide],g=h[e.nextSlide];if(l.cycleStop!=e.stopCount||l.cycleTimeout===0&&!m)return;if(!m&&!l.cyclePause&&!e.bounce&&(e.autostop&&--e.countdown<=0||e.nowrap&&!e.random&&e.nextSlide<e.currSlide)){e.end&&e.end(e);return}var q=b;if((m||!l.cyclePause)&&e.nextSlide!=e.currSlide){q=d;var o=e.fx;j.cycleH=j.cycleH||a(j).height();j.cycleW=j.cycleW||a(j).width();g.cycleH=g.cycleH||a(g).height();g.cycleW=g.cycleW||a(g).width();if(e.multiFx){if(k&&(e.lastFx==undefined||++e.lastFx>=e.fxs.length))e.lastFx=0;else if(!k&&(e.lastFx==undefined||--e.lastFx<0))e.lastFx=e.fxs.length-1;o=e.fxs[e.lastFx]}if(e.oneTimeFx){o=e.oneTimeFx;e.oneTimeFx=c}a.fn.cycle.resetState(e,o);e.before.length&&a.each(e.before,function(b,a){if(l.cycleStop!=e.stopCount)return;a.apply(g,[j,g,e,k])});var r=function(){e.busy=0;a.each(e.after,function(b,a){if(l.cycleStop!=e.stopCount)return;a.apply(g,[j,g,e,k])})};f("tx firing("+o+"); currSlide: "+e.currSlide+"; nextSlide: "+e.nextSlide);e.busy=1;if(e.fxFn)e.fxFn(j,g,e,r,k,m&&e.fastOnEvent);else if(a.isFunction(a.fn.cycle[e.fx]))a.fn.cycle[e.fx](j,g,e,r,k,m&&e.fastOnEvent);else a.fn.cycle.custom(j,g,e,r,k,m&&e.fastOnEvent)}if(q||e.nextSlide==e.currSlide){e.lastSlide=e.currSlide;if(e.random){e.currSlide=e.nextSlide;if(++e.randomIndex==h.length)e.randomIndex=0;e.nextSlide=e.randomMap[e.randomIndex];if(e.nextSlide==e.currSlide)e.nextSlide=e.currSlide==e.slideCount-1?0:e.currSlide+1}else if(e.backwards){var n=e.nextSlide-1<0;if(n&&e.bounce){e.backwards=!e.backwards;e.nextSlide=1;e.currSlide=0}else{e.nextSlide=n?h.length-1:e.nextSlide-1;e.currSlide=n?0:e.nextSlide+1}}else{var n=e.nextSlide+1==h.length;if(n&&e.bounce){e.backwards=!e.backwards;e.nextSlide=h.length-2;e.currSlide=h.length-1}else{e.nextSlide=n?0:e.nextSlide+1;e.currSlide=n?h.length-1:e.nextSlide-1}}}q&&e.pager&&e.updateActivePagerLink(e.pager,e.currSlide,e.activePagerClass);var p=0;if(e.timeout&&!e.continuous)p=s(h[e.currSlide],h[e.nextSlide],e,k);else if(e.continuous&&l.cyclePause)p=10;if(p>0)l.cycleTimeout=setTimeout(function(){i(h,e,0,!e.backwards)},p)}a.fn.cycle.updateActivePagerLink=function(d,c,b){a(d).each(function(){a(this).children().removeClass(b).eq(c).addClass(b)})};function s(d,e,a,g){if(a.timeoutFn){var c=a.timeoutFn.call(d,d,e,a,g);while(a.fx!=m&&c-a.speed<250)c+=a.speed;f("calculated timeout: "+c+"; speed: "+a.speed);if(c!==b)return c}return a.timeout}a.fn.cycle.next=function(a){k(a,1)};a.fn.cycle.prev=function(a){k(a,0)};function k(c,f){var e=f?1:-1,d=c.elements,j=c.$cont[0],g=j.cycleTimeout;if(g){clearTimeout(g);j.cycleTimeout=0}if(c.random&&e<0){c.randomIndex--;if(--c.randomIndex==-2)c.randomIndex=d.length-2;else if(c.randomIndex==-1)c.randomIndex=d.length-1;c.nextSlide=c.randomMap[c.randomIndex]}else if(c.random)c.nextSlide=c.randomMap[c.randomIndex];else{c.nextSlide=c.currSlide+e;if(c.nextSlide<0){if(c.nowrap)return b;c.nextSlide=d.length-1}else if(c.nextSlide>=d.length){if(c.nowrap)return b;c.nextSlide=0}}var h=c.onPrevNextEvent||c.prevNextClick;a.isFunction(h)&&h(e>0,c.nextSlide,d[c.nextSlide]);i(d,c,1,f);return b}function y(c,b){var d=a(b.pager);a.each(c,function(e,f){a.fn.cycle.createPagerAnchor(e,f,d,c,b)});b.updateActivePagerLink(b.pager,b.startingSlide,b.activePagerClass)}a.fn.cycle.createPagerAnchor=function(j,r,l,q,c){var g;if(a.isFunction(c.pagerAnchorBuilder)){g=c.pagerAnchorBuilder(j,r);f("pagerAnchorBuilder("+j+", el) returned: "+g)}else g='<a href="#">'+(j+1)+"</a>";if(!g)return;var e=a(g);if(e.parents("body").length===0){var p=[];if(l.length>1){l.each(function(){var b=e.clone(d);a(this).append(b);p.push(b[0])});e=a(p)}else e.appendTo(l)}c.pagerAnchors=c.pagerAnchors||[];c.pagerAnchors.push(e);var o=function(f){f.preventDefault();c.nextSlide=j;var e=c.$cont[0],b=e.cycleTimeout;if(b){clearTimeout(b);e.cycleTimeout=0}var d=c.onPagerEvent||c.pagerClick;a.isFunction(d)&&d(c.nextSlide,q[c.nextSlide]);i(q,c,1,c.currSlide<j)};if(/mouseenter|mouseover/i.test(c.pagerEvent))e.hover(o,function(){});else e.bind(c.pagerEvent,o);!/^click/.test(c.pagerEvent)&&!c.allowPagerClickBubble&&e.bind(n,function(){return b});var k=c.$cont[0],m=b;c.pauseOnPagerHover&&e.hover(function(){m=d;k.cyclePause++;h(k,d,d)},function(){m&&k.cyclePause--;h(k,d,d)})};a.fn.cycle.hopsFromLast=function(c,e){var d,a=c.lastSlide,b=c.currSlide;if(e)d=b>a?b-a:c.slideCount-a;else d=b<a?a-b:a+c.slideCount-b;return d};function q(d){var c="background-color";f("applying clearType background-color hack");function b(a){a=parseInt(a,10).toString(16);return a.length<2?"0"+a:a}function e(e){for(;e&&e.nodeName.toLowerCase()!="html";e=e.parentNode){var d=a.css(e,c);if(d&&d.indexOf("rgb")>=0){var f=d.match(/\d+/g);return"#"+b(f[0])+b(f[1])+b(f[2])}if(d&&d!="transparent")return d}return"#ffffff"}d.each(function(){a(this).css(c,e(this))})}a.fn.cycle.commonReset=function(f,e,c,i,h,g){a(c.elements).not(f).hide();if(typeof c.cssBefore.opacity=="undefined")c.cssBefore.opacity=1;c.cssBefore.display="block";if(c.slideResize&&i!==b&&e.cycleW>0)c.cssBefore.width=e.cycleW;if(c.slideResize&&h!==b&&e.cycleH>0)c.cssBefore.height=e.cycleH;c.cssAfter=c.cssAfter||{};c.cssAfter.display=m;a(f).css("zIndex",c.slideCount+(g===d?1:0));a(e).css("zIndex",c.slideCount+(g===d?0:1))};a.fn.cycle.custom=function(l,m,b,n,o,d){var i=a(l),j=a(m),f=b.speedIn,e=b.speedOut,h=b.easeIn,g=b.easeOut;j.css(b.cssBefore);if(d){if(typeof d=="number")f=e=d;else f=e=1;h=g=c}var k=function(){j.animate(b.animIn,f,h,function(){n()})};i.animate(b.animOut,e,g,function(){i.css(b.cssAfter);!b.sync&&k()});b.sync&&k()};a.fn.cycle.transitions={fade:function(d,c,b){c.not(":eq("+b.currSlide+")").css("opacity",0);b.before.push(function(c,d,b){a.fn.cycle.commonReset(c,d,b);b.cssBefore.opacity=0});b.animIn={opacity:1};b.animOut={opacity:0};b.cssBefore={top:0,left:0}}};a.fn.cycle.ver=function(){return A};a.fn.cycle.defaults={activePagerClass:"activeSlide",after:c,allowPagerClickBubble:b,animIn:c,animOut:c,aspect:b,autostop:0,autostopCount:0,backwards:b,before:c,center:c,cleartype:!a.support.opacity,cleartypeNoBg:b,containerResize:1,continuous:0,cssAfter:c,cssBefore:c,delay:0,easeIn:c,easeOut:c,easing:c,end:c,fastOnEvent:0,fit:0,fx:"fade",fxFn:c,height:j,manualTrump:d,metaAttr:"cycle",next:c,nowrap:0,onPagerEvent:c,onPrevNextEvent:c,pager:c,pagerAnchorBuilder:c,pagerEvent:n,pause:0,pauseOnPagerHover:0,prev:c,prevNextEvent:n,random:0,randomizeEffects:1,requeueOnImageNotLoaded:d,requeueTimeout:250,rev:0,shuffle:c,skipInitializationCallbacks:b,slideExpr:c,slideResize:1,speed:1e3,speedIn:c,speedOut:c,startingSlide:0,sync:1,timeout:4e3,timeoutFn:c,updateActivePagerLink:c,width:c}})(jQuery);
/*!
 * jQuery Cycle Plugin Transition Definitions
 * This script is a plugin for the jQuery Cycle Plugin
 * Examples and documentation at: http://malsup.com/jquery/cycle/
 * Copyright (c) 2007-2010 M. Alsup
 * Version:	 2.73
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 */
(function(a){var f=10,c=false,e="hidden",d="overflow",b=true,g="block";a.fn.cycle.transitions.none=function(d,c,b){b.fxFn=function(c,d,e,b){a(d).show();a(c).hide();b()}};a.fn.cycle.transitions.fadeout=function(e,d,c){d.not(":eq("+c.currSlide+")").css({display:g,opacity:1});c.before.push(function(e,f,c,h,g,d){a(e).css("zIndex",c.slideCount+(!d===b?1:0));a(f).css("zIndex",c.slideCount+(!d===b?0:1))});c.animIn.opacity=1;c.animOut.opacity=0;c.cssBefore.opacity=1;c.cssBefore.display=g;c.cssAfter.zIndex=0};a.fn.cycle.transitions.scrollUp=function(c,g,b){c.css(d,e);b.before.push(a.fn.cycle.commonReset);var f=c.height();b.cssBefore.top=f;b.cssBefore.left=0;b.cssFirst.top=0;b.animIn.top=0;b.animOut.top=-f};a.fn.cycle.transitions.scrollDown=function(c,g,b){c.css(d,e);b.before.push(a.fn.cycle.commonReset);var f=c.height();b.cssFirst.top=0;b.cssBefore.top=-f;b.cssBefore.left=0;b.animIn.top=0;b.animOut.top=f};a.fn.cycle.transitions.scrollLeft=function(c,g,b){c.css(d,e);b.before.push(a.fn.cycle.commonReset);var f=c.width();b.cssFirst.left=0;b.cssBefore.left=f;b.cssBefore.top=0;b.animIn.left=0;b.animOut.left=0-f};a.fn.cycle.transitions.scrollRight=function(c,g,b){c.css(d,e);b.before.push(a.fn.cycle.commonReset);var f=c.width();b.cssFirst.left=0;b.cssBefore.left=-f;b.cssBefore.top=0;b.animIn.left=0;b.animOut.left=f};a.fn.cycle.transitions.scrollHorz=function(c,f,b){c.css(d,e).width();b.before.push(function(d,e,b,c){if(b.rev)c=!c;a.fn.cycle.commonReset(d,e,b);b.cssBefore.left=c?e.cycleW-1:1-e.cycleW;b.animOut.left=c?-d.cycleW:d.cycleW});b.cssFirst.left=0;b.cssBefore.top=0;b.animIn.left=0;b.animOut.top=0};a.fn.cycle.transitions.scrollVert=function(c,f,b){c.css(d,e);b.before.push(function(d,e,b,c){if(b.rev)c=!c;a.fn.cycle.commonReset(d,e,b);b.cssBefore.top=c?1-e.cycleH:e.cycleH-1;b.animOut.top=c?d.cycleH:-d.cycleH});b.cssFirst.top=0;b.cssBefore.left=0;b.animIn.top=0;b.animOut.left=0};a.fn.cycle.transitions.slideX=function(f,e,d){d.before.push(function(e,f,d){a(d.elements).not(e).hide();a.fn.cycle.commonReset(e,f,d,c,b);d.animIn.width=f.cycleW});d.cssBefore.left=0;d.cssBefore.top=0;d.cssBefore.width=0;d.animIn.width="show";d.animOut.width=0};a.fn.cycle.transitions.slideY=function(f,e,d){d.before.push(function(e,f,d){a(d.elements).not(e).hide();a.fn.cycle.commonReset(e,f,d,b,c);d.animIn.height=f.cycleH});d.cssBefore.left=0;d.cssBefore.top=0;d.cssBefore.height=0;d.animIn.height="show";d.animOut.height=0};a.fn.cycle.transitions.shuffle=function(i,h,c){var e,j=i.css(d,"visible").width();h.css({left:0,top:0});c.before.push(function(c,d,e){a.fn.cycle.commonReset(c,d,e,b,b,b)});if(!c.speedAdjusted){c.speed=c.speed/2;c.speedAdjusted=b}c.random=0;c.shuffle=c.shuffle||{left:-j,top:15};c.els=[];for(e=0;e<h.length;e++)c.els.push(h[e]);for(e=0;e<c.currSlide;e++)c.els.push(c.els.shift());c.fxFn=function(d,h,b,i,c){if(b.rev)c=!c;var e=c?a(d):a(h);a(h).css(b.cssBefore);var g=b.slideCount;e.animate(b.shuffle,b.speedIn,b.easeIn,function(){var j="z-index";for(var m=a.fn.cycle.hopsFromLast(b,c),l=0;l<m;l++)c?b.els.push(b.els.shift()):b.els.unshift(b.els.pop());if(c)for(var h=0,k=b.els.length;h<k;h++)a(b.els[h]).css(j,k-h+g);else{var n=a(d).css(j);e.css(j,parseInt(n,f)+1+g)}e.animate({left:0,top:0},b.speedOut,b.easeOut,function(){a(c?this:d).hide();i&&i()})})};a.extend(c.cssBefore,{display:g,opacity:1,top:0,left:0})};a.fn.cycle.transitions.turnUp=function(f,e,d){d.before.push(function(f,d,e){a.fn.cycle.commonReset(f,d,e,b,c);e.cssBefore.top=d.cycleH;e.animIn.height=d.cycleH;e.animOut.width=d.cycleW});d.cssFirst.top=0;d.cssBefore.left=0;d.cssBefore.height=0;d.animIn.top=0;d.animOut.height=0};a.fn.cycle.transitions.turnDown=function(f,e,d){d.before.push(function(e,f,d){a.fn.cycle.commonReset(e,f,d,b,c);d.animIn.height=f.cycleH;d.animOut.top=e.cycleH});d.cssFirst.top=0;d.cssBefore.left=0;d.cssBefore.top=0;d.cssBefore.height=0;d.animOut.height=0};a.fn.cycle.transitions.turnLeft=function(f,e,d){d.before.push(function(f,d,e){a.fn.cycle.commonReset(f,d,e,c,b);e.cssBefore.left=d.cycleW;e.animIn.width=d.cycleW});d.cssBefore.top=0;d.cssBefore.width=0;d.animIn.left=0;d.animOut.width=0};a.fn.cycle.transitions.turnRight=function(f,e,d){d.before.push(function(e,f,d){a.fn.cycle.commonReset(e,f,d,c,b);d.animIn.width=f.cycleW;d.animOut.left=e.cycleW});a.extend(d.cssBefore,{top:0,left:0,width:0});d.animIn.left=0;d.animOut.width=0};a.fn.cycle.transitions.zoom=function(f,e,d){d.before.push(function(f,d,e){a.fn.cycle.commonReset(f,d,e,c,c,b);e.cssBefore.top=d.cycleH/2;e.cssBefore.left=d.cycleW/2;a.extend(e.animIn,{top:0,left:0,width:d.cycleW,height:d.cycleH});a.extend(e.animOut,{width:0,height:0,top:f.cycleH/2,left:f.cycleW/2})});d.cssFirst.top=0;d.cssFirst.left=0;d.cssBefore.width=0;d.cssBefore.height=0};a.fn.cycle.transitions.fadeZoom=function(e,d,b){b.before.push(function(e,b,d){a.fn.cycle.commonReset(e,b,d,c,c);d.cssBefore.left=b.cycleW/2;d.cssBefore.top=b.cycleH/2;a.extend(d.animIn,{top:0,left:0,width:b.cycleW,height:b.cycleH})});b.cssBefore.width=0;b.cssBefore.height=0;b.animOut.opacity=0};a.fn.cycle.transitions.blindX=function(f,g,b){var c=f.css(d,e).width();b.before.push(function(c,d,b){a.fn.cycle.commonReset(c,d,b);b.animIn.width=d.cycleW;b.animOut.left=c.cycleW});b.cssBefore.left=c;b.cssBefore.top=0;b.animIn.left=0;b.animOut.left=c};a.fn.cycle.transitions.blindY=function(f,g,b){var c=f.css(d,e).height();b.before.push(function(c,d,b){a.fn.cycle.commonReset(c,d,b);b.animIn.height=d.cycleH;b.animOut.top=c.cycleH});b.cssBefore.top=c;b.cssBefore.left=0;b.animIn.top=0;b.animOut.top=c};a.fn.cycle.transitions.blindZ=function(c,h,b){var f=c.css(d,e).height(),g=c.width();b.before.push(function(c,d,b){a.fn.cycle.commonReset(c,d,b);b.animIn.height=d.cycleH;b.animOut.top=c.cycleH});b.cssBefore.top=f;b.cssBefore.left=g;b.animIn.top=0;b.animIn.left=0;b.animOut.top=f;b.animOut.left=g};a.fn.cycle.transitions.growX=function(f,e,d){d.before.push(function(e,f,d){a.fn.cycle.commonReset(e,f,d,c,b);d.cssBefore.left=this.cycleW/2;d.animIn.left=0;d.animIn.width=this.cycleW;d.animOut.left=0});d.cssBefore.top=0;d.cssBefore.width=0};a.fn.cycle.transitions.growY=function(f,e,d){d.before.push(function(e,f,d){a.fn.cycle.commonReset(e,f,d,b,c);d.cssBefore.top=this.cycleH/2;d.animIn.top=0;d.animIn.height=this.cycleH;d.animOut.top=0});d.cssBefore.height=0;d.cssBefore.left=0};a.fn.cycle.transitions.curtainX=function(f,e,d){d.before.push(function(e,f,d){a.fn.cycle.commonReset(e,f,d,c,b,b);d.cssBefore.left=f.cycleW/2;d.animIn.left=0;d.animIn.width=this.cycleW;d.animOut.left=e.cycleW/2;d.animOut.width=0});d.cssBefore.top=0;d.cssBefore.width=0};a.fn.cycle.transitions.curtainY=function(f,e,d){d.before.push(function(f,e,d){a.fn.cycle.commonReset(f,e,d,b,c,b);d.cssBefore.top=e.cycleH/2;d.animIn.top=0;d.animIn.height=e.cycleH;d.animOut.top=f.cycleH/2;d.animOut.height=0});d.cssBefore.height=0;d.cssBefore.left=0};a.fn.cycle.transitions.cover=function(f,i,b){var c=b.direction||"left",h=f.css(d,e).width(),g=f.height();b.before.push(function(d,e,b){a.fn.cycle.commonReset(d,e,b);if(c=="right")b.cssBefore.left=-h;else if(c=="up")b.cssBefore.top=g;else if(c=="down")b.cssBefore.top=-g;else b.cssBefore.left=h});b.animIn.left=0;b.animIn.top=0;b.cssBefore.top=0;b.cssBefore.left=0};a.fn.cycle.transitions.uncover=function(g,j,c){var f=c.direction||"left",i=g.css(d,e).width(),h=g.height();c.before.push(function(d,e,c){a.fn.cycle.commonReset(d,e,c,b,b,b);if(f=="right")c.animOut.left=i;else if(f=="up")c.animOut.top=-h;else if(f=="down")c.animOut.top=h;else c.animOut.left=-i});c.animIn.left=0;c.animIn.top=0;c.cssBefore.top=0;c.cssBefore.left=0};a.fn.cycle.transitions.toss=function(e,h,c){var g=e.css(d,"visible").width(),f=e.height();c.before.push(function(d,e,c){a.fn.cycle.commonReset(d,e,c,b,b,b);if(!c.animOut.left&&!c.animOut.top)a.extend(c.animOut,{left:g*2,top:-f/2,opacity:0});else c.animOut.opacity=0});c.cssBefore.left=0;c.cssBefore.top=0;c.animIn.left=0};a.fn.cycle.transitions.wipe=function(t,w,h){var n="rect(",i="px ",s="rect(0px ",k=t.css(d,e).width(),j=t.height();h.cssBefore=h.cssBefore||{};var l;if(h.clip)if(/l2r/.test(h.clip))l="rect(0px 0px "+j+"px 0px)";else if(/r2l/.test(h.clip))l=s+k+i+j+i+k+"px)";else if(/t2b/.test(h.clip))l=s+k+"px 0px 0px)";else if(/b2t/.test(h.clip))l=n+j+i+k+i+j+"px 0px)";else if(/zoom/.test(h.clip)){var v=parseInt(j/2,f),u=parseInt(k/2,f);l=n+v+i+u+i+v+i+u+"px)"}h.cssBefore.clip=h.cssBefore.clip||l||"rect(0px 0px 0px 0px)";var m=h.cssBefore.clip.match(/(\d+)/g),r=parseInt(m[0],f),q=parseInt(m[1],f),o=parseInt(m[2],f),p=parseInt(m[3],f);h.before.push(function(h,l,m){if(h==l)return;var s=a(h),t=a(l);a.fn.cycle.commonReset(h,l,m,b,b,c);m.cssAfter.display=g;var e=1,d=parseInt(m.speedIn/13,f)-1;(function u(){var g=r?r-parseInt(e*(r/d),f):0,b=p?p-parseInt(e*(p/d),f):0,a=o<j?o+parseInt(e*((j-o)/d||1),f):j,c=q<k?q+parseInt(e*((k-q)/d||1),f):k;t.css({clip:n+g+i+c+i+a+i+b+"px)"});e++<=d?setTimeout(u,13):s.css("display","none")})()});a.extend(h.cssBefore,{display:g,opacity:1,top:0,left:0});h.animIn={left:0};h.animOut={left:0}}})(jQuery);
