// JavaScript Document

Debug.init(false, './debug/');       //comment out to turn off debug
function debug( arg1, arg2, arg3 ){ Debug.raise( arg1, arg2, arg3 ) };


var typeRootMenu = 'typeRootMenu';      
var typeMenu = 'typeMenu';      
var typePage = 'typePage'; 
var typeDummy = 'typeDummy';    //dummy menu option - for display only
var typeVideo = 'typeVideo'; 
var typeList = 'typeList'; 

//var pageImage = 'pageImage'; 
//var pageText = 'pageText'; 
//var pageVideo = 'pageVideo'; 


var MENU_INDEX          = 0;
var MENU_NAME           = 1;
var MENU_TYPE           = 2;
var MENU_SUBARRAY       = 3;
var MENU_DEFIMG         = 4;    //default image to display on selecting menu option of type typeMenu , maybe an array of images that auto slideshow on a timer
var MENU_DEFTXT         = 5;    //default image to display on selecting menu option of type typeMenu , maybe an array of images that auto slideshow on a timer
var MENU_SUB_OPEN       = 6; //submenu is displayed
var MENU_IMGALIGN       = 7;    //left, right, top, bottom, center (default)
var MENU_ICON           = 8;    //left, right, top, bottom, center (default)
var MENU_ROOT_COLOUR    = 9;
var MENU_TEXT_HEIGHT    = 10;
var MENU_IMG_TOP        = 11;
var MENU_TIP            = 12;
var MENU_LINKS          = 13;

//page indexes
var PAGE_INDEX          = 0;
var PAGE_NAME           = 1;
var PAGE_THUMB          = 2;
var PAGE_IMAGE          = 3;
var PAGE_TEXT           = 4;
var PAGE_THMB_WIDTH     = 5;        //only because can't get image width in Safari
var PAGE_BIG_IMAGE      = 6;        //if more detail required
var PAGE_VIDEO          = 7;        
//var PAGE_IMGALIGN       = 4;
//++
var PAGE_ZOOM_FORMAT    = 8;        
var PAGE_ZOOM_DIM    = 9;        //oversized image dimensions array(width, height)


// for use with PAGE_ZOOM_DIM huge image dimensions array
var DIM_WIDTH = 0;
var DIM_HEIGHT = 1;



//zoom formats
var ZOOM_FORMAT_CENTRE = 1;
var ZOOM_FORMAT_HUGE = 2;




var currentRoot;
var currentIndex;
var currentThumb;







function MM_preloadImages() { 
  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){ 
                window.status="preloading: "+a[i]; 
                d.MM_p[j]=new Image; 
                d.MM_p[j++].src=a[i];
            }
        } 
    }
    
    window.status=''; 
}

function getURLPath(){
  var s = new String( document.location.href );
  
   //strip any url arguments
   pos = s.lastIndexOf('?');
   if (pos > 0) {
    s = s.substring(0,pos); 
   }

  //strip path
  var pos = s.lastIndexOf('/');
  if (pos > 0) {
    s = s.substring(0,pos); 
  }

   return s;
}

function stripDot(img){
  if (img.indexOf('.') == 0){
    img = img.substring(1,img.length); 
  }
  return img;
}



function imageAlreadyPreloaded(img){
    var imgpath = getURLPath() + stripDot(img);

    var d=document; 
    var i,  len=d.MM_p.length, result=false;
    
    for(i=0; i<=len-1; i++){

        if (d.MM_p[i].src == imgpath){
            result=true;
            break;
        }
    }
    
    return result;
}

function MM_preloadImagesArray(array) { 
    if (preloadimages){
      var d=document; if(d.images){ 
            if(!d.MM_p) d.MM_p=new Array();
            
            var i,  j=d.MM_p.length,    a=array; 
            
            for(i=0; i<a.length; i++){


                if (a[i].indexOf("#")!=0){ 
                    if (!imageAlreadyPreloaded(a[i])){
                        window.status="preloading: "+a[i]; 
                        d.MM_p[j]=new Image; 
                        d.MM_p[j++].src=a[i];    
                    }
                }
            }
        }
        window.status=''; 
    }
}

/* tooltips  */
function old_showtip(current,event,text){

//getDivLeft(id)
    if (text != ''){

        getObj('popup').style.left=event.clientX + 5;
        getObj('popup').style.top=event.clientY + 15;
        getObj('popup').innerHTML = '&nbsp;'+text+'&nbsp;';
        getObj('popup').style.visibility="visible";

    }



/*
    if (BrowserDetect.browser == "Safari"){     //having to do this as Safari doesn't support CSS property 'bottom'

    }
    else {

        if (document.all||document.getElementById){
            thetitle = text.split('<br>');
    
            if (thetitle.length>1){
                thetitles = '';
                for (var i=0;i<thetitle.length;i++){
                    thetitles += thetitle[i];
                    current.title = thetitles;
                }
            }
            else {
            current.title=text;
            }
        }
        else if (document.layers){
            document.tooltip.document.write('<layer bgColor="white" style="border:1px solid black;font-size:12px;">'+text+'</layer>');
            document.tooltip.document.close();
            document.tooltip.left=event.pageX+5;
            document.tooltip.top=event.pageY+5;
            document.tooltip.visibility="show";
        }
    }
*/
}


function showtip(current,event,text){

    if (text != ''){

        var x, y;
    
        if (event.pageX || event.pageY) {
            x = event.pageX;
            y = event.pageY;
        } 
        else {
            x = event.clientX + 
                (document.documentElement.scrollLeft || 
                document.body.scrollLeft) - 
                document.documentElement.clientLeft;
            y = event.clientY + 
                (document.documentElement.scrollTop || 
                document.body.scrollTop) - 
                document.documentElement.clientTop;
        }

//        getObj('popup').style.left=event.offsetX + 5;       //in zoom mode 
//        getObj('popup').style.top=event.offsetY + 15;
        getObj('popup').style.left=x + 5;       //in zoom mode 
        getObj('popup').style.top=y + 15;
        getObj('popup').innerHTML = '&nbsp;'+text+'&nbsp;';
        getObj('popup').style.visibility="visible";

    }
}

function hidetip(){
        getObj('popup').style.visibility="hidden";

//    if (BrowserDetect.browser == "Safari"){     //having to do this as Safari doesn't support CSS property 'bottom'
//    else  if (document.layers) document.tooltip.visibility="hidden";
}

function insertToolTip(text){
    if (!equalsNull(text)){
        var s = 'onMouseover="showtip(this,window.event,';
        s += "'" + text + "'";
        s += '); " onMouseout="hidetip(); "';
    }    
    return s;
}

//function enableToolTips(){
//    document.write('<div id="tooltip" style="position:absolute;visibility:hidden"></div>');
//}
/* tooltips  */


/*
function getZoomButton(){
    var s = '';

var zoom='zoom';
    s += '<div id="zoom_div" class="zoom_div">';
    s += '<img name="zoom" src="./img/zoom.gif" onclick="showCurrentBigImg()" onmouseover="zoomMouseover(this)" onmouseout="zoomMouseout(this)" onmousedown="zoomMousedown(this)" onmouseup="zoomMouseup(this)" />';

    s += '</div>';

    return s;
}

function getUnZoomButton(){
    var s = '';

    s += '<div id="unzoom_div" class="unzoom_div">';
    s += '<img name="unzoom" src="./img/unzoom.gif" onclick="hideBigImage()" onmouseover="zoomMouseover(this)" onmouseout="zoomMouseout(this)" onmousedown="zoomMousedown(this)" onmouseup="zoomMouseup(this)" />';

    s += '</div>';

    return s;
}

*/

var storeVisibleArray;

function hideEverythingElse(){
    storeVisibleArray = new Array();
    var i = 0;
    storeVisibleArray[i] = new Array( 'logodiv', getObj('logodiv').style.visibility);   i ++;
    storeVisibleArray[i] = new Array( 'floatingMenudiv', getObj('floatingMenudiv').style.visibility);   i ++;
    storeVisibleArray[i] = new Array( 'caption', getObj('caption').style.visibility);   i ++;
    storeVisibleArray[i] = new Array( 'header', getObj('header').style.visibility);   i ++;
    storeVisibleArray[i] = new Array( 'image', getObj('image').style.visibility);   i ++;
    storeVisibleArray[i] = new Array( 'video', getObj('video').style.visibility);   i ++;
    storeVisibleArray[i] = new Array( 'text', getObj('text').style.visibility);   i ++;
    storeVisibleArray[i] = new Array( 'slideshowdiv', getObj('slideshowdiv').style.visibility);   i ++;
    storeVisibleArray[i] = new Array( 'zoomdiv', getObj('zoomdiv').style.visibility);   i ++;
    storeVisibleArray[i] = new Array( 'thumbs', getObj('thumbs').style.visibility);   i ++;
    storeVisibleArray[i] = new Array( 'rootmenudiv', getObj('rootmenudiv').style.visibility);   i ++;
    storeVisibleArray[i] = new Array( 'linksdiv', getObj('linksdiv').style.visibility);   i ++;
    storeVisibleArray[i] = new Array( 'leftScroll', getObj('leftScroll').style.visibility);   i ++;
    storeVisibleArray[i] = new Array( 'rightScroll', getObj('rightScroll').style.visibility);   i ++;

//alert(storeVisibleArray);    
    
    for(i=0; i<storeVisibleArray.length; i++){
        if (getObj( storeVisibleArray[i][0] )) getObj(storeVisibleArray[i][0]).style.visibility="hidden";
    }
//alert(storeVisibleArray);    

/*
    if (getObj('logodiv')) getObj('logodiv').style.visibility="hidden";
    if (getObj('floatingMenudiv')) getObj('floatingMenudiv').style.visibility="hidden"; 
    if (getObj('caption')) getObj('caption').style.visibility="hidden";
    if (getObj('header')) getObj('header').style.visibility="hidden";
    if (getObj('image')) getObj('image').style.visibility="hidden";
    if (getObj('video')) getObj('video').style.visibility="hidden";
    if (getObj('text')) getObj('text').style.visibility="hidden";
    if (getObj('slideshowdiv')) getObj('slideshowdiv').style.visibility="hidden";
    if (getObj('zoomdiv')) getObj('zoomdiv').style.visibility="hidden";
    if (getObj('thumbs')) getObj('thumbs').style.visibility="hidden";
    if (getObj('rootmenudiv')) getObj('rootmenudiv').style.visibility="hidden";
    if (getObj('linksdiv')) getObj('linksdiv').style.visibility="hidden";
    if (getObj('leftScroll')) getObj('leftScroll').style.visibility="hidden";
    if (getObj('rightScroll')) getObj('rightScroll').style.visibility="hidden";
*/    
}

