/* public web pages functions :- all javascript in one file
   main.js
   print.js
   menu.js
   cookies.js
   dropdowns.js
   tree.js
   googlemap functions
   brainjar menu code
*/

/* main.js start */

function test123(){
	alert('d123');
}

/************************** START GLOBAL JS FUNCTIONS **************************/
function divStyle(theDiv)
{
if (document.getElementById) return document.getElementById(theDiv).style;
return eval("document."+((document.all)?"all."+theDiv+".style":theDiv));
}
function clipDiv(thisDiv,cT,cR,cB,cL)
{
if (document.all || document.getElementById) divStyle(thisDiv).clip = "rect("+cT+" "+cR+" "+cB+" "+cL+")";
else
{
divStyle(thisDiv).clip.top = cT;
divStyle(thisDiv).clip.bottom = cB;
divStyle(thisDiv).clip.left = cL;
divStyle(thisDiv).clip.right = cR;
}
}
function showDiv(thisDiv)
{
if (document.getElementById) node=document.getElementById(thisDiv).style.visibility='visible';
else divStyle(thisDiv).visibility = "visible"
}
function hideDiv(thisDiv)
{
if (document.getElementById) node = document.getElementById(thisDiv).style.visibility='hidden';
else divStyle(thisDiv).visibility=(document.all)?"hidden":"hide";
}
function _go(fName,sName,div) {
if (document.layers && div){
if (eval("document." + div + ".document." + fName + "." + sName + ".options[document." + div + ".document." + fName + "." + sName + ".selectedIndex].value"))
location.href=eval("document." + div + ".document." + fName + "." + sName + ".options[document." + div + ".document." + fName + "." + sName + ".selectedIndex].value");
} else {
if (eval("document." + fName + "." + sName + ".options[document." + fName + "." + sName + ".selectedIndex].value"))
location.href=eval("document." + fName + "." + sName + ".options[document." + fName + "." + sName + ".selectedIndex].value");
}
}
/*************************************************/
var mfBannerIndex = 2;
function mfBannerChange2() {
var nxtBan, prevBan;
var vis;
vis = mfBannerIndex - 1;
if (vis == 0) vis = 6;
nxtBan = "ban" + mfBannerIndex;
prevBan = "ban" + vis;
if (document.all){
eval ("document.all." + nxtBan + ".style.visibility = 'visible'");
eval ("document.all." + prevBan + ".style.visibility = 'hidden'");
} else {
eval ("document." + nxtBan + ".visibility = 'visible'");
eval ("document." + prevBan + ".visibility = 'hidden'");
}
mfBannerIndex++;
if(mfBannerIndex > 6)
mfBannerIndex = 1;
}
function startBan(){
if (document.all){
document.all.ban1.style.visibility = 'visible';
} else {
document.ban1.visibility = 'visible';
}
setInterval("mfBannerChange2()", 3000);
}
/****************************************** NS Resize Script */
if (document.layers)
{
origWidth = innerWidth;
origHeight = innerHeight;
}
function resizeDetected()
{
if (document.layers)
{
if (innerWidth != origWidth || innerHeight != origHeight)
{
// location.reload();
location.href = location.href;
}
}
}

    function expandCollapseLayers(name, collapseOthers) {
				targetId = "div_" + name;
        targetElement = document.all(targetId);
        if (targetElement.style.display == "none")
          targetElement.style.display = "";
        else
          targetElement.style.display = "none";

	//collapse other layers starting 'div_'

        if (targetElement.style.display == "none" || !collapseOthers)
          return;

	var objLayers = document.getElementsByTagName('DIV');
		for (var i=0;i<objLayers.length; i++)
	  if (objLayers[i].id.substring(0,4)=='div_' && objLayers[i].id != 'div_'+name)
	    objLayers[i].style.display = "none";
    }


    //insert into textarea. IE support only
    function insertAtCursor(oTA, val) {
	if (document.selection) {
		oTA.focus();
		sel = document.selection.createRange();
		sel.text = val;
	}
    }

    //insert link into texterea. IE support only
    function insertLinkIntoTextArea(oTA, url1) {
	if (document.selection) {
	  oTA.focus();
	  sel = document.selection.createRange();

	  var fullurl;
	  if (url1.indexOf('www.')==0)
	    fullurl = 'http://' + url1;
	  else
	    fullurl = '/' + url1;	// doesnt work on XP

	  if (sel.text != '')
	    sel.text = '<a href="' + fullurl + '">' + trimString(sel.text) + '</a> ';
	  else
	    sel.text = '<a href="' + fullurl + '">' + url1 + '</a> ';
	}
    }

    function trimString (str) {
			str = this != window? this : str;
			return str.replace(/^\s+/g, '').replace(/\s+$/g, '');
    }


	//SB: function to load an iframe or frame (get round Mac/Firefox issues)
	function loadFrame(frameid, src) {

		var oFrame = document.getElementById(frameid);
		if (oFrame) {
	    oFrame.src = src;
	    return;
	  }

		oFrame = eval('parent.'+frameid);
	  if (oFrame) {
	    oFrame.location.href = src;
	    return;
	  }

		oFrame = eval('document.'+frameid);
	  if (oFrame) {
      document.podeditframe.assign(src);
      return;
    }

    alert('Error: Frame ' + frameid + ' does not exist');
	}


/************************** END GLOBAL JS FUNCTIONS **************************/

/* main.js end */

/* print.js start */

var gAutoPrint = true; // Flag for whether or not to automatically call the print function


// printSpecial
// first, try to find the IFRAME and print contents
// otherwise, find the print DIV Tags and print contents
// otherwise, print the complete window

function printSpecial(printdivid, printTitle) {
	if (document.getElementById != null) {
	  if (document.IFRAME || window.frames['IFRAME']) {
	  	//window.status = 'print iframe';
	  	printiframe();
	  } else {
			var html = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">\n<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">\n<head>\n';
			if (document.getElementsByTagName != null) {
				var headTags = document.getElementsByTagName("head");
				if (headTags.length > 0)
					html += headTags[0].innerHTML;
			}

			//inhibit frame-checking function
			html = html.replace('checkFrameStructure(','//checkFrameStructure(');
			html += '\n</he' + 'ad>\n<body>\n';

			var divid;
			if (printdivid)
				divid = printdivid;
			else
				divid = 'printReady';

			var printReadyElem = document.getElementById(divid);

			if (printReadyElem != null) {
				if (printTitle && printTitle!='')
					html = html + '<b>' + printTitle + '</b><br />';
				html += printReadyElem.innerHTML;
			} else {
				//window.status = 'print complete window';
				window.print();
				return;
			}

			//print area between div tags
			html += '\n</BO' + 'DY>\n</HT' + 'ML>';
			var printWin = window.open("", "printSpecial");
			printWin.document.open();
			printWin.document.write(html);
			printWin.document.close();
			if (gAutoPrint)
				printWin.print();
	  }
	} else
		alert('Sorry, the print feature is only available in modern browsers');
}


function CheckIsIE() {
  return (navigator.appName.toUpperCase() == 'MICROSOFT INTERNET EXPLORER');
}

function isMac() {
	return (navigator.appVersion.indexOf('Mac')>0);
}

function isIe() {
	return (navigator.appName.toUpperCase() == 'MICROSOFT INTERNET EXPLORER');
}

function printiframe() {
  if (CheckIsIE()) {
	document.IFRAME.focus();
	document.IFRAME.print();
  } else {
	window.frames['IFRAME'].focus();
	window.frames['IFRAME'].print();
  }
}

function printiframe2(frameName) {
	if (isMac()) {
  	window.status = 'opening iframe for printing (mac)';
		var url2 = window.frames[frameName].location;
		openWin(url2, 700, 800, 50, 50, 'scrollbars=yes,toolbar=no,menubar=yes,location=no');
	} else if (isIe()) {
  	window.status = 'printing iframe (ie)';
		eval('document.' +frameName + '.focus()');
		eval('document.' +frameName + '.print()');
  } else {
  	window.status = 'printing iframe (non-ie)';
		window.frames[frameName].focus();
		window.frames[frameName].print();
  }
}

/* print.js end */


