//**********************************************************************************
// Make browser full window 
//**********************************************************************************

//window.onload = function() {window.moveTo(0,0); window.resizeTo(screen.availWidth,screen.availHeight)}

function resetDropDownLists()
{
	var formName = 'aspnetForm';
	for (i = 0; i < document[formName].elements.length; i++)
	{
        var input = document[formName].elements[i];
        var opt, j = 0;
        if (input.options != null)
        {
            while ((opt = input.options[j++]) != null)
            {
	            opt.selected = (opt.value == '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";  
			      
// 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";
}

	
// 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"),
		getWindowObj("three")
	);
	
	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()*3))+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');
} 
	
//For Products SlideShow
var imageID;
var navClientID;
var arrImages;
var arrText;
var slideIndex = -1;
var slideMax = 0;
var running = true;
function startSlideshow(imageClientID, divNavClientID, images, texts, activateTimer)
{
    slideIndex = -1;
    imageID = imageClientID;
    navClientID = divNavClientID;
    arrImages = images.split("~");
    arrText = texts.split("~");
    slideMax = arrImages.length - 1;
    running = activateTimer;
	nextPhoto(true);
}

function previousPhoto()
{
    if (slideIndex == 0)
        slideIndex = slideMax;
    else
        slideIndex--;
    swapPhoto(running);
}

function nextPhoto(clicked)
{
    if (running || clicked)
    {
        if (slideIndex == slideMax)
            slideIndex = 0;
        else
            slideIndex++;
        swapPhoto(running);
        if (clicked)
            running = false;
        if (running)
	        setTimeout('nextPhoto(false)',3000); 
    }
}

function swapPhoto(keepRunning)
{
    document.getElementById(imageID).src = arrImages[slideIndex];
    document.getElementById(navClientID).innerHTML = 
        "<table border=0>" +
        "<tr><td colspan=\"4\" align=\"center\">" + arrText[slideIndex] + "</td></tr>" +
        "<tr><td><strong>More photos:</strong>&nbsp; </td>" +
        "<td><a href=\"javascript:previousPhoto();\">" + 
        "<img border=\"0\" src=\"/images/prevImgBtn.jpg\"></a></td> " +
        "<td style=\"padding-left:5px; padding-right:5px\">" + 
        "<strong><font color=\"#0C6CB7\">" + (slideIndex + 1) + 
        " / " + (slideMax + 1) + "</font></strong></td>" +
        "<td><a href=\"javascript:nextPhoto(true);\">" + 
        "<img border=\"0\" src=\"/images/nextImgBtn.jpg\"></a></td>" +
        "</tr></table>";
	running = keepRunning;
}



//FOR TECH RESOURCES LEFT NAV SHOW/HIDE
function initialize()
{
    showULFromQueryStringValue();
    setLIClassFromQueryStringValue();
}

function showULFromQueryStringValue()
{
    var args = getArgs();

    showUL(args['UL']);
}

function setLIClassFromQueryStringValue()
{
    var args = getArgs();
    if (document.getElementById("li" + args['LI']) != null)
        document.getElementById("li" + args['LI']).className = "menuHelpSelected";
}

function getArgs()
{
    var args = new Object();
    var query = location.search.substring(1);	  // Get query string
    var pairs = query.split("&");                 // Break at ampersand

    for (var i = 0; i < pairs.length; i++) {
         var pos = pairs[i].indexOf('=');          // Look for 'name=value'
         if (pos == -1) continue;                  // If not found, skip
         var argname = pairs[i].substring(0,pos);  // Extract the name
         var value = pairs[i].substring(pos+1);    // Extract the value
         value = decodeURIComponent(value);        // Decode it, if needed
         args[argname] = value;                    // Store it as a property
    }

    return args;
}

function showUL(layerNum)
{
    var maxDiv = 5;
	var i = 1;
	for (i = 1; i <= maxDiv; i++)
	{
		if (layerNum == i)
			showLayer("ul" + layerNum);
		else
			hideLayer("ul" + i);
	}
}

function showLayer(Layer)
{
	if (document.getElementById(Layer) != null)
		document.getElementById(Layer).style.display = "block";
}

function hideLayer(Layer)
{	
	if (document.getElementById(Layer) != null)
		document.getElementById(Layer).style.display = "none";
}