function showEverythingElse(){
    for(i=0; i<storeVisibleArray.length; i++){
        if (getObj( storeVisibleArray[i][0] )) getObj(storeVisibleArray[i][0]).style.visibility = storeVisibleArray[i][1];
    }

/*    if (getObj('logodiv')) getObj('logodiv').style.visibility="visible";
    if (getObj('floatingMenudiv')) getObj('floatingMenudiv').style.visibility="visible";
    if (getObj('caption')) getObj('caption').style.visibility="visible";
    if (getObj('header')) getObj('header').style.visibility="visible";
    if (getObj('image')) getObj('image').style.visibility="visible";
    if (getObj('video')) getObj('video').style.visibility="visible";
    if (getObj('text')) getObj('text').style.visibility="visible";
    if (getObj('slideshowdiv')) getObj('slideshowdiv').style.visibility="visible";
    if (getObj('zoomdiv')) getObj('zoomdiv').style.visibility="visible";
    if (getObj('thumbs')) getObj('thumbs').style.visibility="visible";
    if (getObj('rootmenudiv')) getObj('rootmenudiv').style.visibility="visible";
    if (getObj('linksdiv')) getObj('linksdiv').style.visibility="visible";
    if (getObj('leftScroll')) getObj('leftScroll').style.visibility="hidden";
    if (getObj('rightScroll')) getObj('leftScroll').style.visibility="hidden";
*/
}

//function showBigImage(img){


function getNumericFromString(s) {
    var filteredValues = '1234567890';     // Characters stripped out
    var returnString = '';
    for (var i = 0; i < s.length; i++) {  // Search through string and append to unfiltered values to returnString.
        var c = s.charAt(i);
        if (filteredValues.indexOf(c) > -1) returnString += c;
    }
    return returnString;
}


function getCurrentThumb(){
    var currItem = getArrayItemByIndex(currentIndex);
    var thumbIndex = getNumericFromString(currentThumb);
    var currThumb = currItem[MENU_SUBARRAY][thumbIndex];
    return currThumb;
}

//++
function showBigImage(img, format){

    hideEverythingElse();


/*  var ww = mainWidth, hh = mainHeight, tt = 0, ll = 0;
  if (format){
    if (format > 0){
      
      ww = zoomFormats[format][0];
      hh = zoomFormats[format][1];
      tt = zoomFormats[format][2];
      ll = zoomFormats[format][3];
      
    }
  }
*/
//--

    quickExitSlideshow(); //stopslideshow
    
//    var s = '<img style="cursor: pointer;" width="'+mainWidth+'" height="'+mainHeight+'" src="'+ img +'" onclick="hideBigImage(); hidetip();" onmouseout="hidetip()" onmousemove="showtip(this,event, &#39; zoom out &#39;);" />';
//    var s = '<img style="cursor: pointer;" width="'+ww+'" height="'+hh+'" src="'+ img +'" onclick="hideBigImage(); hidetip();" onmouseout="hidetip()" onmousemove="showtip(this,event, &#39; zoom out &#39;);" />';
    var s = '<img style="cursor: pointer;" src="'+ img +'" onclick="hideBigImage(); hidetip();" onmouseout="hidetip()" onmousemove="showtip(this,event, &#39; zoom out &#39;);" />';
    
//??    var obj = getObj('bigimagediv');
//??++



//++++


//if (format == ZOOM_FORMAT_CENTRE){

    if (getCurrentThumb()[PAGE_ZOOM_FORMAT]){
        var x = 0; var y = 0;
        var obj = getObj('HUGEimagediv');

        if (getCurrentThumb()[PAGE_ZOOM_FORMAT] == ZOOM_FORMAT_CENTRE){
            if (getCurrentThumb()[PAGE_ZOOM_DIM]){
           
                var imgW = getCurrentThumb()[PAGE_ZOOM_DIM][DIM_WIDTH];
                var imgH = getCurrentThumb()[PAGE_ZOOM_DIM][DIM_HEIGHT];
        
                var windowHeight = window.innerHeight ? window.innerHeight : document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.clientHeight;
                var windowWidth = window.innerWidth ? window.innerWidth : document.documentElement.clientWidth ? document.documentElement.clientWidth : document.body.clientWidth;
        
                if (imgH < windowHeight)  x = ((windowHeight- imgH) / 2);
                if (imgW < windowWidth)  y = ((windowWidth - imgW) / 2);              
            }
        }

        obj.style.top = x;
        obj.style.left = y;
        obj.style.visibility = "visible";
        obj.innerHTML = s;
        obj.style.zIndex = 5;
    }
    else {
        var obj = getObj('bigimagediv');
    }

    if (obj){
        obj.innerHTML = s;
        obj.style.zIndex = 5;
    }


/*        
        
debug( 'iW: ' +iW+ ' iH: ' +iH+ ' contW: ' +contW+ ' contH: ' +contH + ' obj.width: ' +obj.width+ ' obj.height: ' +obj.height);

if (obj.id == 'HUGEimagediv'){
        if ((iW < contW) && (iH < contH)){
debug(1);    
            var L = (contW - iW) / 2;
            var T = (contH - iH) / 2;

            obj.style.top = T;
            obj.style.left = L;

debug( 'top: ' +obj.style.top+ ' left: ' +obj.style.left );
        }
        else if (iW < contW){
debug(2);    
            var L = (contW - iW) / 2;
            obj.style.top = 0;
            obj.style.left = L;

debug( 'top: ' +obj.style.top+ ' left: ' +obj.style.left );
        }
        else if (iH < contH){
debug(3);    
            var T = (contH - iH) / 2;
            obj.style.left = 0;
            obj.style.top = T;

debug( 'top: ' +obj.style.top+ ' left: ' +obj.style.left );
        }
        else {
debug(4);    
            obj.style.top = 0;
            obj.style.left = 0;

debug( 'top: ' +obj.style.top+ ' left: ' +obj.style.left );
        }
}        

  var windowHeight = window.innerHeight ? window.innerHeight : document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.clientHeight;
  var windowWidth = window.innerWidth ? window.innerWidth : document.documentElement.clientWidth ? document.documentElement.clientWidth : document.body.clientWidth;

debug( 'windowHeight: ' +windowHeight+ ' windowWidth: ' +windowWidth );
*/
        
                
//----        
        
/*        //obj.style.width = mainWidth;
        //obj.style.height = mainHeight;
        obj.style.width = ww;
        obj.style.height = hh;
        //obj.style.top = tt;
        //obj.style.left = ll;

        //??
        if (format == ZOOM_FORMAT_TALL){
                obj.style.left = getObj('holder').offsetLeft;
                obj.style.top = tt;
        }
        else if (format == ZOOM_FORMAT_WIDE){
                obj.style.top = getObj('holder').offsetTop/2;
                obj.style.left = ll;
        }
        else if (format == ZOOM_FORMAT_CENTRE){
//debug('ZOOM_FORMAT_CENTRE');
//debug(window.innerWidth);

//  var x = (window.innerWidth / 2) - (getObj('HUGEimagediv').offsetWidth / 2);
//  var y = (window.offsetHeight / 2) - (getObj('HUGEimagediv').offsetHeight / 2);              


  var windowHeight = window.innerHeight ? window.innerHeight : document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.clientHeight;
  var windowWidth = window.innerWidth ? window.innerWidth : document.documentElement.clientWidth ? document.documentElement.clientWidth : document.body.clientWidth;
  var x = ((windowHeight) - (getObj('HUGEimagediv').offsetWidth) / 2);
  var y = ((windowWidth) - (getObj('HUGEimagediv').offsetHeight) / 2);              


debug('windowHeight:   ' + windowHeight);

  
  getObj('HUGEimagediv').style.top = y;
  getObj('HUGEimagediv').style.left = x;

        }
        else {
             obj.style.top = tt;
             obj.style.left = ll;
        }
        //??
*/
//        obj.style.zIndex = 5;
//    }

    //showDimensions(img);

/*
debug('---------------------------------');
debug('HUGEimagediv   top: ' + getObj('HUGEimagediv').style.top + ' left: ' + getObj('HUGEimagediv').style.left + ' height: ' + getObj('HUGEimagediv').style.height + ' width: ' + getObj('HUGEimagediv').style.width + ' offsetWidth: ' + getObj('HUGEimagediv').offsetWidth  + ' offsetHeight: ' + getObj('HUGEimagediv').offsetHeight   );
debug('maintable   top: ' + getObj('maintable').style.top + ' left: ' + getObj('maintable').style.left + ' height: ' + getObj('maintable').style.height + ' width: ' + getObj('maintable').style.width + ' offsetWidth: ' + getObj('maintable').offsetWidth  + ' offsetHeight: ' + getObj('maintable').offsetHeight   );
debug('maindiv   top: ' + getObj('maindiv').style.top + ' left: ' + getObj('maindiv').style.left + ' height: ' + getObj('maindiv').style.height + ' width: ' + getObj('maindiv').style.width + ' offsetWidth: ' + getObj('maindiv').offsetWidth  + ' offsetHeight: ' + getObj('maindiv').offsetHeight   );
debug('holder   top: ' + getObj('holder').style.top + ' left: ' + getObj('holder').style.left + ' height: ' + getObj('holder').style.height + ' width: ' + getObj('holder').style.width + ' offsetWidth: ' + getObj('holder').offsetWidth  + ' offsetHeight: ' + getObj('holder').offsetHeight   );
debug('---------------------------------');

debug('getPos(holder).left: ' + getPos(getObj('holder')).left);
debug('getPos(holder).top: ' + getPos(getObj('holder')).top);
debug('---------------------------------');
*/


  
    //display unzoom button
    var obj = getObj('freecontainer');
    if (obj){
        obj.style.top = 10;
        obj.style.left = 10;
        obj.style.width = 850;
        obj.style.height = 18;
    }
    //setInnerHtml('freecontainer', getUnZoomButton() );
    
    
}


function getImgWidth(img) {
    var imageName = img;
    if (imageName != '') {
        tempImage = new Image();
        tempImage.src = imageName;// + '?randParam=' + new Date().getTime();
        return tempImage.width;
    }
}
function getImgHeight(img) {
    var imageName = img;
    if (imageName != '') {
        tempImage = new Image();
        tempImage.src = imageName;// + '?randParam=' + new Date().getTime();
        return tempImage.height;
    }
}




