(function($){
	var AUTO_TIMEOUT = 6000;
	var AUTO_TIMEOUT_AFTER_INTERACTION = 10000;
	var isIE = $.browser.msie;
	$(function(){
		$("#banner .mainSlides").each(function(){
			var elem = $(this),
				slides = $(".slides>li", this),
				buttons = $(".slideButtons>a[href]", this),
				curSlide = undefined,
				autoTimeout = 0;
				
			var showSlide = function(idx, anim, nextTimeout) {
				anim = (anim == undefined) ? true : anim;
				nextTimeout = (nextTimeout == undefined) ? 0 : nextTimeout;
				
				if (!anim) {
					$(slides[idx]).stop().css({
						opacity:"",
						display:"block"
					});
					if (isIE) {
						$(".flybox",slides[idx]).stop().css({
							opacity:"",
							display:"block"
						});
					}
					curSlide = idx;
					buttons.removeClass("current");
					buttons.filter("[href=#" + $(slides[idx]).attr("id") + "]").addClass("current");
					
					if (nextTimeout) {
						setAutoTimeout(nextTimeout, AUTO_TIMEOUT);
					}
					return;
				}
				
				var toHide = undefined, toShow = undefined;
				
				if (idx == curSlide) return true;
				
				buttons.removeClass("current");
				if (curSlide != undefined && slides[curSlide]) {
					toHide = slides[curSlide];
				}
				
				if (slides[idx]) {
					toShow = slides[idx];
					buttons.filter("[href=#" + $(slides[idx]).attr("id") + "]").addClass("current");
				}
				
				if (toHide != undefined) {
					$(toHide).stop();
					$(toHide).animate({opacity:0}, {queue:false, duration:800, complete:function(){
						$(this).css({
							display:"none",
							opacity:""
						});
					}});
					
					if (isIE) {
						toHide = $(".flybox", toHide);
						$(toHide).stop();
						$(toHide).animate({opacity:0}, {queue:false, duration:800, complete:function(){
							$(this).css({
								display:"none",
								opacity:""
							});
						}});
					}
				}
				
				if (toShow != undefined) {
					$(toShow).stop();
					
					if ($(toShow).css("opacity") == "" || $(toShow).css("opacity") >= 1) {
						$(toShow).css({
							opacity:0
						});
					}
					if ($(toShow).css("display") == "none") {
						$(toShow).css({
							display:"block"
						});
					}
					
					$(toShow).animate({opacity:1}, {queue:false, duration:1200, complete:function(){
						$(this).css({
							display:"block",
							opacity:""
						});
					}});
					
					if (isIE) {
						toShow = $(".flybox", toShow);
						$(toShow).stop();
						
						if ($(toShow).css("opacity") == "" || $(toShow).css("opacity") >= 1) {
							$(toShow).css({
								opacity:0
							});
						}
						if ($(toShow).css("display") == "none") {
							$(toShow).css({
								display:"block"
							});
						}
						
						$(toShow).animate({opacity:1}, {queue:false, duration:1200, complete:function(){
							$(this).css({
								display:"block",
								opacity:""
							});
						}});
					}
				}
				
				curSlide = idx;
				
				if (nextTimeout) {
					setAutoTimeout(nextTimeout, AUTO_TIMEOUT);
				}
			};
				
			var clearAutoTimeout = function() { 
				if (autoTimeout > 0) { 
					window.clearTimeout(autoTimeout); 
					autoTimeout = 0;
				}
			};
			
			var setAutoTimeout = function(timeout, nextTimeout) {
				clearAutoTimeout();
				autoTimeout = window.setTimeout(function(){
					if (curSlide >= slides.length-1) {
						showSlide(0, true, nextTimeout);
					} else {
						showSlide(curSlide+1, true, nextTimeout);
					}
				}, timeout);
			};
			
			buttons.bind("click", function(){
				var href = $(this).attr("href").replace("#","") || "";
				if (href != "") {
					if ($("#" + href).length > 0) {
						for (var i = 0; i < slides.length; i++) {
							if (i != curSlide && $(slides[i]).attr("id") == href) {
								clearAutoTimeout();
								showSlide(i, true, AUTO_TIMEOUT_AFTER_INTERACTION);
								break;
							}
						}
					}
				}
				
				this.blur();
				return false;
			});
			
			/*
			$(".slideButtons", this).css({
				opacity:0,
				display:"block"
			}).animate({opacity:1},{queue:false, duration:800, complete:function(){
				$(this).css({
					display:"block",
					opacity:""
				});
			}});
			*/
			$(".slideButtons", this).show();
			showSlide(0, false, AUTO_TIMEOUT);
		});
	});
})(jQuery);
(function($){
	$(function(){
		var solutionBox = $(".solutionBox");
		var buttonWrappers = $(".buttonWrapper");
		
		var h1 = buttonWrappers.outerHeight();
		var h2 = solutionBox.outerHeight();
		
		if (h2 < h1) {
			$(".sameheight_space", solutionBox).css({
				height:(h1-h2)+"px"
			});
		}
	});
})(jQuery);
 
var $j = jQuery.noConflict();
/*** Simple jQuery Slideshow Script ***/

function slideSwitch() {
	$j('#slideshow .slide').css({
		opacity:0,
		display:"none"
	});
	
	var active = $j("#slideshow .active");
	if (!active.length) {
		active = $j("#slideshow .slide").filter(":first");
		active.addClass("active").css({opacity:"",display:"block"});
	}
	
	if ( $j("#slideshow .slide").length < 2 ) return;
	
	var switchSlide = function() {
		var next = active.next();
		if (!next.length) next = $j("#slideshow .slide").filter(":first");
		
		$j(active).animate({opacity:0}, {queue:false, duration:1000, complete: function() {
			$j(this).css({display:"none", opacity:""});
		}});
		
		$j(next).css({opacity:0, display:"block"});
		$j(next).animate({opacity:1}, {queue:false, duration:1200, complete:function(){
			$j(this).css({display:"block", opacity:""});
			active = $j(this);
		}});
		
		window.setTimeout(switchSlide, 6000);
	}
	
	window.setTimeout(switchSlide, 6000);
}

$j(function() {
	slideSwitch();
});
