//**********************************************************************************
// Make browser full window 
//**********************************************************************************

//window.onload = function() {window.moveTo(0,0); window.resizeTo(screen.availWidth,screen.availHeight)}


function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}


function resetDropDownLists()
{
	//window.onload += resetDropDownListsExecute;
	addLoadEvent(resetDropDownListsExecute);
}

function resetDropDownListsExecute()
{
    var selects = document.forms[0].getElementsByTagName("SELECT");
    for (var i = 0; i < selects.length; i++)
    {
        selects.item(i).selectedIndex = 0;
    }
}


//*********************************************************************************
//Search Box
//*********************************************************************************

function clearDefaultText(controlID, defaultText)
{
    if (document.getElementById(controlID).value == defaultText)
        document.getElementById(controlID).value = '';
}

//**********************************************************************************
// Button rollovers 
//**********************************************************************************
	
if (document.images) {
	
// ON SCRIPT
	img1_on = new Image();
	img1_on.src = "/images/btnOnSince1957.gif";       
	img2_on = new Image();
	img2_on.src = "/images/btnOnDownloadCad.gif"; 
	img3_on = new Image();
	img3_on.src = "/images/btnOnConfigurator.gif";
	img4_on = new Image();
	img4_on.src = "/images/btnOnViewCatalog.gif";  
	img5_on = new Image();
	img5_on.src = "/images/btnOnBandSys.jpg"; 
	img6_on = new Image();
	img6_on.src = "/images/btnOnPurchaseOnline.gif";  
			      
// OFF SCRIPT
	img1_off = new Image();
	img1_off.src = "/images/btnOffSince1957.gif";       
	img2_off = new Image();
	img2_off.src = "/images/btnOffDownloadCad.gif"; 
	img3_off = new Image();
	img3_off.src = "/images/btnOffConfigurator.gif";
	img4_off = new Image();
	img4_off.src = "/images/btnOffViewCatalog.gif";
	img5_off = new Image();
	img5_off.src = "/images/btnOffBandSys.jpg";
	img6_off = new Image();
	img6_off.src = "/images/btnOffPurchaseOnline.gif";
}

	
// Function to turn on images.
	function onImgs(imgName) {
		if (document.images) {
			document[imgName].src = eval(imgName + "_on.src");
		}
	}

// Function to turn off images.
	function offImgs(imgName) {
		if (document.images) {
			document[imgName].src = eval(imgName + "_off.src");
		}
	}


//**********************************************************************************
// Random image display
//**********************************************************************************

var theImages = new Array() 

theImages[0] = 'images/1.jpg'
theImages[1] = 'images/2.jpg'
theImages[2] = 'images/3.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]
}




//**********************************************************************************
// Random featured solutions div display on home page
//**********************************************************************************		

function toggleWindow(ID){
	var arrWindows = new Array(
		getWindowObj("one"),
		getWindowObj("two")
	);
	
	for(var i=0;i<arrWindows.length;i++){
		if(ID == (i+1))
			arrWindows[i].style.display = "block";
		else
			arrWindows[i].style.display = "none";
	}
}

//for button toggle
function getWindowObj(ID){
	return document.getElementById(ID);
}

function randomWindow(){
	var ranNumber = Number(Math.floor(Math.random()*2))+1;
	toggleWindow(ranNumber);
}
 
// fix for: onload event fires after all page content has loaded
function init() {
 // quit if this function has already been called
  if (arguments.callee.done) return;

  // flag this function so we don't do the same thing twice
   arguments.callee.done = true;

    // action
    randomWindow();
 };

// for Mozilla
if (document.addEventListener) {
  document.addEventListener("DOMContentLoaded", init, false);
}

//for other browsers 



//**********************************************************************************
//Toggle DIV -- show or hide
//**********************************************************************************

var rightmenu = new Array('mem00' , 'mem01' , 'mem02' , 'mem03' , 'mem04' , 'mem05', 'mem06', 'mem07','mem08');

