//<!-- this version 1.6 -->
// JavaScript Document
// VERSION 1.0
// VERSION 1.4 amended 12/08/09 - added Houses & housing:  Balancing barn,Suffolk and In Between House: Thorpeness, Suffolk
// VERSION 1.5 amended 21/12/09 - added New images for Gillespie and Cavendish, new Cavendish front page image
// VERSION 1.5.2 amended 25/01/10 - added research/press

//v1.1++
var currentImageAlign = '';
//v1.1--

var thingy = '';

MENU_DELAY = 100;

var count;
var count = 0;
var pos = 0; 

switch (numbers_or_fraction){       //1 = fraction, 2 = list of page numbers (for selecting next and prev pages)
    case 1: 
        var pageSelectMethod = getFraction;
        break;
    case 2: 
        var pageSelectMethod = getPageNumbersList;
        break;
    default: 
        var pageSelectMethod = getFraction;
}

Debug.init(false, './debug/');       //comment out to turn off debug
function debug( arg1, arg2, arg3 ){ Debug.raise( arg1, arg2, arg3 ) };

var mainWidth = 850, mainHeight = 550;
//v1.4 var spaceBetweenMenus = 18;
//v1.4++
//var spaceBetweenMenus = 8;
//v1.5var spaceBetweenMenus = 17;
//v1.4--

//v1.5++

if (navigator.userAgent.indexOf('MSIE') !=-1)
{
    var spaceBetweenMenus = 8; //explorer 
}
else 
{
    var spaceBetweenMenus = 17; //not explorer 
}
//v1.5--

var centreWidth = true, centreHeight = true;

//menu indexes
var MENU_INDEX          = 0;
var MENU_NAME           = 1;
var MENU_TYPE           = 2;
var MENU_FORMAT         = 3;
var MENU_SUBARRAY       = 4;
var MENU_STATICTEXT     = 5;
var MENU_STATICTEXT2    = 6;
var MENU_DEFIMG         = 7;    //default image to display on selecting menu option of type typeMenu , maybe an array of images that auto slideshow on a timer
var MENU_IMGALIGN       = 8;    //left, right, top, bottom, center (default)
//v1.1++
var MENU_MENU_COLOR    = 9;
var MENU_MENU_SEL_COLOR = 10;
//v1.1--
//v1.5.2++
var MENU_FUNCTION = 11;
//v1.5.2--

//page indexes
var PAGE_TITLE          = 0;
var PAGE_IMAGE          = 1;
var PAGE_IMAGEBIG       = 2;
var PAGE_CAPTION        = 3;
var PAGE_TEXT           = 4;
var PAGE_IMGALIGN       = 5;

//content array
var pageFormatNone      = 0;
var pageFormat1         = 1;
var pageFormat2         = 2;
var pageFormat3         = 3;
var pageFormat4         = 4;
var pageFormat5         = 5;
var pageFormat6         = 6;
var pageFormat7         = 7;
var pageFormat8         = 8;
var pageFormat9         = 9;
var pageFormat10        = 10;
//v1.1++
var pageFormat11        = 11;
//v1.1--
//v1.5.2++
var pageFormat12        = 12;
//v1.5.2--

var typeMenu = 'typeMenu';      
var typePage = 'typePage'; 
var typeDummy = 'typeDummy';    //dummy menu option - for display only



var numliststr = 'onmouseover="numlistMouseover(this)" onmouseout="numlistMouseout(this)"';
function numlistMouseover(div) { 

    div.style.cursor = "pointer";

    if (selectedArray[0] != div.id) div.style.color = "black";
}

function numlistMouseout(div) { 
  div.style.cursor = "default";

    if (selectedArray[0] != div.id) div.style.color = "gray";
}


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 insertIntroCaption(){
    var s = '<div id="introcaption" class="introcaption" >'+ introCaptionText +'</div>';
    document.write(s);
}

/* tooltips  */
function showtip(current,e,text){
    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=e.pageX+5;
        document.tooltip.top=e.pageY+5;
        document.tooltip.visibility="show";
    }
}

function hidetip(){
    if (document.layers) document.tooltip.visibility="hidden";
}

function insertToolTip(text){
    if (!equalsNull(text)){
        var s = 'onMouseover="showtip(this,event,';
        s += "'" + text + "'";
        s += ')" onMouseout="hidetip()"';
    }    
    return s;
}

//function enableToolTips(){
//    document.write('<div id="tooltip" style="position:absolute;visibility:hidden"></div>');
//}
/* tooltips  */

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 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=''; 
    }
}
/*
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
*/
function insertMenuDivsNoAnimate(){

    var s = '';
    s += '<div class="logorect" id="logorect">';
//    s += '    <img '+insertToolTip('home')+' id="logo" class="logo" src="./img/mole_logo.gif" onclick="selectedTab = -1; selectedSubTab = -1; window.location.href = '+"'"+'home.html'+"'"+'" />';
//++
//v1.6    s += '    <img '+insertToolTip('home')+' id="logo" class="logo" src="./img/mole_logo.gif" onclick="selectedTab = -1; selectedSubTab = -1; window.location.href = '+"'"+'index.html'+"'"+'" />';
//--

//v1.6++
    s += '    <img '+insertToolTip('home')+' id="logo" class="logo" src="./img/v16_mole_logo.gif" onclick="selectedTab = -1; selectedSubTab = -1; window.location.href = '+"'"+'index.html'+"'"+'" />';
//v1.6--


    s += '</div>';
    s += '<div class="menurect">';

    s += '    <div class="menu" id="mainmenudiv" ></div>';
    s += '    <div class="menu" id="submenudiv1" ></div>';
    s += '    <div class="menu" id="submenudiv2" ></div>';
    s += '    <div class="menu" id="submenudiv3" ></div>';

    s += '</div>';

    getObj('rightrect').innerHTML = s;
}

