// jQEm v0.2: http://davecardwell.co.uk/javascript/jquery/plugins/jquery-em/
eval(function(p,a,c,k,e,d){e=function(c){return(c<a?"":e(c/a))+String.fromCharCode(c%a+161)};while(c--){if(k[c]){p=p.replace(new RegExp(e(c),'g'),k[c])}}return p}('× ¢(){¿ ¾={\'²\':¢(»){£ »!=¤?¡.²=»:¡.²},\'¬\':¢(){£ ¡.¬()},\'«\':¢(¥){£ ¡.«(¥)},\'¯\':¢(¥){£ ¡.¯(¥)},\'¨\':¢(­,¶){£ ¡.¨(­,¶)},\'ª\':¢(){£ ¡.ª},\'³\':¢(¸){£ ¸?¡.³=¸:¡.³},\'©\':¢(){£ ¡.©()},\'°\':¢(){£ ¡.°()},\'§\':¢(){£ ¡.§},\'±\':¢(){£ ¡.±}};$.Ã=¾;¿ ¡={\'e\':$(Á.Ç(\'i\')),\'ª\':·,\'´\':¤,\'§\':¤,\'³\':È,\'½\':¤,\'±\':¤,\'²\':Å,\'¬\':¬,\'«\':«,\'¯\':¯,\'¨\':¨,\'º\':¢(){¡.¨(·);£\'¼\'},\'©\':©,\'°\':°};$(Á).É(¢(){¦(¡.²)¬()});¢ ¬(){$(\'Ê\').Ë(¡.e.Ì({\'Í\':\'Î\',\'Ï\':\'-¼\',\'Ð\':\'Ñ\',\'Ó\':\'Ô\',\'®\':\'¼\'}));¡.´=(¡.e.µ!=¤&&¡.e.µ.Â!=¤);¡.©()};¢ «(¥){¡.e.«(\'¹\',¥)};¢ ¯(¥){¡.e.¯(\'¹\',¥)};¢ ¨(­,¶){¦(­==¤)­=·;¦(­||¡.e.®()!=¡.§){¡.±=¡.§;¡.§=¡.e.®();$.Æ.¨(\'¹\',¶)}};¢ ©(){¦(¡.ª)£;¡.§=¡.±=¡.e.®();¦(¡.´){¡.e.µ.Â(\'®\',\'$.Ã.º();\')}À{¡.½=Ä.Ò(¡.º,¡.³)}¡.ª=Å};¢ °(){¦(!¡.ª)£;¦(¡.´){¡.e.µ.Õ(\'®\')}À{Ä.Ö(¡.½)}}}();',55,55,'Private|function|return|undefined|callback|if|current|trigger|start|active|bind|init|force|width|unbind|stop|previous|auto|delay|canExp|style|args|false|milliseconds|emchange|update|bool|1em|iid|Public|var|else|document|setExpression|jqem|window|true|event|createElement|100|ready|body|prepend|css|display|block|left|position|absolute|setInterval|visibility|hidden|removeExpression|removeInterval|new'.split('|')))


jQuery.extend( jQuery.easing,
{
		easeOutBack: function (x, t, b, c, d, s) {
			if (s == undefined) s = 1.70158;
			return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
		}
	
});

(function($){
	$.fn.__animate=$.fn.animate;
	$.fn.animate=function( prop, speed, easing, callback ) {
		var optall = jQuery.speed(speed, easing, callback);

		return this[ optall.queue === false ? "each" : "queue" ](function(){
			if ( this.nodeType != 1)
				return false;

			var opt = jQuery.extend({}, optall), p,
				hidden = jQuery(this).is(":hidden"), self = this;

			for ( p in prop ) {
				if ( prop[p] == "hide" && hidden || prop[p] == "show" && !hidden )
					return opt.complete.call(this);

				if ( p == "height" || p == "width" ) {
					// Store display property
					opt.display = jQuery.css(this, "display");

					// Make sure that nothing sneaks out
					opt.overflow = this.style.overflow;
				}
			}

			//if ( opt.overflow != null )
				//this.style.overflow = "hidden";

			opt.curAnim = jQuery.extend({}, prop);

			jQuery.each( prop, function(name, val){
				var e = new jQuery.fx( self, opt, name );

				if ( /toggle|show|hide/.test(val) )
					e[ val == "toggle" ? hidden ? "show" : "hide" : val ]( prop );
				else {
					var parts = val.toString().match(/^([+-]=)?([\d+-.]+)(.*)$/),
						start = e.cur(true) || 0;

					if ( parts ) {
						var end = parseFloat(parts[2]),
							unit = parts[3] || "px";

						// We need to compute starting value
						if ( unit != "px" ) {
							self.style[ name ] = (end || 1) + unit;
							start = ((end || 1) / e.cur(true)) * start;
							self.style[ name ] = start + unit;
						}

						// If a +=/-= token was provided, we're doing a relative animation
						if ( parts[1] )
							end = ((parts[1] == "-=" ? -1 : 1) * end) + start;

						e.custom( start, end, unit );
					} else
						e.custom( start, val, "" );
				}
			});

			// For JS strict compliance
			return true;
		});
	}
})(jQuery);

