/*	Tabme by Robert Larsson Aug 2010, Copyright (C) Lägenhetsbyte Sverige AB
	This can only be used with the written permission from Lägenhetsbyte Sverige AB

	This TabMe need JQuery 1.4+
*/

$(document).ready(function(){

	$("#frame_tabs .tabme").click(function(){
		displayTab(this);
		return false;
	});

	displayTab($("#frame_tabs .frame_tab_s"));

});

var unselected_tab_css = ""

function displayTab(obj) {

	// Save unselected tab css
	if (unselected_tab_css == "") {
		$("#frame_tabs .tabme").each(function(){
			if ($(this).hasClass("frame_tab")) {
				unselected_tab_css = "frame_tab";
			}
			if ($(this).hasClass("frame_tab_blue")) {
				unselected_tab_css = "frame_tab_blue";
			}
		});
		if (unselected_tab_css == "") { unselected_tab_css = "frame_tab"; }
	}

	$("#frame_tabs .tabme").removeClass("frame_tab_s").removeClass(unselected_tab_css).addClass(unselected_tab_css);
	$(obj).removeClass(unselected_tab_css).addClass("frame_tab_s");

	var clickedObj = 0;
	var i = 0
	$("#frame_tabs .tabme").each(function(){
		i += 1;
		if ($(this).hasClass("frame_tab_s")) {
			clickedObj = i;
		}
	});

	i = 0;
	$("#frame_tabs .tabme_content").each(function(){
		i += 1;
		if (i == clickedObj) {
			$(this).show();
			//$(this).animate({opacity: 1}, 500).show();
		}
		else
		{
			$(this).hide();//animate({opacity: 0}, 500).hide();
		}
	});
}