function popup(url)
{
	newwindow=window.open(url,'name','height=200,width=150');
	if (window.focus) {newwindow.focus()}
	return false;
}


function resetLeftRect(){
    var s = '';
    s += '<div class="container0" id="container0"></div>';
    s += '<div class="container1" id="container1"></div>';
    s += '<div class="container2" id="container2"></div>';

    if (BrowserDetect.browser == 'Opera')   s += '<div class="container3_opera" id="container3"></div>';
    else            s += '<div class="container3" id="container3"></div>';

    s += '<div class="container4" id="container4"></div>';
    s += '<div class="container5" id="container5"></div>';
    s += '<div class="container6" id="container6"></div>';

    setInnerHtml('leftrectdiv', s);    
}

function getRandomImage(){
    var i = 0;
    while ((i < 1) || (i > 5)) {
        i = Math.round( Math.random( ) * 5);
    }        
    
    return './img/blank'+ i + '.bmp';
}


var CurrentPageArrayIndex = -1
var CurrentPageArray = null;
var CurrentPageArrayParent = null;

var selectedArray = new Array();

function resetAllContainers(){
    setInnerHtml('container0', '');
    setInnerHtml('container1', '');
    setInnerHtml('container2', '');
    setInnerHtml('container3', '');
    setInnerHtml('container4', '');
    setInnerHtml('container5', '');
    setInnerHtml('container6', '');
}

var menuEventsStrColor
var menuEventsStr = 'onmouseover="menuMouseover(this)" onmouseout="menuMouseout(this)" onmousedown="menuMousedown(this)" onmouseup="menuMouseup(this)"';
function menuMouseover(div) { 
    div.style.cursor = "pointer";

//v1.1++
    if (getArrayItemByIndex( div.id )[MENU_MENU_SEL_COLOR]){ 
      if (selectedArray[0] != div.id) div.style.color = getArrayItemByIndex( div.id )[MENU_MENU_SEL_COLOR];
    }
    else { 
//v1.1--
      if (selectedArray[0] != div.id) div.style.color = "black";
//v1.1++
    }
//v1.1--


}

function menuMouseout(div) { 
  div.style.cursor = "default";

//v1.1++
    if (getArrayItemByIndex( div.id )[MENU_MENU_COLOR]){ 
      if (selectedArray[0] != div.id) div.style.color = getArrayItemByIndex( div.id )[MENU_MENU_COLOR];
    }
    else { 
//v1.1--
      if (selectedArray[0] != div.id) div.style.color = "gray";
//v1.1++
    }
//v1.1--
}

function menuMousedown(div) { 
}

function menuMouseup(div) { 
    Id = window.setTimeout( function(){ menuMouseupTimed(div) }, MENU_DELAY);
}


function menuMouseupTimed(div) {         //to solve redrawing problems in some browsers (acting as though left mouse button held down)
//++
//getObj('bigimage').width = 700;
//--
    hideBigImage();
    document.getElementById('leftrectdiv').onclick = '';            
    document.getElementById('rightrect').onclick = '';            

    resetLeftRect();

    selectedArray.length = 1;

    if (selectedArray.length == 0) selectedArray[selectedArray.length] = div.id;
    else selectedArray[0] = div.id;
    
    setInnerHtml('submenudiv1', '');
    setInnerHtml('submenudiv2', '');
    setInnerHtml('submenudiv3', '');


    CurrentPageArray = null;
    CurrentPageArrayParent = null;

    resetAllContainers();

    popMainMenu();  //force menu to redraw itself with selected option highlighted


    var currItem = menuArray[selectedArray[0]];

    popContainersMenuStuff(currItem);   //incase menu option has submenus, but has its own image/text
    
    if (currItem[MENU_TYPE] == typeMenu ) popSubMenu(div);          

    preLoadChildImages(div.id);
}

function popContainersMenuStuff(currItem){
    
    setContainerFormat( currItem[MENU_FORMAT] );

   if ((currItem[MENU_STATICTEXT]) && (currItem[MENU_STATICTEXT] != '')){

        setInnerHtml('container3', currItem[MENU_STATICTEXT]);
        
        //scrollbar stuff
        if (BrowserDetect.browser != 'Opera' ){
            var sbox = getObj('container3');   
    
            if (sbox.scrollHeight > sbox.clientHeight){
                
                setInnerHtml('container3', '<div class="scroll_box" id="scroll_box" name="scroll_box"></div><div class="scroll_bar" id="scroll_bar" name="scroll_bar"></div>');
          
                var sbox2 = getObj('scroll_box');
        
                setInnerHtml('scroll_box', currItem[MENU_STATICTEXT]);
             
                //display scrollbar
                setInnerHtml('scroll_bar', getScrollButtonsString('scroll_box'));
        
                getObj('scroll_box').style.width = getObj('container3').offsetWidth - scrollButtonWidth;
            }
        }
           
   }
    else setInnerHtml('container3','');




   if ((currItem[MENU_STATICTEXT2]) && (currItem[MENU_STATICTEXT2] != '')){
        setInnerHtml('container5', currItem[MENU_STATICTEXT2]);
    }
    else setInnerHtml('container5','');

   if ((currItem[MENU_DEFIMG]) && (currItem[MENU_DEFIMG] != '')){
        setupImage(currItem[MENU_DEFIMG], currItem[MENU_IMGALIGN]);
    }
    
//v1.5.2++
if (currItem[MENU_FUNCTION]) {
    eval(currItem[MENU_FUNCTION]);
}
//v1.5.2--
}

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;
    }
}

