
var ActualPromo = 1;
var SwitchID = 0;

function promoSetUp() { // activates the promo slider
	
	if (document.getElementById("HomepagePromo") != null) {
			showPromo();
	}
	
}


// start positions for promo thumbnails - now are setted to be ousite of its container in the right side

function setPositions(PromoNr) { 

	if (!PromoNr) { PromoNr = ActualPromo; }

	fullwidth = document.body.clientWidth;
	xRight = fullwidth-350;
	xMiddle = parseInt(document.body.clientWidth/2);
	wypos = parseInt(document.getElementById("Header").offsetTop);

	document.getElementById('BigThumbnail'+PromoNr).style.left = xRight+'px';	
	document.getElementById('BigThumbnail'+PromoNr).style.top = 43+'px';		

	document.getElementById('MediumThumbnail'+PromoNr).style.left = xRight+'px';
	document.getElementById('MediumThumbnail'+PromoNr).style.top = 133+'px';		
	

}

function switchPromo(PromoNr) {

	if (PromoNr != ActualPromo) {

	// if somebody clicks very fast on promo buttons the queue is cleared first
	$('#PromoInfo'+ActualPromo).clearQueue();
	$('#MediumThumbnail'+ActualPromo).clearQueue();
	$('#BigThumbnail'+ActualPromo).clearQueue();
	clearTimeout(SwitchID);
	
	// here starts the transition between slides
	hidePromo(ActualPromo);
	$('#PButton'+ActualPromo).removeClass('PromoButton_on').addClass('PromoButton');
	ActualPromo = PromoNr;
	$('#PButton'+ActualPromo).removeClass('PromoButton').addClass('PromoButton_on');
	showPromo(PromoNr);
	
	}
	
}

function showPromo(PromoNr) {
	

	if (!PromoNr) {
		PromoNr = ActualPromo;
	}
	
	setPositions(PromoNr);
	
	fullwidth = document.body.clientWidth;
	xMiddle = parseInt(document.body.clientWidth/2);
	
	xRight1 = xMiddle+170;
	xRight2 = xMiddle+50;

	if (browser != 'Microsoft Internet Explorer') {
	$('#MediumThumbnail'+PromoNr).delay(timeEffects*0.25);
	$('#MediumThumbnail'+PromoNr).fadeIn(timeEffects*0.16);	
	$('#BigThumbnail'+PromoNr).delay(timeEffects*0.375);
	$('#BigThumbnail'+PromoNr).fadeIn(timeEffects*0.16);
	}
	else {
	$('#MediumThumbnail'+PromoNr).delay(timeEffects*0.25);
	$('#MediumThumbnail'+PromoNr).fadeIn(0);	
	$('#BigThumbnail'+PromoNr).delay(timeEffects*0.375);
	$('#BigThumbnail'+PromoNr).fadeIn(0);		
	}
		
	$('#PromoInfo'+ActualPromo).delay(timeEffects*0.375);
	$('#PromoInfo'+ActualPromo).fadeIn(timeEffects*0.20); // change this to animate the showing of promo text in another style

  $('#MTC'+ActualPromo).show(0);   
  $('#BTC'+ActualPromo).show(0);  	
  $('#MTC'+ActualPromo).fadeIn(0);   
  $('#BTC'+ActualPromo).fadeIn(0);
  
   
	$('#MediumThumbnail'+PromoNr).animate( { "left": xRight2 }, timeEffects*0.416); // change this to animate the hiding of smaller thumbnail in another style
  $('#BigThumbnail'+PromoNr).animate({"left": xRight1}, timeEffects*0.416); // change this to animate the hiding of bigger thumbnail in another style

    
	PromoNr = ActualPromo+1;

	if (document.getElementById('PButton'+PromoNr) == null) {
		PromoNr = 1;
	}
	
	if (autoSlides == 'yes') {
		SwitchID = setTimeout("switchPromo("+PromoNr+")", timeBetweenSlides);    
	}

}

function hidePromo(PromoNr) {
	
	if (!PromoNr) {
		PromoNr = ActualPromo;
	}
	
	xMiddle = parseInt(document.body.clientWidth/2);
	fullwidth = document.body.clientWidth;
	xRight = fullwidth-350;
		
	$('#PromoInfo'+ActualPromo).delay(timeEffects*0.25);
	$('#PromoInfo'+ActualPromo).fadeOut(timeEffects*0.20); // change this to animate the hiding of promo text in another style
 
	$('#MediumThumbnail'+PromoNr).animate({ "left": xRight}, timeEffects*0.125); // change this to animate the hiding of smaller thumbnail in another style
  $('#BigThumbnail'+PromoNr).delay(timeEffects*0.083);
 	$('#BigThumbnail'+PromoNr).animate({"left": xRight}, timeEffects*0.125); // change this to animate the hiding of bigger thumbnail in another style

	$('#MTC'+ActualPromo).delay(timeEffects*0.25);
	$('#BTC'+ActualPromo).delay(timeEffects*0.375);
  $('#MTC'+ActualPromo).fadeOut(0)
  $('#BTC'+ActualPromo).fadeOut(0)

	if (browser != 'Microsoft Internet Explorer') {

	$('#BigThumbnail'+PromoNr).fadeOut(timeEffects*0.16);
	$('#MediumThumbnail'+PromoNr).fadeOut(timeEffects*0.16);	
	
	}
	else {
	$('#BigThumbnail'+PromoNr).fadeOut(0);
	$('#MediumThumbnail'+PromoNr).fadeOut(0);			
	}
   
}

var mousex;
var mousey;

jQuery(document).ready(function(){
   $(document).mousemove(function(e){
      mousex = e.pageX;
      mousey = e.pageY;
   }); 
})


	


function show_details(obj) {
	
	$('#'+obj).show(0);
	
}


function popup_details(obj) {
	document.getElementById(obj).style.left = mousex+'px';
	document.getElementById(obj).style.top = mousey+'px';	
}

function hide_details(obj) {
	
	$('#'+obj).hide(0);
	
}

function changeHomepageTabs(obj, buttobj) {
	
	$('#UserSelectedArticles').fadeOut(200);
	$('#LatestArticles').fadeOut(200);
	$('#LatestTopics').fadeOut(200);
	
	$('#Butt1').removeClass('CurrentPagedepth1').addClass('depth1');
	$('#Butt2').removeClass('CurrentPage');
	$('#Butt3').removeClass('CurrentPagedepth3').addClass('depth3');
	
	if (buttobj == 'Butt1') {
		$('#'+buttobj).removeClass('depth1').addClass('CurrentPagedepth1');
	}
	if (buttobj == 'Butt2') {
		$('#'+buttobj).addClass('CurrentPage');
	}
	if (buttobj == 'Butt3') {
		$('#'+buttobj).removeClass('depth3').addClass('CurrentPagedepth3');
	}	
	
	$('#'+obj).delay(200);
	$('#'+obj).fadeIn(200);
	
}


