/*
$(function(){
	$("ul.panel li:not("+$("ul.panel li a.selected").attr("href")+")").hide()
	$("ul.panel li a").click(function(){
		$("ul.panel li a").removeClass("selected");
		$(this).addClass("selected");
		$("ul.panel li").hide();
		$($(this).attr("href")).show();
		return false;
	});
});
*/
$(document).ready(function() {
  tab_current = 1;
  tab_button = 1;
  tab_images = 16;  // 10
  tab_width = 530;

  $('#panel-1').animate({ "left": "0px" }, 1000, "swing");
  $('#t1').css("backgroundPosition", "left bottom")
  $('#t1 t').css("color", "#fff");
  $('#loading').css("display", "none");


  $("#next").click(function() {
    tab_button = tab_current;
    tab_current++
    if (tab_current == (tab_images + 1)) { tab_current = 1 }
    animateLeft(tab_current, tab_button)
  });

  $("#previous").click(function() {
    tab_button = tab_current;
    tab_current--
    if (tab_current == 0) { tab_current = tab_images }
    animateRight(tab_current, tab_button)
  });

  $("#tab_container a").click(function() {
    tab_button = tab_current;
    clickButton = $(this).attr('id');
    tab_current = parseInt(clickButton.slice(1));
//	alert(tab_button+":"+tab_current);
    if (tab_current > tab_button) { animateLeft(tab_current, tab_button) }
    if (tab_current < tab_button) { animateRight(tab_current, tab_button) }
	settab_button(tab_current, tab_button)
});
/*
  $("#tab_buttons div b").mouseover(function() {
    if (($(this).css("color")) == "#16a" || ($(this).css("color")) == "rgb(17, 102, 170)") { $(this).css("color", "#000"); }
  });

  $("#tab_buttons div b").mouseout(function() {
    if (($(this).css("color")) == "#000" || ($(this).css("color")) == "rgb(0, 0, 0)") { $(this).css("color", "#16a"); }
  });
*/
  function animateLeft(tab_current, tab_button) {
    $('#panel-' + tab_current).css("left", tab_width + "px");
    $('#panel-' + tab_current).animate({ "left": "0px" }, 1000, "swing");
    $('#panel-' + tab_button).animate({ "left": -tab_width + "px" }, 1000, "swing");
    settab_button()
  }

  function animateRight(tab_current, tab_button) {
    $('#panel-' + tab_current).css("left", -tab_width + "px");
    $('#panel-' + tab_current).animate({ "left": "0px" }, 1000, "swing");
    $('#panel-' + tab_button).animate({ "left": tab_width + "px" }, 1000, "swing");
    settab_button()
  }

  function settab_button(tab_current, tab_button) {
    $('#t' + tab_button).css({
						backgroundImage : "url(http://www.feast.to/renew3/css6/image/tab.jpg)",
						display : "block",
						color : "blue",
						cursor: "pointer"

					})
	$('#t' + tab_current).css({
						backgroundImage : "url(http://www.feast.to/renew3/css6/image/tab_selected.jpg)",
						display : "block",
						color : "#333",
						cursor: "default"
					})
  }

});

