/*
 * @developer Bitface
 * @date 2009
 * www.pls.com Javascript functionality
 *
 */ 



/*
 * UI manager
 *
 */

var UIManager = {
  Common: {
  
    init: function(e) {
      $('body').removeClass('nojs').addClass('js');
	  
    }
	
  }
};


$(document).ready(function() {

  UIManager.Common.init();

  DD_belatedPNG.fix('#page, #ft, #hd-image, #button-bar ul, .content-module .box-head, .content-module .box-head h1, .content-module .box-wrap, .content-module .box-body, .content-module .box-foot, .content-module .box-foot div');

 $('#button-bar').thoughtBubbleControl({}); // init the thought bubble

 // main nav tabs
$(".main-nav-links a").hover(function(event){
	$(event.target).closest("li").addClass('hover');
}, function(event){
	$(event.target).closest("li").removeClass('hover');
}); 


});

/**
 * Homepage Thought Bubble
 * Shows and hides the thought bubbles on the homepage.
 * @version 1.0
 */
(function($){
  var settings;

  $.fn.thoughtBubbleControl = function(callerSettings) {
    settings = $.extend({
	  openId: null,
	  flyout: '.homepage-flyout'
    },callerSettings||{});
	// set up
	$(this, 'a').click(showBubble);
	$(settings.flyout+' a.close').click(hideBubble);
	$(settings.flyout).hide();
	return this;
  };
// show a bubble
  var showBubble = function(e) {
	e.preventDefault();
	if (settings.openId != null && $(e.target).attr('rel') == settings.openId) {
		// already open, toggle close
		hideBubble();
	} else {
		hideBubble();
		settings.openId = $(e.target).attr('rel');
		$('#'+settings.openId).show();
	}
  };
// hide a Bubbles
  var hideBubble = function(e) {
	  if (e) {e.preventDefault();}
	// close the openId
	if (settings.openId != null) {
		$('#'+settings.openId).hide();
		settings.openId = null;
	}
  }

})(jQuery);
