// JavaScript Document




$(document).ready(function(){

	// Highlighted navigation
	$("a").each(function(){
		var href = $(this).attr("href");
		var uri = location.href.replace(/(http)?(ftp)?(:\/\/)?(test)?(www)?\.clancyparks\.com/,"");
		if(href == uri.replace(/\/$/,"") || href == uri || href == location.pathname.replace(/\/$/,"")) {
			$(this).addClass("selected");
		}
	})
	
	// Fix PNG

	// Font Replacement
	Cufon.replace("#rcpMainNav li a, .contact, .adr, #rcpPage h2, .btn-small, .btn-large", {
		fontFamily: "Kabel",
		hover: true
	});	
});
Veil = {
	toOpen:{
		duration:800,
		easing:"easeOutQuad",
		complete:function() {
			$(this).data("veiled", false);
		}
	},
	toClose:{
		duration:800,
		easing:"easeOutQuad",
		complete:function() {
			$(this).data("veil", true);
		}
	},
	showHide:function(s) {
		s = (typeof s === "string") ? $(s) : s;
		if(s.is(":hidden")) {
			this.show(s, arguments[1]);
		} else {
			this.hide(s, arguments[1]);
		}
	},
	show:function(s) {
		s = (typeof s === "string") ? $(s) : s;
		var c = s.children(":not(script)");
		var opt = (arguments[1]) ? arguments[1] : jQuery.extend( {}, this.toOpen );
		c.fadeIn((opt.duration < 1000) ? opt.duration : 1000, "jswing");
		s.slideDown(opt);
	},
	hide:function(s) {
		s = (typeof s === "string") ? $(s) : s;
		var c = s.children(":not(script)");
		var opt = (arguments[1]) ? arguments[1] : jQuery.extend( {}, this.toClose );
		c.fadeOut((opt.duration < 1000) ? opt.duration : 1000, "jswing");
		s.slideUp(opt);
	},
	getDurationByRate:function(s, r) {
		// s : selector :: r : Rate
		// beacuse the transitions in this object are slides, we can just worry about the elements innerHeight
		s = (typeof s === "string") ? $(s) : s;
		var h = s.innerHeight();
		if( s.children().is(":hidden") ) {
			s.children().show()
			h = s.innerHeight();
			s.children().hide()
		}
		// returns a duration (time) in milliseconds.
		return ( (h < r*2) ? h : r*2) / r * 1000;;
	}
}