/*
*		BASE
*/
	

var Miso = {};
    
Miso.base = {};
	
	
Miso.settings = {
	signinAnimateSpeed: 1,
	scrollAnimateSpeed: 500
}
	
Miso.base.init = function() {
  $(".noticeButton").live('click', function(){ $("#notificationBar").slideUp(300, 0.0); }  )
  $(".closeButton").live('click', Miso.announcement.dismiss);
}
    
Miso.announcement = {
  dismiss : function() {
    $("#announcementBox").fadeOut(300, 0.0);
    $.cookie('announcement_dismiss', 'true', { path: '/', expires: 10 });
  }
};

Miso.outboundLinks = {
  // "data_outbound" => "iTunes - Miso"
  init : function() {
    $('a[data-outbound]').live('click', function(e) {
      e.preventDefault();
      recordOutboundLink(this, 'Outbound Links', $(this).attr('data-outbound'));
    });
  }
};

Miso.message = function( m, ele, color ) {
	this.message = m;
	this.messageFormElement = ele;
	this.offFocusColor = color;
	
	this.init = function() {
		this.messageFormElement.live( 'focus', {handler: this}, this.onFocus );	
		this.messageFormElement.live( 'blur',  {handler: this}, this.onBlur );
		
		// set a default message, if the message box is empty.
		if (this.messageFormElement.val() == "") {
			this.setDefaultMessage();
		}
	}
			
			
	this.isEmpty = function() {
		return (this.messageFormElement.val() == "");
	}
	
	this.notEmpty = function() {
		return (this.messageFormElement.val() != "");
	}
	
	this.isPrompt = function() {
		return (this.messageFormElement.val() == this.message);
	}
	
  this.setDefaultMessage = function() {
  	this.messageFormElement.val( this.message );
  	this.messageFormElement.css("color", this.offFocusColor );
  }
    
  this.clearDefaultMessage = function() {
  	this.messageFormElement.val( "" );
  	this.messageFormElement.css("color", "");
  }
    
  this.onFocus = function(e){ 
  	var handler = e.data.handler;
   	if( handler.isPrompt() ) { handler.clearDefaultMessage(); }
  }
    
  this.onBlur = function(e) {
    var handler = e.data.handler;
    if( handler.isEmpty() ) { handler.setDefaultMessage(); }
  }
}

$(document).ready( Miso.base.init );
$(document).ready( Miso.outboundLinks.init );