/* menu.js start

function Browser() {

  var ua, s, i;

  this.isIE    = false;  // Internet Explorer
  this.isNS    = false;  // Netscape
  this.version = null;

  ua = navigator.userAgent;

  s = "MSIE";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isIE = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  s = "Netscape6/";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  // Treat any other "Gecko" browser as NS 6.1.

  s = "Gecko";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = 6.1;
    return;
  }
}

var browser = new Browser();

//----------------------------------------------------------------------------
// Code for handling the menu bar and active button.
//----------------------------------------------------------------------------

var activeButton = null;


function buttonClick(event, menuId) {
  var button;

  // Get the target button element.

  if (browser.isIE)
    button = window.event.srcElement;
  else
    button = event.currentTarget;

  // Blur focus from the link to remove that annoying outline.

  button.blur();

  // Associate the named menu to this button if not already done.
  // Additionally, initialize menu display.

  if (button.menu == null) {
    button.menu = document.getElementById(menuId);
    if (button.menu.isInitialized == null)
      menuInit(button.menu);
  }

  // [MODIFIED] Added for activate/deactivate on mouseover.

  // Set mouseout event handler for the button, if not already done.

  if (button.onmouseout == null)
    button.onmouseout = buttonOrMenuMouseout;

  // Exit if this button is the currently active one.

  if (button == activeButton)
    return false;

  // [END MODIFIED]

  // Reset the currently active button, if any.

  if (activeButton != null)
    resetButton(activeButton);

  // Activate this button, unless it was the currently active one.

  if (button != activeButton) {
    depressButton(button);
    activeButton = button;
  }
  else
    activeButton = null;

  return false;
}

function buttonMouseover(event, menuId) {
  var button;

  // [MODIFIED] Added for activate/deactivate on mouseover.

  // Activates this button's menu if no other is currently active.

  if (activeButton == null) {
    buttonClick(event, menuId);
    return;
  }

  // [END MODIFIED]

  // Find the target button element.

  if (browser.isIE)
    button = window.event.srcElement;
  else
    button = event.currentTarget;

  // If any other button menu is active, make this one active instead.

  if (activeButton != null && activeButton != button)
    buttonClick(event, menuId);
}

function depressButton(button) {

  var x, y;

  // Update the button's style class to make it look like it's
  // depressed.

  button.className += " menuOptionActive";

  // [MODIFIED] Added for activate/deactivate on mouseover.

  // Set mouseout event handler for the button, if not already done.

  if (button.onmouseout == null)
    button.onmouseout = buttonOrMenuMouseout;
  if (button.menu.onmouseout == null)
    button.menu.onmouseout = buttonOrMenuMouseout;

  // [END MODIFIED]

  // Position the associated drop down menu under the button and
  // show it.

  x = getPageOffsetLeft(button);
  y = getPageOffsetTop(button) + button.offsetHeight;

  // For IE, adjust position.

  if (browser.isIE) {
    x += button.offsetParent.clientLeft;
    y += button.offsetParent.clientTop;
  }

  button.menu.style.left = x + "px";
  button.menu.style.top  = y + "px";
  button.menu.style.visibility = "visible";
}

function resetButton(button) {

  // Restore the button's style class.

  removeClassName(button, "menuOptionActive");

  // Hide the button's menu, first closing any sub menus.

  if (button.menu != null) {
    closeSubMenu(button.menu);
    button.menu.style.visibility = "hidden";
  }
}

//----------------------------------------------------------------------------
// Code to handle the menus and sub menus.
//----------------------------------------------------------------------------

function menuMouseover(event) {

  var menu;

  // Find the target menu element.

  if (browser.isIE)
    menu = getContainerWith(window.event.srcElement, "DIV", "menu");
  else
    menu = event.currentTarget;

  // Close any active sub menu.

  if (menu.activeItem != null)
    closeSubMenu(menu);
}

function menuItemMouseover(event, menuId) {

  var item, menu, x, y;

  // Find the target item element and its parent menu element.

  if (browser.isIE)
    item = getContainerWith(window.event.srcElement, "A", "menuItem");
  else
    item = event.currentTarget;
  menu = getContainerWith(item, "DIV", "menu");

  // Close any active sub menu and mark this one as active.

  if (menu.activeItem != null)
    closeSubMenu(menu);
  menu.activeItem = item;

  // Highlight the item element.

  item.className += " menuItemHighlight";

  // Initialize the sub menu, if not already done.

  if (item.subMenu == null) {
    item.subMenu = document.getElementById(menuId);
    if (item.subMenu.isInitialized == null)
      menuInit(item.subMenu);
  }

  // [MODIFIED] Added for activate/deactivate on mouseover.

  // Set mouseout event handler for the sub menu, if not already done.

  if (item.subMenu.onmouseout == null)
    item.subMenu.onmouseout = buttonOrMenuMouseout;

  // [END MODIFIED]

  // Get position for submenu based on the menu item.

  x = getPageOffsetLeft(item) + item.offsetWidth;
  y = getPageOffsetTop(item);

  // Adjust position to fit in view.

  var maxX, maxY;

  if (browser.isNS) {
    maxX = window.scrollX + window.innerWidth;
    maxY = window.scrollY + window.innerHeight;
  }
  if (browser.isIE) {
    maxX = Math.max(document.documentElement.scrollLeft, document.body.scrollLeft) +
      (document.documentElement.clientWidth != 0 ? document.documentElement.clientWidth : document.body.clientWidth);
    maxY = Math.max(document.documentElement.scrollTop, document.body.scrollTop) +
      (document.documentElement.clientHeight != 0 ? document.documentElement.clientHeight : document.body.clientHeight);
  }
  maxX -= item.subMenu.offsetWidth;
  maxY -= item.subMenu.offsetHeight;

  if (x > maxX)
    x = Math.max(0, x - item.offsetWidth - item.subMenu.offsetWidth
      + (menu.offsetWidth - item.offsetWidth));
  y = Math.max(0, Math.min(y, maxY));

  // Position and show the sub menu.

  item.subMenu.style.left = x + "px";
  item.subMenu.style.top  = y + "px";
  item.subMenu.style.visibility = "visible";

  // Stop the event from bubbling.

  if (browser.isIE)
    window.event.cancelBubble = true;
  else
    event.stopPropagation();
}

function closeSubMenu(menu) {

  if (menu == null || menu.activeItem == null)
    return;

  // Recursively close any sub menus.

  if (menu.activeItem.subMenu != null) {
    closeSubMenu(menu.activeItem.subMenu);
    menu.activeItem.subMenu.style.visibility = "hidden";
    menu.activeItem.subMenu = null;
  }
  removeClassName(menu.activeItem, "menuItemHighlight");
  menu.activeItem = null;
}

// [MODIFIED] Added for activate/deactivate on mouseover. Handler for mouseout
// event on buttons and menus.

function buttonOrMenuMouseout(event) {

  var el;

  // If there is no active button, exit.

  if (activeButton == null)
    return;

  // Find the element the mouse is moving to.
  if (browser.isIE)
    el = window.event.toElement;
  else if (event.relatedTarget != null)
      el = (event.relatedTarget.tagName ? event.relatedTarget : event.relatedTarget.parentNode);

  // If the element is not part of a menu, reset the active button.

  if (getContainerWith(el, "DIV", "menu") == null) {
    resetButton(activeButton);
    activeButton = null;
  }
}

// [END MODIFIED]

//----------------------------------------------------------------------------
// Code to initialize menus.
//----------------------------------------------------------------------------

function menuInit(menu) {

  var itemList, spanList;
  var textEl, arrowEl;
  var itemWidth;
  var w, dw;
  var i, j;

  // For IE, replace arrow characters.

  if (browser.isIE) {
    menu.style.lineHeight = "2.5ex";
    spanList = menu.getElementsByTagName("SPAN");
    for (i = 0; i < spanList.length; i++)
      if (hasClassName(spanList[i], "menuItemArrow")) {
        spanList[i].style.fontFamily = "Webdings";
        spanList[i].firstChild.nodeValue = "4";
      }
  }

  // Find the width of a menu item.

  itemList = menu.getElementsByTagName("A");
  if (itemList.length > 0)
    itemWidth = itemList[0].offsetWidth;
  else
    return;

  // For items with arrows, add padding to item text to make the
  // arrows flush right.

  for (i = 0; i < itemList.length; i++) {
    spanList = itemList[i].getElementsByTagName("SPAN");
    textEl  = null;
    arrowEl = null;
    for (j = 0; j < spanList.length; j++) {
      if (hasClassName(spanList[j], "menuItemText"))
        textEl = spanList[j];
      if (hasClassName(spanList[j], "menuItemArrow"))
        arrowEl = spanList[j];
    }
    if (textEl != null && arrowEl != null)
      textEl.style.paddingRight = (itemWidth
        - (textEl.offsetWidth + arrowEl.offsetWidth)) + "px";
  }

  // Fix IE hover problem by setting an explicit width on first item of
  // the menu.

  if (browser.isIE) {
    w = itemList[0].offsetWidth;
    itemList[0].style.width = w + "px";
    dw = itemList[0].offsetWidth - w;
    w -= dw;
    itemList[0].style.width = w + "px";
  }

  // Mark menu as initialized.

  menu.isInitialized = true;
}

//----------------------------------------------------------------------------
// General utility functions.
//----------------------------------------------------------------------------

function getContainerWith(node, tagName, className) {

  // Starting with the given node, find the nearest containing element
  // with the specified tag name and style class.

  while (node != null) {
    if (node.tagName != null && node.tagName == tagName &&
        hasClassName(node, className))
      return node;
    node = node.parentNode;
  }

  return node;
}

function hasClassName(el, name) {

  var i, list;

  // Return true if the given element currently has the given class
  // name.

  list = el.className.split(" ");
  for (i = 0; i < list.length; i++)
    if (list[i] == name)
      return true;

  return false;
}

function removeClassName(el, name) {

  var i, curList, newList;

  if (el.className == null)
    return;

  // Remove the given class name from the element's className property.

  newList = new Array();
  curList = el.className.split(" ");
  for (i = 0; i < curList.length; i++)
    if (curList[i] != name)
      newList.push(curList[i]);
  el.className = newList.join(" ");
}

function getPageOffsetLeft(el) {

  var x;

  // Return the x coordinate of an element relative to the page.

  x = el.offsetLeft;
  if (el.offsetParent != null)
    x += getPageOffsetLeft(el.offsetParent);

  return x;
}

function getPageOffsetTop(el) {

  var y;

  // Return the x coordinate of an element relative to the page.

  y = el.offsetTop;
  if (el.offsetParent != null)
    y += getPageOffsetTop(el.offsetParent);

  return y;
}

 menu.js end */



/* cookies.js start */

  // Set a cookie given a name, value and expiration date.

  function setCookie (name, value, expires) {
    var cookie = escape(name) + "=" + escape(value);
    cookie += "; expires=" + expires.toGMTString();
    cookie +=  "; path=/";

    document.cookie = cookie;
  }

  function setCookieDays (name, value, numDays) {
    var cookie = escape(name) + "=" + escape(value);
    var dt = new Date();
    dt.setTime (dt.getTime() + (86400 * 1000 * numDays));
    cookie += "; expires=" + dt.toGMTString();
    cookie +=  "; path=/";
    document.cookie = cookie;
  }


  // Returns the value of the named cookie.

  function getCookieValue(name) {

    var search, cookieValue;

    cookieValue = "";

    search = name + "=";
    offset = document.cookie.indexOf(search);
    if (offset != -1) {
      offset += search.length;
      end = document.cookie.indexOf(";", offset);
      if (end == -1)
        end = document.cookie.length;
        cookieValue = unescape(document.cookie.substring(offset, end));
    }
    return cookieValue;
  }


  // Delete the named cookie.

  function deleteCookie(name) {

    var expdate = new Date();
    expdate.setTime(expdate.getTime() - (86400 * 1000 * 1));
    setCookie(name, "", expdate);
  }

/* cookies.js end */



