function initTabs() {
	$('.tabset').each(function(){
		var _list = $(this);
		var _links = _list.find('a.tab');

		_links.each(function() {
			var _link = $(this);
			var _href = _link.attr('href');
			var _tab = $(_href);
			if(_link.hasClass('active')) _tab.show();
			else _tab.hide();

			_link.click(function(){
				_tab.show();
				_links.filter('.active').each(function(){
					$($(this).attr('href')).hide();
				});
				_links.removeClass('active');
				_link.addClass('active');
				return false;
			});
		});
	});
}

var count = 0;

function initMainRolloverAndTimer() {
		
		
    $("li.A-frame").mouseover(function() {
    $("#MainImage").attr("src","images/Social-entrepreneurship-A.jpg");
	if(count % 3 != 0){
			$(".promo-list .title-who").css("color","#d0d61b");
			$("#arrow_who").attr("src","images/arrow_hero_off.png");
	}
  });
    $("li.B-frame").mouseover(function() {
    $("#MainImage").attr("src","images/Social-entrepreneurship-B.jpg");
	if(count % 3 != 1){
		$(".promo-list .title-what").css("color","#d0d61b");
		$("#arrow_what").attr("src","images/arrow_hero_off.png");
	}
  });
    $("li.C-frame").mouseover(function() {
    $("#MainImage").attr("src","images/Social-entrepreneurship-C.jpg");
	if(count % 3 != 2){
		$(".promo-list .title-girls").css("color","#d0d61b");
		$("#arrow_girl").attr("src","images/arrow_hero_off.png");
	}
  });
  
   $("li.A-frame").mouseout(function() {
   $(".promo-list .title-who").css("color","#727206");
   $("#arrow_who").attr("src","images/arrow_hero_on.png");
  }); 
    $("li.B-frame").mouseout(function() {
    $(".promo-list .title-what").css("color","#727206");
	$("#arrow_what").attr("src","images/arrow_hero_on.png");
  });
    $("li.C-frame").mouseout(function() {
    $(".promo-list .title-girls").css("color","#727206");
	$("#arrow_girl").attr("src","images/arrow_hero_on.png");
  });

}




function swapImages(count) {
//alert(count);

    if(count % 3 == 0){
    	$("#MainImage").attr("src","images/Social-entrepreneurship-B.jpg");

		
		$(".promo-list li.B-frame a").css("background-color","#d8d8d8");
		 $(".promo-list .title-who").css("color","#727206");
		$(".promo-list li.A-frame a").css("background-color","");
		$(".promo-list li.C-frame a").css("background-color","");
		

		
	}if(count % 3 == 1){
		$("#MainImage").attr("src","images/Social-entrepreneurship-C.jpg");

		$(".promo-list li.C-frame a").css("background-color","#d8d8d8");
		 $(".promo-list .title-what").css("color","#727206");
		$(".promo-list li.B-frame a").css("background-color","");
		$(".promo-list li.A-frame a").css("background-color","");
		
	}if(count % 3 == 2){
		$("#MainImage").attr("src","images/Social-entrepreneurship-A.jpg");

		$(".promo-list li.A-frame a").css("background-color","#d8d8d8");
		 $(".promo-list .title-girls").css("color","#727206");
		$(".promo-list li.C-frame a").css("background-color","");
		$(".promo-list li.B-frame a").css("background-color","");
		
		
	}

}


$(document).ready(function(){
	initTabs();
	initMainRolloverAndTimer();
	
	setInterval(function(){swapImages(count++)}, 5000);
	
	setTimeout(function(){$('#flashAd').load("/Ads/homePage.htm");},20000);
	
	


});
