// JavaScript Document
jQuery(document).ready(function(){
						   
jQuery.noConflict();

jQuery('#gotop').click(function(){
	jQuery('html, body').animate({scrollTop:0}, 1000);
	return false;
});



jQuery(window).scroll(
function(){  
    if(jQuery(window).scrollTop()>=200){jQuery('#top-link').stop().fadeTo(1000,1).show()}
    else{
    if(jQuery('#top-link').css('opacity')!='0'){
    jQuery('#top-link').stop().fadeTo(500,0,function(){jQuery('#top-link').hide()})}}})
    jQuery('#top-link').click(function(){jQuery('html, body').animate({scrollTop:0},1000)
return false
})

jQuery(".voteazaBataliaLoading").height(jQuery(".teaserPoll").height())
jQuery(".teaserPoll").height(jQuery(".teaserPoll").height())




// STUDENT PARADE ANIMATION

var studentParadeImgsNr =  jQuery(".studentParadeImgs img").size();
var studentParadeCurrent = 0;
jQuery(".studentParadeImgs").css("width",760*studentParadeImgsNr)

studentParadeAnim();

function studentParadeAnim(){
	if (studentParadeCurrent < studentParadeImgsNr){
		jQuery('.studentParadeImgs').animate({
			left: -(760*studentParadeCurrent)+"px"
			}, 2000,function() {								
				jQuery('.studentParadeImgs').animate({	
						opacity: 1				
					}, 4000,function() {
					studentParadeCurrent++;
					studentParadeAnim();
				})	
		})
	}else{
		studentParadeCurrent = 0;
		jQuery('.studentParadeImgs').animate({
			left: -(760*studentParadeCurrent)+"px"
			}, 2000,function() {
				jQuery('.studentParadeImgs').animate({
						opacity: 1
					}, 4000,function() {
					studentParadeAnim();
				})
		})
	}
}



// NEWS LIST ANIMATION
jQuery(".newsListPlaceholder").scrollable({
	    vertical: true,
	    clickable: true,
	    circular:true,
	    speed:500,
	    easing:"swing"
    }).autoscroll({autoplay:true,interval:5000});


jQuery('#newsListPannel ul li').eq("2").clone().appendTo('#newsListPannel ul').addClass('cloned');
jQuery('#newsListPannel ul li').eq("3").clone().appendTo('#newsListPannel ul').addClass('cloned');
jQuery('#newsListPannel ul li').eq("4").clone().appendTo('#newsListPannel ul').addClass('cloned');
jQuery('#newsListPannel ul li').eq("5").clone().appendTo('#newsListPannel ul').addClass('cloned');
jQuery('#newsListPannel ul li').eq("6").clone().appendTo('#newsListPannel ul').addClass('cloned');
jQuery('#newsListPannel ul li').eq("7").clone().appendTo('#newsListPannel ul').addClass('cloned');
jQuery('#newsListPannel ul li').eq("8").clone().appendTo('#newsListPannel ul').addClass('cloned');
jQuery('#newsListPannel ul li').eq("9").clone().appendTo('#newsListPannel ul').addClass('cloned');





jQuery('#mainContentLeftCol a[rel*=lightbox-myGroup]').lightBox();

/*
-----------------------------------------------
/ Equalize height of the Graphic Teasers on the same line
-----------------------------------------------
*/

pannelHeight1 = jQuery(".contentCol .newVideos").height();
pannelHeight2 = jQuery(".contentCol .hot40Pannel").height();
	
if((pannelHeight1 != null) && (pannelHeight2 != null) && (pannelHeight1 > pannelHeight2))
{
    jQuery(".contentCol .hot40Pannel").height(pannelHeight1)
}
else 
if((pannelHeight1 != null) && (pannelHeight2 != null) && (pannelHeight1 < pannelHeight2))
{
    jQuery(".contentCol .newVideos").height(pannelHeight2)
}


pannelHeight1 = jQuery(".contentCol .newFaceBookLike").height();
pannelHeight2 = jQuery(".contentCol .newsListStiri").height();
	
if((pannelHeight1 != null) && (pannelHeight2 != null) && (pannelHeight1 > pannelHeight2))
{
    jQuery(".contentCol .newsListStiri").height(pannelHeight1)
}
else 
if((pannelHeight1 != null) && (pannelHeight2 != null) && (pannelHeight1 < pannelHeight2))
{
    jQuery(".contentCol .newFaceBookLike").height(pannelHeight2)
}


pannelHeight1 = jQuery(".contentCol .newMusicPannel").height();
pannelHeight2 = jQuery(".contentCol .newFaceBookStream").height();
	
if((pannelHeight1 != null) && (pannelHeight2 != null) && (pannelHeight1 > pannelHeight2))
{
    jQuery(".contentCol .newFaceBookStream").height(pannelHeight1)
}
else 
if((pannelHeight1 != null) && (pannelHeight2 != null) && (pannelHeight1 < pannelHeight2))
{
    jQuery(".contentCol .newMusicPannel").height(pannelHeight2)
}


pannelHeight1 = jQuery(".contentCol .topPaginiPannel").height();
pannelHeight2 = jQuery(".contentCol .podcastsPannel").height();

if ((pannelHeight1 != null) && (pannelHeight2 != null) && (pannelHeight1 > pannelHeight2)) {
    jQuery(".contentCol .podcastsPannel").height(pannelHeight1)
}
else
    if ((pannelHeight1 != null) && (pannelHeight2 != null) && (pannelHeight1 < pannelHeight2)) {
        jQuery(".contentCol .topPaginiPannel").height(pannelHeight2)
}



// TOP HEADER CURRENT/NEXT SHOW ANIMATION
currentShowFade();
function currentShowFade(){
	jQuery(".currentShowActive").delay(3000).fadeOut(500).delay(3000).fadeIn(500);
	jQuery(".currentShowNext").delay(3000).fadeIn(500).delay(3000).fadeOut(500);
	timeOutDelay = setTimeout(function () {currentShowFade()}, 3000); 
}



var tabsHeight;
// FRONT PAGE TABS TEXT HEIGHT PROBLEM FIX
jQuery("#headlinesTabs li").each(function(i){	
	jQuery(this).children("span").children("a").css('height', 'auto')
	tabsHeight = jQuery(this).children("span").children("a").height();
	jQuery(this).children("span").children("a").css("paddingTop", ((45-tabsHeight)/2)+"px")
	
});





// FRONTPAGE HEADLINES ANIMATION
var timeOutDelay;
var nrOfTabs = jQuery("#headlinesTabs li").size();
jQuery('#headlinesArticles li:first').addClass("activeBanner");
jQuery("#headlinesTabs li:first").addClass("activeTab");

frontPageHeadlinesAnim()

function frontPageHeadlinesAnim(){
	jQuery('#headlinesArticles .activeBanner').fadeIn(1000, function(){
			timeOutDelay = setTimeout(function () {		 
				jQuery('#headlinesArticles li').each(function(i){	
					if ( jQuery(this).hasClass('activeBanner'))	{
						jQuery('#headlinesArticles li:not(.activeBanner)').fadeOut(1000);
						jQuery('#headlinesArticles li.activeBanner').fadeIn(1000, function(){
							if (i < (nrOfTabs-1)){
								jQuery(this).removeClass("activeBanner").next().addClass("activeBanner");
								jQuery("#headlinesTabs li").removeClass("activeTab");
								jQuery("#headlinesTabs li").eq(i).addClass("activeTab");
							}else{
								jQuery(this).removeClass("activeBanner");
								jQuery('#headlinesArticles li:first').addClass("activeBanner");
								jQuery("#headlinesTabs li").removeClass("activeTab");
								jQuery("#headlinesTabs li:last").addClass("activeTab");
							}
							});
					}
				})				
			frontPageHeadlinesAnim()}, 5000);
	})	 
}


var headlineActiveTab;
var headlineActiveTabZIndex = 20;
jQuery("#headlinesArticles li:first").css("zIndex",headlineActiveTabZIndex);
jQuery("#headlinesTabs li").click(function(){
										   
	clearTimeout(timeOutDelay);
										   
	jQuery("#headlinesTabs li").removeClass("activeTab");
	jQuery(this).addClass("activeTab");
	headlineActiveTab = jQuery("#headlinesTabs li").index(this);
	headlineActiveTabZIndex++;
	
	jQuery("#headlinesArticles li").removeClass("activeBanner");
	jQuery("#headlinesArticles li").eq(headlineActiveTab).addClass("activeBanner")
	jQuery("#headlinesArticles li:not(.activeBanner)").fadeOut(1000);
	jQuery("#headlinesArticles li.activeBanner").fadeIn(1000);
	
	jQuery("#headlinesArticles li").eq(headlineActiveTab).css("zIndex",headlineActiveTabZIndex);
	
	timeOutDelay = setTimeout(function () {frontPageHeadlinesAnim()}, 5000); 
	
})

// if there are less than three teasers on a row, we need to clear the content or it won't take into consideration the .graphicTeaser{margin-bottom: 10px;}
if(jQuery.browser.msie){
     
}

});
