// global Shunnyboy class
var Shunnyboy = new function() {
  // init public scope
  this.root = 'http://shunnyboy.com/';
  this.helpers = {
	logOut : function() {
	  var btn = $('#logout');
	  var ht = $('html')[0]; 
	  if (btn.size()) {
		btn[0].onclick = function(e) {
		  ht.style.filter = 'progid:DXImageTransform.Microsoft.BasicImage(grayscale=1)';  
		  if (confirm('Are you sure you want to log out?')) {
			return true;
		  } else {
			ht.style.filter = '';
			return false;
		  }
		};
	  }
	},
	
	loadFocus : function() {
	  var f = $('#loadfocus');
	  if (f.size()) {
		try {
		  f[0].focus();
		} catch (e) {};
	  }
	  return true;
	},
	
	confirmDelete : function(m) {
	  return confirm('Are you sure you want to delete ' + m + '.\nOnce deleted you will not be able to get it back!');
	},
	
	confirmSend : function(m) {
	  return confirm('Are you sure you want to send ' + m + '!');
	}
  };
  
  this.init = function() {
	$(function() {
	  // init on load
	  Shunnyboy.loadFlash();
	  // init helpers
	  Shunnyboy.helpers.loadFocus();
	  Shunnyboy.helpers.logOut();
	  //start tabs
	  Shunnyboy.initTabs();
	  // init misc
	  Shunnyboy.initMisc();
	});	  
  };
  this.loadFlash = function () {
	// create menu
	UFO.create({ 
	  movie:this.root + '/skins/shunnyboy/assets/flash/menu.swf', 
	  width:'710', 
	  height:'60', 
	  majorversion:'8', 
	  build:'0', 
	  wmode:'transparent', 
	  allowscriptaccess:'always', 
	  flashvars: 'href=' + window.location
	}, 'flashmenu');
	// create player
	/*UFO.create({ 
	  movie:this.root + '/skins/shunnyboy/assets/flash/mp3player.swf', 
	  width:'170', 
	  height:'150', 
	  majorversion:'7', 
	  build:'0', 
	  bgcolor:'#111111', 
	  allowscriptaccess:'always', 
	  flashvars:'file=' + this.root + 'resources/xml/playlist.xml&lightcolor=0xFF4747&backcolor=0x111111&frontcolor=0xFFFFFF&displayheight=0&showicons=false&showeq=false&repeat=true&shuffle=false&transition=random&allowfullscreen=false' 
	}, 'player');  	  */
  };
  this.initTabs = function () {
	// start any tabs
	$('.tabs').tabs({selectedClass: 'selected'});
  };
  this.initMisc = function () {
	// set click handlers
	$('.confirmdelete').bind( 'click', function() { 
	  return Shunnyboy.helpers.confirmDelete( this.title ); 
	});
	$('.confirmsend').bind( 'click', function() { 
	  return Shunnyboy.helpers.confirmSend( this.title ); 
	});  
	// set messages to show
	$('.message').fadeIn(1500);	  
	// init input styling
	$('form.nice').niceInputs();
  };
};
Shunnyboy.init();