var displayArray=new Array("premiumcontent1","premiumcontent2");
var currentPremium=1;
var loopTimer = 0;
var drop1down="FALSE";
var drop2down="FALSE";

function searchfocus() {
  document.searchform.searchboxfield.style.color="#333333";
}
function searchunfocus() {
  document.searchform.searchboxfield.style.color="#666666";
}

function showdropmenu(whichone) {
  if (whichone==1) {
    if(drop1down=="TRUE") {
      fadeOut("dropmenu1content");
      drop1down="FALSE";
    }
    else {
      if(drop2down=="TRUE") {
        fadeOut("dropmenu2content");
        drop2down="FALSE";
      }

      fadeIn("dropmenu1content");      
      drop1down="TRUE";
    }
  }
  else if (whichone==2) {
    if(drop2down=="TRUE") {
      fadeOut("dropmenu2content");
      drop2down="FALSE";
    }
    else {
      if(drop1down=="TRUE") {
        fadeOut("dropmenu1content");
        drop1down="FALSE";
      }

      fadeIn("dropmenu2content");      
      drop2down="TRUE";
    }
  }
  else if (whichone==0) {
    if(drop1down=="TRUE") {
      fadeOut("dropmenu1content");
      drop1down="FALSE";
    }
    if(drop2down=="TRUE") {
      fadeOut("dropmenu2content");
      drop2down="FALSE";
    }
  }
}

function toggleDisplay(id){
       var e = document.getElementById(id);
       if(e.style.display == 'block') {
          e.style.display = 'none';
       }
       else {
          e.style.display = 'block';
       }
}

function setOpacity(eID, opacityLevel) {
    var eStyle = document.getElementById(eID).style;
    eStyle.opacity = opacityLevel / 100;
    eStyle.filter = 'alpha(opacity='+opacityLevel+')';
}

function changeto(whichone) {
  if (whichone!=currentPremium) {
    show("premiumcontent"+whichone);
    hide("premiumtop"+currentPremium);
    show("premiumtop"+whichone);    
    setOpacity("premiumcontent"+whichone, 0);
    fadeOut("premiumcontent"+currentPremium);
    fadeIn("premiumcontent"+whichone);
  
    currentPremium=whichone;
  }
  clearTimeout(loopTimer);
  loopTimer = setTimeout("loopPremium()", 10000);
}

function fade(eID, startOpacity, stopOpacity, duration) {
    var speed = Math.round(duration / 100);
    var timer = 0;
    if (startOpacity < stopOpacity){ // fade in
        for (var i=startOpacity; i<=stopOpacity; i++) {
            setTimeout("setOpacity('"+eID+"',"+i+")", timer * speed);
            timer++;
        } return;
    }
    for (var i=startOpacity; i>=stopOpacity; i--) { // fade out
        setTimeout("setOpacity('"+eID+"',"+i+")", timer * speed);
        timer++;
    }
}

function getElm(eID) {
    return document.getElementById(eID);
}
function show(eID) {
    getElm(eID).style.display='block';
}
function hide(eID) {
    getElm(eID).style.display='none';
}
function fadeIn(eID) {
    setOpacity(eID, 0); show(eID); var timer = 1;
    for (var i=1; i<=100; i+=1) {
        setTimeout("setOpacity('"+eID+"',"+i+")", timer * 1);
        timer++;
    }
}
function fadeOut(eID) {
    var timer = 0;
    for (var i=100; i>=1; i-=1) {
        setTimeout("setOpacity('"+eID+"',"+i+")", timer * 1);
        timer++;
    }
    setTimeout("hide('"+eID+"')", 100);
}

function loopPremium() {
  var nextOne=1;
  if (currentPremium == 2)
    nextOne=1;
  else nextOne=currentPremium+1;
  changeto(nextOne);
  clearTimeout(loopTimer);
  loopTimer = setTimeout("loopPremium()", 10000);
}

setTimeout("changeto("+(currentPremium+1)+")", 10000);



