// slideshow

function showPic (whichpic) {
 if (document.getElementById) {
  document.getElementById('placeholder').src = whichpic.href;
  if (whichpic.title) {
   document.getElementById('desc').childNodes[0].nodeValue = whichpic.title;
  } else {
   document.getElementById('desc').childNodes[0].nodeValue = whichpic.childNodes[0].nodeValue;
  }
  return false;
 } else {
  return true;
 }
}


// thumbnail popup

function resizePhoto(img){
  photo1= new Image();
  photo1.src=(img);
  controller(img);
}
function controller(img){
  if((photo1.width!=0)&&(photo1.height!=0)){
    viewPhoto(img);
  }
  else{
    altResult="controller('"+img+"')";
    interval=setTimeout(altResult,20);
  }
}
function viewPhoto(img){
  winWidth=photo1.width+20;
  winHeight=photo1.height+20;
  txtString="width="+winWidth+",height="+winHeight;
  postResults=window.open(img,"",txtString);
}


// RandomImage from Javascript Source for Design & Planning 
var theImages = new Array()

theImages[0] = 'images/mfc_conf_rm_stock.jpg'
theImages[1] = 'images/chatham_co_new_mobile.jpg'
theImages[2] = 'images/electrolux_cubicles.jpg'
theImages[3] = 'images/modern_biz_files.jpg'


var j = 0
var p = theImages.length;
var preBuffer = new Array()
for (i = 0; i < p; i++){
   preBuffer[i] = new Image()
   preBuffer[i].src = theImages[i]
}
var whichImage = Math.round(Math.random()*(p-1));
function showImage(){
document.write('<img class="fig" src="'+theImages[whichImage]+'">');
}

// RandomImage from Javascript Source for Client Profiles 
var theImagesB = new Array()

theImagesB[0] = 'images/electrolux_workarea.jpg'
theImagesB[1] = 'images/yellow_workarea.jpg'
theImagesB[2] = 'images/infosquare.jpg'

var jB = 0
var pB = theImagesB.length;
var preBufferB = new Array()
for (i = 0; i < pB; i++){
   preBufferB[i] = new Image()
   preBufferB[i].src = theImagesB[i]
}
var whichImageB = Math.round(Math.random()*(pB-1));
function showImageB(){
document.write('<img class="fig" src="'+theImagesB[whichImageB]+'">');
}

// show-hide datagrid layers

function displayToggle(id) {
	var layer = document.getElementById(id).style;
	if(layer.display == "none") {
		layer.display = "block";
	}
	else if(layer.display == "block") {
		layer.display = "none";
	}
}


// document object constructor for tab nav

function getDocObj(elem,parent) {
	if (document.layers) {
	    if (parent) {
	     return "document."+parent+".document."+elem;
	      }
	    else {
		return "document."+elem;
		     }
		
	  } 
	    else if (document.all) {
		return "document.all."+elem;
	} 
	    else if (document.getElementById) {
		return "document.getElementById('"+elem+"')";
	}
}

function getStyleObj(elem,parent) {
	if (document.layers) {
	    if (parent) {
	     return "document."+parent+".document."+elem;
	      }
	    else {
		return "document."+elem + ".style";
		     }
		
	  } 
	    else if (document.all) {
		return "document.all."+elem + ".style";
	  } 
	    else if (document.getElementById) {
		return "document.getElementById('"+elem+"').style";
		
	}
}

// tabs navigation script

// Set up array of tab element style property strings 

var tabArray = new Array(5);
tabArray[0] = null;
tabArray[1] = getStyleObj('tab1');
tabArray[2] = getStyleObj('tab2');
tabArray[3] = getStyleObj('tab3');
tabArray[4] = getStyleObj('tab4');


// Set up array of tabmiddle td element style property strings 

var tabTextArray = new Array(5);
tabTextArray[0] = null;
tabTextArray[1] = getStyleObj('tabmiddle1');
tabTextArray[2] = getStyleObj('tabmiddle2');
tabTextArray[3] = getStyleObj('tabmiddle3');
tabTextArray[4] = getStyleObj('tabmiddle4');


// Set up array of text box element style property strings

var boxArray = new Array(5);
boxArray[0] = null;
boxArray[1] = getStyleObj('box1');
boxArray[2] = getStyleObj('box2');
boxArray[3] = getStyleObj('box3');
boxArray[4] = getStyleObj('box4');

// the global variables for the tab functions 
var active = null;