/* dropdowns.js start */

  // removes items from a select box. removes all unless a range is supplied
  function removeItems(fromCtrl, idxFrom, idxTo) {
    var from;
    var to;
    var l = fromCtrl.options.length;
    if (!idxFrom) from = 0; else from = idxFrom;
    if (!idxTo) to = l; else to = idxTo;

    for (i = from; i < to; i++)
      fromCtrl.options[fromCtrl.options.length - 1] = null;
  }


  // removes Item(s) from a select box by locating its value
  function removeItemByValue(ctrl, val, newIdx) {
    for (var i = 0; i < ctrl.options.length; i++)
      if (ctrl.options[i].value == val)
        ctrl.options[i] = null;
    if (newIdx) ctrl.selectedIndex = newIdx;
  }


  // adds an item to a select box at end
  function addItem(toCtrl, value, name) {
    var nextitem = toCtrl.options.length;
    toCtrl.options[nextitem] = new Option(name);
    toCtrl.options[nextitem].value = value;
  }

	function moveItems2(FromItem, ToItem) {
    var spacerName, aNode, v, n;
    var fromCount = FromItem.options.length;

    for (var i=0; i<fromCount; i++) {
      v = FromItem.options[i].value;
      n = FromItem.options[i].text;

      if (v != '') {
        if (FromItem.options[i].selected) {

		  		//remove option from from-dropdown
		  		removeItemByValue(FromItem, v);

		  		//and add to to-dropdown
		  		addItem(ToItem, v, n);

		  		fromCount = FromItem.options.length;
		  		i = i-1;
				}
			}
		}
	}

  // transfers items from one select box to another (uses spacer-node)
	function moveItems(FromItem, ToItem) {
    var spacerName, aNode, v, n;
    var fromCount = FromItem.options.length;

    for (var i=0; i<fromCount; i++) {
      v = FromItem.options[i].value;
      n = FromItem.options[i].text;

      if (v != '') {
        if (FromItem.options[i].selected) {
		  		//remove spacer option from To-dropdown
		  		spacerName = ToItem.options[ToItem.options.length-1].text;
		  		removeItemByValue(ToItem, '');

		  		//remove option from from-dropdown
		  		removeItemByValue(FromItem, v);

		  		//and add to to-dropdown
		  		addItem(ToItem, v, n);

				  //put spacer option back
				  addItem(ToItem, '', spacerName);

		  		fromCount = FromItem.options.length;
		  		i--;
				}
			}
		}
	}

/* dropdowns.js end */




/* tree.js start */

    function clickHandler() {

      var targetID, srcElement, theLayer, theImage;
      srcElement = window.event.srcElement;

      if (srcElement.className == "tree")
        targetID = srcElement.id;
      else if (srcElement.className == "treeLabel")
        targetID = srcElement.id.replace('Label','');
      else
      	return;

      for (var i=0;i<document.images.length;i++)
	if (document.images[i].id == targetID) {
	  theLayer = document.all(targetID + 'V');
	  theImage = document.images[i];
	}

      if (theLayer.style.display == "none") {
           theLayer.style.display = "";
           theImage.src = theImage.src.replace('open.gif','close.gif');
      } else {
           theLayer.style.display = "none";
           theImage.src = theImage.src.replace('close.gif','open.gif');
      }
    }

    document.onclick = clickHandler;

/* tree.js end */


/* functions.js start */

/* general javascript functions */

    //openWin
    //open a window of specified size and position.
    //prevent multiple opens

    var theWin;
    function openWin (theurl, w, h, x, y, params) {
      if (theWin && theWin.open && !theWin.closed) {
      	//window is open
      	theWin.location = theurl;
      	theWin.focus();
      } else {
				//open window
        if (!x || x==0) x=screen.width/2 - w/2;
        if (!y || y==0) y=screen.height/2 - h/2;
        if (!params)
          params = 'scrollbars=no,toolbar=no,menubar=no,location=no,left=' + x + ',top=' + y + ',height=' + h + ',width=' + w;
        else
          params = params + ',left=' + x + ',top=' + y + ',height=' + h + ',width=' + w;
        theWin = window.open(theurl, '', params)
      }
    }

		function openWin2 (w,h,params,file) {
			openWin(file, w, h, 0, 0, params);
		}

    //openModelessWin
    //open a modeless window of specified size
    function openModelessWin(url,w,h) {
      if (document.all && window.print) //ie5
        eval('window.showModelessDialog(url,"","help:0;resizable:1;dialogWidth:'+w+'px;dialogHeight:'+h+'px")')
      else
        eval('window.open(url,"","width='+w+'px,height='+h+'px,resizable=1,scrollbars=1")')
    }


  // add an element to an array at the specified index

  function addElement(arr, idx, val) {
    var size = arr.length;
    for (var i=arr.length+1;i>idx; i--)
      arr[i] = arr[i-1];
    arr[idx] = val;
    arr.length = arr.length-1;
  }


  // delete the specified index from an array

  function deleteElement(arr, idx) {
    var size = arr.length;
    for (var j=idx;j<size-1;j++)
      if (j != size) arr[j] = arr[j+1];
    arr.length = size - 1;
  }


   // delete the specified range of indices from an array

  function deleteElementRange(arr, idx1, idx2) {
    var range;
    var size = arr.length;

    if (idx2>=size) idx2=size-1;
    range = idx2-idx1+1;

    var d = 0;
    for (var j=idx2;j<size-1;j++) {
      if (idx2+d<size) arr[idx1+d] = arr[idx2+d+1];
      d++;
    }
    arr.length = size - range;
  }


  function isvalidtime(timStr) {
    var timePat = /^(\d{1,2}):(\d{2})(:(\d{2}))?(\s?(AM|am|PM|pm))?$/;
    var matchArray = timStr.match(timePat);
    if (matchArray == null) {
      return "time format must be '00:00'";
    }
    hour = matchArray[1];
    minute = matchArray[2];

    if (hour < 0  || hour > 23) {
      return "hours must be between 0 and 23";
    }
    if (minute<0 || minute > 59) {
      return "minutes must be between 0 and 59.";
    }
    return "";
  }


  function isEmail (str) {
    // are regular expressions supported?
    var supported = 0;
    if (window.RegExp) {
      var tempStr = "a";
      var tempReg = new RegExp(tempStr);
      if (tempReg.test(tempStr)) supported = 1;
    }
    if (!supported)
      return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
    var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
    var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
    return (!r1.test(str) && r2.test(str));
  }

	//valid persons name checker
  function isPhone(str) {
  	return consistsOf(str,'+0123456789 ');
  }

  function isYear (val) {
    var ch;
    var digits = '0123456789';
    for (var i=0;i<val.length;i++) {
      ch = val.substring(i,i+1);
      if (digits.indexOf(ch)==-1)
        return false;
    }
    return (val.length == 4);
  }

  function isDNS (strDNS) {
    //var DNSpattern=/^(\w{1,30})\.(\w{1,30})\.(\w{1,3})?$/;
    //return (patternMatches(strDNS, DNSpattern));
    return (strDNS.length > 6);
  }


  function isIP (strIP) {
    var IPpattern=/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})?$/;
    return (patternMatches(strIP, IPpattern));
  }

  function isNumber (val) {
    var ch;
    var allowedChars = '0123456789. ';
    for (var i=0;i<val.length;i++) {
      ch = val.substring(i,i+1);
      if (allowedChars.indexOf(ch)==-1)
        return false;
    }
    return true;
  }

  function isPhoneNumber (val) {
    var ch;
    var allowedChars = '0123456789+ ';
    for (var i=0;i<val.length;i++) {
      ch = val.substring(i,i+1);
      if (allowedChars.indexOf(ch)==-1)
        return false;
    }
    return true;
  }


  function isSMS (val) {
    var ch;
    var allowedChars = '0123456789+ ';
    for (var i=0;i<val.length;i++) {
      ch = val.substring(i,i+1);
      if (allowedChars.indexOf(ch)==-1)
        return false;
    }
    return true;
  }

  function isName (str) {
  	return consistsOf(str,"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ '-");
  }

	function isPostcode(p) {
		var postcodeRegEx = /[A-Z]{1,2}[0-9]{1,2} ?[0-9][A-Z]{2}/i;
		return postcodeRegEx.test(p);
	}

	/*	AB120XY -> AB1 0XY */
	function tidyPostcode(p) {
		if (isPostcode(p)) {
			var postcodeRegEx = /(^[A-Z]{1,2}[0-9]{1,2})([0-9][A-Z]{2}$)/i;
			return p.replace(postcodeRegEx,"$1 $2");
		} else {
			return p;
		}
	}

  function isBlank(val) {
    var ch;
    for (var i=0;i<val.length;i++) {
      ch = val.substring(i,i+1);
      if (ch != ' ')
        return false;
    }
    return true;
  }

  function isStandardFilename(filePath) {
  	var fname = getFilenameFromPath(filePath);
		return consistsOf(fname, 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789. _-');
  }

	function getFilenameFromPath(filePath) {
		var arr = filePath.split("\\");
		return arr[arr.length-1];
	}

  function consistsOf(val,allowedChars) {
    var ch;
    for (var i=0;i<val.length;i++) {
      ch = val.substring(i,i+1);
      if (allowedChars.indexOf(ch)==-1)
        return false;
    }
    return true;
  }

  function isAlphanumeric(val) {
    var ch;
    var allowedChars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
    for (var i=0;i<val.length;i++) {
      ch = val.substring(i,i+1);
      if (allowedChars.indexOf(ch)==-1)
        return false;
    }
    return true;
  }

  function isTextOnlyParagraph(s) {
    var ch, chCode;
    var allowedChars = '1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ';
    for (var i=0;i<s.length;i++) {
      ch = s.substring(i,i+1);
      chCode = ch.charCodeAt(0);
      if (allowedChars.indexOf(ch)<0 && chCode!=10 && chCode!=13)
        return false;
    }
    return true;
  }

  function isNormalText(s) {
    var ch, chCode;
    var allowedChars = "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ !-?$%*£().,&/[]<>#'";
    for (var i=0;i<s.length;i++) {
      ch = s.substring(i,i+1);
      chCode = ch.charCodeAt(0);
      if (allowedChars.indexOf(ch)<0 && chCode!=10 && chCode!=13)
        return false;
    }
    return true;
  }

  function numberTextLines(s) {
    var arr = s.split("\n");
    return arr.length;
  }

  // isValidDate
  // returns true when date has format dd/mm/yyyy
  function isValidDate(strDate) {
    var DatePattern=/^(\d{1,2})\/(\d{1,2})\/(\d{4})?$/;
    return (patternMatches(strDate, DatePattern));
  }


  // match a string to a pattern
  // examples
  // /^(\d{1,6})?(.(\d{1,2}))?$/;	// 9, 9.9, 9.99, 99.99 - 999999.99
  // /[a-z]{3}\d{2}/i;			// XXX99, ABC01

  function patternMatches (str, pattern) {
    var res = str.match(pattern);
    return (res != null);
  }


  var patternKnownDomains=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum|co|uk)$/;


  // returns true if valid domain.
  // NoWWW and CheckTLD are optional, both accept values of true, false, and null.
  // NoWWW is used to check that a domain name does not begin with 'www.', eg. for WHOIS lookups.
  function isValidDomain(sDomain, NoWWW, CheckTLD) {
	//if (CheckTLD==null) {CheckTLD=true}
	var specialChars="/\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
	var validChars="\[^\\s" + specialChars + "\]";
	var atom=validChars + '+';
	var atomPat=new RegExp("^" + atom + "$");
	var domArr=sDomain.split(".");
	var len=domArr.length;

	if (len==1)
	  return false;			//invalid

	for (var i=0;i<len;i++)
	  if (domArr[i].search(atomPat)==-1)
	    return false;		//invalid

	//if ((CheckTLD) && (domArr[domArr.length-1].length!=2) && (domArr[domArr.length-1].search(patternKnownDomains)==-1))
	//  return false;		//must end in a well-known domain or two letter country

	if ((NoWWW) && (sDomain.substring(0,4).toLowerCase()=="www."))
	  return false;		//do not include www

	return true;
  }

  function findObjectByName(obj, name, tagType) {
	    var objList = obj.getElementsByTagName(tagType);
	    for (var i = 0; i < objList.length; i++)
	      if (objList[i].id == name) {
					//alert(objList[i].id);
	        return objList[i];
	      }
  }


  // startSessionMonitor
  // starts a timer that warns after x minutes if the page has not been submitted
  function startSessionMonitor(numMinutes) {
    setTimeout('warnSession(' + numMinutes + ')', numMinutes*1000*60);
  }

  // warnSession
  // pops up the session expire warning page
  function warnSession(numMinutes) {
    openWin('sessionexpire.asp?m='+numMinutes, 300, 100)
  }

  function confirmnavigate(msg, urlpath) {
    if (confirm(msg))
      document.location.href = urlpath;
  }

  //finds an element and changes its inner text
  function changeInnerText(elementId, txt) {
    if (document.getElementById) {
      var ele = document.getElementById(elementId);
      if (!ele)
      	return;
      if (document.all)
      	ele.innerText = txt;
      else
      	ele.textContent = txt;
		}
  }

  function changeElementInnerText(ele, txt) {
		if (!ele)
     	return;
    if (document.all)
    	ele.innerText = txt;
     else
     	ele.textContent = txt;
  }

	//look for element with old title
  function changeLabel(oldLabel, newLabel) {
  	var i, oElements;
		oElements = document.getElementsByTagName('H1');
		for (i=0;i<oElements.length; i++) {
	  	if (oElements[i].innerHTML == oldLabel) {
	  		oElements[i].innerHTML = newLabel;
	  		return;
	  	}
    }

		oElements = document.getElementsByTagName('H2');
		for (i=0;i<oElements.length; i++) {
	  	if (oElements[i].innerHTML == oldLabel) {
	  		oElements[i].innerHTML = newLabel;
	  		return;
	  	}
    }

		oElements = document.getElementsByTagName('P');
		for (i=0;i<oElements.length; i++) {
	  	if (oElements[i].innerHTML == oldLabel) {
	  		oElements[i].innerHTML = newLabel;
	  		return;
	  	}
    }
		oElements = document.getElementsByTagName('DIV');
		for (i=0;i<oElements.length; i++) {
	  	if (oElements[i].innerHTML == oldLabel) {
	  		oElements[i].innerHTML = newLabel;
	  		return;
	  	}
    }
	}


