var rotator = "";

function resumeRotate() {
  var elementscount = $(".tab_content").length;
  if (rotate_type == 1) {
    if (rotate_delay > 0 && elementscount > 1) {
      rotator = setTimeout('changeActiveTab()', rotate_delay);
    }
  } else if (rotate_type == 2) {
    if (image_delay > 0 && elementscount > 1) {
      rotator = setTimeout('changeActiveTab()', image_delay);
    }
  }
}

function changeActiveTab () {
	
  	 var selectedTab = $("ul.tabs li a.active");
  	 if (selectedTab.parent().next().children().attr("href")) {
  	    nextTab = selectedTab.parent().next();
  	 } else { nextTab = $("ul.tabs li:first");
		 }
		 var nextA = nextTab.children();
	 
	  $("ul.tabs li a").removeClass("active"); //Remove any "active" class
		nextA.addClass("active"); //Add "active" class to selected tab
		$(".tab_content").hide(); //Hide all tab content
		$(".tab_container_news").hide(); //S
 
		var activeTab = nextA.attr("href"); //Find the href attribute value to identify the active tab + content
		$(activeTab).fadeIn(); //Fade in the active ID content
		var activeTab2 = nextA.attr("rel"); //Find the href attribute value to identify the active tab + content
		$(activeTab2).fadeIn(); //Fade in the active ID content
		
    if (rotate_type == 1) {
      if (rotate_delay > 0) {
        rotator = setTimeout('changeActiveTab()', rotate_delay);
      }
    } else if (rotate_type == 2) {
      if (image_delay > 0) {
        rotator = setTimeout('changeActiveTab()', image_delay);
      }
    }
		
		return false;
	}

$(document).ready(function() {
  
	//tab 1
	$(".tab_content").hide(); //Hide all content
	$(".tab_container_news").hide(); //S
	$("ul.tabs li:first").addClass("active").show(); //Activate first tab
	$(".tab_content:first").show(); //Show first tab content
	$(".tab_container_news:first").show(); //S
	
 
	//On Click Event
	$("ul.tabs li a").click(function() {
 
		$("ul.tabs li a").removeClass("active"); //Remove any "active" class
		$(this).addClass("active"); //Add "active" class to selected tab
		$(".tab_content").hide(); //Hide all tab content
		$(".tab_container_news").hide(); //S
 
		var activeTab = $(this).attr("href"); //Find the href attribute value to identify the active tab + content
		$(activeTab).fadeIn(); //Fade in the active ID content
		var activeTab2 = $(this).attr("rel"); //Find the href attribute value to identify the active tab + content
		$(activeTab2).fadeIn(); //Fade in the active ID content
		return false;
	});
	
	//tab 2
	$(".tabb_content").hide(); //Hide all content
	$("ul.tabbs li:first").addClass("active").show(); //Activate first tab
	$(".tabb_content:first").show(); //Show first tab content
 
	//On Click Event
	$("ul.tabbs li").click(function() {
 
		$("ul.tabbs li").removeClass("active"); //Remove any "active" class
		$(this).addClass("active"); //Add "active" class to selected tab
		$(".tabb_content").hide(); //Hide all tab content
 
		var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content
		$(activeTab).fadeIn(); //Fade in the active ID content
		return false;
	});

	var elementscount = $(".tab_content").length;
  if (rotate_type == 1) {
  	if (rotate_delay > 0 && elementscount > 1) {
	    rotator = setTimeout('changeActiveTab()', rotate_delay);
    }
  } else if (rotate_type == 2) {
  	if (image_delay > 0 && elementscount > 1) {
	    rotator = setTimeout('changeActiveTab()', image_delay);
    }
  }

});