var subMenuEventsStr = 'onmouseover="subMenuMouseover(this)" onmouseout="subMenuMouseout(this)" onmousedown="subMenuMousedown(this)" onmouseup="subMenuMouseup(this)"';

function subMenuMouseover(div) { 


  div.style.cursor = "pointer";

    var s = div.id;
    var argu = s.split("_");
    
//v1.1++
    if (getArrayItemByIndex( div.id )[MENU_MENU_SEL_COLOR]){ 
      if (selectedArray[getNoLayers(div.id)-1] != argu[getNoLayers(div.id)-1]) div.style.color = getArrayItemByIndex( div.id )[MENU_MENU_SEL_COLOR];
    }
    else { 
//v1.1--
      if (selectedArray[getNoLayers(div.id)-1] != argu[getNoLayers(div.id)-1]) div.style.color = "black";
//v1.1++
    }
//v1.1--
}

function subMenuMouseout(div) { 

  div.style.cursor = "default";

    var s = div.id;
    var argu = s.split("_");

//v1.1++
    if (getArrayItemByIndex( div.id )[MENU_MENU_COLOR]){ 
      if (selectedArray[getNoLayers(div.id)-1] != argu[getNoLayers(div.id)-1]) div.style.color = getArrayItemByIndex( div.id )[MENU_MENU_COLOR];
    }
    else { 
//v1.1--
      if (selectedArray[getNoLayers(div.id)-1] != argu[getNoLayers(div.id)-1]) div.style.color = "gray";
//v1.1++
    }
//v1.1--
}

function subMenuMousedown(div) { 
}

function subMenuMouseup(div) { 
    Id = window.setTimeout( function(){ subMenuMouseupTimed(div) }, MENU_DELAY);
}


function subMenuMouseupTimed(div) {         //to solve redrawing problems in some browsers (acting as though left mouse button held down)
    resetScroll('container3');

    resetAllContainers();

    CurrentPageArrayIndex = -1;
    CurrentPageArray = null;
    CurrentPageArrayParent = null;


    var i = getNoLayers(div.id);

    if (selectedArray.length < i) {
        selectedArray[selectedArray.length] = -1;
    }
    else if (selectedArray.length > i){
        selectedArray.length = i;
    }    
    var s = div.id;
    var args = s.split("_");

    selectedArray[i-1] = args[ args.length-1 ];


    var ss='';
    for(var i=0; i<=args.length-2; i++){
        ss += args[i];
        if (i < args.length-2) ss += "_"; 
    }
    
    popSubMenu( document.getElementById(ss) );

    popSubMenu(div);
      
    var parentItem = getArrayItemByIndex( ss );     

    preLoadChildImages(div.id); 

 
    if (getArrayItemByIndex(div.id)[MENU_TYPE] == typeMenu) 
    {
        popContainersMenuStuff(getArrayItemByIndex(div.id)); 
        popSubMenu(div);
    }        
    else 
    {
        populateContainers(true, div);
    }
}

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
        if (currItem.length > PAGE_IMGALIGN) {  //i.e. not image list

            if ((currItem[MENU_TYPE] == typeMenu) || (currItem[MENU_TYPE] == typePage)){
                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_IMGALIGN) {  //i.e. not image list

            if ((currItem[MENU_TYPE] == typeMenu) || (currItem[MENU_TYPE] == typePage)){
            
                if (currItem[MENU_INDEX] == index){

                    res = currItem;
                    break;
                }
                else {
                    res = iterateThruArray( index, currItem[MENU_SUBARRAY] );                

                    if (res) break;
                }
            }
        }
    }
    
    return res;                
}

function getArrayItemByIndex(index){  
    var res = iterateThruArray(index, menuArray);
    return res;
}

function setContainerFormat(format){
    //container0 = header
    //container1 = image caption
    //container2 = image
    //container3 = text
    //container4 = buttons
    var _top = 0; var _left = 1; var _height = 2; var _width = 3;
    
    for(var i=0; i<=formats[format].length-1; i++){
        if (formats[format][i].length > 0){
            var s = 'top: ' + formats[format][i][_top] + '; left: ' + formats[format][i][_left] + '; height: ' + formats[format][i][_height] + '; width: ' + formats[format][i][_width] + ';';
            if (BrowserDetect.browser == 'Opera') getObj('container'+i).style = s;
            else getObj('container'+i).style.cssText = s;
        } 
    }
}