function getPos (obj) {
	var output = new Object();
	var mytop=0, myleft=0;
	while( obj) {
		mytop+= obj.offsetTop;
		myleft+= obj.offsetLeft;
		obj= obj.offsetParent;
	}
	output.left = myleft;
	output.top = mytop;
	return output;
}

function hideBigImage(){

    showEverythingElse();

    //setInnerHtml('freecontainer', '' ); //clear unzoom button

//??++
    var obj = getObj('HUGEimagediv')
    if (obj){
        if (obj.style.zIndex > -1){
document.body.scrollTop = 0;
document.body.scrollLeft = 0;

            //obj.style.cssText = '';
            obj.innerHTML = '';
            obj.style.width = 0;
            obj.style.height = 0;
            obj.style.zIndex = -1;
            obj.style.background = '';
            obj.style.top = 0;
            obj.style.left = 0;
            obj.style.visibility = 'hidden';
        }
    }
//??--

    var obj = getObj('bigimagediv')
    if (obj){
        if (obj.style.zIndex > -1){
            obj.style.cssText = '';
            obj.innerHTML = '';
            obj.style.width = 0;
            obj.style.height = 0;
            obj.style.zIndex = -1;
            obj.style.background = '';
        }
    }
  
}

function slideshow(startstop, thumbClick){
    if (startstop){
        getObj('slideshowdiv').innerHTML = '';
        getObj('slideshowdiv').innerHTML = '<img src="./gifs/slideshowStop.gif" onmouseover="showtip(this,event, &#39; stop slideshow &#39;);" onmouseout="hidetip()" onmouseup="slideshow(false);">';

        var currItem = getArrayItemByIndex(currentIndex);
        var arr = currItem[MENU_SUBARRAY];

        if ((arr) && (arr.length > 0)) {
            clearMain(); 
            if (arr[0][PAGE_TEXT] != '') {
                setBigText(arr[0][PAGE_TEXT]);
                setCaption( '' );
                getObj('image').innerHTML = '';
            }
            else {
                getObj('text').innerHTML = '';
                setBigImage( arr[0][PAGE_IMAGE], arr[0][PAGE_BIG_IMAGE] );                        
//++
//                setBigImage( arr[0][PAGE_IMAGE], arr[0][PAGE_BIG_IMAGE], arr[0][PAGE_ZOOM_FORMAT] );                        
//--
                setCaption( arr[0][PAGE_NAME] );
            }
            setCurrentThumb('thumb'+0);

            slideShowID = window.setTimeout('nextSlide('+0+')',3000);	
        }

    }
    else{
        getObj('slideshowdiv').innerHTML = '';
        getObj('slideshowdiv').innerHTML = '<img src="./gifs/slideshowStart.gif" onmouseover="showtip(this,event, &#39; start slideshow &#39;);" onmouseout="hidetip()" onmouseup="slideshow(true);">';

        if (slideShowID > 0) { 
            window.clearTimeout(slideShowID); 
            slideShowID = 0;
        }
        
        if (!thumbClick) {
            var currItem = getArrayItemByIndex(currentIndex);
            var arr = currItem[MENU_SUBARRAY];
            if ((arr) && (arr.length > 0)) {
                //clearMain(); 
                if (arr[0][PAGE_TEXT] != ''){
                    setBigText(arr[0][PAGE_TEXT]);
                    setCaption( '' );
                    getObj('image').innerHTML = '';
                }
                else {
                    getObj('text').innerHTML = '';
                    setBigImage( arr[0][PAGE_IMAGE], arr[0][PAGE_BIG_IMAGE] );                        
//++
//                    setBigImage( arr[0][PAGE_IMAGE], arr[0][PAGE_BIG_IMAGE], arr[0][PAGE_ZOOM_FORMAT] );                        
//--
                    setCaption( arr[0][PAGE_NAME] );
                }
                setCurrentThumb('thumb'+0);
            }
        }

    }
}

function quickExitSlideshow(){
    getObj('slideshowdiv').innerHTML = '';
    getObj('slideshowdiv').innerHTML = '<img src="./gifs/slideshowStart.gif" onmouseover="showtip(this,event, &#39; start slideshow &#39;);" onmouseout="hidetip()" onmouseup="slideshow(true);">';

    if (slideShowID > 0) { 
        window.clearTimeout(slideShowID); 
        slideShowID = 0;
    }
}

function nextSlide(lastId){
    var currItem = getArrayItemByIndex(currentIndex);
    var arr = currItem[MENU_SUBARRAY];
    
    var i = 1;
    i += lastId;

    if ((i) < (arr.length)) {
        //clearMain(); 
        if (arr[i][PAGE_TEXT] != '') {
            setBigText(arr[i][PAGE_TEXT]);
            setCaption( '' );
            getObj('image').innerHTML = '';
        }
        else {
            getObj('text').innerHTML = '';
            setBigImage( arr[i][PAGE_IMAGE], arr[i][PAGE_BIG_IMAGE] );                        
//++
//              setBigImage( arr[i][PAGE_IMAGE], arr[i][PAGE_BIG_IMAGE], arr[i][PAGE_ZOOM_FORMAT] );
//--

            setCaption( arr[i][PAGE_NAME] );
        }

        setCurrentThumb('thumb'+i);

        slideShowID = window.setTimeout('nextSlide('+i+')',3000);	

        //auto scroll
        if (i > 2){
            autoScroll('thumbs',arr[i][PAGE_THMB_WIDTH]);
            checkForScroll();
        }

    }
    else{
        slideshow(false);
        //auto scroll
        if (i > 3){
            toLeft('thumbs');
            checkForScroll();
        }

    }
}


//        if getObj('leftScroll').style.visibility="visible";
//        if getObj('rightScroll').style.visibility="visible";
//    scrollVisible


function setInnerHtml(name, str, mouseclick){
    if (document.all) document.all[name].innerHTML = str;
    else document.getElementById(name).innerHTML = str;
    
    if (mouseclick){
        if (document.all) document.all[name].onmouseup = mouseclick;
        else document.getElementById(name).onmouseup = mouseclick;
    }
}



function getObj(name){
    var obj = null;

//    if (document.all) obj = document.all[name];
//    else obj = document.getElementById(name);

//++
    if (document.getElementById) obj = document.getElementById(name);
    else obj = document.all[name];
//--
    
    return obj;
}

function getArrayItemByIndex(index){  
    var res = iterateThruArray(index, config);
    return res;
}

/*
function iterateThruArrayAddIndex(arr, passedindex ){
    for(var i=0; i<=arr.length-1; i++){
        var currItem = arr[i];

        
//        if (currItem.length > PAGE_TEXT) {  //i.e. not image list

//news            if ((currItem[MENU_TYPE] == typeMenu) || (currItem[MENU_TYPE] == typePage) || (currItem[MENU_TYPE] == typeRootMenu) || (currItem[MENU_TYPE] == typeVideo)) {
//news++          
            if ((currItem[MENU_TYPE] == typeMenu) || (currItem[MENU_TYPE] == typePage) || (currItem[MENU_TYPE] == typeRootMenu) || (currItem[MENU_TYPE] == typeVideo) || (currItem[MENU_TYPE] == typeList) ) {
//news--
                if (passedindex) currItem[MENU_INDEX] += passedindex + '_';

                currItem[MENU_INDEX] += i; 

                if (currItem[MENU_SUBARRAY].length > 0) iterateThruArrayAddIndex( currItem[MENU_SUBARRAY], currItem[MENU_INDEX] );  //recursive call to self
            }
//        }
//        }
    }
    
}


function iterateThruArray(index, arr){
    var res = null;
    
    for(var i=0; i<=arr.length-1; i++){

        var currItem = arr[i];
        
//        if (currItem.length > PAGE_TEXT) {  //i.e. not image list
        if (currItem.length > PAGE_TEXT) {  //i.e. not image list

//news            if ((currItem[MENU_TYPE] == typeMenu) || (currItem[MENU_TYPE] == typePage) || (currItem[MENU_TYPE] == typeRootMenu) || (currItem[MENU_TYPE] == typeVideo)){
//news++
            if ((currItem[MENU_TYPE] == typeMenu) || (currItem[MENU_TYPE] == typePage) || (currItem[MENU_TYPE] == typeRootMenu) || (currItem[MENU_TYPE] == typeVideo) || (currItem[MENU_TYPE] == typeList) ){
//news--
            
                if (currItem[MENU_INDEX] == index){

                    res = currItem;
                    break;
                }
                else {
                    res = iterateThruArray( index, currItem[MENU_SUBARRAY] );                

                    if (res) break;
                }
            }
        }
    }
    
    return res;                
}


*/

function iterateThruArrayAddIndex(arr, passedindex ){
    for(var i=0; i<=arr.length-1; i++){
        var currItem = arr[i];

        if (passedindex) currItem[MENU_INDEX] += passedindex + '_';

        currItem[MENU_INDEX] += i; 

        
        if (!isPageItem(currItem)) {
          if (currItem[MENU_SUBARRAY].length > 0) iterateThruArrayAddIndex( currItem[MENU_SUBARRAY], currItem[MENU_INDEX] );  //recursive call to self
        }
    }
    
}


function isPageItem(obj){
    var res = true;
    if ((obj[MENU_TYPE] == typeRootMenu) || (obj[MENU_TYPE] == typeMenu) || (obj[MENU_TYPE] == typePage) || (obj[MENU_TYPE] == typeDummy) || (obj[MENU_TYPE] == typeVideo) || (obj[MENU_TYPE] == typeList) )
    {
        res = false;
    }
    return res;
}


function iterateThruArray(index, arr){
    var res = null;
    
    for(var i=0; i<=arr.length-1; i++){

        var currItem = arr[i];
   
        if (currItem[MENU_INDEX] == index){

            res = currItem;
            break;
        }
        else {
            if (!isPageItem(currItem)) {
                res = iterateThruArray( index, currItem[MENU_SUBARRAY] );                
            
                if (res) break;
            }
        }
    }
    
    return res;                
}

function returnParentId(id){
    var pos = id.lastIndexOf('_');

    if (pos > -1){
        var s = id.substr(0,pos);
        
        return s;
    }
}


