/// <reference path="doc/jquery-vsdoc.js" />


var AMUSE = {
	start: function() {
		this.playButton();
		this.formClear();
	},

formClear: function() {
		var prevValue='';
		jQuery('form.wpcf7-form input').focus(function() {
			if(jQuery(this).val() != '')
			{
				prevValue = jQuery(this).val();
				jQuery(this).val('');
			}
		
		});
		
		jQuery('form.wpcf7-form input').blur(function() {
			if(jQuery(this).val() == '')
			{
				jQuery(this).val(prevValue);
			}
		
		});
		
		
		jQuery('form.wpcf7-form textarea').focus(function() {
			if(jQuery(this).text() != '')
			{
				prevValue = jQuery(this).text();
				jQuery(this).text('');
			}
		
		});
		
		jQuery('form.wpcf7-form textarea').blur(function() {
			if(jQuery(this).text() == '')
			{
				jQuery(this).text(prevValue);
			}
		
		});
	},

	playButton: function() {
		$play = jQuery('#play-wrap');
		
		/* because audio.js creates the play button dynamically, unless we use event delegation we need to have a static wrapper to bind to */
	
		
		$play.bind('mouseenter', function() {
			$play.toggleClass("play-hover");

		});

		$play.bind('mouseleave', function() {
			$play.toggleClass("play-hover");
		});
		
		$play.bind('click', function(){
			jQuery.get('/wp-content/themes/amusegrafik/listened.php', function(data){
				
				jQuery('p#listeners').fadeOut('fast', function(){
        			jQuery.trim(data);
   		 			jQuery(this).html(data);
        			
        			//Cufon.replace('#audio p');
        			
        			jQuery(this).fadeIn('slow');
        		});
   	    	});
		});
	}};

jQuery(function() {
	AMUSE.start();
});

