
var dcurrent = 1;
var rint;

function rotateDemo( dindex, manual )
{
	if( dindex == null )
		dindex = dcurrent == 3 ? 1 : dcurrent + 1;
	
	if( manual )
		clearInterval( rint );
	
	document.getElementById( 'demo_content_'+dcurrent ).style.display = 'none';
	document.getElementById( 'demo_link_'+dcurrent ).className = document.getElementById( 'demo_link_'+dcurrent ).className.replace( ' current', '' ); 
	
	document.getElementById( 'demo_content_'+dindex ).style.display = 'block';
	document.getElementById( 'demo_link_'+dindex ).className += ' current';
	
	dcurrent = dindex;
}

function startDemoRotation()
{
	rint = setInterval( "rotateDemo()", 5000 );
}
function setLinks() 
{
  if( !document.getElementsByTagName ) return false;
  
  var links = document.getElementsByTagName("a");
  if( links.length == 0 ) return false;

  for( var i = 0; i < links.length; i++ ) 
  {
    var relation = links[i].getAttribute("rel");
    if (relation == "blank") 
      links[i].onclick = function() { return !window.open(this.href); }
  }
}

window.onload = function() {
	setLinks();
	startDemoRotation();
}