function populateContainers(loadzoom, div){

    //resetAllContainers();

    if (div) CurrentPageArrayParent = getArrayItemByIndex( div.id );
    if (CurrentPageArray == null) CurrentPageArray = getArrayItemByIndex( div.id );

    if (CurrentPageArrayIndex == -1) CurrentPageArrayIndex = 0;  //set to first in list

    setContainerFormat(CurrentPageArray[MENU_FORMAT]);

    var currPage = CurrentPageArray[MENU_SUBARRAY][CurrentPageArrayIndex];

    if ((currPage[PAGE_TITLE]) && (currPage[PAGE_TITLE] != "")) setInnerHtml('container0', currPage[PAGE_TITLE]);
    else setInnerHtml('container0','');

    if ((currPage[PAGE_CAPTION]) && (currPage[PAGE_CAPTION] != "")) setInnerHtml('container1', currPage[PAGE_CAPTION]);
    else setInnerHtml('container1','');


    //display image if name specified
    if (currPage[PAGE_IMAGE] != "") {
        setupImage(currPage[PAGE_IMAGE], currPage[PAGE_IMAGEBIG], currPage[PAGE_IMGALIGN]);
    }


    if ((currPage[PAGE_IMAGEBIG]) && (currPage[PAGE_IMAGEBIG] != '')) { 
        setInnerHtml('container6', getZoomButton() );
    }
    else setInnerHtml('container6','');

    if ((currPage[PAGE_TEXT]) && (currPage[PAGE_TEXT] != '')){      //images individual text takes precedent over general text in CurrentPageArrayParent[MENU_STATICTEXT]
        setInnerHtml('container3', currPage[PAGE_TEXT]);
    }
    else if ((CurrentPageArrayParent[MENU_STATICTEXT]) && (CurrentPageArrayParent[MENU_STATICTEXT] != '')) {
        setInnerHtml('container3', CurrentPageArrayParent[MENU_STATICTEXT]);
    }
    else setInnerHtml('container3','');



    if ((CurrentPageArrayParent[MENU_STATICTEXT2]) && (CurrentPageArrayParent[MENU_STATICTEXT2] != '')) setInnerHtml('container5', CurrentPageArrayParent[MENU_STATICTEXT2]);
    else setInnerHtml('container5','');
    
    var sbox = getObj('container3');
    
    if (BrowserDetect.browser != 'Opera' ){
        if (sbox.scrollHeight > sbox.clientHeight){
            
            setInnerHtml('container3', '<div class="scroll_box" id="scroll_box" name="scroll_box"></div><div class="scroll_bar" id="scroll_bar" name="scroll_bar"></div>');
      
            var sbox2 = getObj('scroll_box');
    
            if ( (CurrentPageArrayParent.length-1) == MENU_STATICTEXT2 ) setInnerHtml('scroll_box', CurrentPageArrayParent[MENU_STATICTEXT]); 
//v1.1 bug            else  setInnerHtml('scroll_box', currPage[PAGE_TEXT]);
//v1.1 bugfix++

            else  setInnerHtml('scroll_box', CurrentPageArrayParent[MENU_STATICTEXT]);
//v1.1 bugfix--
            
            //display scrollbar
            setInnerHtml('scroll_bar', getScrollButtonsString('scroll_box'));
    
            getObj('scroll_box').style.width = getObj('container3').offsetWidth - scrollButtonWidth;
        }
    }

    if (BrowserDetect.browser == "Safari"){     //having to do this as Safari doesn't support CSS property 'bottom'
        var stats = getObj('propertystats');
        
        if (stats){ //bottom justify
            var cont = getObj('container5');
            stats.style.top = cont.offsetHeight - stats.offsetHeight - 2; 
        }
    }

    if (CurrentPageArray[MENU_SUBARRAY].length > 1){
        setInnerHtml('container4', getPrevButtonString() +  pageSelectMethod()  + getNextButtonString() );
 
        getObj('fraction').style.left = (getObj('container4').offsetWidth - getObj('fraction').offsetWidth) / 2;    //center the fraction div
    }    

/* v1.1
    if (loadzoom){      //preload the zoomed image for the selected page
        if  ((currPage[PAGE_IMAGEBIG]) && (currPage[PAGE_IMAGEBIG] != "")) {

            if (BrowserDetect.browser == "Firefox"){     
                Id = window.setTimeout( function() { MM_preloadImagesArray( new Array(currPage[PAGE_IMAGEBIG]) ) }, 5);	        //on timer so this function can terminate without waiting for download
            }
            else {
                var a = new Array( currPage[PAGE_IMAGEBIG] );
                MM_preloadImagesArray( a );
            }
        }
    }
v1.1 */    
}

//v1.1++
function isImageOk(img) {

    // During the onload event, IE correctly identifies any images
    // that weren't downloaded as not complete. Others should too.
    // Gecko-based browsers act like NS4 in that they report this
    // incorrectly: they always return true.
    if (!img.complete) {
        return false;
    }

    // However, they do have two very useful properties: naturalWidth
    // and naturalHeight. These give the true size of the image. If
    // it failed to load, either of these should be zero.
    if (typeof img.naturalWidth != "undefined" && img.naturalWidth == 0) {
        return false;
    }

    // No other way of checking: assume it's ok.
    return true;
}
//v1.1--