function toggleThis(div){  document.getElementById(div).style.display = (document.getElementById(div).style.display == 'none')? 'block' : 'none';  for(a = 0; a < rightmenu.length; a++)
	{
		if(div != rightmenu[a]){
			document.getElementById(rightmenu[a]).style.display = 'none';
		}
	}			
}




//**********************************************************************************
// <select> html menu item with url links
//**********************************************************************************
	
function redirect(which){
	var Milliseconds = 0;
	var Location = which.options[which.selectedIndex].value;
	setTimeout("document.location.href='" + Location + "'",Milliseconds);
	which.options[0].selected = true;
}




//*********************************************************************************
// Pop up window functions
//*********************************************************************************

function OpenBrWindow(theURL,winName,features) { 
  window.open(theURL,winName,features);
}

// onClick="OpenBrWindow('theURL', 'winName', 'location=yes,toolbar=yes,status=yes,menubar=yes,scrollbars=yes,width=800,height=600,resizable=no')"



//*********************************************************************************
// Pop-up window with image, caption text and page title
//*********************************************************************************
	
	function imagePopWin(img, title, txt, winW, winH, imgW, imgH) {
		w = window.open('','','width='+ winW +', height='+ winH + ', toolbar=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no');
			w.document.write('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">', '\n');
			w.document.write('<html>', '\n');
			w.document.write('<head>', '\n');
			w.document.write('	<title>' + title + '</title>', '\n');
			w.document.write('	<link rel="stylesheet" href="css/imgPopWinStyle.css" type="text/css">', '\n');
			w.document.write('</head>', '\n');
			w.document.write('<body>', '\n');
			w.document.write('	<table align="center" bgcolor="#ffffff" border=0 width=350 border=0 cellspacing=0 cellpadding=0>', '\n');
			w.document.write('		<tr><td class="body"><a href="#" class="bodyContentText" ONCLICK="javascript:window.close();">Close Window</a><br><br></td></tr>', '\n');
			w.document.write('		<tr><td>' + '<img src=' + 'images/' + img + ' ' + 'width=' + imgW + ' ' +  'height=' + imgH + ' ' +  'border=0>' + '</td></tr>', '\n');
			w.document.write('		<tr><td class="body"><br>' + txt + '</td></tr>', '\n');
			w.document.write('	</table>', '\n');
			w.document.write('</body>', '\n');
			w.document.write('</html>', '\n');
	} 



//*********************************************************************************
// Multiple forms validation
//*********************************************************************************

// General contact form (contactUs.php)
var Form1_Fields = new Array('FirstName','LastName','Title','Company','Email','State');
var Form1_Errors = new Array('First Name','Last Name','Title','Company','Email','State');

// Placeholder for future form
var Form2_Fields = new Array('FirstName','LastName','Company','Email','Phone','State');
var Form2_Errors = new Array('First Name','Last Name','Company','Email','Phone','State');

// Placeholder for future form
var Form3_Fields = new Array('FirstName','LastName','Title','Company','Email','Phone','State');
var Form3_Errors = new Array('First Name','Last Name','Title','Company','Email','Phone','State');

function SetWhichForm(num){
	document.vForm.whichForm.value = num;
}

function MainForm() {
	var pass = true;
	var ErrorMessage = "The following fields are required:\n";
	var theArray = null;
	var theErrors = null;
	
	switch(document.vForm.whichForm.value){
		case "0":
			theArray = Form1_Fields;
			theErrors = Form1_Errors;
			break;
		
		case "1":
			theArray = Form2_Fields;
			theErrors = Form2_Errors;
			break;
		
		case "2":
			theArray = Form3_Fields;
			theErrors = Form3_Errors;
			break;
	}
	
	for (i = 0;i < theArray.length;i++) {
		var tempobj = eval("document.vForm." + theArray[i]);
		if(tempobj.value == ""){
			ErrorMessage += " - " + theErrors[i] + "\n";
			pass = false;
		}
	}
	if (!pass) {
		alert(ErrorMessage)
		return false;
	}
	else {
		return true;
	}
}



