// JScript File
$(document).ready(function() {
    
//================= Right Column Resourse slider =====================
   
    var imgWid = $('.sliderCont li').width();
    var imgLeng = $('.sliderCont li').length
    $('.sliderCont ul').css('width', imgWid*imgLeng)
    
    $('.scroller a.next').click(function(ev){
            ev.preventDefault();
            if($('.sliderCont ul:animated').length == 0)
            var margCurr = parseInt($('.sliderCont ul').css('margin-left'))
            if(margCurr >= -($('.sliderCont li').length -2)*200)
                $('.sliderCont ul').animate({
		            "margin-left": (margCurr - 223)})
        });
        
        $('.scroller a.prev').click(function(ev){
            ev.preventDefault();
            if($('.sliderCont ul:animated').length == 0)
            var margCurr = parseInt($('.sliderCont ul').css('margin-left'))
            if(margCurr != 0)
                $('.sliderCont ul').animate({
		            "margin-left": (margCurr + 223)})
        });
    

});

//================= Homepage Tab Slider =====================

//array to store IDs of our tabs
var bannertab = [];
//index for array
var ind = 0;
//store setInterval reference
var inter;

//change tab and highlight current tab title
function change(stringref){
	//hide the other tabs
	$('.contentDiv:not(#' + stringref + ')').hide();
	//show proper tab, catch IE6 bug
	if ($.browser.msie && $.browser.version.substr(0,3) == "6.0")
		$('.contentDiv#' + stringref).show();
	else 
		$('.contentDiv#' + stringref).fadeIn();
	//clear highlight from previous tab title
	$('.bannertab a:not(#' + stringref + 't)').removeClass('actv');
	//highlight currenttab title
	$('.bannertab a[href=#' + stringref + ']').addClass('actv');
}
function next(){
	//call change to display next tab
	change(bannertab[ind++]);
	//if it's the last tab, clear the index
	if(ind >= 3)
		ind = 0;
}


$(document).ready(function(){
	//store all tabs in array
	$(".contentDiv").map(function(){
		bannertab[ind++] = $(this).attr("id");
    })
	//set index to next element to fade
	ind = 1;
	//initialize tabs, display the current tab
	$(".contentDiv:not(:first)").hide();
	$(".contentDiv:first").show();
	//highlight the current tab title
	$('#' + bannertab[0] + 't').addClass('actv');
	//handler for clicking on tabs
	$(".bannertab a").click(function(){
		
		//if tab is clicked, stop rotating 
		clearInterval(inter);
		//store reference to clicked tab
		stringref = $(this).attr("href").split('#')[1];
		//display referenced tab
		change(stringref);
		return false;
	});
	//start rotating tabs
	inter = setInterval("next()", 3000);
});


//================= Homepage Tab mrnu =====================

$(document).ready(function() {
    
//Default Action
	$(".popularArticle .tab_content").hide(); //Hide all content
	$(".popularArticle ul.tabs li:first").addClass("active").show(); //Activate first tab
	$(".popularArticle .tab_content:first").show(); //Show first tab content
	
	//On Click Event
	$(".popularArticle ul.tabs li").click(function(event) {
	    event.preventDefault();
		$(".popularArticle ul.tabs li").removeClass("active"); //Remove any "active" class
		$(this).addClass("active"); //Add "active" class to selected tab
		$(".popularArticle .tab_content").hide(); //Hide all tab content
		var activeTab = $(this).find("a").attr("href"); //Find the rel attribute value to identify the active tab + content
		$(activeTab).show(); //Fade in the active content
	});

	//Default Action
	$(".webcast .tab_content").hide(); //Hide all content
	$(".webcast ul.tabs li:first").addClass("active").show(); //Activate first tab
	$(".webcast .tab_content:first").show(); //Show first tab content
	
	//On Click Event
	$(".webcast ul.tabs li").click(function(event) {
	    event.preventDefault();
		$(".webcast ul.tabs li").removeClass("active"); //Remove any "active" class
		$(this).addClass("active"); //Add "active" class to selected tab
		$(".webcast .tab_content").hide(); //Hide all tab content
		var activeTab = $(this).find("a").attr("href"); //Find the rel attribute value to identify the active tab + content
		$(activeTab).show(); //Fade in the active content
	});
    

});