function showBigImage(img){
    var s = '<img style="cursor: pointer;" '+insertToolTip('zoom out')+' width="'+mainWidth+'" height="'+mainHeight+'" src="'+ img +'" onclick="hideBigImage();" />';
    
    var obj = getObj('bigimagediv');
    if (obj){
        obj.innerHTML = s;
        obj.style.width = mainWidth;
        obj.style.height = mainHeight;
        obj.style.zIndex = 3;
    }
  
    //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 hideBigImage(){

/*    if (intervalId > 0) { 
        window.clearInterval(intervalId); //just incase still running
        intervalId = 0;
                
        var obj = getObj('introcaption');
        if (obj){
            if (obj.style.zIndex > -1){
                obj.style.cssText = '';
                obj.innerHTML = '';
                obj.style.width = 0;
                obj.style.height = 0;
                obj.style.zIndex = -1;
            }
        }
    }


    if (Id > 0) { 
        window.clearTimeout(Id); //just incase still running
        Id = 0;
    }
*/

    setInnerHtml('freecontainer', '' ); //clear unzoom button

    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 = '';
        }
    }
    
    var obj = getObj('bigimagediv2')
    if (obj){
        if (obj.style.zIndex > -1){
            obj.style.cssText = '';
            obj.innerHTML = '';
            obj.style.width = 0;
            obj.style.height = 0;
            obj.style.zIndex = -1;
        }
    }

//++
        var obj = getObj('introcaption');
        if (obj){
            if (obj.style.zIndex > -1){
                obj.style.cssText = '';
                obj.innerHTML = '';
                obj.style.width = 0;
                obj.style.height = 0;
                obj.style.zIndex = -1;
            }
        }
//--
}

function fadeBigImageIntervalReverse(){
    count += 1;
    
    if (count < 700){
        getObj('bigimagediv2').style.width = count;
    }
    else {
        hideBigImage();
    }
}


function setupImage(imgName, bigImageName, imgAlign){
    if (arguments.length == 1) {
        imgAlign = 'center';  //if not passed, set to center bt default
        bigImageName = '';
    }
    if (arguments.length == 2) {
        if ((arguments[1] == 'left') || (arguments[1] == 'right') || (arguments[1] == 'top')  || (arguments[1] == 'bottom') || (arguments[1] == 'center')){
            imgAlign = arguments[1];
            bigImageName = '';
        }
        else bigImageName = arguments[1];
    }
    
       var img = new Image()
       img.src = imgName; 

        var cont = getObj('container2');
            
        var s = '';    

        if ((bigImageName) && (bigImageName != '')) { 
            s =  insertToolTip('zoom')+'  style="cursor: pointer;" onclick="showBigImage('+ "'" + bigImageName + "'" +')"';
        }
  
          //if image not same size as container, adjust to fit
         if ((img.width == cont.offsetWidth) && (img.height == cont.offsetHeight)){
                setInnerHtml('container2', '<img id="myPic" class="myPic" src="'+ imgName +'" '+s+' />');
         }
         else if (!((img.width == cont.offsetWidth) && (img.height == cont.offsetHeight))){
        
           if (img.width >= img.height){
                setInnerHtml('container2', '<img id="myPic" class="myPic" width="100%" src="'+ imgName +'" '+s+' />');
                if (getObj('myPic').offsetHeight > getObj('container2').offsetHeight){ 
                    getObj('myPic').style.width='auto'; getObj('myPic').style.height = getObj('container2').offsetHeight; 
                }
           }
           else if (img.height > img.width){
                setInnerHtml('container2', '<img id="myPic" class="myPic" height="100%" src="'+ imgName +'" '+s+' />');
                if (getObj('myPic').offsetWidth > getObj('container2').offsetWidth){ 
                    getObj('myPic').style.height='auto'; getObj('myPic').style.width = getObj('container2').offsetWidth; 
                }
           }


            //MENU_IMGALIGN        
            switch (imgAlign){
                case 'left':
                        //happens by default
                    break;
                case 'right':
                        var pic = getObj('myPic');
    
                        if (pic.offsetWidth < (cont.offsetWidth - 5)){
                            pic.style.left = cont.offsetWidth - pic.offsetWidth;
                        }            
                        
                    break;
                case 'top':
                        //happens by default
                    break;
                case 'bottom':
                        var pic = getObj('myPic');
    
                        if (pic.offsetHeight < (cont.offsetHeight - 5)){
                            pic.style.top = cont.offsetHeight - pic.offsetHeight; 
                        }
                
                    break;
                default:
                    //centre image (check if necessary)
                    var pic = getObj('myPic');
            
                    if (centreHeight) {
                        if (pic.offsetHeight < (cont.offsetHeight - 5)){
                            pic.style.top = Math.round( (cont.offsetHeight - pic.offsetHeight) / 2);  
                        }
                    }
                            
                    if (centreWidth){
                        if (pic.offsetWidth < (cont.offsetWidth - 5)){
                            pic.style.left = Math.round( (cont.offsetWidth - pic.offsetWidth) / 2);  
                        }
                    }
            }
            
      }

}




//v1.1++
function validValue(val){
    var valid = false;
    if ( (!equalsNull(val))  &&  (!equalsEmpty(val)) && (!equalsUndefined(val))  ) {
      valid = true;
    }
    return valid;
}

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;
}
//v1.1--