function insertRootMenu(){
    
            var pos = 18;
            for(var i=0; i<=config.length-1; i++){

                if (config[i][2] == typeRootMenu){
                var s = '';

                if (config[i][MENU_ICON] == '') {
                    s += '<div id="'+i+'" class="mainmenuitem" style="position: absolute; left: '+pos+'; top: 10;  " onmouseover="this.style.color = &#39;black&#39;; " onmouseup="process('+i+')" onmouseout="this.style.color = &#39;gray&#39;; " >';
                    s += config[i][1];
                }
                else {
//                    s += '<div id="'+i+'" class="mainmenuitem" style="position: absolute; left: '+pos+'; top: 10;  " onmouseover="showtip(this,event,&#39;'+config[i][1]+'&#39;); this.style.color = &#39;black&#39;; " onmouseup="process('+i+')" onmouseout="hidetip(); this.style.color = &#39;gray&#39;; " >';
//                    s += '<img src="'+config[i][MENU_ICON]+'">';
//++
                    s += '<div id="'+i+'" class="mainmenuitem" style="position: absolute; left: '+pos+'; top: 20;  " onmouseover="showtip(this,event,&#39;'+config[i][1]+'&#39;); this.style.color = &#39;black&#39;; " onmouseup="process('+i+')" onmouseout="hidetip(); this.style.color = &#39;gray&#39;; " >';
                    s += '<img src="'+config[i][MENU_ICON]+'" width="45">';
//--
                }

                s += '</div>';

                document.write( s );                
                pos += 115;
                }
            }
}

function equalsNull(val){
  var s = new String(val);
  if (s == "null") return true;
  else return false;
}

function equalsEmpty(val){
  var s = new String(val);
  if (s == "") return true;
  else return false;
}

function equalsUndefined(val){
  var s = new String(val);
  if (s == "undefined") return true;
  else return false;
}



//function setBigImage(img, zoomimg){
//++
function setBigImage(img, zoomimg, zoomformat){
//--
    if ((zoomimg) && (zoomimg != '') && ( !equalsUndefined(zoomimg)) ) { 
//        var s =  '  style="cursor: pointer;"  onclick="showBigImage('+ "'" + zoomimg + "'" +')" onmousemove="showtip(this,event, &#39; zoom &#39;);" onmouseout="hidetip()"  ';
//        getObj('image').innerHTML = '<img src="'+ img +'" '+ s +'  >';
//        getObj('zoomdiv').innerHTML = '<img src="zoom.gif" onclick="showBigImage('+ "'" + zoomimg + "'" +')" onmousemove="showtip(this,event, &#39; zoom &#39;);" onmouseout="hidetip()" >';
//++

        

        var s =  '  style="cursor: pointer;"  onclick="showBigImage('+ "'" + zoomimg + "'" +','+ "'" + zoomformat + "'" +')" onmousemove="showtip(this,event, &#39; zoom &#39;);" onmouseout="hidetip()"  ';
        getObj('image').innerHTML = '<img src="'+ img +'" '+ s +'  >';
        
        z_mode( z_image );

        getObj('zoomdiv').innerHTML = '<img src="./gifs/zoom.gif" onclick="showBigImage('+ "'" + zoomimg + "'" +','+ "'" + zoomformat + "'" +')" onmousemove="showtip(this,event, &#39; zoom &#39;);" onmouseout="hidetip()" >';
//--

    }
    else{
        getObj('image').innerHTML = '<img src="'+ img +'"  >';
//++
        getObj('zoomdiv').innerHTML = '';
//--
    }
}

var z_image = 0;
var z_text = 1;
var z_video = 2;

function z_mode( m ){
    var obj_image = getObj('image');
    var obj_text = getObj('text');
    var obj_video = getObj('video');

    if (m == z_image){
        if (obj_image) obj_image.style.zIndex = 1;
        if (obj_text) obj_text.style.zIndex = 0;
        if (obj_video) obj_video.style.zIndex = 0;
    }
    else if (m == z_text){
        if (obj_image) obj_image.style.zIndex = 0;
        if (obj_text) obj_text.style.zIndex = 1;
        if (obj_video) obj_video.style.zIndex = 0;
    }
    else {
        if (obj_image) obj_image.style.zIndex = 0;
        if (obj_text) obj_text.style.zIndex = 1;
        if (obj_video) obj_video.style.zIndex = 0;
    }
}

function setBigImage2(img){
    getObj('image').innerHTML = '<img src="'+ img +'"  >';
}

function setBigText(txt){
    getObj('text').innerHTML = txt;       
    getObj('zoomdiv').innerHTML = '';
    z_mode( z_text );
}


function setBigTextFromIndex(index){
    var obj = getArrayItemByIndex(index);   
    var txt = obj[PAGE_TEXT];
    getObj('text').innerHTML = txt;       
    getObj('zoomdiv').innerHTML = '';
    z_mode( z_text );
}





function setVideo(txt){

clearMain();

//getObj('text').innerHTML = txt;       
getObj('video').innerHTML = txt;       

z_mode( z_video );


/* 
    //getObj('zoomdiv').innerHTML = '';
        getObj('video').style.visibility="visible";


      var s = '<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab" height="356" width="320">'; 
      s += '<param name="src" value="'+txt+'">';
      s += '<param name="autoplay" value="true">';
      s += '<param name="type" value="video/quicktime" height="356" width="320">';
      s += '<embed src="'+txt+'" height="356" width="320" autoplay="false" type="video/quicktime" pluginspage="http://www.apple.com/quicktime/download/" >';
      s += '</object>';



//        getObj('video').style.visibility="hidden";

    getObj('video').innerHTML = s;
    
*/    
           
}


function setCaption(txt){
    getObj('caption').innerHTML = txt;       
}

function getImageWidth(myImage) {
	var x, obj;
	if (document.layers) {
//		var img = getImage(myImage);
		var img = getObj(myImage);
		return img.width;
	} else {
		return getElementWidth(myImage);
	}
	return -1;
}

function getImageHeight(myImage) {
	var y, obj;
	if (document.layers) {
		var img = getImage(myImage);
		return img.height;
	} else {
		return getElementHeight(myImage);
	}
	return -1;
}


//iterateThruArrayAddIndex(menuArray);    //call the function to create the MENU_INDEXes

var currentSelection = -1;

var out="out";
var over="over";

function clearMain(){
    getObj('zoomdiv').innerHTML = '';


    getObj('caption').innerHTML = '';
    getObj('image').innerHTML = '';
    getObj('text').innerHTML = '';       

    getObj('video').innerHTML = '';       

//    getObj('slideshowdiv').innerHTML = '';       
}

function process(id){


clearMain();
    Id = window.setTimeout( function(){ process2(id) }, 1);
}


//+++++
function iterateThruArrayCloseAnyOpenSubMenus(a){
    for(var i=0; i<=a.length-1; i++){
        var currItem = a[i];
        //if (currItem[MENU_TYPE] != typePage) {
//news        if ((currItem[MENU_TYPE] == typeMenu) || (currItem[MENU_TYPE] == typePage) || (currItem[MENU_TYPE] == typeRootMenu) || (currItem[MENU_TYPE] == typeVideo)) {
//news++
        if ((currItem[MENU_TYPE] == typeMenu) || (currItem[MENU_TYPE] == typePage) || (currItem[MENU_TYPE] == typeRootMenu) || (currItem[MENU_TYPE] == typeVideo)) {
//news--
            currItem[MENU_SUB_OPEN] = false;
            if (currItem[MENU_SUBARRAY].length > 0) {
                iterateThruArrayCloseAnyOpenSubMenus( currItem[MENU_SUBARRAY] );  //recursive call to self
            }
        }
    }
    
}
//------

function getMenuLinks( arr ){
                function stripChar(ch, s){
                    var temp = new Array();
                    temp = s.split(ch);
                    s = '';
                    for(var i=0; i<=temp.length-1; i++){
                        s = s + temp[i];
                    }
                    return s;
                }
                function addHTTP(url){
                  if ((url.search('http://') == -1) && (url.search('HTTP://') == -1)){
                    url = 'http://' + url;
                  }
                  return url;
                }

    if (arr){
        
        var s = '<font style="color: #cc0000; font-size: 6.5pt; font-weight: bold;">related links<br></font>';
        for(var i=0; i<=arr.length-1; i++){
//            s += '<a href="'+arr[i]+'">' + arr[i] + '</a><br>';
            var ss = arr[i];
            ss = stripChar('-', ss);
            ss = stripChar('?', ss);
            ss = stripChar('/', ss);
            ss = stripChar('&', ss);
            
            s += '<a style="font-size: 10px" href="'+ addHTTP(arr[i]) +'">' + ss + '</a><br>';
        }    
        
        getObj('linksdiv').innerHTML = s;
    }
}


function initScrollThumbs(){
    toLeft('thumbs');
}

