sfHover = function() {
	var sfEls = document.getElementById("vert-menu").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}

	}
	var sfEls = document.getElementById("horz-menu").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" hzhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" hzhover\\b"), "");
		}

	}

}
if (window.attachEvent) window.attachEvent("onload", sfHover);

// scrollbar

var scrollDiv=null;
var scrollSpeed=2;
var scrollerId;

function scrollSetup() {
  scrollDiv=document.getElementById('scrollbox');
  if (!scrollDiv) {
    alert("Scroll Box not found");
  }
}

function startScroll(dir) {
  switch (dir) {
    case 0:
      scrollerId = setInterval(scrollDown, 20);
      break;
    case 1:
      scrollerId = setInterval(scrollUp, 20);
      break;

  }
}
function scrollUp() {
  if (scrollDiv.scrollTop>0) {
    scrollDiv.scrollTop-=scrollSpeed;
  }
}

function scrollDown() {
  if ((scrollDiv.scrollTop)<(scrollDiv.scrollHeight-scrollDiv.offsetHeight)) {
    scrollDiv.scrollTop+=scrollSpeed;
  }
  
  
}

function stopScroller() {
  clearInterval (scrollerId);
}

var fadeEffect=function(){    
  return{       
    init:function(id, flag, target){
      this.elem = document.getElementById(id);            
      clearInterval(this.elem.si);            
      this.target = target ? target : flag ? 100 : 0;
      this.flag = flag || -1;
      this.alpha = this.elem.style.opacity ? parseFloat(this.elem.style.opacity) * 100 : 0;
      this.si = setInterval(function(){fadeEffect.tween()}, 20);
    },        
    tween:function(){           
      if(this.alpha == this.target){               
        clearInterval(this.elem.si);            
      }else{                
        var value = Math.round(this.alpha + ((this.target - this.alpha) * .05)) + (1 * this.flag);
        this.elem.style.opacity = value / 100;
        this.elem.style.filter = 'alpha(opacity=' + value + ')';
        this.alpha = value            
      }        
    }    
  }
}();

var quotes= new Array(5);
var currentQuote=0;
var currentStep=-1;
var quoteText;
quotes[0]='"Very thorough and informative... perfect level for both people who have never audited and those who have"<br/><span>Philips Respironics UK</span>';
quotes[1]='"Bywater are professional, competent and enjoyable to study with"<br/><span>CATCH, Impress<span>';
quotes[2]='"May I say how enjoyable the training was and the content and delivery of the course was excellent"<br/><span>Wyman-Gordon Limited</span>';
quotes[3]='"The trainer was approachable, made me feel relaxed and had good knowledge and experience"<br/><span>EDF Energy<span>';
quotes[4]='"My understanding of the standard vastly improved, the course was well presented and the tutor pitched it at the right level.  Highly recommended."<br/><span>Tube Lines</span>';

function nextQuote() {
  currentQuote++;
  if (currentQuote>=quotes.length) {
    currentQuote=0;
  }
  return quotes[currentQuote];
}

function beginQuoteRotator() {
  quoteText=document.getElementById("quoteText");
  
  if (!quoteText) return;
  quoteText.fadeState=0;
  quoteText.innerHTML=quotes[currentQuote];
  quoteRotator();
  
}

function quoteRotator() {
  currentStep++;
  if (currentStep>3) {
    currentStep=0;
  }
  
  switch (currentStep) {
    case 0 : // fade text up;
     quoteText.timer = setInterval("fadeUp()", 10);
     break;    
    case 1 : // wait 7 seconds;
     setTimeout("quoteRotator()",7000);
     break;
    case 2 : // fade text down;
     quoteText.timer = setInterval("fadeDown()", 10);
     break;
    case 3 : // display next quote
     quoteText.innerHTML=nextQuote();
     quoteRotator();
     break;
    
  }
}

function fadeUp() {
  quoteText.fadeState++;
  if (quoteText.fadeState>=100) {
    clearInterval(quoteText.timer); 
    quoteRotator();
  } else {
    quoteText.style.opacity = quoteText.fadeState / 100;
    quoteText.style.filter = 'alpha(opacity=' + quoteText.fadeState + ')';  
  } 
}

function fadeDown() {
  quoteText.fadeState--;
  if (quoteText.fadeState<=0) {
    clearInterval(quoteText.timer); 
    quoteRotator();
  } else {
    quoteText.style.opacity = quoteText.fadeState / 100;
    quoteText.style.filter = 'alpha(opacity=' + quoteText.fadeState + ')';  
  }
}
