﻿/* Merged Plone Javascript file
 * This file is dynamically assembled from separate parts.
 * Some of these parts have 3rd party licenses or copyright information attached
 * Such information is valid for that section,
 * not for the entire composite file
 * originating files are separated by ----- filename.js -----
 */

/* ----- formsubmithelpers.js ----- */
function inputSubmitOnClick(event) {
    if (!event) var event = window.event; // IE compatibility

    if (hasClassName(this, 'submitting')) {
        return confirm(window.form_resubmit_message);
    } else {
        addClassName(this, 'submitting');
    }
    return true;
}

function registerSubmitHandler() {
    var nodes = cssQuery('input[type=submit]');
    for (var i=0; i<nodes.length; i++) {
        var node = nodes[i];
        if (!node.onclick) {
            node.onclick = inputSubmitOnClick;
        }
    }
}
registerPloneFunction(registerSubmitHandler);


/* ----- sbs_menu.js ----- */
  var ie5 = (document.all && document.getElementById);
  var ns6 = (!document.all && document.getElementById);
  var opac = 0;
  var nopac = 100;
  var timer;
  var curid;
  var selectedtop;
  var selectedsub;
  var actual;

  function showNav(id,tid) {
  var menuul = document.getElementById("topnav");
	var subdiv = document.getElementById("subnav");
	var uls = subdiv.getElementsByTagName("ul");
	var curul = document.getElementById(tid);
	var links = menuul.getElementsByTagName("a");
    for (var i=0; i<links.length; i++) {
  	  if (links[i]==curul) {
  		  links[i].className='selected'
      } else {
    	  links[i].className='';
      }
    }
    for (var i=0;i<uls.length;i++) {
	    if(uls[i].id == id) {
	      uls[i].className='';
	    } else {
        uls[i].className='hidenav';
	    }
	  }
  }
  window.onload = function() {
	  prepareLinks();
          ticker = setTimeout("rotateNews(0)",10000);
  }

  function prepareLinks() {
    var menuul = document.getElementById("topnav");
    var links = menuul.getElementsByTagName("a");
    for (var i=0; i<links.length; i++) {
      if (links[i].className == 'selected') { selectedtop = links[i]; }
      links[i].onmouseover = function() {
		    opac=0;
		    tid = this.getAttribute("id");
		    nid = "sub-" + tid;
        if(curid!=tid) { curid = tid; fadeIn(nid); }
		    showNav(nid,tid);
      }
    }
	var optionl = document.getElementById("optionsbox");
	if (optionl) {
      var links = optionl.getElementsByTagName("a");
      for (var i=0; i<links.length; i++) {
        links[i].onmouseover = function() {
		  clearTimeout(timer);
		  opac=40;
		  tid = this.className;
          fadeIn(tid);
        }
        links[i].onmouseout = function() {
	  	  nopac=100;
		  tid = this.className;
          fadeOut(tid);
        }
	  }
    }
  }
 
  function fadeIn(id) {
	  if(document.getElementById(id)) {
        if(ie5) document.getElementById(id).style.filter="alpha(opacity=100)";
        if(ns6) document.getElementById(id).style.MozOpacity = 1;
	  }
  } 
  
    function fadeOut(id) {
	  if(document.getElementById(id)) {
        if(ie5) document.getElementById(id).style.filter="alpha(opacity=40)";
        if(ns6) document.getElementById(id).style.MozOpacity = 40/100;
	  }
  } 
  
  function resetMenu(e) {
    if (!e) var e = window.event;
	  var tg = (window.event) ? e.srcElement : e.target;
	  if (tg.nodeName != 'DIV') return;
	  var reltg = (e.relatedTarget) ? e.relatedTarget : e.toElement;
          if (reltg) {
	    while (reltg != tg && reltg.nodeName != 'BODY') {
	  	    reltg = reltg.parentNode;
	  	  }
	    if (reltg == tg) return;
          }
      if (selectedtop) {
        tid = selectedtop.getAttribute("id");
        nid = "sub-" + tid;
        showNav(nid,tid);
      } else { 
        showNews(); 
      }
  }

  function showNews() {
    var menuul = document.getElementById("topnav");
    var subdiv = document.getElementById("subnav");
    var uls = subdiv.getElementsByTagName("ul");
    for (var i=0;i<uls.length;i++) {
        uls[i].className='hidenav';
    }
    var newslist=document.getElementById('news-list-ul');
    newslist.className='';
  }

  function rotateNews(id) {
    var newslist=document.getElementById('news-list-ul');
    if (!newslist) return;
    var newsdivs=newslist.getElementsByTagName("div");
    var newid = id + 1;
    for (var i=0; i<newsdivs.length; i++) {
      if (i==id) {
        newsdivs[i].className='';
      } else {
        newsdivs[i].className='hidenav';
      }
    }
    if (newid == newsdivs.length) newid=0;
    ticker = setTimeout("rotateNews(" + newid +")",10000);
  }

  function popUp(URL) {
    var nwin = window.open(URL, 'mapwindow', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=420,height=320');
  }


/* ----- flash.js ----- */
// JavaScript Document
var requiredVersion = 8;  		// version required

var flash2Installed = false;    // boolean. true if flash 2 is installed
var flash3Installed = false;    // boolean. true if flash 3 is installed
var flash4Installed = false;    // boolean. true if flash 4 is installed
var flash5Installed = false;    // boolean. true if flash 5 is installed
var flash6Installed = false;    // boolean. true if flash 6 is installed
var flash7Installed = false;    // boolean. true if flash 7 is installed
var flash8Installed = false;    // boolean. true if flash 7 is installed

var maxVersion = 8;             // highest version we can actually detect
var actualVersion = 0;          // version the user really has
var detected = false;			// have we already detected?
var hasRightVersion = false;			// Are we OK?

showFlash = function (LHIid, LHIfilename, LHIwidth, LHIheight) {

	if (!detected) {
		detectFlash();
		detected = true;
	}
	if (hasRightVersion && document.getElementById) {
		document.getElementById(LHIid).innerHTML = 	printTheCode(LHIfilename, LHIwidth, LHIheight);
		//document.getElementById(LHIid).style.display = "none";

	}
	return true;
}

printTheCode = function (LHIfilename, LHIwidth, LHIheight) {
	
	// Print out the code for the flash.
	text = '<object class="sliding_text" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=4,0,0,0"  width="' + LHIwidth + '" height="' + LHIheight + '" >';
	text += '	<param name=movie value="' + LHIfilename + '">';
	text += '	<param name=quality value=high>';
	text += '	<embed src="' + LHIfilename + '" quality=high width="' + LHIwidth + '" height="' + LHIheight + '" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>';
	text += '</object>';
	return text;
}


// Check the browser...we're looking for ie/win
var isIE = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;    // true if we're on ie
var isWin = (navigator.appVersion.indexOf("Windows") != -1) ? true : false; // true if we're on windows

// Write vbscript detection on ie win. IE on Windows doesn't support regular
// JavaScript plugins array detection.
if(isIE && isWin){
  document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n');
  document.write('on error resume next \n');
  document.write('flash2Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.2"))) \n');
  document.write('flash3Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.3"))) \n');
  document.write('flash4Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.4"))) \n');
  document.write('flash5Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.5"))) \n');  
  document.write('flash6Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.6"))) \n');  
  document.write('flash7Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.7"))) \n');  
  document.write('flash8Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.8"))) \n');  
  document.write('</SCR' + 'IPT\> \n'); // break up end tag so it doesn't end our script
}


detectFlash = function () {  
  // If navigator.plugins exists...
  if (navigator.plugins) {
    // ...then check for flash 2 or flash 3+.
    if (navigator.plugins["Shockwave Flash 2.0"]
        || navigator.plugins["Shockwave Flash"]) {

      // Some version of Flash was found. Time to figure out which.
      
      // Set convenient references to flash 2 and the plugin description.
      var isVersion2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
      var flashDescription = navigator.plugins["Shockwave Flash" + isVersion2].description;
 
      var flashVersion = parseInt(flashDescription.charAt(flashDescription.indexOf(".") - 1));
      
	  flash2Installed = flashVersion == 2;    
      flash3Installed = flashVersion == 3;
      flash4Installed = flashVersion == 4;
      flash5Installed = flashVersion == 5;
      flash6Installed = flashVersion == 6;
      flash7Installed = flashVersion == 7;
      flash8Installed = flashVersion >= 8;
    }
  }
  
  // Loop through all versions we're checking, and
  // set actualVersion to highest detected version.
  for (var i = 2; i <= maxVersion; i++) {  
    if (eval("flash" + i + "Installed") == true) actualVersion = i;
  }
  
  // If we're on webtv, the version supported is 2 (pre-summer2000, 
  // or 3, post-summer2000). Note that we don't bother sniffing varieties
  // of webtv. You could if you were sadistic...
  if(navigator.userAgent.indexOf("WebTV") != -1) actualVersion = 3;  

  // If the user has a new enough version...
  if (actualVersion >= requiredVersion) {
    hasRightVersion = true; 
  } else {  
    hasRightVersion = false; 
  }
  
}