function process2(id){
    quickExitSlideshow();
    hideScroll();

    var sameMenuAsLastSelected = (currentIndex == id);

    currentIndex = id;

    getObj('caption').innerHTML = ''; 
    getObj('image').innerHTML = '';
    getObj('thumbs').innerHTML = '';
    getObj('text').innerHTML = '';       
    getObj('slideshowdiv').innerHTML = '';       
    getObj('zoomdiv').innerHTML = '';       
    getObj('linksdiv').innerHTML = '';       

    var currItem = getArrayItemByIndex(id);  
    
//debug(id + '  ' + currItem[MENU_NAME]);

    //reset these
    getObj('text').style.height = def_text_height ;
    getObj('image').style.top = 0;

    if (currItem[MENU_TYPE] == typeRootMenu){

        iterateThruArrayCloseAnyOpenSubMenus(config);

        currentRoot = id;
        currentIndex = '';
        getObj('header').style.color = currItem[MENU_ROOT_COLOUR];
        getObj('header').innerHTML = currItem[MENU_NAME];
        showFloater(id);
    }

    else {

        ///////getArrayItemByIndex

//++

            getMenuLinks( currItem[MENU_LINKS] );////???
//--

//news++
            if (currItem[MENU_TYPE] == typeList){
            
                if ( getArrayItemByIndex(returnParentId(currItem[MENU_INDEX]))[MENU_TYPE] == typeRootMenu  )   iterateThruArrayCloseAnyOpenSubMenus(config);
            }
//news--

            if (currItem[MENU_TYPE] == typePage){
                if ( getArrayItemByIndex(returnParentId(currItem[MENU_INDEX]))[MENU_TYPE] == typeRootMenu  )   iterateThruArrayCloseAnyOpenSubMenus(config);
            }

            if (currItem[MENU_TYPE] == typeMenu){

                if (sameMenuAsLastSelected){
                    currItem[MENU_SUB_OPEN] = !currItem[MENU_SUB_OPEN];
                }
                else {
                    iterateThruArrayCloseAnyOpenSubMenus(config);
                    currItem[MENU_SUB_OPEN] = true;
                }

                //toggle visibility of submenu
//                if (currItem[MENU_SUB_OPEN] == true) currItem[MENU_SUB_OPEN] = false;
//                else currItem[MENU_SUB_OPEN] = true;


//                showFloater( returnParentId(id), id  );
                showFloater( currentRoot  );

                if ((currItem[MENU_DEFIMG] != '') && (currItem[MENU_DEFTXT] != '')) {             //main img and main text

                    getObj('text').innerHTML = currItem[MENU_DEFTXT];       

                    getObj('image').innerHTML = '<img src="'+currItem[MENU_DEFIMG]+'">';
                    
                    getObj('text').style.height = currItem[MENU_TEXT_HEIGHT];
                    getObj('image').style.top = currItem[MENU_IMG_TOP];
                    //MENU_TEXT_HEIGHT
                    //def_text_height 
//++
//                    getObj('image').style.top = 0;
//debug( getObj('image').style.top + "  " + getObj('image').style.height );
//                    getObj('text').style.top = getObj('image').style.height;
                    //getObj('image').style.top = currItem[MENU_IMG_TOP];

//--

                }
                else if (currItem[MENU_DEFIMG] != ''){             //main img
                    getObj('image').innerHTML = '<img src="'+currItem[MENU_DEFIMG]+'">';
                }
                else if (currItem[MENU_DEFTXT] != ''){             //main text
                    getObj('text').innerHTML = currItem[MENU_DEFTXT];       
                    z_mode( z_text );
                }

            }
            else if (currItem[MENU_TYPE] == typePage){
                z_mode( z_text );

                //if (currItem[MENU_SUBARRAY] != ''){             //array of images
                if (currItem[MENU_SUBARRAY].length > 0){             //array of images
                 
                    var arr = currItem[MENU_SUBARRAY];
        
                    var s = '';




/*
                    for(j=0; j<=arr.length-1; j++){

                        if (arr[j][PAGE_TEXT] != '') s += '<img id="thumb'+j+'" src="'+ arr[j][PAGE_THUMB] +'" onmouseover="this.style.cursor = &#39;pointer&#39;; " onmouseup="setCurrentThumb(this.id); clearMain(); setBigText(&#39;'+arr[j][PAGE_TEXT]+'&#39;)" >'
                        else s += '<img  id="thumb'+j+'" src="'+ arr[j][PAGE_THUMB] +'" onmouseup="setCurrentThumb(this.id); hidetip(); clearMain(); setBigImage(&#39;'+arr[j][PAGE_IMAGE]+'&#39;); setCaption(&#39;'+arr[j][PAGE_NAME]+'&#39;);" onmouseover="this.style.cursor = &#39;pointer&#39;; showtip(this,event, &#39;'+ arr[j][PAGE_NAME] +'&#39;);" onmousemove="" onmouseout="hidetip()" >'

                        s += '<font style="width: 3; font-size: 1; color: white;">&nbsp;&nbsp;&nbsp;</font>';
                    }
                    getObj('thumbs').innerHTML = s;
*/
                    var left = 0;
                    for(j=0; j<=arr.length-1; j++){
                        var s = '';
                    
                        if (j == 0) { 
                            left = 0; 
                        }
                        else {
                            left += getObj('thumb'+(j-1) ).offsetWidth;
//+
//                            left += getObj('thumb'+(j-1) ).width;
//-
                            left += 1;
                        }

                    
//                        if (arr[j][PAGE_TEXT] != '') s += '<img id="thumb'+j+'" style="border: 2px solid white; position: absolute; top: 0; left: '+left+';" src="'+ arr[j][PAGE_THUMB] +'" onmouseover="this.style.cursor = &#39;pointer&#39;; " onmouseup="setCurrentThumb(this.id); clearMain(); setBigText(&#39;'+arr[j][PAGE_TEXT]+'&#39;)" >'
//                        else s += '<img  id="thumb'+j+'" style="border: 2px solid white; position: absolute; top: 0; left: '+left+';" src="'+ arr[j][PAGE_THUMB] +'" onmouseup="setCurrentThumb(this.id); hidetip(); clearMain(); setBigImage(&#39;'+arr[j][PAGE_IMAGE]+'&#39;); setCaption(&#39;'+arr[j][PAGE_NAME]+'&#39;);" onmouseover="this.style.cursor = &#39;pointer&#39;; showtip(this,event, &#39;'+ arr[j][PAGE_NAME] +'&#39;);" onmousemove="" onmouseout="hidetip()" >'


//                        if (arr[j][PAGE_TEXT] != '') s += '<img id="thumb'+j+'" style="border: 2px solid white; position: absolute; top: 0; left: '+left+'; width: '+arr[j][PAGE_THMB_WIDTH]+'" src="'+ arr[j][PAGE_THUMB] +'" onmouseover="this.style.cursor = &#39;pointer&#39;; " onmouseup="slideshow(false); setCurrentThumb(this.id); clearMain(); setBigText(&#39;'+arr[j][PAGE_TEXT]+'&#39;)" >'
//                        else s += '<img  id="thumb'+j+'" style="border: 2px solid white; position: absolute; top: 0; left: '+left+'; width: '+arr[j][PAGE_THMB_WIDTH]+'" src="'+ arr[j][PAGE_THUMB] +'" onmouseup="slideshow(false); setCurrentThumb(this.id); hidetip(); clearMain(); setBigImage(&#39;'+arr[j][PAGE_IMAGE]+'&#39;,&#39;'+arr[j][PAGE_BIG_IMAGE]+'&#39;); setCaption(&#39;'+arr[j][PAGE_NAME]+'&#39;);" onmouseover="this.style.cursor = &#39;pointer&#39;; showtip(this,event, &#39;'+ arr[j][PAGE_NAME] +'&#39;);" onmousemove="" onmouseout="hidetip()" >'

//++
//                        if (arr.length > PAGE_BIG_IMAGE) {
                      
                          //s += '<img  id="thumb'+j+'" style="border: 2px solid white; position: absolute; top: 0; left: '+left+'; width: '+arr[j][PAGE_THMB_WIDTH]+'" src="'+ arr[j][PAGE_THUMB] +'" onmouseup="slideshow(false); setCurrentThumb(this.id); hidetip(); clearMain(); setVideo(&quot;'+arr[j][PAGE_VIDEO]+'&quot;); setCaption(&quot;'+arr[j][PAGE_NAME]+'&quot;);" onmouseover="this.style.cursor = &quot;pointer&quot;; showtip(this,event, &quot;'+ arr[j][PAGE_NAME] +'&quot;);" onmousemove="" onmouseout="hidetip()" >'
//                        }
//                        else
//--
                        if (arr[j][PAGE_TEXT] != '') { 
                            if (arr[j].length-1 > PAGE_BIG_IMAGE) {
                            //s += '<img  id="thumb'+j+'" style="border: 2px solid white; position: absolute; top: 0; left: '+left+'; width: '+arr[j][PAGE_THMB_WIDTH]+'" src="'+ arr[j][PAGE_THUMB] +'" onmouseup="slideshow(false); setCurrentThumb(this.id); hidetip(); clearMain(); setVideo(&quot;'+arr[j][PAGE_VIDEO]+'&quot;); setCaption(&quot;'+arr[j][PAGE_NAME]+'&quot;);" onmouseover="this.style.cursor = &quot;pointer&quot;; showtip(this,event, &quot;'+ arr[j][PAGE_NAME] +'&quot;);" onmousemove="" onmouseout="hidetip()" >'

                             s += '<img id="thumb'+j+'" style="border: 2px solid white; position: absolute; top: 0; left: '+left+'; width: '+arr[j][PAGE_THMB_WIDTH]+'" src="'+ arr[j][PAGE_THUMB] +'" onmouseover="this.style.cursor = &quot;pointer&quot;; showtip(this,event, &quot;'+ arr[j][PAGE_NAME] +'&quot;);" onmouseout="hidetip();" onmouseup="hidetip(); slideshow(false); setCurrentThumb(this.id); clearMain(); setVideo(&quot;'+arr[j][PAGE_VIDEO]+'&quot;)" >'
//++++
                            }else if (arr[j][PAGE_THUMB] == '') {
                                s = '';
//----

                            }else 

//////////////////                            s += '<img id="thumb'+j+'" style="border: 2px solid white; position: absolute; top: 0; left: '+left+'; width: '+arr[j][PAGE_THMB_WIDTH]+'" src="'+ arr[j][PAGE_THUMB] +'" onmouseover="this.style.cursor = &quot;pointer&quot;; showtip(this,event, &quot;'+ arr[j][PAGE_NAME] +'&quot;);" onmouseout="hidetip();" onmouseup="hidetip(); slideshow(false); setCurrentThumb(this.id); clearMain(); setBigText(&quot;'+arr[j][PAGE_TEXT]+'&quot;)" >'
                            s += '<img id="thumb'+j+'" style="border: 2px solid white; position: absolute; top: 0; left: '+left+'; width: '+arr[j][PAGE_THMB_WIDTH]+'" src="'+ arr[j][PAGE_THUMB] +'" onmouseover="this.style.cursor = &quot;pointer&quot;; showtip(this,event, &quot;'+ arr[j][PAGE_NAME] +'&quot;);" onmouseout="hidetip();" onmouseup="hidetip(); slideshow(false); setCurrentThumb(this.id); clearMain(); setBigTextFromIndex(&quot;'+arr[j][PAGE_INDEX]+'&quot;)" >'


                        }
//                        else s += '<img  id="thumb'+j+'" style="border: 2px solid white; position: absolute; top: 0; left: '+left+'; width: '+arr[j][PAGE_THMB_WIDTH]+'" src="'+ arr[j][PAGE_THUMB] +'" onmouseup="slideshow(false); setCurrentThumb(this.id); hidetip(); clearMain(); setBigImage(&quot;'+arr[j][PAGE_IMAGE]+'&quot;,&quot;'+arr[j][PAGE_BIG_IMAGE]+'&quot;); setCaption(&quot;'+arr[j][PAGE_NAME]+'&quot;);" onmouseover="this.style.cursor = &quot;pointer&quot;; showtip(this,event, &quot;'+ arr[j][PAGE_NAME] +'&quot;);" onmousemove="" onmouseout="hidetip()" >'
//--
                        else{ 
                              
                              //if (arr[j][PAGE_ZOOM_FORMAT]) {
                              //s += '<img  id="thumb'+j+'" style="border: 2px solid white; position: absolute; top: 0; left: '+left+'; width: '+arr[j][PAGE_THMB_WIDTH]+'" src="'+ arr[j][PAGE_THUMB] +'" onmouseup="slideshow(false); setCurrentThumb(this.id); hidetip(); clearMain(); setBigImage(&quot;'+arr[j][PAGE_IMAGE]+'&quot;,&quot;'+arr[j][PAGE_BIG_IMAGE]+'&quot;,&quot;'+arr[j][PAGE_ZOOM_FORMAT]+'&quot;); setCaption(&quot;'+arr[j][PAGE_NAME]+'&quot;);" onmouseover="this.style.cursor = &quot;pointer&quot;; showtip(this,event, &quot;'+ arr[j][PAGE_NAME] +'&quot;);" onmousemove="" onmouseout="hidetip()" >'
                              //  }
                              //else {
                                s += '<img  id="thumb'+j+'" style="border: 2px solid white; position: absolute; top: 0; left: '+left+'; width: '+arr[j][PAGE_THMB_WIDTH]+'" src="'+ arr[j][PAGE_THUMB] +'" onmouseup="slideshow(false); setCurrentThumb(this.id); hidetip(); clearMain(); setBigImage(&quot;'+arr[j][PAGE_IMAGE]+'&quot;,&quot;'+arr[j][PAGE_BIG_IMAGE]+'&quot;,&quot;0&quot;); setCaption(&quot;'+arr[j][PAGE_NAME]+'&quot;);" onmouseover="this.style.cursor = &quot;pointer&quot;; showtip(this,event, &quot;'+ arr[j][PAGE_NAME] +'&quot;);" onmousemove="" onmouseout="hidetip()" >'
                              //}
                        }
//--

//                        getObj('thumbs').innerHTML += s;
                        if (s != '') getObj('thumbs').innerHTML += s;

                        initScrollThumbs();
                        
                    }
                    //set up first image
//                    if (arr[0][PAGE_TEXT] != '') getObj('text').innerHTML = arr[0][PAGE_TEXT];
                    if (arr[0][PAGE_TEXT] != '') {
                        getObj('text').innerHTML = arr[0][PAGE_TEXT];
                    }
                    else {
                        //getObj('image').innerHTML = '<img src="'+ arr[0][PAGE_IMAGE] + '" >';
                        setBigImage( arr[0][PAGE_IMAGE], arr[0][PAGE_BIG_IMAGE] );                        
//++
//                        setBigImage( arr[0][PAGE_IMAGE], arr[0][PAGE_BIG_IMAGE], arr[0][PAGE_ZOOM_FORMAT] );                        
//--
                        
                        setCaption( arr[0][PAGE_NAME] );
//                        setCurrentThumb('thumb0');

                    }

                    setCurrentThumb('thumb0');



                    checkForScroll();


                    if (arr.length > 2){
                        getObj('slideshowdiv').innerHTML = '<img src="./gifs/slideshowStart.gif" onmouseover="showtip(this,event, &#39; start slideshow &#39;);" onmouseout="hidetip();" onmouseup="slideshow(true);">';
                    }


                }
                else {

                    if (currItem[MENU_DEFIMG] != ''){             //main img

                        getObj('image').innerHTML = '<img src="'+ currItem[MENU_DEFIMG] + '" >';

                    }
                    
                    if (currItem[MENU_DEFTXT] != ''){             //main text     ///this may be a video
                        getObj('text').innerHTML = currItem[MENU_DEFTXT];       
                    }



                }

                showFloater( currentRoot  );

            }
            else if (currItem[MENU_TYPE] == typeVideo){
                getObj('video').innerHTML = currItem[MENU_DEFTXT];       
                showFloater( currentRoot  );
            }
            else if (currItem[MENU_TYPE] == typeList){
                
                
                z_mode( z_text );

                if (currItem[MENU_SUBARRAY].length > 0){             //array of images

                    var arr = currItem[MENU_SUBARRAY];
        
                    var s = '';

                    var left = 0;
  
s += "<font style='font-size: 12px; font-weight: bold'>" + currItem[MENU_NAME] + "</font><br><br>";

s += "<table align='right' width='100%' class='medfont' border='0' cellspacing='0' cellpadding='0'>";

                    for(j=0; j<=arr.length-1; j++){
  
//                        s += arr[j][0] + ' ' + arr[j][1] + ' ' + arr[j][2] + '<br><br>';
//                        s += '<hr width="100%">';
s += '<tr>'
s += '<td class="newsDateCol">' + arr[j][0] + '</td>';
//s += '<td  class="newsDateCol" width="10px">&nbsp;|&nbsp;</td>';
s += '<td width="88%">' + arr[j][1] + '</td>';
//s += '<td width="10">' + arr[j][2] + '</td>';


s += '</tr>'

                    }

                    
s += "</table>";

                    getObj('text').innerHTML = s;
                }

                showFloater( currentRoot  );
            }
    }
//------

//slideshow(true);

}

