function formHandler(form){
  var URL = form.site.options[form.site.selectedIndex].value;
  window.location.href = URL;
}

function formsectionHandler(form){
  var URL = form.sectionnav.options[form.sectionnav.selectedIndex].value;
  window.location.href = URL;
}

//Fancy text scrolling script
var visible = 'visible';
var hidden = 'hidden';
var layerRef = '';
var styleRef = '';

if (navigator.appName == "Netscape"){
  visible = 'show';
  hidden = 'hide';
  layerRef = '.layers';
  styleRef = '';
}
else {
  visible = 'visible';
  hidden = 'hidden';
  layerRef = '.all';
  styleRef = '.style';
}

// begin absolutely positioned scrollable area object scripts

function verifyCompatibleBrowser(){
  this.ver=navigator.appVersion
  this.dom=document.getElementById?1:0
  this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom)?1:0;
  this.ie4=(document.all && !this.dom)?1:0;
  this.ns5=(this.dom && parseInt(this.ver) >= 5) ?1:0;
  this.ns4=(document.layers && !this.dom)?1:0;
  this.bw=(this.ie5 || this.ie4 || this.ns4 || this.ns5)
  return this
}

bw=new verifyCompatibleBrowser()
var speed=50
var loop, timer;

var initialised;

function ConstructObject(obj,nest){
  if(obj && document.getElementById(obj)){
    nest=(!nest) ? '':'document.'+nest+'.'
    this.el=bw.dom?document.getElementById(obj):bw.ie4?document.all[obj]:bw.ns4?eval(nest+'document.'+obj):0;
    this.css=bw.dom?document.getElementById(obj).style:bw.ie4?document.all[obj].style:bw.ns4?eval(nest+'document.'+obj):0;
    this.scrollHeight=bw.ns4?this.css.document.height:this.el.offsetHeight
    this.clipHeight=bw.ns4?this.css.clip.height:this.el.offsetHeight
    this.up=MoveAreaUp;this.down=MoveAreaDown;
    this.MoveArea=MoveArea; this.x; this.y;
    this.obj = obj + "Object"
    eval(this.obj + "=this")
    return this;
  }
}

function MoveArea(x,y){
  this.x=x;this.y=y
  this.css.left=this.x
  this.css.top=this.y
}

function MoveAreaDown(move){
  if(this.y>-this.scrollHeight+objContainer.clipHeight){
    this.MoveArea(0,this.y-move)
    if(loop){ setTimeout(this.obj+".down("+move+")",speed) }
  }
}

function MoveAreaUp(move){
  if(this.y<0){
    this.MoveArea(0,this.y-move)
    if(loop){ setTimeout(this.obj+".up("+move+")",speed) }
  }
}
function PerformScroll(speed){
  if(initialised){
    loop=true;
    if(speed>0){ objScroller.down(speed) }
    else { objScroller.up(speed) }
  }
}

function CeaseScroll(){
  loop=false
  if(timer){ clearTimeout(timer) }
}

function InitialiseScrollableArea(){
  objContainer=new ConstructObject('recentNewsScroller')
  objScroller=new ConstructObject('recentNewsItems','recentNewsScroller')
  objScroller.MoveArea(0,0)
  objContainer.css.visibility='visible'
  initialised=true;
}

/* Check if Flash can play */
var MM_FlashCanPlay = checkFlash();
var checkFlashCookieDomain='.agilissystems.com'

function checkFlash(){
  var MM_contentVersion = 6;
  var plugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;
  if (plugin) {
    var words = navigator.plugins["Shockwave Flash"].description.split(" ");
    for (var i = 0; i < words.length; ++i)
    {
      if (isNaN(parseInt(words[i])))
      continue;
      var MM_PluginVersion = words[i]; 
    }
    var MM_FlashCanPlay = MM_PluginVersion >= MM_contentVersion;
  }
  else if (navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0 
    && (navigator.appVersion.indexOf("Win") != -1)) {
    oFlash = eval("new ActiveXObject('ShockwaveFlash.ShockwaveFlash." + MM_contentVersion + "');");
    if(oFlash) { MM_FlashCanPlay = true; }
  }

  expires = new Date();
  expires.setFullYear(expires.getFullYear()+1);
  if(window.location.search == "?noflash=1"){ 
  	MM_FlashCanPlay = 0; 
  	// set no flash cookie
  	document.cookie="flash=0; expires="+ expires.toGMTString() +"; domain="+ checkFlashCookieDomain
  }
  else if(window.location.search == "?noflash=0" || window.location.search == "?flash=1"){
  	document.cookie="flash=1; expires="+ expires.toGMTString() +"; domain="+ checkFlashCookieDomain
  }
  else {
  	var c 	= document.cookie;
  	var pos = c.indexOf("flash=");
  	if(pos != -1){
  		var start = pos + 6;
  		var end   = c.indexOf(";",start);
  		if (end == -1){ end = c.length; }
  		var val = c.substring(start,end);
  		
  		if(val == "0"){
  			MM_FlashCanPlay = 0;
  		}
  	}
  }
  return MM_FlashCanPlay;
}

var PNMGFlash=[];
function Flash(file,width,height,div,image,flashCanPlay){
  this.file = file;
  this.width = width;
  this.height = height;
  this.div = div;
  this.image = image;
  this.flashCanPlay = flashCanPlay;
  
  if(this.flashCanPlay){ this.register(); }
}
Flash.prototype.getObject = function(){
  return '<object type="application/x-shockwave-flash" data="'+ this.file +'" width="'+ this.width +'" height="'+ this.height +'" wmode="transparent">'+
    '<param name="movie" value="'+ this.file +'" /><param name="wmode" value="transparent" /></object>';
}
Flash.prototype.register = function(){
  if(addLoadEvent){
    PNMGFlash[PNMGFlash.length]=this;
  }
  else { alert("PNMGFlash error: Could not show the flash because the function addLoadEvent() does not exist."); }
}
Flash.prototype.show = function(){
  if(document.getElementById){
    var e = getElement(this.div);
    if(e){
      showElement(e);
      if(getElement(this.image)){
        setElementClass(this.image,'printOnly');
        h=e.innerHTML + this.getObject();
        e.innerHTML='';
        e.innerHTML=h;
      }
      else { alert("PNMGFlash error: The image '"+ this.image +"' does not exist."); }
    }
    else { alert("PNMGFlash error: The flash div '"+ this.div +"' does not exist.");  }
  }
}
addLoadEvent(function(){
  for(var i=0;i<PNMGFlash.length;i++){
    PNMGFlash[i].show();
  }
});