var activebgcolor = "#005F8C";
var activetextcolor = "#FFFFFF";

var inactivebgcolor = "#F7F7F7";
var inactivetextcolor = "#999999";

var overbgcolor = "#E4E4E4";
var overtextcolor = "#3A3D3F";


// the tab appearance changing function

function tabcolor(tabnum,color1,color2) {
tab = eval(tabArray[tabnum]);
tabtext = eval(tabTextArray[tabnum]);
tab.backgroundColor = color1;
tabtext.color = color2;

if (document.all) {
 tabtext.cursor = 'hand';
 }
else {
 tabtext.cursor = 'pointer';
 }
}

// the central tab navigation function 

function choosebox(num) {
if (document.all || document.getElementById) { 
if (active) {
activetablayer = eval(tabArray[active]);
activetabtext = eval(tabTextArray[active]);
activeboxlayer = eval(boxArray[active]);
activetablayer.zIndex = 0;
activeboxlayer.zIndex = 0;
tabcolor(active,inactivebgcolor, inactivetextcolor);
        }

tablayer = eval(tabArray[num]);
tabtext = eval(tabTextArray[num]);
boxlayer = eval(boxArray[num]);
tablayer.zIndex = 11;
boxlayer.zIndex = 10;

tabcolor(num,activebgcolor, activetextcolor);

active = num;

  }
}

// invoked onmouseover the tab 

function tabover(tabnum) {
if (tabnum != active) {
 tabcolor(tabnum,overbgcolor,overtextcolor);
  }
}

//invoked onmouseout of the tab 

function tabout(tabnum) {

if (tabnum != active) {
tabcolor(tabnum,inactivebgcolor,inactivetextcolor);
 }
}

// dhtml menu controls

/* global variables */
var section;

/* just a bit of browser sniffing is necessary. */

var ie = (document.all) ? true: false; 
var isWin = (navigator.platform.indexOf("Win") != -1) ? true : false;

var ieWin = (ie && isWin) ? true : false;

var ieWin50 = (isWin && navigator.appVersion.indexOf('MSIE 5.0') != -1) ? true : false;


/* the menu open/close function. */

function togglemenu(num) { 

/* set local variables. */
var submenu = "sub"+num;
var square = "sq"+num;

/* Set the display style to "none" if the value is null */
if (document.getElementById(submenu).style.display == null) {
 document.getElementById(submenu).style.display = "none";
 }
 
/* The toggle section. 
If the value of the submenu element's display is "none", 
then it's set to "block"; if the value is "block", it's set to "none".
The plus/minus GIF is also reset accordingly.
*/

if (document.getElementById(submenu).style.display == "none") {
document.getElementById(submenu).style.display = "block";
document.getElementById(square).src = "images/minus.gif";
}
else {
document.getElementById(submenu).style.display = "none";
document.getElementById(square).src = "images/plus.gif";
 }
}


/* Get all the elements with a given class name */

function getElementsByClassName(tagname, classname) {
 
 /* only execute in 5+ browsers. */
 if (!document.getElementById) return false;

 /* get all elements with the tag name tagname. */

 var TagElements = document.getElementsByTagName(tagname);

 /* define an array which will hold the elements with the class name classname. */
 var elementsByClassName = new Array();

 /* Look at all the elements in TagElements, and find the ones with the class name classname. */

 for (i=0; i<TagElements.length; i++) {
  if (TagElements[i].className == classname) {
    elementsByClassName[elementsByClassName.length] = TagElements[i];
    }
 }
  return elementsByClassName;
}


function changeclassstyle(tagname,classname,styleproperty,newstyle) {
 var tochange = getElementsByClassName(tagname,classname);
  for (k=0; k < tochange.length; k++) {
    eval("tochange[k].style." + styleproperty + " = " + "'" + newstyle + "'");
  }
}

/* change the cursor style */
function changecursor(num) {
var square = "sq" + num;
if (ieWin50) {
 var cursorstyle = 'hand'; }
else {
 var cursorstyle = 'pointer';
 }
 
document.getElementById(square).style.cursor = cursorstyle;
}

var section;
function init() {
if (document.getElementById) {
changeclassstyle('div','sublevel','display','none');
changeclassstyle('td','pic','display','none');

if (section > 0) { togglemenu(section); }
 }
}


// Date Stamp

function stampIt() {

var now = new Date();
var year = now.getFullYear();

document.write("<p>Copyright &copy; " + year + " Modern Business Systems Incorporated - All rights reserved.</p>");
}