$(document).ready(function() { 
	// Contact forms (eg: creation.cirv.com)
	var emailTextBox = $("#contact_form #email");
	var emailLabelText = "Your Email: relation@cirv.com";
	emailTextBox.val(emailLabelText).addClass("showLabel");	
	emailTextBox.focus(function(){ if( $(this).hasClass("showLabel") ){ $(this).val("").removeClass("showLabel"); }  });
	emailTextBox.blur(function(){ if( $(this).val().length == 0 ){ $(this).val(emailLabelText).addClass("showLabel"); }  });
	
	$(".horizMenu .wrap > a").bind("mouseenter",function() { $(this).parents("li").addClass("over"); $("#nav-main").addClass("over"); return false; });
	$(".horizMenu > li").bind("mouseleave",function(event) { $(this).removeClass("over"); $("#nav-main").removeClass("over"); return false; });
	
	initActiveMenu();
	
//	$(".horizMenu li").each(function() { $(this).css("display","inline-block").css("clear","both").css("padding","0").css("margin","0"); });	
/*	$(".horizMenu li a").each(function() {
		$(this).css("font-family",'"Trebuchet MS", "Lucida Grande", "Lucida Sans Unicode", Verdana, sans-serif');
		$(this).css("font-size","10px").css("display","inline-block").css("text-decoration","none").css("white-space","nowrap").css("clear","both");
		var strLen = $(this).text().length;
		var wBefore = $(this).width();
		var diff = (100- wBefore)
		var fontWidth = wBefore + diff;
		var fontSize = Math.round((250/strLen)/1.2);
		$(this).css("font-size",fontSize+"pt").css("line-height","1.2em");
	});
*/
});

function initActiveMenu(){
	var menupath = "";
	var paths = getPathsArray(document.location.toString());
	if(paths.toString().length > 0){
		$(".horizMenu a").each(function() { 
			menupath = getPathsArray( $(this).attr("href") );
			if( menupath.toString() == paths.toString()
				|| ( ( menupath[0].toString() == paths[0].toString() ) && menupath.length == 1) ){
				$(this).closest("li").addClass("active");
//				alert(menupath.toString() + " | " + paths.toString() + " L="+paths.length);
			}
		});
	}
}
function getPathsArray(urlStr){return urlStr.toString().replace("http://","").split("/").slice(1).clean("");}
Array.prototype.clean = function(deleteValue) {for(var i=0; i<this.length; i++){if(this[i]==deleteValue){this.splice(i, 1); i--;}} return this;};
