init = function(){
    // input/textarea clearing stuff
    // set the rel attribute for inputs as the value
    $('#contact-form label').each(function(){
        var newValue = $(this).attr('rel');
        $(this).next().find('input[type="text"]').attr('value', newValue).attr('rel', newValue);        
    });
    
    // set the rel attribute for textareas as the value
    $('.for-textarea').each(function(){
        var newValue = $(this).attr('rel');
        $(this).next().find('textarea').attr('value', newValue).attr('rel', newValue);        
    });
    
    // on input focus, clear the element
    $('input[type=text]').focus(function(){
        var defaultValue = $(this).attr('rel');
        if($(this).attr('value') == defaultValue) {
            $(this).attr('value','');
        };
    });
    
    // on input blur, restore the text if no value
    $('input[type=text]').blur(function(){
        var defaultValue = $(this).attr('rel');
        if($(this).attr('value').length == 0) {
            $(this).attr('value', defaultValue);
        };
    });
    
    // on textarea focus, clear the element
    $('textarea').focus(function(){
        var defaultValue = $(this).attr('rel');
        if($(this).attr('value') == defaultValue) {
            $(this).attr('value','');
        };
    });
    
    // on textarea blur, restore the text if no value
    $('textarea').blur(function(){
        var defaultValue = $(this).attr('rel');
        if($(this).attr('value').length == 0) {
            $(this).attr('value', defaultValue);
        };
    });
    

	
	$('nav.sections ul').superfish();


}


// javascript for the works section.
works = function(ap){	
	
	if($.browser.msie){
		var player = new MediaElementPlayer('#the_player', {pluginPath: ap});
		var the_playlist_items = $('#the_playlist li');	
		$('#the_playlist a').click(function(){
			$('#player_wrapper').empty();
			$('#player_wrapper').html('<audio id="the_player" src="'+$(this).attr('href')+'" type="audio/mp3" controls="controls"></audio>');
			$('\#the_player').mediaelementplayer({pluginPath: ap});
			the_playlist_items.removeClass('selected');
			$(this).parent().addClass('selected');
			return false;
		});
	} else  if($.browser.mozilla){
		var the_playlist_items = $('#the_playlist li');	
		$('#the_playlist a').click(function(){
			$('.mejs-container').remove();
			$('#player_wrapper').html('<audio id="the_player" src="'+$(this).attr('href')+'" type="audio/mp3" controls="controls"></audio>');
			var player = new MediaElementPlayer('audio#the_player', {pluginPath: ap});	
			the_playlist_items.removeClass('selected');
			$(this).parent().addClass('selected');
			return false;
		});
		var player = new MediaElementPlayer('#the_player', {pluginPath: ap});
	} else {
		var the_player = $('#the_player');
		var the_player_instance = the_player.get(0);
		var the_playlist_items = $('#the_playlist li');	
		$('#the_playlist a').click(function(){
			the_player_instance.pause();
			the_player.attr('src', $(this).attr('href'));
			the_player_instance.load();
			the_player_instance.play();
			the_playlist_items.removeClass('selected');
			$(this).parent().addClass('selected');
			return false;
		});
		the_player.mediaelementplayer({pluginPath: ap});	
	}
}


emailer = function()
// Email obfuscator script 2.1 by Tim Williams, University of Arizona
// Random encryption key feature by Andrew Moulden, Site Engineering Ltd
// This code is freeware provided these four comment lines remain intact
// A wizard to generate this code is at http://www.jottings.com/obfuscator/
{ coded = "u2ym3@0DuZyhD4msK.3Ku"
  key = "2HqEFWkdPxtyKRbCfl6zmMpASeJjragnUcvL7YhOIu5X9NZ80wD1so34GBVQTi"
  shift=coded.length
  link=""
  for (i=0; i<coded.length; i++) {
    if (key.indexOf(coded.charAt(i))==-1) {
      ltr = coded.charAt(i)
      link += (ltr)
    }
    else {     
      ltr = (key.indexOf(coded.charAt(i))-shift+key.length) % key.length
      link += (key.charAt(ltr))
    }
  }
  document.write("<a href='mailto:"+link+"'>music@jameslavino.com</a>")
}