/* functions.js end */


/* stuff to show/hide rows. see useredit.asp */

function toggleRows(id) {
      var obj;
      for (var i=1;i<10;i++) {
        obj = document.getElementById(id+''+i);
        if (obj)
          toggleVis(obj);
        else
          break;
      }
      var img = document.getElementById(id+'0');
      if (img) {
        img.src = img.src.replace('close.gif','x.gif');
        img.src = img.src.replace('open.gif','close.gif');
        img.src = img.src.replace('x.gif','open.gif');
      };
}

function toggleVis(myItem) {
	if (myItem.style.visibility != 'hidden') {
		HideItem(myItem);
	} else {
		ShowItem(myItem);
	}
	return false;
}
function ShowItem(myItem) {
	myItem.style.visibility = 'visible';
	myItem.style.display = '';
}
function HideItem(myItem) {
	myItem.style.visibility = 'hidden';
	myItem.style.display = 'none';
}




/*************************************/
/**** tooltips ***********************/

/*
 Please leave this notice.
 DHTML tip message version 1.2 copyright Essam Gamal 2003 (http://migoicons.tripod.com, migoicons@hotmail.com)
 All modifications are done in the style.js you should not modify this file.  Created on : 06/03/2003
 Script featured on and can be found at Dynamic Drive (http://www.dynamicdrive.com)
*/

var ua = navigator.userAgent
var ps = navigator.productSub
var dom = (document.getElementById)? 1:0
var ie4 = (document.all&&!dom)? 1:0
var ie5 = (document.all&&dom)? 1:0
var nn4 =(navigator.appName.toLowerCase() == "netscape" && parseInt(navigator.appVersion) == 4)
var nn6 = (dom&&!ie5)? 1:0
var sNav = (nn4||nn6||ie4||ie5||ie6||ie7)? 1:0
var cssFilters = ((ua.indexOf("MSIE 5.5")>=0||ua.indexOf("MSIE 6")>=0)&&ua.indexOf("Opera")<0)? 1:0
var Style=[],Text=[],Count=0,sbw=0,move=0,hs="",mx,my,scl,sct,ww,wh,obj,sl,st,ih,iw,vl,hl,sv,evlh,evlw,tbody
var HideTip = "eval(obj+sv+hl+';'+obj+sl+'=0;'+obj+st+'=-800')"
var doc_root = ((ie5&&ua.indexOf("Opera")<0||ie4)&&document.compatMode=="CSS1Compat")? "document.documentElement":"document.body"
var PX = (nn6)? "px" :""

if(sNav) {
	window.onresize = ReloadTip
	document.onmousemove = MoveTip
	if(nn4) document.captureEvents(Event.MOUSEMOVE)
}
if(nn4||nn6) {
	mx = "e.pageX"
	my = "e.pageY"
	scl = "window.pageXOffset"
	sct = "window.pageYOffset"
	if(nn4) {
		obj = "document.TipLayer."
		sl = "left"
		st = "top"
		ih = "clip.height"
		iw = "clip.width"
		vl = "'show'"
		hl = "'hide'"
		sv = "visibility="
	}
	else obj = "document.getElementById('TipLayer')."
}
if(ie4||ie5) {
	obj = "TipLayer."
	mx = "event.x"
	my = "event.y"
	scl = "eval(doc_root).scrollLeft"
	sct = "eval(doc_root).scrollTop"
	if(ie5) {
		mx = mx+"+"+scl
		my = my+"+"+sct
	}
}
if(ie4||dom){
	sl = "style.left"
	st = "style.top"
	ih = "offsetHeight"
	iw = "offsetWidth"
	vl = "'visible'"
	hl = "'hidden'"
	sv = "style.visibility="
}
if(ie4||ie5||ps>=20020823) {
	ww = "eval(doc_root).clientWidth"
	wh = "eval(doc_root).clientHeight"
}
else {
	ww = "window.innerWidth"
	wh = "window.innerHeight"
	evlh = eval(wh)
	evlw = eval(ww)
	sbw=15
}

function applyCssFilter(){
	if(cssFilters&&FiltersEnabled) {
		var dx = " progid:DXImageTransform.Microsoft."
		TipLayer.style.filter = "revealTrans()"+dx+"Fade(Overlap=1.00 enabled=0)"+dx+"Inset(enabled=0)"+dx+"Iris(irisstyle=PLUS,motion=in enabled=0)"+dx+"Iris(irisstyle=PLUS,motion=out enabled=0)"+dx+"Iris(irisstyle=DIAMOND,motion=in enabled=0)"+dx+"Iris(irisstyle=DIAMOND,motion=out enabled=0)"+dx+"Iris(irisstyle=CROSS,motion=in enabled=0)"+dx+"Iris(irisstyle=CROSS,motion=out enabled=0)"+dx+"Iris(irisstyle=STAR,motion=in enabled=0)"+dx+"Iris(irisstyle=STAR,motion=out enabled=0)"+dx+"RadialWipe(wipestyle=CLOCK enabled=0)"+dx+"RadialWipe(wipestyle=WEDGE enabled=0)"+dx+"RadialWipe(wipestyle=RADIAL enabled=0)"+dx+"Pixelate(MaxSquare=35,enabled=0)"+dx+"Slide(slidestyle=HIDE,Bands=25 enabled=0)"+dx+"Slide(slidestyle=PUSH,Bands=25 enabled=0)"+dx+"Slide(slidestyle=SWAP,Bands=25 enabled=0)"+dx+"Spiral(GridSizeX=16,GridSizeY=16 enabled=0)"+dx+"Stretch(stretchstyle=HIDE enabled=0)"+dx+"Stretch(stretchstyle=PUSH enabled=0)"+dx+"Stretch(stretchstyle=SPIN enabled=0)"+dx+"Wheel(spokes=16 enabled=0)"+dx+"GradientWipe(GradientSize=1.00,wipestyle=0,motion=forward enabled=0)"+dx+"GradientWipe(GradientSize=1.00,wipestyle=0,motion=reverse enabled=0)"+dx+"GradientWipe(GradientSize=1.00,wipestyle=1,motion=forward enabled=0)"+dx+"GradientWipe(GradientSize=1.00,wipestyle=1,motion=reverse enabled=0)"+dx+"Zigzag(GridSizeX=8,GridSizeY=8 enabled=0)"+dx+"Alpha(enabled=0)"+dx+"Dropshadow(OffX=3,OffY=3,Positive=true,enabled=0)"+dx+"Shadow(strength=3,direction=135,enabled=0)"
	}
}
function showTip(s) {
  show_tip(['', s]);
}

