/*** SET BUTTON'S FOLDER HERE ***/
var buttonFolder = "images/buttons/";

/*** SET BUTTONS' FILENAMES HERE ***/
upSources = new Array("home_light.gif","products_light.gif","services_light.gif","var_light.gif","client_light.gif","press_light.gif", "about_light.gif", "contact2_light.gif", "financial_light.gif");

overSources = new Array("home_dark.gif","products_dark.gif","services_dark.gif","var_dark.gif","client_dark.gif","press_dark.gif", "about_dark.gif", "contact2_dark.gif", "financial_dark.gif");

// SUB MENUS DECLARATION, YOU DONT NEED TO EDIT THIS
subInfo = new Array();
subInfo[1] = new Array();
subInfo[2] = new Array();
subInfo[3] = new Array();
subInfo[4] = new Array();
subInfo[5] = new Array();
subInfo[6] = new Array();
subInfo[7] = new Array();
subInfo[8] = new Array();
subInfo[9] = new Array();




//*** SET SUB MENUS TEXT LINKS AND TARGETS HERE  - remove entirely if no subs - ***//

subInfo[2][1] = new Array("ATMs","atms.php","class=\"subheader\"");
subInfo[2][2] = new Array("Cash & Coin Handling","Counters.php","class=\"subheader\"");
subInfo[2][3] = new Array("Kiosks","Heritage.php","class=\"subheader\"");
subInfo[2][4] = new Array("Point of Sale","coming_soon_pos.php","class=\"subheader\"");
subInfo[2][5] = new Array("Self-Service Checkout","Quickway.php","class=\"subheader\"");
subInfo[2][6] = new Array("Environmental Monitoring Systems","Winland.php","class=\"subheader\"");
subInfo[2][7] = new Array("Customer/Employee Management","Siga.php","class=\"subheader\"");

subInfo[3][1] = new Array("ATM Sales","services.php?s=1","class=\"subheader\"");
subInfo[3][2] = new Array("Service Parts","services.php?s=2","class=\"subheader\"");
subInfo[3][3] = new Array("Certified Service Technicians","services.php?s=3","class=\"subheader\""); 
subInfo[3][4] = new Array("Online & Phone Tech Support","services.php?s=4","class=\"subheader\""); 
subInfo[3][5] = new Array("Joint Ventures","services.php?s=5","class=\"subheader\"");
subInfo[3][6] = new Array("Outsourcing","services.php?s=6","class=\"subheader\""); 
subInfo[3][7] = new Array("24 Hour Monitoring / Reporting","services.php?s=7","class=\"subheader\""); 
subInfo[3][8] = new Array("Dispenser Repair","services.php?s=8","class=\"subheader\""); 
subInfo[3][9] = new Array("Processing","services.php?s=9","class=\"subheader\"");
subInfo[3][10] = new Array("Leasing","services.php?s=10","class=\"subheader\""); 
subInfo[3][11] = new Array("Placement","services.php?s=11","class=\"subheader\""); 
subInfo[3][12] = new Array("Vault Cash & Armored Services","services.php?s=12","class=\"subheader\"");
subInfo[3][13] = new Array("Custom Kiosks","services.php?s=13","class=\"subheader\"");
subInfo[3][14] = new Array("Custom Signage","services.php?s=14","class=\"subheader\""); 
subInfo[3][15] = new Array("Custom Receipt Paper","services.php?s=15","class=\"subheader\""); 
subInfo[4][1] = new Array("Information","become_var.php","class=\"subheader\"");
subInfo[4][2] = new Array("Web Reporting","../Section10/Default.asp","class=\"subheader\""); 
subInfo[4][3] = new Array("Resources","resources.php","class=\"subheader\""); 
subInfo[4][4] = new Array("Online Ordering","mainorder.html","class=\"subheader\""); 
subInfo[5][1] = new Array("Information","client.php","class=\"subheader\"");
subInfo[5][2] = new Array("Web Reporting","../Section10/Default.asp","class=\"subheader\"");
subInfo[5][3] = new Array("Resources","resources.php","class=\"subheader\""); 
subInfo[9][1] = new Array("Information","financial.php","class=\"subheader\"");
subInfo[9][2] = new Array("Web Reporting","../Section10/Default.asp","class=\"subheader\""); 
subInfo[9][3] = new Array("Resources","resources.php","class=\"subheader\""); 
subInfo[9][4] = new Array("Online Ordering","_ordering.php","class=\"subheader\""); 


//*** SET SUB MENU POSITION ( RELATIVE TO BUTTON ) ***//
var xSubOffset = 50;
var ySubOffset = 23;



//*** NO MORE SETTINGS BEYOND THIS POINT ***//
var overSub = false;
var delay = 1000;
totalButtons = upSources.length;