function hideScroll(){
    getObj('leftScroll').style.visibility="hidden";
    getObj('rightScroll').style.visibility="hidden";

    getObj('thumbs').style.visibility="hidden";
}

function checkForScroll(){

//++
        //safari won't work without this bit
        var scrollWidth = 0;
        var currItem = getArrayItemByIndex(currentIndex);
        var arr = currItem[MENU_SUBARRAY];
        for(j=0; j<=arr.length-1; j++){
            scrollWidth += arr[j][PAGE_THMB_WIDTH] + 3;
        }
//--




    var width = getObj('thumbs').offsetWidth;
//    var scrollWidth = getObj('thumbs').scrollWidth;       //got rid if because of safari
    var scrollLeft = getObj('thumbs').scrollLeft;
   
    if (scrollWidth > width) {
        if (scrollLeft > 0) getObj('leftScroll').style.visibility="visible";
        else getObj('leftScroll').style.visibility="hidden";

//        if ((scrollLeft+width) < scrollWidth) getObj('rightScroll').style.visibility="visible";
        if ((scrollLeft+width) < scrollWidth) getObj('rightScroll').style.visibility="visible";
        else getObj('rightScroll').style.visibility="hidden";
    }


    //center icons 
    if ((getObj('thumb'+0)) && (getObj('thumb'+0).style.left == '0px')){        //i.e. not already been centered and this is post autoscroll
        if (scrollWidth <= width) {
            var move = ((width - scrollWidth) / 2);
            var currItem = getArrayItemByIndex(currentIndex);
            var arr = currItem[MENU_SUBARRAY];
            for(j=0; j<=arr.length-1; j++){
                getObj('thumb'+j).style.left  = getObj('thumb'+j).offsetLeft + move;
    //            getObj('thumb'+j).left  = getObj('thumb'+j).offsetLeft + move;
            }
        }
    }

    getObj('thumbs').style.visibility="visible";
}

function setCurrentThumb(id){
    currentThumb = id;
    
    var currItem = getArrayItemByIndex(currentIndex);
    
    var arr = currItem[MENU_SUBARRAY];

    for(j=0; j<=arr.length-1; j++){
//        getObj('thumb'+j).style.cssText = 'border: 1px solid white;'
        
        //getObj('thumb'+j).style.borderWidth = '0'; //= 'border: 1px solid white;'
        getObj('thumb'+j).style.borderColor = 'white';
        
        
    }
    //getObj(currentThumb).style.cssText = 'border: 1px solid red;'
        //getObj(currentThumb).style.borderWidth = '1'; //= 'border: 1px solid white;'
        getObj(currentThumb).style.borderColor = '#cc0000';
}


function getTip(subarr){
  var s = '';
     
  if (subarr.length-1 == MENU_TIP){
    s = 'showtip(this,event, &#39;' + subarr[MENU_TIP] + '&#39;);';
  }             
  return s;
}

function showFloater(id){
    getObj('floatingMenudiv').innerHTML = '';

    var s = '';

    getObj('floatingMenudiv').style.width = '120';

    getObj('floatingMenudiv').style.left = 0;
    getObj('floatingMenudiv').style.top = 40;
//    getObj('floatingMenudiv').style.top = 55;

    currItem = getArrayItemByIndex(id);

    if (currItem[MENU_TYPE] == typePage){
    }
    if (currItem[MENU_TYPE] == typeRootMenu){
    
        subarr = currItem[MENU_SUBARRAY];
        var numItems = 0;

        for(var i=0; i<=subarr.length-1; i++){


            if (subarr[i][MENU_INDEX] == currentIndex) {
//                s += '<div id="'+subarr[i][MENU_INDEX]+'" class="mainmenuitemselected" style="position: absolute; left: 0; top: '+ (numItems * 20) +';" onmouseover="" onmouseout="" onmouseup="process(this.id)" >';
//++
                s += '<div id="'+subarr[i][MENU_INDEX]+'" class="mainmenuitemselected" style="position: absolute; left: 0; top: '+ (numItems * 20) +';" onmouseover=" '+getTip(subarr[i])+' " onmouseout="hidetip(); " onmouseup="hidetip(); process(this.id)" >';
              
//--
            } 
//            else s += '<div id="'+subarr[i][MENU_INDEX]+'" class="mainmenuitem" style="position: absolute; left: 0; top: '+ (numItems * 20) +';" onmouseover="showtip(this,event, &#39; zoom out &#39;); this.style.color = &#39;black&#39;; " onmouseout="hidetip(); this.style.color = &#39;gray&#39;; " onmouseup="hidetip(); process(this.id)" >';
//++
            else s += '<div id="'+subarr[i][MENU_INDEX]+'" class="mainmenuitem" style="position: absolute; left: 0; top: '+ (numItems * 20) +';" onmouseover=" '+getTip(subarr[i])+' this.style.color = &#39;black&#39;; " onmouseout="hidetip(); this.style.color = &#39;gray&#39;; " onmouseup="hidetip(); process(this.id)" >';
              
//--

            s += subarr[i][MENU_NAME];
            s += '</div>';

            numItems += 1;


/*!!!            if (subarr[i][MENU_SUB_OPEN]) {
                //debug('MENU_SUB_OPEN ' + subarr[i][MENU_NAME]);
                subsubarr = subarr[i][MENU_SUBARRAY];
        
                for(var j=0; j<=subsubarr.length-1; j++){
                    if (subsubarr[j][MENU_INDEX] == currentIndex) {
                        s += '<div id="'+subarr[i][MENU_INDEX]+'" class="mainmenuitemselected" style="position: absolute; left: 20; top: '+ (numItems * 20) +';" onmouseover="" onmouseout="" onmouseup="process(this.id)" >';
                    } 
                    else s += '<div id="'+subsubarr[j][MENU_INDEX]+'" class="mainmenuitem" style="position: absolute; left: 20; top: '+ (numItems * 20) +';" onmouseover="this.style.color = &#39;black&#39;; " onmouseout="this.style.color = &#39;gray&#39;; " onmouseup="process(this.id)" >';
                    s += subsubarr[j][MENU_NAME];
                    s += '</div>';
        
                    numItems += 1;                
                }
            }
!!!*/
//!!!!!!!!!!++++++++++++++
            if (subarr[i][MENU_SUB_OPEN]) {
                //debug('MENU_SUB_OPEN ' + subarr[i][MENU_NAME]);
                subsubarr = subarr[i][MENU_SUBARRAY];
        
                for(var j=0; j<=subsubarr.length-1; j++){
                    if (subsubarr[j][MENU_INDEX] == currentIndex) {
                        s += '<div id="'+subsubarr[j][MENU_INDEX]+'" class="mainmenuitemselected" style="position: absolute; left: 20; top: '+ (numItems * 20) +';" onmouseover="" onmouseout="" onmouseup="process(this.id)" >';
                    } 
                    else s += '<div id="'+subsubarr[j][MENU_INDEX]+'" class="mainmenuitem" style="position: absolute; left: 20; top: '+ (numItems * 20) +';" onmouseover="this.style.color = &#39;black&#39;; " onmouseout="this.style.color = &#39;gray&#39;; " onmouseup="process(this.id)" >';
                    s += subsubarr[j][MENU_NAME];
                    s += '</div>';
        
                    numItems += 1;                
                }
            }
//!!!!!!!!!!----------


            
            
        }

        getObj('floatingMenudiv').style.height = (numItems)*20;
        getObj('floatingMenudiv').style.width = '190';
        getObj('floatingMenudiv').innerHTML = s;
        getObj('floatingMenudiv').style.visibility="visible";
    }
}