function show_tip(t,s) {
  if (!s) s = Style[12];
  if(sNav) {
  	if(t.length<2 || s.length<25) {
		var ErrorNotice = "DHTML TIP MESSAGE VERSION 1.2 ERROR NOTICE.\n";
		if(t.length<2 && s.length<25)
			alert(ErrorNotice+"It looks like you removed an entry or more from the Style Array and Text Array of this tip.\nTheir should be 25 entries in every Style Array even though empty and 2 in every Text Array. You defined only "+s.length+" entries in the Style Array and "+t.length+" entry in the Text Array. This tip won't be viewed to avoid errors")
		else if(t.length<2)
			alert(ErrorNotice+"It looks like you removed an entry or more from the Text Array of this tip.\nTheir should be 2 entries in every Text Array. You defined only "+t.length+" entry. This tip won't be viewed to avoid errors.")
		else if(s.length<25)
			alert(ErrorNotice+"It looks like you removed an entry or more from the Style Array of this tip.\nTheir should be 25 entries in every Style Array even though empty. You defined only "+s.length+" entries. This tip won't be viewed to avoid errors.")
 	}
  	else {
		var ab = "" ;var ap = ""
		var titCol = (s[0])? "COLOR='"+s[0]+"'" : ""
		var txtCol = (s[1])? "COLOR='"+s[1]+"'" : ""
		var titBgCol = (s[2])? "BGCOLOR='"+s[2]+"'" : ""
		var txtBgCol = (s[3])? "BGCOLOR='"+s[3]+"'" : ""
		var titBgImg = (s[4])? "BACKGROUND='"+s[4]+"'" : ""
		var txtBgImg = (s[5])? "BACKGROUND='"+s[5]+"'" : ""
		var titTxtAli = (s[6] && s[6].toLowerCase()!="left")? "ALIGN='"+s[6]+"'" : ""
		var txtTxtAli = (s[7] && s[7].toLowerCase()!="left")? "ALIGN='"+s[7]+"'" : ""
		var add_height = (s[15])? "HEIGHT='"+s[15]+"'" : ""
		if(!s[8])  s[8] = "Verdana,Arial,Helvetica"
		if(!s[9])  s[9] = "Verdana,Arial,Helvetica"
		if(!s[12]) s[12] = 1
		if(!s[13]) s[13] = 1
		if(!s[14]) s[14] = 200
		if(!s[16]) s[16] = 0
		if(!s[17]) s[17] = 0
		if(!s[18]) s[18] = 10
		if(!s[19]) s[19] = 10
		hs = s[11].toLowerCase()
		if(ps==20001108){
		if(s[2]) ab="STYLE='border:1px solid"+" "+s[2]+"'"
		ap="STYLE='padding:1px 1px 1px 1px'"}
		var closeLink=(hs=="sticky")? "<TD ALIGN='right'><A HREF='javascript:void(0)' ONCLICK='stickyhide()' STYLE='text-decoration:none;color:"+s[0]+"'><B>Close</B></A></TD>":""
		var title=(t[0]||hs=="sticky")? "<TABLE WIDTH='100%' BORDER=0><TR><TD "+titTxtAli+"><B>"+t[0]+"</B></TD>"+closeLink+"</TR></TABLE>" : ""
		var txt="<TABLE "+titBgImg+" "+ab+" WIDTH='"+s[14]+"' BORDER=0 "+titBgCol+" ><TR><TD>"+title+"<TABLE WIDTH='100%' "+add_height+" BORDER=0 "+txtBgCol+" "+txtBgImg+"><TR><TD CLASS='tipText' VALIGN='top'>"+t[1]+"</TD></TR></TABLE></TD></TR></TABLE>"
		if(nn4) {
			with(eval(obj+"document")) {
				open()
				write(txt)
				close()
			}
		}
		else eval(obj+"innerHTML=txt")
		tbody = {
			Pos:s[10].toLowerCase(),
			Xpos:s[18],
			Ypos:s[19],
			Transition:s[20],
			Duration:s[21],
			Alpha:s[22],
			ShadowType:s[23].toLowerCase(),
			ShadowColor:s[24],
			Width:parseInt(eval(obj+iw)+3+sbw)
		}
		if(ie4) {
			TipLayer.style.width = s[14]
	 		tbody.Width = s[14]
		}
		Count=0
		move=1
 	 }
  }
}

function MoveTip(e) {
	if(move) {
		var X,Y,MouseX = eval(mx),MouseY = eval(my); tbody.Height = parseInt(eval(obj+ih)+3)
		tbody.wiw = parseInt(eval(ww+"+"+scl)); tbody.wih = parseInt(eval(wh+"+"+sct))

		switch(tbody.Pos) {
			case "left" : X=MouseX-tbody.Width-tbody.Xpos; Y=MouseY+tbody.Ypos; break
			case "center": X=MouseX-(tbody.Width/2); Y=MouseY+tbody.Ypos; break
			case "float": X=tbody.Xpos+eval(scl); Y=tbody.Ypos+eval(sct); break
			case "fixed": X=tbody.Xpos; Y=tbody.Ypos; break
			default: X=MouseX+tbody.Xpos; Y=MouseY+tbody.Ypos
		}

		if(tbody.wiw<tbody.Width+X) X = tbody.wiw-tbody.Width
		if(tbody.wih<tbody.Height+Y+sbw) {
			if(tbody.Pos=="float"||tbody.Pos=="fixed") Y = tbody.wih-tbody.Height-sbw
			else Y = MouseY-tbody.Height
		}
		if(X<0) X=0
		eval(obj+sl+"=X+PX;"+obj+st+"=Y+PX")
		ViewTip()
	}
}

function ViewTip() {
  	Count++
	if(Count == 1) {
		if(cssFilters&&FiltersEnabled) {
			for(Index=28; Index<31; Index++) { TipLayer.filters[Index].enabled = 0 }
			for(s=0; s<28; s++) { if(TipLayer.filters[s].status == 2) TipLayer.filters[s].stop() }
			if(tbody.Transition == 51) tbody.Transition = parseInt(Math.random()*50)
			var applyTrans = (tbody.Transition>-1&&tbody.Transition<24&&tbody.Duration>0)? 1:0
			var advFilters = (tbody.Transition>23&&tbody.Transition<51&&tbody.Duration>0)? 1:0
			var which = (applyTrans)?0:(advFilters)? tbody.Transition-23:0
			if(tbody.Alpha>0&&tbody.Alpha<100) {
	  			TipLayer.filters[28].enabled = 1
	  			TipLayer.filters[28].opacity = tbody.Alpha
			}
			if(tbody.ShadowColor&&tbody.ShadowType == "simple") {
	  			TipLayer.filters[29].enabled = 1
	  			TipLayer.filters[29].color = tbody.ShadowColor
			}
			else if(tbody.ShadowColor&&tbody.ShadowType == "complex") {
	  			TipLayer.filters[30].enabled = 1
	  			TipLayer.filters[30].color = tbody.ShadowColor
			}
			if(applyTrans||advFilters) {
				eval(obj+sv+hl)
	  			if(applyTrans) TipLayer.filters[0].transition = tbody.Transition
	  			TipLayer.filters[which].duration = tbody.Duration
	  			TipLayer.filters[which].apply()
			}
		}
 		eval(obj+sv+vl)
		if(cssFilters&&FiltersEnabled&&(applyTrans||advFilters)) TipLayer.filters[which].play()
		if(hs == "sticky") move=0
  	}
}

function stickyhide() {
	eval(HideTip)
}

function ReloadTip() {
	 if(nn4&&(evlw!=eval(ww)||evlh!=eval(wh))) location.reload()
	 else if(hs == "sticky") eval(HideTip)
}

function htm() {
	if(sNav) {
		if(hs!="keep") {
			move=0;
			if(hs!="sticky") eval(HideTip)
		}
	}
}

/*************************************/


function getRadioValue(colRadio) {
	for (var i = 0; i < colRadio.length; i++)
		if (colRadio[i].checked)
			return colRadio[i].value;
		return null;
}

function getRadioSelectedIndex(objRadio) {
	for (var i = 0; i < objRadio.length; i++)
		if (objRadio[i].checked)
			return i;
		return -1;
}


function strLeft(str, n){
	if (n <= 0)
	    return "";
	else if (n > String(str).length)
	    return str;
	else
	    return String(str).substring(0,n);
}
function strRight(str, n){
    if (n <= 0)
       return "";
    else if (n > String(str).length)
       return str;
    else {
       var iLen = String(str).length;
       return String(str).substring(iLen, iLen - n);
    }
}

/* Browser Window Size and Position functions */
function winPageWidth() {return window.innerWidth != null? window.innerWidth : document.documentElement && document.documentElement.clientWidth ?       document.documentElement.clientWidth : document.body != null ? document.body.clientWidth : null;}
function winPageHeight() {return  window.innerHeight != null? window.innerHeight : document.documentElement && document.documentElement.clientHeight ?  document.documentElement.clientHeight : document.body != null? document.body.clientHeight : null;}
function winPosLeft() {return typeof window.pageXOffset != 'undefined' ? window.pageXOffset :document.documentElement && document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft ? document.body.scrollLeft : window.screenLeft-3;}
function winPosTop() {return typeof window.pageYOffset != 'undefined' ?  window.pageYOffset : document.documentElement && document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop ? document.body.scrollTop : window.screenTop-51;}
function winPosRight() {return winPosLeft()+winPageWidth();}
function winPosBottom() {return winPosTop()+winPageHeight();}

/* open and close popup windows in the same place */
var wpop = new Array(10);

