//Tab Switcher
//Author: Marghoob Suleman | Search me on google
// jquery.tabs.js
;(function($){
		   $.fn.tabs = function(options) {
			   options = $.extend({
								  tabs:'a',
								  contentSuffix:'_content',
								  event:'click',
								  selected:'selected',
								  effects:'fade',
								  defaultTab:''
								  }, options);
			   
			   var oProp = new Object();
			   oProp.old = "";
			   var elementid = $(this).attr("id");
			   init();
			   function init() {
				   $("#"+elementid + " " + options.tabs).bind(options.event, switchTab);
				   if(options.defaultTab=='') {
					   options.defaultTab = $("#"+elementid + " " + options.tabs)[0].id;
				   }
				   switchTab(options.defaultTab);
			   }
			   function switchTab(evt) {
				   if(typeof(evt)!="string") {
					   evt.preventDefault();
				   }
				   var id = (typeof(evt)=="string") ? evt : $(this).attr("id");
				   var content = id+options.contentSuffix;				   
				   if(oProp.old!="") {
					  $("#"+oProp.old).removeClass(options.selected);
					  if(options.effects=='fade') {
						  $("#"+oProp.oldContent).fadeOut("fast", function(evt) {$("#"+content).fadeIn("fast");});
					  } else {
						  $("#"+oProp.oldContent).slideUp("fast", function(evt) {$("#"+content).slideDown("fast");});
					  }
				   } else {
					   if(options.effects=='fade') {
							$("#"+content).fadeIn("fast"); 
					   } else {
						   $("#"+content).slideDown("fast"); 
					   }
				   }
				    $("#"+id).addClass(options.selected);
				   oProp.old = id;
				   oProp.oldContent = content;
			   }
			   
		   }
		   })(jQuery);