$(document).ready(function(){
	$(".bot_tabs").each( function() {
		//CREATE OUR BUTTON AREA
			var button_area = $("<div>").attr({
				'class': "buttons"
			});
			$(this).prepend(button_area);
		//CREATE A BUTTON FOR EACH DEFINED TAB
			$(".tabs > div").each( function() {
				//HIDE THE TAB TO START
					$(this).css({
						"display": "none"
					});
					$(this).addClass("tab");
				//CREATE OUR BUTTON
					var tmp_button = $("<div>").attr({
						'class': 'button',
						'title': $(this).attr("id")
					}).html($(this).attr("title"));
					button_area.append(tmp_button);
				//SETUP THE EVENT FOR THE BUTTON
					tmp_button.mousedown(function () {
						resetTabs();
						$("#"+$(this).attr("title")).css({
							"display": "block"
						});
						$(this).addClass("selected");
					});
			});
			//FIRST RUN SHOW THE FIRST TAB
				$(".tabs div:first").css({
					"display": "block"
				});
			//
				$(".buttons div:first").addClass("selected");
	});
	//FUNCTION TO RESET OUR TABS
		function resetTabs(){
			$(".tabs > div").each( function() {
				$(this).css({
					"display": "none"
				});
			});
			$(".bot_tabs .button").each( function() {
				if($(this).hasClass("selected")){
					$(this).removeClass("selected")
				}
			});
		}
});