function open_popup(winIndex, windowname, theurl, w, h, params) {
	//alert(theurl);
  if (wpop[winIndex] && wpop[winIndex].open && !wpop[winIndex].closed) {
  	//the window is open, so reload if necessary and bring to top
  	wpop[winIndex].focus();
  	if (theurl)
  		wpop[winIndex].document.location.href=theurl;
	} else {
		// open window
	  var x = getCookieValue(winIndex+'_x');
		var y = getCookieValue(winIndex+'_y');
		if (!x || x=='') x=50;
		if (!y || y=='') y=50;
		var p = params;
		if (!p || p=='')
			p = 'scrollbars=no,toolbar=no,menubar=no,location=no';

		p = p + ',left='+x+',top='+y+',width='+w+',height='+h;

		wpop[winIndex] = window.open(theurl, windowname+winIndex, p);
	}
}

function close_popup(winIndex) {
	setCookieDays (winIndex+'_x', winPosLeft(), 90);
	setCookieDays (winIndex+'_y', winPosTop(), 90);
	window.close();
}

function help_popup (guide, subj) {
	open_popup(9,'help','/__cms/help/' + guide + '.asp#' + subj,700,700,'scrollbars=yes,toolbar=no,menubar=no,location=no');
}


var classSaved;
function classChange(me,newClass) {
	classSaved = me.className;
	me.className = newClass;
}

function classRestore(me) {
	me.className = classSaved;
}

var arrh = new Array();
function hiliteField(obj,numSeconds) {
	obj.className = 'hilite';
	arrh.push(obj);

	//trigger (once) to reset in a few seconds
	if (numSeconds && numSeconds>0 && arrh.length>0)
		setTimeout("dehiliteFields()", numSeconds*1000);
}

function dehiliteFields() {
	for (var i=0;i<arrh.length;i++)
		arrh[i].className='';
	arrh = new Array();
}

function addAndHilite(msg, obj) {
	if (obj) hiliteField(obj,2);
	return ' - ' + msg + '\n';
}


// image selector functions

function imgSelectorChange(me, objName, sroot) {
	var oImgSelected = document.getElementById('img_' + objName);
	if (!oImgSelected)
		return;

	if (me.selectedIndex==0)
		oImgSelected.src = '/__cms/images/spacer.gif'
	else {
		var val = me.options[me.selectedIndex].value;

		var arr = val.split('~');

		var path = arr[2].replace(/\\/g, '/');				// make all \'s
		arr = path.split('/');
		arr[arr.length-1] = 'TN_' + arr[arr.length-1];
		path = sroot + 'imagesLR/' + arr.join('/');

		path = path.replace(/.gif/, '.gif.jpg');						// TN's always jpegs

		//alert(path);
		oImgSelected.src = path;
	}
}


var saved_field_value = '';
function fieldValueSave(me) {
	saved_field_value = getObjectValue(me);
}

function fieldValueIsSame(me) {
	var isSame = false;
	if (saved_field_value==getObjectValue(me)) {
		isSame=true;
		saved_field_value = getObjectValue(me);
	}
	return isSame;
}

function getObjectValue(obj) {
	if (obj.tagName=='SELECT' && obj.selectedIndex==0 && obj.options[0].text.toLowerCase() == 'none')
		return 'none';
	return obj.value;
}



//  map/google stuff

//  multimap window
  var winMultimap;
  function openmultimapwin(pc, title) {
    if (winMultimap && winMultimap.open && !winMultimap.closed) {
      //bring window to top
      winMultimap.focus();
    } else {
      //open window
    }

    // multimap
    var url = 'http://uk.multimap.com/p/browse.cgi?pc=';
    winMultimap = window.open(url+pc+'&title='+title+'&scale=25000', 'multiMapWindow', '');
  }

//  googleMap window
var winGoogleMap;
function opengooglemapwin(sid,pc,mapInfo,lng,lat,zoomlevel,maptype,showmarkericon) {
    if (winGoogleMap && winGoogleMap.open && !winGoogleMap.closed) {
      //bring window to top
      winGoogleMap.focus();
    } else {
      //open window
    }

    // google API
    var mt;
    if (maptype)
      mt = maptype;
    else
      mt = '';

    var mapInfo2 = mapInfo.replace("\'", "~");
    mapInfo2 = mapInfo2.replace(" & ", " and ");
    var url = '/__cms/maps/googlemap.asp?sid=' + sid + '&lat=' + lat + '&lng=' + lng + '&z=' + zoomlevel + '&mi=' + mapInfo2 + '&pc=' + pc + '&mt=' + mt + '&showmarkericon=' + showmarkericon;

    var w = 700;
    var h = 500;
    var winx = 10;//getCookieOrSet('popup_map_x', 10);
    var winy = 10;//getCookieOrSet('popup_map_y', 10);
    winGoogleMap = window.open(url, 'googleMapWindow', 'scrollbars=no,toolbar=no,menubar=no,location=no,height=' + h + ',width=' + w + ',left=' + winx + ',top=' + winy);
  }

function setThisLink(thisUrl) {
	if (thisUrl=='' || !document.getElementsByTagName) return;
	var thisLink = thisUrl.toLowerCase().replace('/default.asp','');
	if (thisLink=='') return;
	var anchors = document.getElementsByTagName('a');
	var sClass = 'class';		// was 'className' for IE. 'class' works in IE8
	//if (navigator.appName.indexOf('Microsoft') == -1) sClass = 'class';
	//var s='';
	for (var i=0;i<anchors.length;i++) {
		var a = anchors[i];
		//s = s + a.getAttribute('href') + ', ' + a.getAttribute(sClass) + '\n';
		//if (a.getAttribute('class'))
		//	s=s + i + '.' + a.getAttribute('href') + '\n';
		if (a.getAttribute(sClass) && a.getAttribute('href') && (a.getAttribute(sClass)=='level1' || a.getAttribute(sClass)=='level2')) {
			var lk = a.getAttribute('href').toLowerCase().replace('/default.asp','');
			if (strRight(lk,thisLink.length) == thisLink) {
				a.setAttribute(sClass, a.getAttribute(sClass) + '_selected');
				return;
	}}}
	//if (thisUrl=='/colts/news-archive.asp') alert(sClass+','+','+s);
}

function confirmgo(msg, sto, sfrom) {
	var s;
	if (confirm(msg)) {
		if (sto.indexOf('?')>0)
			s = sto + '&rto=' + sfrom;
		else
			s = sto + '?rto=' + sfrom;
		document.location.href = s;
	}
}

function browserType() {
	var agt=navigator.userAgent.toLowerCase();
	if (agt.indexOf("opera") != -1) return 'Opera';
	if (agt.indexOf("staroffice") != -1) return 'Star Office';
	if (agt.indexOf("webtv") != -1) return 'WebTV';
	if (agt.indexOf("beonex") != -1) return 'Beonex';
	if (agt.indexOf("chimera") != -1) return 'Chimera';
	if (agt.indexOf("netpositive") != -1) return 'NetPositive';
	if (agt.indexOf("phoenix") != -1) return 'Phoenix';
	if (agt.indexOf("firefox") != -1) return 'Firefox';
	if (agt.indexOf("safari") != -1) return 'Safari';
	if (agt.indexOf("skipstone") != -1) return 'SkipStone';
	if (agt.indexOf("msie") != -1) return 'Internet Explorer';
	if (agt.indexOf("netscape") != -1) return 'Netscape';
	if (agt.indexOf("mozilla/5.0") != -1) return 'Mozilla';
	if (agt.indexOf('\/') != -1) {
		if (agt.substr(0,agt.indexOf('\/')) != 'mozilla')
			return navigator.userAgent.substr(0,agt.indexOf('\/'));
		else
			return 'Netscape';
	} else if (agt.indexOf(' ') != -1)
		return navigator.userAgent.substr(0,agt.indexOf(' '));
	else
		return navigator.userAgent;
}



//*****************************************************************************
// Start brainjar.com menu code
//*****************************************************************************

function BrowserInfo() {

  var ua, s, i;

  this.isIE    = false;  // Internet Explorer
  this.isOP    = false;  // Opera
  this.isNS    = false;  // Netscape
  this.version = null;

  ua = navigator.userAgent;

  s = "Opera";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isOP = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  s = "Netscape6/";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  // Treat any other "Gecko" browser as Netscape 6.1.

  s = "Gecko";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = 6.1;
    return;
  }

  s = "MSIE";
  if ((i = ua.indexOf(s))) {
    this.isIE = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }
}

var browser = new BrowserInfo();

//----------------------------------------------------------------------------
// Code for handling the menu bar and active button.
//----------------------------------------------------------------------------

var activeButton = null;

/* [MODIFIED] This code commented out, not needed for activate/deactivate
   on mouseover.

// Capture mouse clicks on the page so any active button can be
// deactivated.

if (browser.isIE)
  document.onmousedown = pageMousedown;
else
  document.addEventListener("mousedown", pageMousedown, true);

function pageMousedown(event) {

  var el;

  // If there is no active button, exit.

  if (activeButton == null)
    return;

  // Find the element that was clicked on.

  if (browser.isIE)
    el = window.event.srcElement;
  else
    el = (event.target.tagName ? event.target : event.target.parentNode);

  // If the active button was clicked on, exit.

  if (el == activeButton)
    return;

  // If the element is not part of a menu, reset and clear the active
  // button.

  if (getContainerWith(el, "DIV", "menu") == null) {
    resetButton(activeButton);
    activeButton = null;
  }
}

[END MODIFIED] */

function btnClick(event, menuId) {

  var button;

  // Get the target button element.

  if (browser.isIE)
    button = window.event.srcElement;
  else
    button = event.currentTarget;

  // Blur focus from the link to remove that annoying outline.

  button.blur();

  // Associate the named menu to this button if not already done.
  // Additionally, initialize menu display.

  if (button.menu == null) {
    button.menu = document.getElementById(menuId);
    if (button.menu.isInitialized == null)
      menuInit(button.menu);
  }

  // [MODIFIED] Added for activate/deactivate on mouseover.

  // Set mouseout event handler for the button, if not already done.

  if (button.onmouseout == null)
    button.onmouseout = buttonOrMenuMouseout;

  // Exit if this button is the currently active one.

  if (button == activeButton)
    return false;

  // [END MODIFIED]

  // Reset the currently active button, if any.

  if (activeButton != null)
    resetButton(activeButton);

  // Activate this button, unless it was the currently active one.

  if (button != activeButton) {
    depressButton(button);
    activeButton = button;
  }
  else
    activeButton = null;

  return false;
}