//*********************************************************************************
//Browser and platform detection
//*********************************************************************************

var exclude=1;
var agt=navigator.userAgent.toLowerCase();
var win=0;var mac=0;var lin=1;
if(agt.indexOf('win')!=-1){win=1;lin=0;}
if(agt.indexOf('mac')!=-1){mac=1;lin=0;}
var lnx=0;if(lin){lnx=1;}
var ice=0;
var ie=0;var ie4=0;var ie5=0;var ie6=0;var com=0;var dcm;
var op5=0;var op6=0;var op7=0;
var ns4=0;var ns6=0;var ns7=0;var mz7=0;var kde=0;var saf=0;
if(typeof navigator.vendor!="undefined" && navigator.vendor=="KDE"){
	var thisKDE=agt;
	var splitKDE=thisKDE.split("konqueror/");
	var aKDE=splitKDE[1].split("; ");
	var KDEn=parseFloat(aKDE[0]);
	if(KDEn>=2.2){
		kde=1;
		ns6=1;
		exclude=0;
		}
	}
else if(agt.indexOf('webtv')!=-1){exclude=1;}
else if(typeof window.opera!="undefined"){
	exclude=0;
	if(/opera[\/ ][5]/.test(agt)){op5=1;}
	if(/opera[\/ ][6]/.test(agt)){op6=1;}
	if(/opera[\/ ][7-9]/.test(agt)){op7=1;}
	}
else if(typeof document.all!="undefined"&&!kde){
	exclude=0;
	ie=1;
	if(typeof document.getElementById!="undefined"){
		ie5=1;
		if(agt.indexOf("msie 6")!=-1){
			ie6=1;
			dcm=document.compatMode;
			if(dcm!="BackCompat"){com=1;}
			}
		}
	else{ie4=1;}
	}
else if(typeof document.getElementById!="undefined"){
	exclude=0;
	if(agt.indexOf("netscape/6")!=-1||agt.indexOf("netscape6")!=-1){ns6=1;}
	else if(agt.indexOf("netscape/7")!=-1||agt.indexOf("netscape7")!=-1){ns6=1;ns7=1;}
	else if(agt.indexOf("gecko")!=-1){ns6=1;mz7=1;}
	if(agt.indexOf("safari")!=-1 || (typeof document.childNodes!="undefined" && typeof document.all=="undefined" && typeof navigator.taintEnabled=="undefined")){mz7=0;ns6=1;saf=1;}
	}
else if((agt.indexOf('mozilla')!=-1)&&(parseInt(navigator.appVersion)>=4)){
	exclude=0;
	ns4=1;
	if(typeof navigator.mimeTypes['*']=="undefined"){
		exclude=1;
		ns4=0;
		}
	}
if(agt.indexOf('escape')!=-1){exclude=1;ns4=0;}
if(typeof navigator.__ice_version!="undefined"){exclude=1;ie4=0;}

//<![CDATA[
function googleMapsLoad()
{
  if (GBrowserIsCompatible())
  {
    var map = new GMap2(document.getElementById("map"));
    map.addControl(new GSmallMapControl());
    map.addControl(new GMapTypeControl());
    map.setCenter(new GLatLng(41.433467, -87.739855), 15);

    var icon = new GIcon();
    icon.image = "/images/bimbaicon.gif";
    icon.iconSize = new GSize(40, 40);
    icon.iconAnchor = new GPoint(6, 20);
    icon.infoWindowAnchor = new GPoint(5, 1);

    var point = new GLatLng(41.433467, -87.739855);
    var marker = new GMarker(point, icon);
    map.addOverlay(marker);      
  }
}
//]]>

//Uncheck relative checkboxes
function toggleCheckboxes(cb1, cb2, cb3)
{
    document.getElementById(cb1).checked = false;
    document.getElementById(cb2).checked = false;
    document.getElementById(cb3).checked = false;
}