function getPrevButtonString(){
    var s = '';
    s += '<div id="prev_div" class="prev_div">';
    s += '<img name="prev" src="./img/left.gif" onclick="prevClick()" onmouseover="arrowMouseover(prev)" onmouseout="arrowMouseout(prev)" onmousedown="arrowMousedown(prev)" onmouseup="arrowMouseup(prev)" />';
    s += '</div>';

    return s;
}

function getNextButtonString(){
    var s = '';

    s += '<div id="next_div" class="next_div">';
    s += '<img name="next" src="./img/right.gif" onclick="nextClick()" onmouseover="arrowMouseover(this)" onmouseout="arrowMouseout(this)" onmousedown="arrowMousedown(this)" onmouseup="arrowMouseup(this)" />';
    s += '</div>';

    return s;
}

function showCurrentBigImg(){
    var currPage = CurrentPageArray[MENU_SUBARRAY][CurrentPageArrayIndex];
    showBigImage(currPage[PAGE_IMAGEBIG]);
}

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;
}

function getFraction(){
    var s = '';
    s += '<div align="center" id="fraction" class="fraction">';
    s += (CurrentPageArrayIndex+1) + '/' + CurrentPageArray[MENU_SUBARRAY].length; 
    s += '</div>';
    return s;
}

function getPageNumbersList(){
    var s = '';
    s += '<div align="center" id="fraction" class="fraction"  >';

    for(var i=1; i<=CurrentPageArray[MENU_SUBARRAY].length; i++){
        if (i == (CurrentPageArrayIndex+1)){
            s += '<span class="numlist" style="color: black;">' + i + '</span>';
        }
        else{
            s += '<span class="numlist" '+numliststr+' onclick="assignPage('+i+')">' + i + '</span>';
        }
    
        if (i <= CurrentPageArray[MENU_SUBARRAY].length-1){
            s += '&nbsp;&nbsp;&nbsp;';
        }
    }

    s += '</div>';
    
    return s;
}

function assignPage(i){
    CurrentPageArrayIndex = i-1;
    populateContainers(true);
    resetScroll('container3');
}

function nextClick(){
    if (CurrentPageArrayIndex < CurrentPageArray[MENU_SUBARRAY].length-1) {
        CurrentPageArrayIndex += 1;
    
        populateContainers(true);
    }
    
    resetScroll('container3');
}

function prevClick(){
    
    if (CurrentPageArrayIndex > 0) {
        CurrentPageArrayIndex -= 1;
    
        populateContainers(false);
    }
    
    resetScroll('container3');
}

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 arrowMouseover(td) { 
    if (td.name == "prev"){
         td.src = "./img/left_hover.gif";
    }
    else if (td.name == "next"){
        td.src = "./img/right_hover.gif";
     }
}

function arrowMouseout(td) { 
    if (td.name == "prev"){
        td.src = "./img/left.gif";       
    }
    else if (td.name == "next"){
        td.src = "./img/right.gif";
    }
}

function arrowMousedown(td) { 
}

function arrowMouseup(td) { 
}


function zoomMouseover(td) { 
    td.style.cursor = "pointer";

    if (td.name == "zoom"){
        td.src = "./img/zoom_hover.gif";
        if (document.all) showtip(td,event,'zoom');       //this tip doesn't work with mozilla for some reason
    }
    else if (td.name == "unzoom"){
        td.src = "./img/unzoom_hover.gif";
        if (document.all) showtip(td,event,'zoom out');   //this tip doesn't work with mozilla for some reason
     }
}

function zoomMouseout(td) { 
    td.style.cursor = "default";

    if (td.name == "zoom"){
        td.src = "./img/zoom.gif";       
    }
    else if (td.name == "unzoom"){
        td.src = "./img/unzoom.gif";
    }

    if (document.all) hidetip();    //showtip above doesn't work with mozilla for some reason
}

function zoomMousedown(td) { 
}

function zoomMouseup(td) { 
}

function nextMouseover(div) { 
  div.style.cursor = "hand";

    div.style.color = "black";
}

function nextMouseout(div) { 
  div.style.cursor = "default";

    div.style.color = "gray";

}