function buttonMouseover(event, menuId) {

  var button;

  // [MODIFIED] Added for activate/deactivate on mouseover.

  // Activates this button's menu if no other is currently active.

  if (activeButton == null) {
    btnClick(event, menuId);
    return;
  }

  // [END MODIFIED]

  // Find the target button element.

  if (browser.isIE)
    button = window.event.srcElement;
  else
    button = event.currentTarget;

  // If any other button menu is active, make this one active instead.

  if (activeButton != null && activeButton != button)
    btnClick(event, menuId);
}

function depressButton(button) {

  var x, y;

  // Update the button's style class to make it look like it's
  // depressed.

  button.className += " menuButtonActive";

  // [MODIFIED] Added for activate/deactivate on mouseover.

  // Set mouseout event handler for the button, if not already done.

  if (button.onmouseout == null)
    button.onmouseout = buttonOrMenuMouseout;
  if (button.menu.onmouseout == null)
    button.menu.onmouseout = buttonOrMenuMouseout;

  // [END MODIFIED]

  // Position the associated drop down menu under the button and
  // show it.

  x = getPageOffsetLeft(button);
  y = getPageOffsetTop(button) + button.offsetHeight;

  // For IE, adjust position.

  if (browser.isIE) {
    x += button.offsetParent.clientLeft;
    y += button.offsetParent.clientTop;
  }

  button.menu.style.left = x + "px";
  button.menu.style.top  = y + "px";
  button.menu.style.visibility = "visible";

  // For IE; size, position and show the menu's IFRAME as well.

  if (button.menu.iframeEl != null)
  {
    button.menu.iframeEl.style.left = button.menu.style.left;
    button.menu.iframeEl.style.top  = button.menu.style.top;
    button.menu.iframeEl.style.width  = button.menu.offsetWidth + "px";
    button.menu.iframeEl.style.height = button.menu.offsetHeight + "px";
    button.menu.iframeEl.style.display = "";
  }
}

function resetButton(button) {

  // Restore the button's style class.

  removeClassName(button, "menuButtonActive");

  // Hide the button's menu, first closing any sub menus.

  if (button.menu != null) {
    closeSubMenu(button.menu);
    button.menu.style.visibility = "hidden";

    // For IE, hide menu's IFRAME as well.

    if (button.menu.iframeEl != null)
      button.menu.iframeEl.style.display = "none";
  }
}

//----------------------------------------------------------------------------
// Code to handle the menus and sub menus.
//----------------------------------------------------------------------------

function menuMouseover(event) {

  var menu;

  // Find the target menu element.

  if (browser.isIE)
    menu = getContainerWith(window.event.srcElement, "DIV", "menu");
  else
    menu = event.currentTarget;

  // Close any active sub menu.

  if (menu.activeItem != null)
    closeSubMenu(menu);
}

function menuItemMouseover(event, menuId) {
  var item, menu, x, y;

  // Find the target item element and its parent menu element.

  if (browser.isIE)
    item = getContainerWith(window.event.srcElement, "A", "menuItem");
  else
    item = event.currentTarget;
  menu = getContainerWith(item, "DIV", "menu");

  // Close any active sub menu and mark this one as active.

  if (menu.activeItem != null)
    closeSubMenu(menu);
  menu.activeItem = item;

  // Highlight the item element.

  item.className += " menuItemHighlight";

  // Initialize the sub menu, if not already done.

  if (item.subMenu == null) {
    item.subMenu = document.getElementById(menuId);
    if (item.subMenu.isInitialized == null)
      menuInit(item.subMenu);
  }

  // [MODIFIED] Added for activate/deactivate on mouseover.

  // Set mouseout event handler for the sub menu, if not already done.

  if (item.subMenu.onmouseout == null)
    item.subMenu.onmouseout = buttonOrMenuMouseout;

  // [END MODIFIED]

  // Get position for submenu based on the menu item.

  x = getPageOffsetLeft(item) + item.offsetWidth;
  y = getPageOffsetTop(item);

  // Adjust position to fit in view.

  var maxX, maxY;

  if (browser.isIE) {
    maxX = Math.max(document.documentElement.scrollLeft, document.body.scrollLeft) +
      (document.documentElement.clientWidth != 0 ? document.documentElement.clientWidth : document.body.clientWidth);
    maxY = Math.max(document.documentElement.scrollTop, document.body.scrollTop) +
      (document.documentElement.clientHeight != 0 ? document.documentElement.clientHeight : document.body.clientHeight);
  }
  if (browser.isOP) {
    maxX = document.documentElement.scrollLeft + window.innerWidth;
    maxY = document.documentElement.scrollTop  + window.innerHeight;
  }
  if (browser.isNS) {
    maxX = window.scrollX + window.innerWidth;
    maxY = window.scrollY + window.innerHeight;
  }
  maxX -= item.subMenu.offsetWidth;
  maxY -= item.subMenu.offsetHeight;

  if (x > maxX)
    x = Math.max(0, x - item.offsetWidth - item.subMenu.offsetWidth
      + (menu.offsetWidth - item.offsetWidth));
  y = Math.max(0, Math.min(y, maxY));

  // Position and show the sub menu.

  item.subMenu.style.left       = x + "px";
  item.subMenu.style.top        = y + "px";
  item.subMenu.style.visibility = "visible";

  // For IE; size, position and display the menu's IFRAME as well.

  if (item.subMenu.iframeEl != null)
  {
    item.subMenu.iframeEl.style.left    = item.subMenu.style.left;
    item.subMenu.iframeEl.style.top     = item.subMenu.style.top;
    item.subMenu.iframeEl.style.width   = item.subMenu.offsetWidth + "px";
    item.subMenu.iframeEl.style.height  = item.subMenu.offsetHeight + "px";
    item.subMenu.iframeEl.style.display = "";
  }

  // Stop the event from bubbling.

  if (browser.isIE)
    window.event.cancelBubble = true;
  else
    event.stopPropagation();
}

function closeSubMenu(menu) {

  if (menu == null || menu.activeItem == null)
    return;

  // Recursively close any sub menus.

  if (menu.activeItem.subMenu != null) {
    closeSubMenu(menu.activeItem.subMenu);
    menu.activeItem.subMenu.style.visibility = "hidden";

    // For IE, hide the sub menu's IFRAME as well.

    if (menu.activeItem.subMenu.iframeEl != null)
      menu.activeItem.subMenu.iframeEl.style.display = "none";

    menu.activeItem.subMenu = null;
  }

  // Deactivate the active menu item.

  removeClassName(menu.activeItem, "menuItemHighlight");
  menu.activeItem = null;
}

// [MODIFIED] Added for activate/deactivate on mouseover. Handler for mouseout
// event on buttons and menus.

function buttonOrMenuMouseout(event) {

  var el;

  // If there is no active button, exit.

  if (activeButton == null)
    return;

  // Find the element the mouse is moving to.

  if (browser.isIE)
    el = window.event.toElement;
  else if (event.relatedTarget != null)
      el = (event.relatedTarget.tagName ? event.relatedTarget : event.relatedTarget.parentNode);

  // If the element is not part of a menu, reset the active button.

  if (getContainerWith(el, "DIV", "menu") == null) {
    resetButton(activeButton);
    activeButton = null;
  }
}

// [END MODIFIED]


//----------------------------------------------------------------------------
// Code to initialize menus.
//----------------------------------------------------------------------------

function menuInit(menu) {

  var itemList, spanList;
  var textEl, arrowEl;
  var itemWidth;
  var w, dw;
  var i, j;

  // For IE, replace arrow characters.

  if (browser.isIE) {
    menu.style.lineHeight = "2.5ex";
    spanList = menu.getElementsByTagName("SPAN");
    for (i = 0; i < spanList.length; i++)
      if (hasClassName(spanList[i], "menuItemArrow")) {
        spanList[i].style.fontFamily = "Webdings";
        spanList[i].firstChild.nodeValue = "4";
      }
  }

  // Find the width of a menu item.

  itemList = menu.getElementsByTagName("A");
  if (itemList.length > 0)
    itemWidth = itemList[0].offsetWidth;
  else
    return;

  // For items with arrows, add padding to item text to make the
  // arrows flush right.

  for (i = 0; i < itemList.length; i++) {
    spanList = itemList[i].getElementsByTagName("SPAN");
    textEl  = null;
    arrowEl = null;
    for (j = 0; j < spanList.length; j++) {
      if (hasClassName(spanList[j], "menuItemText"))
        textEl = spanList[j];
      if (hasClassName(spanList[j], "menuItemArrow"))
        arrowEl = spanList[j];
    }
    if (textEl != null && arrowEl != null) {
      textEl.style.paddingRight = (itemWidth
        - (textEl.offsetWidth + arrowEl.offsetWidth)) + "px";
      // For Opera, remove the negative right margin to fix a display bug.
      if (browser.isOP)
        arrowEl.style.marginRight = "0px";
    }
  }

  // Fix IE hover problem by setting an explicit width on first item of
  // the menu.

  if (browser.isIE) {
    w = itemList[0].offsetWidth;
    itemList[0].style.width = w + "px";
    dw = itemList[0].offsetWidth - w;
    w -= dw;
    itemList[0].style.width = w + "px";
  }

  // Fix the IE display problem (SELECT elements and other windowed controls
  // overlaying the menu) by adding an IFRAME under the menu.

  if (browser.isIE) {
    var iframeEl = document.createElement("IFRAME");
    iframeEl.frameBorder = 0;
    iframeEl.src = "javascript:false;";
    iframeEl.style.display = "none";
    iframeEl.style.position = "absolute";
    iframeEl.style.filter = "progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)";
    menu.iframeEl = menu.parentNode.insertBefore(iframeEl, menu);
  }

  // Mark menu as initialized.

  menu.isInitialized = true;
}

