var activeArticle = 1;
var isPlaying = 0;

	var opacity1 = 100;
	var opacity2 = 0;
	var processing = 0;

	function showArticle(id, play)
	{
		if(!processing)
		{
			document.getElementById('article_slider_page_'+activeArticle).style.color = '#94938e';
			
			if(id == 'prev')
			{
			if((play && isPlaying) || (!play && !isPlaying))
				{
				activeArticle == 1 ? id = slide_count : id = parseInt(activeArticle)-1;
				
				current = document.getElementById('article_'+id);
				active  = document.getElementById('article_'+activeArticle);
				
				opacity1 = 100;
				opacity2 = 0;
				
				processing = 1;
				crossfade(active.id, current.id);
				processing = 0;
				
				activeArticle = id;
				}
			}
			else if(id == 'next')
			{
				if((play && isPlaying) || (!play && !isPlaying))
				{
					activeArticle == slide_count ? id = 1 : id = parseInt(activeArticle)+1;
					
					current = document.getElementById('article_'+id);
					active  = document.getElementById('article_'+activeArticle);
					
					opacity1 = 100;
					opacity2 = 0;
					
					processing = 1;
					crossfade(active.id, current.id);
					processing = 0;
					
					activeArticle = id;
					
					if(isPlaying)
						setTimeout("javascript:showArticle('next', 1);", 3000);
				}
			}
			else
			{
				current = document.getElementById('article_'+id);
				active  = document.getElementById('article_'+activeArticle);
				
				opacity1 = 100;
				opacity2 = 0;
				
				processing = 1;
				crossfade(active.id, current.id);
				processing = 0;
				
				activeArticle = id;
			}
			document.getElementById('article_slider_page_'+activeArticle).style.color = '#000000';
		}
	}
	
	function playPauseSlide()
	{
		isPlaying = 1 - isPlaying;
		if (isPlaying)
		{
			document.getElementById('slidecontroller').src = '/images/pause.png';
			setTimeout("javascript: showArticle('next', 1);", 3000);
		}
		else
		{
			document.getElementById('slidecontroller').src = '/images/play.png';
		}
	}

	function setOpacity(obj, opacity)
	{
     opacity = (opacity == 100)?99.999:opacity;
     // IE/Win  
	//obj.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity='+opacity+')';
	 obj.style.filter = "alpha(opacity="+opacity+")";  
     // Safari<1.2, Konqueror  
     obj.style.KHTMLOpacity = opacity/100;
     // Older Mozilla and Firefox  
     obj.style.MozOpacity = opacity/100;  
     // Safari 1.2, newer Firefox and Mozilla, CSS3  
     obj.style.opacity = opacity/100;  
 }
	
	function crossfade(objId1, objId2)
	{
		obj1 = document.getElementById(objId1);
		obj2 = document.getElementById(objId2);

		obj1.style.zIndex = 0;
		obj2.style.zIndex = 1;
		
		if (opacity2 <= 100)
		{
			setOpacity(obj1, opacity1);
			opacity1 -= 10;
			setOpacity(obj2, opacity2);
			opacity2 += 10;
			
			window.setTimeout("crossfade('"+objId1+"','"+objId2+"')", 70);
		}
	}