function popMainMenu(init){     //init = true only at first time called from home.html
    var s = '';

    if (!document.all) { getObj('mainmenudiv').style.height = 0; }

    for (var i=0; i<=menuArray.length-1; i++) {    

//v1.1        if (selectedArray[0] == i) s += '<div '+menuEventsStr+' class="mainmenuitemselected" id="'+menuArray[i][MENU_INDEX]+'" name="'+ menuArray[i][MENU_NAME] +'" >' + menuArray[i][MENU_NAME] + '</div>';
//v1.1        else s += '<div '+menuEventsStr+' class="mainmenuitem" id="'+menuArray[i][MENU_INDEX]+'" name="'+ menuArray[i][MENU_NAME] +'" >' + menuArray[i][MENU_NAME] + '</div>';        
//v1.1++

if ((menuArray[i][MENU_MENU_COLOR]) && (menuArray[i][MENU_MENU_SEL_COLOR])){
    if (selectedArray[0] == i) s += '<div style="color: '+menuArray[i][MENU_MENU_SEL_COLOR]+'" '+menuEventsStr+' class="mainmenuitemselected" id="'+menuArray[i][MENU_INDEX]+'" name="'+ menuArray[i][MENU_NAME] +'" >' + menuArray[i][MENU_NAME] + '</div>';
    else s += '<div style="color: '+menuArray[i][MENU_MENU_COLOR]+'" '+menuEventsStr+' class="mainmenuitem" id="'+menuArray[i][MENU_INDEX]+'" name="'+ menuArray[i][MENU_NAME] +'" >' + menuArray[i][MENU_NAME] + '</div>';        
}
else{
    if (selectedArray[0] == i) s += '<div '+menuEventsStr+' class="mainmenuitemselected" id="'+menuArray[i][MENU_INDEX]+'" name="'+ menuArray[i][MENU_NAME] +'" >' + menuArray[i][MENU_NAME] + '</div>';
    else s += '<div '+menuEventsStr+' class="mainmenuitem" id="'+menuArray[i][MENU_INDEX]+'" name="'+ menuArray[i][MENU_NAME] +'" >' + menuArray[i][MENU_NAME] + '</div>';        
}

//v1.1--


        if (!document.all) { getObj('mainmenudiv').style.height = getObj('mainmenudiv').offsetHeight + spaceBetweenMenus; }
        
        getObj('mainmenudiv').style.zIndex = 1;
    }

    setInnerHtml('mainmenudiv', s);
    
    if (submenudiv1) getObj('submenudiv1').style.top = getObj('mainmenudiv').offsetTop + getObj('mainmenudiv').offsetHeight + spaceBetweenMenus; //preset top position of first submenu div
    
    if (init){      //init passed so check main menu options for images and preload them
        var plarr = new Array();
        for (var i=0; i<=menuArray.length-1; i++) {    
                
            if (menuArray[i][MENU_DEFIMG] > '') plarr[plarr.length] = menuArray[i][MENU_DEFIMG];    //preload array
        }
        MM_preloadImagesArray(plarr);
    }  
}

function getNoLayers(index){
    
    var args = index.split("_");

    return args.length;
}