function getDivLeft(id){
//    var ss = new String(getObj(id).style.left);
//    return parseInt(ss.slice( 0, ss.length-2 ));
    
    return getObj(id).offsetLeft;
}

function getDivWidth(id){
//    var ss = new String(getObj(id).style.width);
//    return parseInt(ss.slice( 0, ss.length-2 ));


    return getObj(id).offsetWidth;
}

function getDivTop(id){
//    var ss = new String(getObj(id).style.width);
//    return parseInt(ss.slice( 0, ss.length-2 ));


    return getObj(id).offsetTop;
}

function getDivHeight(id){
//    var ss = new String(getObj(id).style.width);
//    return parseInt(ss.slice( 0, ss.length-2 ));


    return getObj(id).offsetTop;
}


function hideFloater(){
    getObj('floatingMenudiv').style.visibility="hidden";
}

function hideFloater2(){
    getObj('floatingMenudiv2').style.visibility="hidden";
}

function hideBothFloaters(){
    getObj('floatingMenudiv').style.visibility="hidden";
    getObj('floatingMenudiv2').style.visibility="hidden";
}

function getNoLayers(index){
    
    var args = index.split("_");

    return args.length;
}

function getLastLayer(index){
    var ss = index;
    var args = ss.split("_");
    return args[args.length-1];
}





////////////////////////////////////////////////////////////////////////////////
// all functions below from mole site
////////////////////////////////////////////////////////////////////////////////
function popup(url)
{
	newwindow=window.open(url,'name','height=200,width=150');
	if (window.focus) {newwindow.focus()}
	return false;
}

function setInnerHtml(name, str, mouseclick){
    if (document.all) document.all[name].innerHTML = str;
    else document.getElementById(name).innerHTML = str;
    
    if (mouseclick){
        if (document.all) document.all[name].onmouseup = mouseclick;
        else document.getElementById(name).onmouseup = mouseclick;
    }
}

function preLoadChildImages(index){
    var item = getArrayItemByIndex(index);

    var arr = new Array();

    if (item[MENU_TYPE] == typeMenu){

        if (item[MENU_DEFIMG] > '') arr[arr.length] = item[MENU_DEFIMG];

        for(var i=0; i<=item[MENU_SUBARRAY].length-1; i++){
            var subitem = item[MENU_SUBARRAY][i];

            if (subitem[MENU_TYPE] == typeMenu){
                if (subitem[MENU_DEFIMG] > '') arr[arr.length] = subitem[MENU_DEFIMG];
            }
            else{
                var subarr = subitem[MENU_SUBARRAY];
                if (subarr.length > 0) {
                    if (subarr[0][PAGE_IMAGE] > '') arr[arr.length] = subarr[0][PAGE_IMAGE];
                }
            }
        }

    }
    else{
        for(var i=0; i<=item[MENU_SUBARRAY].length-1; i++){
            if (item[MENU_SUBARRAY][i][PAGE_IMAGE] > '') arr[arr.length] = item[MENU_SUBARRAY][i][PAGE_IMAGE];
        }
    }
    MM_preloadImagesArray(arr);
}

function getNoLayers(index){
    
    var args = index.split("_");

    return args.length;
}


//load url in new browser window
function load(url){
    var load = window.open(url,'','scrollbars=yes,menubar=yes,resizable=yes,toolbar=yes,location=yes,status=yes');
}


/* Is+ */
function Is () 
{   // convert all characters to lowercase to simplify testing 
    var agt=navigator.userAgent.toLowerCase(); 

    // *** BROWSER VERSION *** 
    // Note: On IE5, these return 4, so use is.ie5up to detect IE5. 
    this.major = parseInt(navigator.appVersion); 
    this.minor = parseFloat(navigator.appVersion); 

    this.nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1) 
                && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1) 
                && (agt.indexOf('webtv')==-1)); 
    this.nav2 = (this.nav && (this.major == 2)); 
    this.nav3 = (this.nav && (this.major == 3)); 
    this.nav4 = (this.nav && (this.major == 4)); 
    this.nav4up = (this.nav && (this.major >= 4)); 
    this.navonly      = (this.nav && ((agt.indexOf(";nav") != -1) || 
                          (agt.indexOf("; nav") != -1)) ); 
    this.nav5 = (this.nav && (this.major == 5)); 
    this.nav5up = (this.nav && (this.major >= 5)); 

    this.ie   = (agt.indexOf("msie") != -1); 
    this.ie3  = (this.ie && (this.major < 4)); 
    this.ie4  = (this.ie && (this.major == 4) && (agt.indexOf("msie 5.0")==-1) ); 
    this.ie4up  = (this.ie  && (this.major >= 4)); 
    this.ie5  = (this.ie && (this.major == 4) && (agt.indexOf("msie 5.0")!=-1) ); 
    this.ie5up  = (this.ie  && !this.ie3 && !this.ie4); 

    // KNOWN BUG: On AOL4, returns false if IE3 is embedded browser 
    // or if this is the first browser window opened.  Thus the 
    // properties is.aol, is.aol3, and is.aol4 aren't 100% reliable. 
    this.aol   = (agt.indexOf("aol") != -1); 
    this.aol3  = (this.aol && this.ie3); 
    this.aol4  = (this.aol && this.ie4); 

    this.opera = (agt.indexOf("opera") != -1); 
    this.webtv = (agt.indexOf("webtv") != -1); 

    this.mozilla = (agt.indexOf("mozilla") != -1); 

    // *** JAVASCRIPT VERSION CHECK *** 
    // Useful to workaround Nav3 bug in which Nav3 
    // loads <SCRIPT LANGUAGE="JavaScript1.2">. 
    if (this.nav2 || this.ie3) this.js = 1.0 
    else if (this.nav3 || this.opera) this.js = 1.1 
    else if ((this.nav4 && (this.minor <= 4.05)) || this.ie4) this.js = 1.2 
    else if ((this.nav4 && (this.minor > 4.05)) || this.ie5) this.js = 1.3 
    else if (this.nav5) this.js = 1.4 
    // NOTE: In the future, update this code when newer versions of JS 
    // are released. For now, we try to provide some upward compatibility 
    // so that future versions of Nav and IE will show they are at 
    // *least* JS 1.x capable. Always check for JS version compatibility 
    // with > or >=. 
    else if (this.nav && (this.major > 5)) this.js = 1.4 
    else if (this.ie && (this.major > 5)) this.js = 1.3 
    // HACK: no idea for other browsers; always check for JS version with > or >= 
    else this.js = 0.0; 

    // *** PLATFORM *** 
    this.win   = ( (agt.indexOf("win")!=-1) || (agt.indexOf("16bit")!=-1) ); 
    // NOTE: On Opera 3.0, the userAgent string includes "Windows 95/NT4" on all 
    //        Win32, so you can't distinguish between Win95 and WinNT. 
    this.win95 = ((agt.indexOf("win95")!=-1) || (agt.indexOf("windows 95")!=-1)); 

    // is this a 16 bit compiled version? 
    this.win16 = ((agt.indexOf("win16")!=-1) || 
                  (agt.indexOf("16bit")!=-1) || (agt.indexOf("windows 3.1")!=-1) || 
                  (agt.indexOf("windows 16-bit")!=-1) ); 

    this.win31 = ((agt.indexOf("windows 3.1")!=-1) || (agt.indexOf("win16")!=-1) || 
                  (agt.indexOf("windows 16-bit")!=-1)); 

    // NOTE: Reliable detection of Win98 may not be possible. It appears that: 
    //       - On Nav 4.x and before you'll get plain "Windows" in userAgent. 
    //       - On Mercury client, the 32-bit version will return "Win98", but 
    //         the 16-bit version running on Win98 will still return "Win95". 
    this.win98 = ((agt.indexOf("win98")!=-1) || (agt.indexOf("windows 98")!=-1)); 
    this.winnt = ((agt.indexOf("winnt")!=-1) || (agt.indexOf("windows nt")!=-1)); 
    this.win32 = ( this.win95 || this.winnt || this.win98 || 
                   ((this.major >= 4) && (navigator.platform == "Win32")) || 
                   (agt.indexOf("win32")!=-1) || (agt.indexOf("32bit")!=-1) ); 

    this.os2   = ((agt.indexOf("os/2")!=-1) || 
                  (navigator.appVersion.indexOf("OS/2")!=-1) || 
                  (agt.indexOf("ibm-webexplorer")!=-1)); 

    this.mac    = (agt.indexOf("mac")!=-1); 
    this.mac68k = (this.mac && ((agt.indexOf("68k")!=-1) || 
                               (agt.indexOf("68000")!=-1))); 
    this.macppc = (this.mac && ((agt.indexOf("ppc")!=-1) || 
                               (agt.indexOf("powerpc")!=-1))); 

    this.sun   = (agt.indexOf("sunos")!=-1); 
    this.sun4  = (agt.indexOf("sunos 4")!=-1); 
    this.sun5  = (agt.indexOf("sunos 5")!=-1); 
    this.suni86= (this.sun && (agt.indexOf("i86")!=-1)); 
    this.irix  = (agt.indexOf("irix") !=-1);    // SGI 
    this.irix5 = (agt.indexOf("irix 5") !=-1); 
    this.irix6 = ((agt.indexOf("irix 6") !=-1) || (agt.indexOf("irix6") !=-1)); 
    this.hpux  = (agt.indexOf("hp-ux")!=-1); 
    this.hpux9 = (this.hpux && (agt.indexOf("09.")!=-1)); 
    this.hpux10= (this.hpux && (agt.indexOf("10.")!=-1)); 
    this.aix   = (agt.indexOf("aix") !=-1);      // IBM 
    this.aix1  = (agt.indexOf("aix 1") !=-1); 
    this.aix2  = (agt.indexOf("aix 2") !=-1); 
    this.aix3  = (agt.indexOf("aix 3") !=-1); 
    this.aix4  = (agt.indexOf("aix 4") !=-1); 
    this.linux = (agt.indexOf("inux")!=-1); 
    this.sco   = (agt.indexOf("sco")!=-1) || (agt.indexOf("unix_sv")!=-1); 
    this.unixware = (agt.indexOf("unix_system_v")!=-1); 
    this.mpras    = (agt.indexOf("ncr")!=-1); 
    this.reliant  = (agt.indexOf("reliantunix")!=-1); 
    this.dec   = ((agt.indexOf("dec")!=-1) || (agt.indexOf("osf1")!=-1) || 
         (agt.indexOf("dec_alpha")!=-1) || (agt.indexOf("alphaserver")!=-1) || 
         (agt.indexOf("ultrix")!=-1) || (agt.indexOf("alphastation")!=-1)); 
    this.sinix = (agt.indexOf("sinix")!=-1); 
    this.freebsd = (agt.indexOf("freebsd")!=-1); 
    this.bsd = (agt.indexOf("bsd")!=-1); 
    this.unix  = ((agt.indexOf("x11")!=-1) || this.sun || this.irix || this.hpux || 
                 this.sco ||this.unixware || this.mpras || this.reliant || 
                 this.dec || this.sinix || this.aix || this.linux || this.bsd || 
                 this.freebsd); 

    this.vms   = ((agt.indexOf("vax")!=-1) || (agt.indexOf("openvms")!=-1)); 
} 

