	function replacemail(a,b,c,d){
		var e=(a + '&#064;' + b + '.' + c); 
		if (d){
		var f=('<a h' + 'ref="mai' + 'lto:' + e + '" class="email">' + d + '<\/a>');
		} else {
		var f=('<a h' + 'ref="mai' + 'lto:' + e + '" class="email">' + e + '<\/a>');	
		}
		document.write(f);
	}
$(document).ready(function(){ 

	$('#body').css('background-image','');
	var c = new Image();
	c.src = "/images/index_background.jpg";
	c.onload = function(){
		$('#body').css('background-image','/images/index_background.jpg');
		$(".faded").delay(500).each(function(i) {
		  $(this).delay(i * 1500).fadeIn(1200, function(){
			});
		});
	}

	$('a').click(function(){
		$(this).blur();
	});
	$('#sidebar a').click(function(){
//		$('.interior-content').hide();
//		target = $(this).attr('href');
//		$(target).fadeIn();
//		window.location.hash = target;
//		return false;
	});
	$('#sidebar a.current').click(function(){
		return false;
	});

	// Try to hide link to the PDF resume
	$('.hide_link1').attr('href','eric-gallegos' + '.' + 'pdf');

});

$(function(){
  
  // Keep a mapping of url-to-container for caching purposes.
  var cache = {
    // If url is '' (no fragment), display this div's content.
    '': $('#index')
  };
  
  // Bind an event to window.onhashchange that, when the history state changes,
  // gets the url from the hash and displays either our cached content or fetches
  // new content to be displayed.
  $(window).bind( 'hashchange', function(e) {
        
	$( '#content' ).children( ':visible' ).fadeOut();

    // Remove .current class from any previously "current" link(s).
    $( 'a.current' ).removeClass( 'current' );
    
    // Get the hash (fragment) as a string, with any leading # removed. Note that
    // in jQuery 1.4, you should use e.fragment instead of $.param.fragment().
	var url = $.param.fragment();

    // Add .current class to "current" nav link(s), only if url isn't empty.
    url && $( 'a[href="#' + url + '"]' ).addClass( 'current' );
    url && $( 'a[href="#' + url + '"]' ).parent().addClass( 'current' );

    
    if ( cache[ url ] ) {
      // Since the element is already in the cache, it doesn't need to be
      // created, so instead of creating it again, let's just show it!
      cache[ url ].show();
      
    } else {

	    //$('body').addClass( 'index' );

		// change body class
		$('body').removeClass();
		$('body').addClass( url );

		widgetCallback = function(u){
			if(u) $('#'+u).fadeIn();
		}

	    // Hide any visible ajax content.
		if( !$( '#content' ).children().is(":visible") )  { 
			widgetCallback(url);
		} else {
 			$( '#content' ).children( ':visible' ).fadeOut('fast', function(){
				widgetCallback(url);
			});
		 } 
    }
  })
  
  // Since the event is only triggered when the hash changes, we need to trigger
  // the event now, to handle the hash the page may have loaded with.
  $(window).trigger( 'hashchange' );

	// prevent page "jump" to anchor on anchor click
	setTimeout(function() {
	  if (location.hash) {
	    window.scrollTo(0, 0);
	  }
	}, 2);
      
});