// GENERATE SUB MENUS
for ( x=0; x<totalButtons; x++) { //first for statement
	// SET EMPTY DIV FOR BUTTONS WITHOUT SUBMENU
	if ( subInfo[x+1].length < 1 ) { 
		document.write('<div id="submenu' + (x+1) + '">');
	// SET DIV FOR BUTTONS WITH SUBMENU
	} else { // first if statement
		document.write('<div id="submenu' + (x+1) + '" class="dropmenu" ');
		document.write('onMouseOver="overSub=true;');
		document.write('setOverImg(\'' + (x+1) + '\',\'\');"');
		document.write('onMouseOut="overSub=false;');
		document.write('setTimeout(\'hideSubMenu(\\\'submenu' + (x+1) + '\\\')\',delay);');
		document.write('setOutImg(\'' + (x+1) + '\',\'\');">');


		document.write('<ul>');
		for ( k=0; k<subInfo[x+1].length-1; k++ ) { 
				document.write('<li ' + subInfo[x+1][k+1][2] + '>');
				document.write('<a href="' + subInfo[x+1][k+1][1] + '" ');
				document.write('>');
				document.write(subInfo[x+1][k+1][0] + '</a>');
									
				document.write('</li>');
				
		}//second for statement
		document.write('</ul>');
		document.write('</div>');
	} // first if statement
	
} //first for statement




//*** MAIN BUTTONS FUNCTIONS ***//
// PRELOAD MAIN MENU BUTTON IMAGES
function preload() {
	for ( x=0; x<totalButtons; x++ ) {
		buttonUp = new Image();
		buttonUp.src = buttonFolder + upSources[x];
		buttonOver = new Image();
		buttonOver.src = buttonFolder + overSources[x];
	}
}

// SET MOUSEOVER BUTTON
function setOverImg(But, ID) {
	document.getElementById('button' + But + ID).src = buttonFolder + overSources[But-1];
}

// SET MOUSEOUT BUTTON
function setOutImg(But, ID) {
	document.getElementById('button' + But + ID).src = buttonFolder + upSources[But-1];
}



//*** SUB MENU FUNCTIONS ***//
// GET ELEMENT ID MULTI BROWSER
function getElement(id) {
	return document.getElementById ? document.getElementById(id) : document.all ? document.all(id) : null; 
}

// GET X COORDINATE
function getRealLeft(id) { 
	var el = getElement(id);
	if (el) { 
		xPos = el.offsetLeft;
		tempEl = el.offsetParent;
		while (tempEl != null) {
			xPos += tempEl.offsetLeft;
			tempEl = tempEl.offsetParent;
		} 
		return xPos;
	} 
} 

// GET Y COORDINATE
function getRealTop(id) {
	var el = getElement(id);
	if (el) { 
		yPos = el.offsetTop;
		tempEl = el.offsetParent;
		while (tempEl != null) {
			yPos += tempEl.offsetTop;
			tempEl = tempEl.offsetParent;
		}
		return yPos;
	}
}

// MOVE OBJECT TO COORDINATE
function moveObjectTo(objectID,x,y) {
	var el = getElement(objectID);
	el.style.left = x;
	el.style.top = y;
}

// MOVE SUBMENU TO CORRESPONDING BUTTON
function showSubMenu(subID, buttonID) {
	hideAllSubMenus();
	butX = getRealLeft(buttonID);
	butY = getRealTop(buttonID);
	moveObjectTo(subID,butX+xSubOffset, butY+ySubOffset);
}

// HIDE ALL SUB MENUS
function hideAllSubMenus() {
	for ( x=0; x<totalButtons; x++) {
		moveObjectTo("submenu" + (x+1) + "",-500, -500 );
	}
}

// HIDE ONE SUB MENU
function hideSubMenu(subID) {
	if ( overSub == false ) {
		moveObjectTo(subID,-500, -500);
	}
}



//preload();

/*
   The isEmpty and isWhitespace functions were taken straight from Netscape's JavaScript development site, http://developer.netscape.com.
*/


      // whitespace characters
      var whitespace = " \t\n\r";

      /****************************************************************/

      // Check whether string s is empty.
      function isEmpty(s)
      { return ((s == null) || (s.length == 0)) }

      /****************************************************************/

      function isWhitespace (s)
      {
           var i;

           // Is s empty?
           if (isEmpty(s)) return true;

           // Search through string's characters one by one
           // until we find a non-whitespace character.
           // When we do, return false; if we don't, return true.

           for (i = 0; i < s.length; i++)
           {
                // Check that current character isn't whitespace.
                var c = s.charAt(i);

                if (whitespace.indexOf(c) == -1) return false;
           }

           // All characters are whitespace.
           return true;
      }

      /****************************************************************/

      function ForceEntry(val, str) {
           var strInput = new String(val.value);

           if (isWhitespace(strInput)) {
                alert(str);
                return false;
           } else
                return true;

      }

      /****************************************************************/

      function ValidateRanking() {
           // This function ensures document.forms[0].nRanking.value >=1 && <= 10

           if (parseInt(document.forms[0].nRanking.value) >= 1 && parseInt(document.forms[0].nRanking.value) <=10)
                return true;
           else
                return false;
      }

      /****************************************************************/

      function ValidateData() {
           var CanSubmit = false;

           // Check to make sure that the full name field is not empty.
           CanSubmit = ForceEntry(document.forms[0].txtName,"You supply a full name.");

           // Check to make sure ranking is between 1 and 10
           if (CanSumbit) CanSubmit = ValidRanking();

           return CanSubmit;
      }



function clickButton(e, buttonid)
{
    var bt = document.getElementById(buttonid);
    if (typeof bt == 'object')
    {
        if(navigator.appName.indexOf("Netscape") > (-1))
        {
            if (e.keyCode == 13)
            {
                bt.click();
                return false;
            }
        }
        if (navigator.appName.indexOf("Microsoft Internet Explorer") > (-1))
        {
            if (event.keyCode == 13)
            {
                bt.click();
                return false;
            }
        }
    }
}