var is; 
var isIE3Mac = false; 
// this section is designed specifically for IE3 for the Mac 

if ((navigator.appVersion.indexOf("Mac")!=-1) && (navigator.userAgent.indexOf("MSIE")!=-1) && (parseInt(navigator.appVersion)==3)) 
       isIE3Mac = true; 
else   is = new Is();  
/* Is- */

/* BrowserDetect+ */
var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	
	dataBrowser: [
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};

BrowserDetect.init();
/* BrowserDetect- */


////////////////////////////////////////////////////////////////////////////////
// Plugin Detect

// initialize global variables
var detectableWithVB = false;
var pluginFound = false;


function goURL(daURL) {
    // if the browser can do it, use replace to preserve back button
    if(javascriptVersion1_1) {
	window.location.replace(daURL);
    } else {
	window.location = daURL;
    }
    return;
}

function redirectCheck(pluginFound, redirectURL, redirectIfFound) {
    // check for redirection
    if( redirectURL && ((pluginFound && redirectIfFound) || 
	(!pluginFound && !redirectIfFound)) ) {
	// go away
	goURL(redirectURL);
	return pluginFound;
    } else {
	// stay here and return result of plugin detection
	return pluginFound;
    }	
}

function canDetectPlugins() {
    if( detectableWithVB || (navigator.plugins && navigator.plugins.length > 0) ) {
	return true;
    } else {
	return false;
    }
}

function detectFlash(redirectURL, redirectIfFound) {
    pluginFound = detectPlugin('Shockwave','Flash'); 
    // if not found, try to detect with VisualBasic
    if(!pluginFound && detectableWithVB) {
	pluginFound = detectActiveXControl('ShockwaveFlash.ShockwaveFlash.1');
    }
    // check for redirection
    return redirectCheck(pluginFound, redirectURL, redirectIfFound);
}

function detectDirector(redirectURL, redirectIfFound) { 
    pluginFound = detectPlugin('Shockwave','Director'); 
    // if not found, try to detect with VisualBasic
    if(!pluginFound && detectableWithVB) {
	pluginFound = detectActiveXControl('SWCtl.SWCtl.1');
    }
    // check for redirection
    return redirectCheck(pluginFound, redirectURL, redirectIfFound);
}

function detectQuickTime(redirectURL, redirectIfFound) {
    pluginFound = detectPlugin('QuickTime');
    // if not found, try to detect with VisualBasic
    if(!pluginFound && detectableWithVB) {
	pluginFound = detectQuickTimeActiveXControl();
    }
    return redirectCheck(pluginFound, redirectURL, redirectIfFound);
}

function detectReal(redirectURL, redirectIfFound) {
    pluginFound = detectPlugin('RealPlayer');
    // if not found, try to detect with VisualBasic
    if(!pluginFound && detectableWithVB) {
	pluginFound = (detectActiveXControl('rmocx.RealPlayer G2 Control') ||
		       detectActiveXControl('RealPlayer.RealPlayer(tm) ActiveX Control (32-bit)') ||
		       detectActiveXControl('RealVideo.RealVideo(tm) ActiveX Control (32-bit)'));
    }	
    return redirectCheck(pluginFound, redirectURL, redirectIfFound);
}

function detectWindowsMedia(redirectURL, redirectIfFound) {
    pluginFound = detectPlugin('Windows Media');
    // if not found, try to detect with VisualBasic
    if(!pluginFound && detectableWithVB) {
	pluginFound = detectActiveXControl('MediaPlayer.MediaPlayer.1');
    }
    return redirectCheck(pluginFound, redirectURL, redirectIfFound);
}

function detectPlugin() {
    // allow for multiple checks in a single pass
    var daPlugins = detectPlugin.arguments;
    // consider pluginFound to be false until proven true
    var pluginFound = false;
    // if plugins array is there and not fake
    if (navigator.plugins && navigator.plugins.length > 0) {
	var pluginsArrayLength = navigator.plugins.length;
	// for each plugin...
	for (pluginsArrayCounter=0; pluginsArrayCounter < pluginsArrayLength; pluginsArrayCounter++ ) {
	    // loop through all desired names and check each against the current plugin name
	    var numFound = 0;
	    for(namesCounter=0; namesCounter < daPlugins.length; namesCounter++) {
		// if desired plugin name is found in either plugin name or description
		if( (navigator.plugins[pluginsArrayCounter].name.indexOf(daPlugins[namesCounter]) >= 0) || 
		    (navigator.plugins[pluginsArrayCounter].description.indexOf(daPlugins[namesCounter]) >= 0) ) {
		    // this name was found
		    numFound++;
		}   
	    }
	    // now that we have checked all the required names against this one plugin,
	    // if the number we found matches the total number provided then we were successful
	    if(numFound == daPlugins.length) {
		pluginFound = true;
		// if we've found the plugin, we can stop looking through at the rest of the plugins
		break;
	    }
	}
    }
    return pluginFound;
} // detectPlugin


// Here we write out the VBScript block for MSIE Windows
if ((navigator.userAgent.indexOf('MSIE') != -1) && (navigator.userAgent.indexOf('Win') != -1)) {
    document.writeln('<script language="VBscript">');

    document.writeln('\'do a one-time test for a version of VBScript that can handle this code');
    document.writeln('detectableWithVB = False');
    document.writeln('If ScriptEngineMajorVersion >= 2 then');
    document.writeln('  detectableWithVB = True');
    document.writeln('End If');

    document.writeln('\'this next function will detect most plugins');
    document.writeln('Function detectActiveXControl(activeXControlName)');
    document.writeln('  on error resume next');
    document.writeln('  detectActiveXControl = False');
    document.writeln('  If detectableWithVB Then');
    document.writeln('     detectActiveXControl = IsObject(CreateObject(activeXControlName))');
    document.writeln('  End If');
    document.writeln('End Function');

    document.writeln('\'and the following function handles QuickTime');
    document.writeln('Function detectQuickTimeActiveXControl()');
    document.writeln('  on error resume next');
    document.writeln('  detectQuickTimeActiveXControl = False');
    document.writeln('  If detectableWithVB Then');
    document.writeln('    detectQuickTimeActiveXControl = False');
    document.writeln('    hasQuickTimeChecker = false');
    document.writeln('    Set hasQuickTimeChecker = CreateObject("QuickTimeCheckObject.QuickTimeCheck.1")');
    document.writeln('    If IsObject(hasQuickTimeChecker) Then');
    document.writeln('      If hasQuickTimeChecker.IsQuickTimeAvailable(0) Then ');
    document.writeln('        detectQuickTimeActiveXControl = True');
    document.writeln('      End If');
    document.writeln('    End If');
    document.writeln('  End If');
    document.writeln('End Function');

    document.writeln('</scr' + 'ipt>');
}
////////////////////////////////////////////////////////////////////////////////



        function showDimensions(img) {
//            debug('showDimensions()');
            var imageName = img;
            if (imageName != '') {
                //imageName = 'file:///' + escape(imageName.split('\\').join('/'));
                //imageName = imageName.split('%3A').join(':');

                tempImage = new Image();
                tempImage.src = imageName;// + '?randParam=' + new Date().getTime();
            debug(tempImage.src);

            debug(tempImage.width + ' x ' + tempImage.height);

                // append a timestamp to avoid caching issues - which happen if you overwrite any image with one of different dimensions, and try to get the dimensions again
                // even with cache settings to max, in both ff and ie!
            }
        }