//----------------------------------------------------------------------------
// General utility functions.
//----------------------------------------------------------------------------

function getContainerWith(node, tagName, className) {

  // Starting with the given node, find the nearest containing element
  // with the specified tag name and style class.

  while (node != null) {
    if (node.tagName != null && node.tagName == tagName &&
        hasClassName(node, className))
      return node;
    node = node.parentNode;
  }

  return node;
}

function hasClassName(el, name) {

  var i, list;

  // Return true if the given element currently has the given class
  // name.

  list = el.className.split(" ");
  for (i = 0; i < list.length; i++)
    if (list[i] == name)
      return true;

  return false;
}

function removeClassName(el, name) {

  var i, curList, newList;

  if (el.className == null)
    return;

  // Remove the given class name from the element's className property.

  newList = new Array();
  curList = el.className.split(" ");
  for (i = 0; i < curList.length; i++)
    if (curList[i] != name)
      newList.push(curList[i]);
  el.className = newList.join(" ");
}

function getPageOffsetLeft(el) {

  var x;

  // Return the x coordinate of an element relative to the page.

  x = el.offsetLeft;
  if (el.offsetParent != null)
    x += getPageOffsetLeft(el.offsetParent);

  return x;
}

function getPageOffsetTop(el) {

  var y;

  // Return the x coordinate of an element relative to the page.

  y = el.offsetTop;
  if (el.offsetParent != null)
    y += getPageOffsetTop(el.offsetParent);

  return y;
}

//*****************************************************************************
// End brainjar.com menu code
//*****************************************************************************


// loads a link into a specified frame
function loadlink(u, framename) {
	var oFrame;
	if (framename) {
		eval('oFrame = parent.'+framename);
		if (!oFrame)
			oFrame = parent.mainframe;
		if (oFrame) {
			//if (u.indexOf('?')>0)
				oFrame.location = u;
			//else
			//	oFrame.location = u;
		} else
			window.status = 'frame ' + framename + ' does not exist';
	} else
		document.location = u;
}

function cancelAndReturn() {
	var r = document.getElementById('rto');
	if (r && r.value && r.value!='' && r.value.indexOf('admin.asp')==0 && r.value.indexOf('admin_menu.asp')==0) {
		document.location = r.value;
	} else {
		history.go(-1);
	}
}



/**********************************************************
 Transitions Slideshow - www.javascriptkit.com
 Created: Nov 3rd, 2008
 Accompanying styles go in sites default.css
/**********************************************************/

var global_transitions=[ //array of IE transition strings
	"progid:DXImageTransform.Microsoft.Barn()",
	"progid:DXImageTransform.Microsoft.Blinds()",
	"progid:DXImageTransform.Microsoft.CheckerBoard()",
	"progid:DXImageTransform.Microsoft.Fade()",
	"progid:DXImageTransform.Microsoft.GradientWipe()",
	"progid:DXImageTransform.Microsoft.Inset()",
	"progid:DXImageTransform.Microsoft.Iris()",
	"progid:DXImageTransform.Microsoft.Pixelate()",
	"progid:DXImageTransform.Microsoft.RadialWipe()",
	"progid:DXImageTransform.Microsoft.RandomBars()",
	"progid:DXImageTransform.Microsoft.RandomDissolve()",
	"progid:DXImageTransform.Microsoft.Slide()",
	"progid:DXImageTransform.Microsoft.Spiral()",
	"progid:DXImageTransform.Microsoft.Stretch()",
	"progid:DXImageTransform.Microsoft.Strips()",
	"progid:DXImageTransform.Microsoft.Wheel()",
	"progid:DXImageTransform.Microsoft.Zigzag()"
]

function flashyslideshow(setting){
	this.wrapperid=setting.wrapperid
	this.imagearray=setting.imagearray
	this.pause=setting.pause
	this.effect = ''; if (setting.effect) this.effect = setting.effect.toLowerCase();		//SB added

	this.transduration=setting.transduration/1000 //convert from miliseconds to seconds unit to pass into el.filters.play()
	this.currentimg=0
	var preloadimages=[] //temp array to preload images
	for (var i=0; i<this.imagearray.length; i++){
		preloadimages[i]=new Image()
		preloadimages[i].src=this.imagearray[i][0]
	}
	document.write('<div id="'+this.wrapperid+'" class="'+setting.wrapperclass+'">'+this.getSlideHTML(this.currentimg)+'</div>')

	var effectindex = Math.floor(Math.random()*global_transitions.length) 	//randomly pick a transition to utilize
	if (this.effect && this.effect!="")
		for (var j=0; j<global_transitions.length; j++)
			if (global_transitions[j].toLowerCase() == "progid:dximagetransform.microsoft." + this.effect + "()")
				effectindex = j;

	var wrapperdiv=document.getElementById(this.wrapperid)
	if (wrapperdiv.filters){ //if the filters[] collection is defined on element (only in IE)
		wrapperdiv.style.filter=global_transitions[effectindex] //define transition on element
		this.pause+=setting.transduration //add transition time to pause
	}
	this.filtersupport=(wrapperdiv.filters && wrapperdiv.filters.length>0)? true : false //test if element supports transitions and has one defined
	var slideshow=this
	setInterval(function(){slideshow.rotate()}, this.pause)
}

flashyslideshow.prototype.getSlideHTML=function(index){
	var slideHTML=(this.imagearray[index][1])? '<a href="'+this.imagearray[index][1]+'" target="'+this.imagearray[index][1]+'">\n' : '' //hyperlink slide?
	slideHTML+='<img src="'+this.imagearray[index][0]+'" />'
	slideHTML+=(this.imagearray[index][1])? '</a><br />' : '<br />'
	slideHTML+=(this.imagearray[index][3])? this.imagearray[index][3] : '' //text description?
	return slideHTML //return HTML for the slide at the specified index
}

flashyslideshow.prototype.rotate=function(){
	var wrapperdiv=document.getElementById(this.wrapperid)
	this.currentimg=(this.currentimg<this.imagearray.length-1)? this.currentimg+1 : 0
	if (this.filtersupport)
		wrapperdiv.filters[0].apply()
	wrapperdiv.innerHTML=this.getSlideHTML(this.currentimg)
	if (this.filtersupport)
		wrapperdiv.filters[0].play(this.transduration)
}


///Sample call on your page
/*
var flashyshow=new flashyslideshow({ //create instance of slideshow
	wrapperid: "myslideshow", //unique ID for this slideshow
	wrapperclass: "flashclass", //desired CSS class for this slideshow
	imagearray: [
		["summer.jpg", "http://en.wikipedia.org/wiki/Summer", "_new", "Such a nice Summer getaway."],
		["winter.jpg", "http://en.wikipedia.org/wiki/Winter", "", "Winter is nice, as long as there's snow right?"],
		["spring.jpg", "", "", "Flowers spring back to life in Spring."],
		["autumn.jpg", "", "", "Ah the cool breeze of autumn."]
	],
	pause: 2000, //pause between slides (milliseconds)
	transduration: 1000 //transition duration (milliseconds)
})
*/
/**********************************************************
 Transitions Slideshow - end
/**********************************************************/


/**********************************************************
 Dreamweaver Functions - start
/**********************************************************/
	function MM_swapImgRestore() { //v3.0
	  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
	}

	function MM_preloadImages() { //v3.0
	  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
	    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
	    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
	}

	function MM_findObj(n, d) { //v4.01
	  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
	    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
	  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
	  if(!x && d.getElementById) x=d.getElementById(n); return x;
	}

	function MM_swapImage() { //v3.0
	  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
	   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
	}
/**********************************************************
 Dreamweaver Functions - end
/**********************************************************/


/**********************************************************
 checkFrameStructure()
 This function is called in every page to ensure that the frame
 structure is reconstructed when someone who was logged in returns to
 a normal page, bypassing the frames (__cms/admin.asp)
 currently this is ADMINISTRATORS, AUTHORS, MANAGERS
 IT MUST ONLY BE CALLED WHEN A USER WITH FRAME INTERFACE IS LOGGED IN.
 IT MUST BE EXHAUSTIVE AND THOROUGHLY TESTED.
 If session variables were used instead of cookies this wouldnt be an
 issue because closing the window would end their session.
 But session variables are too memory intensive and time restrictive.
 To help reduce the amount it gets called:
 1. reduce cookie life to a day
/**********************************************************/

function checkFrameStructure(siteAddress, sroot) {
	//tidy up site address and remove site root for subfolder sites

	var sa = siteAddress.toLowerCase();
	//if (sroot.length>1 && strRight(sroot,1)!="/")
	if (sroot.length>1)
		sa = sa.replace(sroot, '') + "/";

	//get top url and remove any querystring
	var topurl = window.top.location.toString().toLowerCase();

	var idx = topurl.indexOf('?');
	if (idx>0)
		topurl = topurl.substring(0, idx);

	//if top url is not the admin link then reload frames
	if (topurl != sa + '__cms/admin.asp') {
		var thisPage = document.location.toString().toLowerCase().replace(siteAddress,'');
		window.top.location = sa + '__cms/admin.asp?mf=' + sroot + thisPage;
	}
}

/**********************************************************
 Tab Control Stuff (event edit, user edit, etc)
**********************************************************/

var tabContentOld, tabOld;

function tabOn(tabNum) {

	// de-highlight old tab
	if (tabOld)
		tabOld.className = "Tab";

	// hide its contents
	if (tabContentOld) {
		tabContentOld.style.visibility = 'hidden';
		tabContentOld.style.display = 'none';
	}

	// highlight new Tab
	var tab = document.getElementById('t' + tabNum);
	tab.className = "TabSelected";

	// show contents of new Tab
	var tabContent = document.getElementById('t' + tabNum + 'Contents');
	tabContent.style.visibility = 'visible';
	tabContent.style.display = 'block';

	// save current Tab
	tabContentOld = tabContent;
	tabOld = tab;
}

function TabOver(tab) {
  if (tab.className == "Tab")
		tab.className = "TabOver";
  else if(tab.className == "TabOver")
		tab.className = "Tab";
}
