jQuery(function($) {
	var curSelected = $("li.selected");
	
	// nav drop-down
	$("#nav li.withmenu").mouseenter(
		function() {
			$(this).addClass("hovered");
			$("ul",this).css({"top":$(this).height() - 4}).show();
	});
	$("#nav li.withmenu").mouseleave(
		function() {
			$(this).removeClass("hovered");
			$("ul",this).hide();
	});
	
	$("#clientpaging a").click(function() {
		var curPanel = $(".clientpanel.visible").attr("id");
		var whichPanel = $(this).attr("href");
		if("#"+curPanel != whichPanel) {
			$("#"+curPanel).fadeOut("slow", function() {
				$(whichPanel).fadeIn("slow", function() {
					$(this).addClass("visible");
				});
				$("#"+curPanel).removeClass("visible");
				$("#"+curPanel).hide();
			});
			$("#clientpaging a").removeClass("active");
			$(this).addClass("active");
		}
		return false;
	});
	
	$(".clientbox").hover(
		function(e) {
		$(this).hoverFlow(e.type, { 'opacity': '1.0' }, "easeInOut");
		},
		function(e) {
		$(this).hoverFlow(e.type, { 'opacity': '0.65' }, "easeInOut");
		}	
	);
	
	$("#tourbtn").hover(
		function(e) {
			$(this).hoverFlow(e.type, {
				marginTop: "+=10",
				opacity: 1
			},500,"easeOutBounce");
		},
		function(e) {
			$(this).hoverFlow(e.type, {
				marginTop: "-=10",
				opacity: 0.75
			},500,"easeOutQuad");
		}	
	);
	
	function setup() {
		$("a#tourbtn").fadeTo("fast",0.75);
		$(".clientbox").fadeTo("fast",0.65);
	}
	
	window.setTimeout(function() {
		setup();
	},100);
	
	$("div.service_block:odd").addClass("alt");
	
	$("a[rel*='external']").click(function() {
	      window.open(this.href);
	      return false;
	});
});


// DD rounded rules

DD_roundies.addRule('#nav a.toplevel','5px',true);
DD_roundies.addRule('ul.subnav li a.firstmenuitem','5px 5px 0 0',true);
DD_roundies.addRule('ul.subnav li a.lastmenuitem','0 0 5px 5px',true);
DD_roundies.addRule('.clientbox span.badge','10px',true);
DD_roundies.addRule('#quoteform input, #quoteform textarea, button.submitter', '7px 7px 7px 7px', true);
