$(document).ready(function(){
	$("#pageContainer").bind("click", function(){ 
		var path = document.location.pathname;
		var file = path.substring(path.lastIndexOf('/')+1);
		var v = $("#parent").attr("class") + ".html";
		if(path.indexOf('/cv/')!=-1) {
			var n = path.replace('cv/', v);
		} else {
			var n = path.replace(file,v);
		}
		location.replace(n);
	});
	$(".menuitem a").bind("mouseenter focus", function(){
		var ext = getFileExtension($(this).children("img").attr("src"));
		if($(this).children("img").attr("src").indexOf('_over'+ext)==-1){
			$(this).children("img").attr("src", $(this).children("img").attr("src").substring(0, $(this).children("img").attr("src").indexOf(ext))+"_over"+ext);
		}
	}).bind("mouseleave blur", function(){
		var ext = getFileExtension($(this).children("img").attr("src"));
		if($(this).children("img").attr("src").indexOf('_over'+ext)!=-1) {
			$(this).children("img").attr("src", $(this).children("img").attr("src").substring(0, $(this).children("img").attr("src").indexOf('_over'+ext))+ext);
		}
	});
	
});

function getFileExtension(fileName) 
{ 
	if( fileName.length == 0 ) return "";
	var dot = fileName.lastIndexOf(".");
	if( dot == -1 ) return "";
	var extension = fileName.substr(dot,fileName.length);
	return extension;
} 