(function($){
	$.fn.lava=function(options){
		options=$.extend({
			easing:"swing",
			duration:500,
			defaultLiClass:"active"		
		},options || {});
		return this.each(function(){
			var active=$("li."+options.defaultLiClass,this);
			var _this=$(this);
			//var template="<div id='lvbg'><div id='inner_lvbg'><div id='lvbg_hiliter'></div></div></div>";
			var menuItems=$("li",this);
			//$(this).prepend(template);
			$('#lvbg').css("display","block");

			var caret=$("#lvbg #inner_lvbg");
			var innerCaret=$("#lvbg #inner_lvbg #lvbg_hiliter");
			if(active.length>0){
				_setCurrent(active);	
			}else{
				span_all();
			}
			menuItems.hover(function(){
				_move($(this));
			},function(){
			});
			_this.hover(function(){},
			function(){
				if(active.length>0){
					_move(active);	
				}else{
					span_all();
				}	
			}
			)
			$(window).bind("emchange",function(){
				if(active.length>0){
					_move(active);	
				}else{
					span_all();
				}
			})
			
			
			function _setCurrent(el){
				setTimeout(function(){
					_move(el);
				},1)

			}

			function _move(el){
				$('#lvbg').fadeIn("fast",function(){
					caret.stop().animate({
						height:(el.offset().top - el.parent().offset().top + el.height()+6)+"px"	
					},options.duration,options.easing);

					innerCaret.stop().animate({
							height: (el.height())+"px"
					}, options.duration,options.easing);
				});
				
				
			}
			function span_all(){
				$('#lvbg').fadeOut("fast");
			}
						
		});
	}	
	
})(jQuery);

(function($){
	$.fn.carouselize=function(options){
		options=$.extend({
			animate:true,
			duration:3000
		},options || {});
		return this.each(function(){
			var container=this;
			var slideholder=$("#slides",container);
			var slides=$("ul li",slideholder);
			var pointers=$("ul#pointers li",container);
			//position items
			slideholder.css({
				position:"absolute",
				top:"37px",
				left:"0px"
			});
			slides.css({
				position:"absolute",
				top:"0px",
				left:"0px",
				display:"none"
			});
			$(slides[0]).show();
			pointers.each(function(i,el){
				$(el).attr("rel",i).bind("mouseenter",function(){
					pointers.removeClass("active")
					$(this).addClass("active");
					fadeSlide(i);
				})
				
			});
			$(container).bind("mouseenter",function(){
				options.animate=false;
			}).bind("mouseleave",function(){
				options.animate=true;
			})
			setTimeout(function(){
				animate();
			},options.duration);
			
			function fadeSlide(i){
				var slidetobeanimated=slides[i];
				var current_slide=$("li.active","#slides");
				$(slidetobeanimated).css({
					display:"none"
				})
				.addClass("active");
				
				current_slide.
				removeClass("active").
				after($(slidetobeanimated));
				
				
				$(slidetobeanimated).fadeIn();
				
			}
			
			function animate(){
				if(options.animate==true){
					$(pointers).each(function(){
						if($(this).is(".active")){
							//console.log($(this).next().text())
							if($(this).next().length){
								$(this).next().trigger("mouseenter");	
							}else{
								$(pointers).eq(0).trigger("mouseenter")
							}
								
							return false;				
						}
					})
				}
				setTimeout(function(){
					animate();
				},options.duration);
			}
			
		});
	}
})(jQuery);

$(document).ready(function() {
	$("#menu_holder ul li ul").lava({easing:"easeOutBack",duration:400});
	$('#flash_holder').flash(
	        { 
	          src: 'flash/banners.swf',
	          width: 570,
	          height: 170,
	          flashvars: { wmode: 'transparent' }
	        },
	        { version: 6 }
	    );
	$('#services_item a.false_link').click(function(){return false;});
	$("#home_carousel").carouselize();
});

function openMap(){
	window.open('map.html','map','width=820,height=620,resizable=no,scrollbars=no,toolbars=no');
	return false;
}