function popSubMenu(div){
    var item = getArrayItemByIndex(div.id);

    var s = '';

    var lastArray = item[MENU_SUBARRAY];

    if (item[MENU_TYPE] == typeMenu) {
            if (!document.all) { getObj('submenudiv'+getNoLayers(div.id) ).style.height = 0; }  //resizing div for mozilla
    }

    for (var j=0; j<=lastArray.length-1; j++) {

        if (lastArray[j][MENU_TYPE] == typeDummy) {
//v1.5.2            s += '<div class="mainmenudummy" id="'+lastArray[j][MENU_INDEX]+'" name="'+ lastArray[j][MENU_NAME] +'" >' + lastArray[j][MENU_NAME] + '</div>';                
//v1.5.2++
//            s += '<div class="mainmenudummy" id="'+lastArray[j][MENU_INDEX]+'" name="'+ lastArray[j][MENU_NAME] +'" ><u>' + lastArray[j][MENU_NAME] + '</u></div>';                
//            s += '<div class="mainmenudummy" id="'+lastArray[j][MENU_INDEX]+'" name="'+ lastArray[j][MENU_NAME] +'" >' + lastArray[j][MENU_NAME] + '</div>';                
//            s += '<div class="mainmenudummy" id="'+lastArray[j][MENU_INDEX]+'" name="'+ lastArray[j][MENU_NAME] +'" >' + '<hr align="left" width="100%" color="#ffcc00" size="1">' + '</div>';                

            //stick an orange line under the dummy menu item
            if (navigator.userAgent.indexOf('MSIE') !=-1)
            {
                s += '<div class="mainmenudummy" id="'+lastArray[j][MENU_INDEX]+'" name="'+ lastArray[j][MENU_NAME] +'" >' + lastArray[j][MENU_NAME] + '<hr style="position: absolute; top: 17; left: 0;" align="left" width="126" color="'+myorange+'" size="1">' + '</div>';                
            }
            else {
                s += '<div class="mainmenudummy" id="'+lastArray[j][MENU_INDEX]+'" name="'+ lastArray[j][MENU_NAME] +'" >' + lastArray[j][MENU_NAME] + '<hr style="position: absolute; top: 11; left: 0;" align="left" width="126" color="'+myorange+'" size="1">' + '</div>';                
            }

//v1.5.2--
        }  
/*v1.1
        else if (lastArray[j][MENU_TYPE] == typePage) {
            if (selectedArray[getNoLayers(div.id)] == j) s += '<div '+subMenuEventsStr+' class="mainmenuitemselected" id="'+lastArray[j][MENU_INDEX]+'" name="'+ lastArray[j][MENU_NAME] +'" >' + lastArray[j][MENU_NAME] + '</div>';
            else s += '<div '+subMenuEventsStr+' class="mainmenuitem" id="'+lastArray[j][MENU_INDEX]+'" name="'+ lastArray[j][MENU_NAME] +'" >' + lastArray[j][MENU_NAME] + '</div>';

        }
        else if (lastArray[j][MENU_TYPE] == typeMenu) {
            if (selectedArray[getNoLayers(div.id)] == j) s += '<div '+subMenuEventsStr+' class="mainmenuitemselected" id="'+lastArray[j][MENU_INDEX]+'" name="'+ lastArray[j][MENU_NAME] +'" >' + lastArray[j][MENU_NAME] + '</div>';
            else s += '<div '+subMenuEventsStr+' class="mainmenuitem" id="'+lastArray[j][MENU_INDEX]+'" name="'+ lastArray[j][MENU_NAME] +'" >' + lastArray[j][MENU_NAME] + '</div>';                
        }        
v1.1*/        
//v1.1++
        else if (lastArray[j][MENU_TYPE] == typePage) {
          if ((lastArray[j][MENU_MENU_COLOR]) && (lastArray[j][MENU_MENU_SEL_COLOR])){
              if (selectedArray[getNoLayers(div.id)] == j) s += '<div style="color: '+lastArray[j][MENU_MENU_SEL_COLOR]+'" '+ subMenuEventsStr +' class="mainmenuitemselected" id="'+lastArray[j][MENU_INDEX]+'" name="'+ lastArray[j][MENU_NAME] +'" >' + lastArray[j][MENU_NAME] + '</div>';
              else s += '<div style="color: '+lastArray[j][MENU_MENU_COLOR]+'" '+subMenuEventsStr+' class="mainmenuitem" id="'+lastArray[j][MENU_INDEX]+'" name="'+ lastArray[j][MENU_NAME] +'" >' + lastArray[j][MENU_NAME] + '</div>';
          }
          else{
              if (selectedArray[getNoLayers(div.id)] == j) s += '<div '+subMenuEventsStr+' class="mainmenuitemselected" id="'+lastArray[j][MENU_INDEX]+'" name="'+ lastArray[j][MENU_NAME] +'" >' + lastArray[j][MENU_NAME] + '</div>';
              else s += '<div '+subMenuEventsStr+' class="mainmenuitem" id="'+lastArray[j][MENU_INDEX]+'" name="'+ lastArray[j][MENU_NAME] +'" >' + lastArray[j][MENU_NAME] + '</div>';
          }

        }
        else if (lastArray[j][MENU_TYPE] == typeMenu) {
          if ((lastArray[j][MENU_MENU_COLOR]) && (lastArray[j][MENU_MENU_SEL_COLOR])){
              if (selectedArray[getNoLayers(div.id)] == j) s += '<div  style="color: '+lastArray[j][MENU_MENU_SEL_COLOR]+'" '+subMenuEventsStr+' class="mainmenuitemselected" id="'+lastArray[j][MENU_INDEX]+'" name="'+ lastArray[j][MENU_NAME] +'" >' + lastArray[j][MENU_NAME] + '</div>';
              else s += '<div  style="color: '+lastArray[j][MENU_MENU_COLOR]+'" '+subMenuEventsStr+' class="mainmenuitem" id="'+lastArray[j][MENU_INDEX]+'" name="'+ lastArray[j][MENU_NAME] +'" >' + lastArray[j][MENU_NAME] + '</div>';                
          }
          else{
            if (selectedArray[getNoLayers(div.id)] == j) s += '<div '+subMenuEventsStr+' class="mainmenuitemselected" id="'+lastArray[j][MENU_INDEX]+'" name="'+ lastArray[j][MENU_NAME] +'" >' + lastArray[j][MENU_NAME] + '</div>';
            else s += '<div '+subMenuEventsStr+' class="mainmenuitem" id="'+lastArray[j][MENU_INDEX]+'" name="'+ lastArray[j][MENU_NAME] +'" >' + lastArray[j][MENU_NAME] + '</div>';                
          }
        }        

//v1.1--
        
        
        
        if (item[MENU_TYPE] == typeMenu) {
                var i = getNoLayers(div.id);
                if (!document.all) { getObj('submenudiv'+i).style.height = getObj('submenudiv'+i).offsetHeight + spaceBetweenMenus; } //resizing div for mozilla
        }                
    }

    if (item[MENU_TYPE] == typeMenu) {
        if (getNoLayers(div.id) == 1) { 
            setInnerHtml('submenudiv1', s);
            setInnerHtml('submenudiv2', '');
            setInnerHtml('submenudiv3', '');

            getObj('submenudiv1').style.top = getObj('mainmenudiv').offsetTop + getObj('mainmenudiv').offsetHeight + spaceBetweenMenus;
            getObj('submenudiv1').style.zIndex = 0;
            getObj('submenudiv2').style.zIndex = -1;
            getObj('submenudiv3').style.zIndex = -1;
            
        }
        else if (getNoLayers(div.id) == 2) { 
            setInnerHtml('submenudiv2', s);
            setInnerHtml('submenudiv3', '');

            getObj('submenudiv2').style.top = getObj('submenudiv1').offsetTop + getObj('submenudiv1').offsetHeight + spaceBetweenMenus;
            getObj('submenudiv2').style.zIndex = 0;
            getObj('submenudiv3').style.zIndex = -1;
        }
  
        else if (getNoLayers(div.id) == 3) { 
            setInnerHtml('submenudiv3', s);

            getObj('submenudiv3').style.top = getObj('submenudiv2').offsetTop + getObj('submenudiv2').offsetHeight + spaceBetweenMenus;
            getObj('submenudiv3').style.zIndex = 0;
        } 
    }    
}

//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- */

