function montre(id) {
  var d = document.getElementById(id);
	for (var i = 1; i<=20; i++) {
		if (document.getElementById('smenu'+i)) {
      document.getElementById('smenu'+i).style.display='none';
    }
	}
  if (d) {
    d.style.display='block';
  }
}

function hide(id) {
  var d = document.getElementById(id);
	for (var i = 1; i<=20; i++) {
		if (document.getElementById('coupon'+i)) {
      document.getElementById('coupon'+i).style.display='none';
    }
	}
  if (d) {
    d.style.display='block';
  }
}

function showcal(id) {
  var d = document.getElementById(id);
	for (var i = 1; i<=20; i++) {
		if (document.getElementById('cal'+i)) {
      document.getElementById('cal'+i).style.display='none';
    }
	}
  if (d) {
    d.style.display='block';
  }
}


function hide(id) {
  var d = document.getElementById(id);
	for (var i = 1; i<=20; i++) {
		if (document.getElementById('coupon'+i)) {
      document.getElementById('coupon'+i).style.display='none';
    }
	}
  if (d) {
    d.style.display='block';
  }
}

function show(id) {
  
  var p = document.getElementById( 'playlinks' );
  var c = 1;
  
  for( var i = 0; i < p.childNodes.length; i++ ) {
    if ( p.childNodes[i].tagName == 'LI' ) {
      p.childNodes[i].className = '';
      
      document.getElementById( 'play' + c ).style.display = 'none';
      
      if ( id == 'play' + c ) {
        p.childNodes[i].className = 'active';
        document.getElementById( 'play' + c ).style.display = 'block';
      }
      
      c ++;
    }
  }
}

function showone(id) {
  
  var p = document.getElementById( 'oneplaylinks' );
  var c = 1;
  
  for( var i = 0; i < p.childNodes.length; i++ ) {
    if ( p.childNodes[i].tagName == 'LI' ) {
      p.childNodes[i].className = '';
      
      document.getElementById( 'oneplay' + c ).style.display = 'none';
      
      if ( id == 'oneplay' + c ) {
        p.childNodes[i].className = 'active';
        document.getElementById( 'oneplay' + c ).style.display = 'block';
      }
      
      c ++;
    }
  }
}

function showtwo(id) {
  
  var p = document.getElementById( 'twoplaylinks' );
  var c = 1;
  
  for( var i = 0; i < p.childNodes.length; i++ ) {
    if ( p.childNodes[i].tagName == 'LI' ) {
      p.childNodes[i].className = '';
      
      document.getElementById( 'twoplay' + c ).style.display = 'none';
      
      if ( id == 'twoplay' + c ) {
        p.childNodes[i].className = 'active';
        document.getElementById( 'twoplay' + c ).style.display = 'block';
      }
      
      c ++;
    }
  }
}

function ReferenceBrowser() {
  
  this.sliders = new Array();
  this.activeSlideElement = null;
  this.timer = null;

  
  this.displayReference = function( ref ) {
    
    
    if ( !ref.reference || ref == this.activeSlideElement )
      return;
      
    this.activeSlideElement.className = '';
    this.activeSlideElement.reference.style.display = 'none';
    ref.reference.style.display = 'block';
    ref.className ='active';
    this.activeSlideElement = ref;
    
    
  }
  
  this.displayNext = function() {
    
    var ref = null;
    
    for ( var i = 0; i < this.sliders.length; i++ ) {
      if ( this.activeSlideElement == this.sliders[i] ) {
      
        if ( i == ( this.sliders.length - 1 ) )
          ref = this.sliders[0];
        else
          ref = this.sliders[i+1];
      
      }
    }
    
    if ( ref == null ) return;
    this.displayReference( ref );
    this.startSliding();
  }
  
  
  this.stopSliding = function() {
    clearTimeout( this.timer );
  }
  
  this.startSliding = function() {
      this.timer = setTimeout( 'window.rb.displayNext()', 3500 );
  }
  
  
  this.init = function( parent ) {
    var c = 1;
    for( var i = 0; i < parent.childNodes.length; i++ ) {
      var el = parent.childNodes[i];
      if ( el.tagName == 'LI') {
        el.reference = document.getElementById( 'slide' + c );
        c++;
        if ( el.className == 'active' ) {
          this.activeSlideElement = el;
        }
        
        el.onclick = function() {
          window.rb.stopSliding();
          window.rb.displayReference( this );
        }
        
        this.sliders.push( el );
        
      }
    }
  }
}

window.onload = function() {
  window.rb =  new ReferenceBrowser();
  window.rb.init( document.getElementById( 'reflinks' ) );
  window.rb.startSliding();
  
  
}

