$(function(){
	
	//var pathname = window.location.pathname;
	//console.log(pageName);
	//$("#header li, #sidebar ul.sidenav li").find("a[href='"+location.pathname+"']").each(function(){
    //$(this).addClass("currentpage")
    //})

	// navigation effects
	$("#header li").hover(function(){
		
		$("#header li:hover").css({ 'margin-top' : '-5px' });
		
		$(this).stop().animate({ marginTop: "0px" }, 'fast' );
		},function(){
        $(this).stop().animate({ marginTop: "-5px"}, 'fast');
	});
	
	$("#sidebar ul.sidenav li").hover(function(){
	
		$("#sidebar ul.sidenav li:hover").css({ 'margin-Right' : '0px' });
		
		$(this).stop().animate({ marginRight: "-10px" }, 'fast' );
		},function(){
        $(this).stop().animate({ marginRight: "0px"}, 'fast');
	});
	
	// Portfolio sidenav
	
	$("ul.subnav").hide();
	$("ul.subnav-current").show();
	
	$("#sidebar ul.sidenav li.portfolios a").click(function(event){
		$("#sidebar ul.subnav").slideToggle("normal");
		event.preventDefault();
	});
	
	
	// meet the team section
	
	$('#people div').css({'position' : 'absolute', 'top' : '0', 'left' : '0'}).hide();
	$('#people div img').css({'position' : 'absolute', 'top' : '-229px', 'left' : '20px'})
	$('#blank').fadeIn("slow");
	
	$('#team a').click(function(event){
		
		event.preventDefault();
		var name = $(this).text().toLowerCase().replace(' ','-');
		$('#blank').hide();
		$('#people div:visible').hide();
		
		$('#' + name).fadeIn("slow");
	});	

    // disguise email addresses
    
    $('span.mailme').mailme();
    $('span.mailme1').mailme1();
	$('span.mailme2').mailme2();
	//$('span.mailreplace').mailreplace();
});

    jQuery.fn.mailme = function() {
    var at = / at /;
    var dot = / dot /g;
    this.each( function() {
    var addr = jQuery(this).text().replace(at,"@").replace(dot,".");
    var title = jQuery(this).attr('title')
    $(this)
    .after('<span class="mailme"><a href="mailto:'+addr+'" title="'+title+'">Email Me</a></span>')
    .remove();
    });
	};
    
    jQuery.fn.mailme1 = function() {
    var at = / at /;
    var dot = / dot /g;
    this.each( function() {
    var addr = jQuery(this).text().replace(at,"@").replace(dot,".");
    var title = jQuery(this).attr('title')
    $(this)
    .after('<a href="mailto:'+addr+'" title="'+title+'">' + addr + '</a>')
    .remove();
    });
	};
	
	jQuery.fn.mailme2 = function() {
    var at = / at /;
    var dot = / dot /g;
    this.each( function() {
	var linktext = jQuery(this).attr('text');
    var addr = jQuery(this).text().replace(at,"@").replace(dot,".");
    var title = jQuery(this).attr('title')
    $(this)
    .after('<a href="mailto:'+addr+'" title="'+title+'">' + linktext + '</a>')
    .remove();
    });
	};
	
	/*jQuery.fn.mailreplace = function(){
		var name = jQuery(this).text();
		console.log(name);
		switch (name) {
			case 'Sue Dainton':
				$(this)
					.after('<a href="mailto:sue@isleofmanadvertising.com">Sue Dainton</a>')
					.remove();
			break;
			case 'Tiny Tim':
				$(this)
					.after('<a href="mailto:sue@isleofmanadvertising.com">Sue Dainton</a>')
					.remove();
			break;
		}
	};*/











