// JavaScript Document
function showdiv(pass) { 
var divs = document.getElementsByTagName('div'); 
for(i=0;i<divs.length;i++){ 
if(divs[i].id.match(pass)){//if they are 'see' divs 
if (document.getElementById) // DOM3 = IE5, NS6 
divs[i].style.visibility="visible";// show/hide 
else 
if (document.layers) // Netscape 4 
document.layers[divs[i]].display = 'visible'; 
else // IE 4 
document.all.divs[i].visibility = 'visible'; 
} else { 
if (document.getElementById) 
divs[i].style.visibility="hidden"; 
else 
if (document.layers) // Netscape 4 
document.divs[i].visibility = 'hidden'; 
else // IE 4 
document.all.divs[i].visibility = 'hidden'; 
} 
} 
} 

function hidediv(pass) { 
var divs = document.getElementsByTagName('div'); 
for(i=0;i<divs.length;i++){ 
if(divs[i].id.match(pass)){//if they are 'see' divs 
if (document.getElementById) // DOM3 = IE5, NS6 
divs[i].style.visibility="hidden";// show/hide 
else 
if (document.layers) // Netscape 4 
document.layers[divs[i]].display = 'hidden'; 
else // IE 4 
document.all.hideShow.divs[i].visibility = 'hidden'; 
} 
} 
} 


sfHover = function() {
	// test to see if the element exists first before performing actions on it
	if (document.getElementById("nav")) {
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);



var defaultImg;

function Func1()
{
init();
} 

/*
function animated_init()
{
document.getElementById('banner_person').style.backgroundImage = "url(images/animated_banner_logo.gif)";	
setTimeout("Func1()", 3000);
}
*/


function init(){
	if(document.banner){
		defaultImg = document.banner.src;
	}
	// Quotes
	quotes_array = ["\"When you are involved in the food industry it's very important to find the right suppliers.  I have been fortunate to be partnered up with Farner-Bocken since I opened my restaurants.  They are a one-stop shop for me, providing quality products, and excellent customer service from the ordering process to the final delivery.\"<br><div>-Mike Deeth, Owner, Main Street Pizza and Subs, Coon Rapids, Iowa</div>",
									"\"Everyone that I have encountered with Farner-Bocken, from my sales rep to my drivers to the customer service people, are always the friendliest and most polite vendor that I deal with...\"<br><div>-Renae Stroughter, Yankee Hill Amoco, Lincoln, Nebraska</div>",
"\"...I have never worked with a company with the unique character of Farner-Bocken. A real low profile powerhouse built with a solid foundation on local talent that remains committed to your continued success...if we could bottle what you have and sprinkle it like holy water over other industries, perhaps we would not have the challenges to our economy now being experienced. I am so proud, and so humble to be considered a 'member of the Farner-Bocken Family\"<br><div>Don Dobesh, PDA Inc., Sioux Falls, SD </div>",
"\"I have been very pleased with the service we receive. They keep me informed on all new products and our salesman Jon does a great job keeping our inventory where it needs to be.  Jon  also does a great job of resolving any problems we may encounter.\"<br><div>Connie Hynick, General Manager, The Nutcracker</div>",
"\"Farner Bocken has been an exceptional company to work with and their customer service is excellent. I would recommend Farner Bocken to anyone out there looking for a company that will help you be successful.\"<br><div>Gail Schwartz, Vice President, Lakehead Companies</div>",
"\"For over 25 years Kum & Go has been a corporate partner with Farner-Bocken. As a company, they have met our changing needs as we have moved forward through the years. They are a valuable distribution resource for us and we thank them for their dedication, professionalism and partnership. We congratulate Farner-Bocken on 70 excellent years of business.\"<br><div>Kevin Krause- Sr. VP of Marketing, Kum & Go Stores</div>",
"\"Partnering with Farner Bocken was one of my best decisions. Advanced technology and superb service from customer reps makes working with them an incredible experience\"<br><div>Mark, Les's Superette, Maplewood MN</div>",
"\"After suffering the June 23rd fire that destroyed our entire building and its contents, our Rep. Chris Jones and the entire Farner-Bocken family of management and employees have worked tirelessly to provide product and service to us at our little rented kitchen, just to keep us viable as we struggle to rebuild.  Their loyalty and sincerity will not be forgotten.\"<br><div>Kae Hoppe, Tweeter’s Bar & Grill, Inc., Okoboji, IA</div>",
"\"...thank you for your drivers' patience and always pleasant helpful demeanor, thank you for searching out products to help us satisfy that one customer's wish.  Thank you for helping keep us in front of our customers.\"<br><div>Kae Hoppe, Tweeter's Bar & Grill, Okoboji, IA</div>",
"\"I have yet to meet anyone at the Farner Bocken Company who has not been anything but friendly & professional. They have a job to do and they do it best.. I have been an avid supporter of the Farner Service for more than 20 years. Thanks for making my job a little easier and alot more fun.\"<br><div>Kathy @ the Quik Spot, Everly, Ia</div>",
"\"I would be extremely happy to to tell anyone starting a new business or anyone that has been doing this for a long time, that I have been very happy with this company!  ...But not only is it the people, the products and prices are great too!!\"<br><div>Jane Blum,Owner, The Rose Bud Cafe, Spirit Lake, Ia.</div>",
"\"...we have always been treated as a valued customer and not just an account number.  If we have ever had an issue, good or bad, it has always been addressed immediately and appropriately.\"<br><div>Leslie Cowan, Cowans 66, Stratford Mo.</div>",
"\"As a long time customer of Farner-Bocken, we have benefited from their knowledge and willingness to do whatever it takes to make our business a success.  This long term relationship has mutual benefits, and we appreciate their high quality of service.\"<br><div>Marty Ryan, MR Convenience</div>",
"\"We started with Farner-Bocken Co. in 1984 to help is grow our food program and help us merchandise our stores.  We have had a great relationship over the years.  They have outstanding people.\"<br><div>Richard Cossert, President, Cubby's Stores</div>",
"\"Our experience with them has been excellent in every way.  At the retail operations level they have worked with store management to continually review and upgrade the product and service we provide our customers.  I highly recommend the Farner-Bocken Company as a superior product supplier to the convenience store market.\"<br><div>Robert Ahlstrom, Eagle Mobil</div>",
"\"A significant edge Farner-Bocken maintains in the industry is it's ability to produce measurable results through it's service offering .  The Farner-Bocken staff provides attention to detail through it's product analysis, awareness of consumer buying trends and creative in-store merchandising placement.  Each of these factors is invaluable as a customer.  It is much more efficient to allow “specialists” to assist in the growth of the business.\"<br><div>Raymond D. Anderson III, President, Anderson Food Shops</div>",
"\"our Farner-Bocken rep does everything humanly possible to make us happy and keep us happy. He promptly takes care of  any problems, keeps us updated through e-mails of any new items, or issues and overall makes sure we have the best service available.\"<br><div>Connie, Heritage of Emerson</div>",
"\"I truly believe I have never done business, in any form, with such a great company, from sales people, supervisors, delivery drivers, to the girls in the office I have spoken with when I have needed assistance, to the the people that set the stores.  I haven't ever met or talked to one person from your company that wasn't extremely helpful or seemed to be having a bad day.  Therefore I wanted to take the time to say thank you so much for making it such a pleasure doing business with your company.\"<br><div>Douglas Herrick, Herrick's One Stop</div>",
"\"What Farner-Bocken really provides to our company is expert advice and direction on how to become better convenience store operators, enabling us to increase our sales and become more profitable.  They understand that we are in a highly competitive and ever changing business.  They believe that their success is largely hinged on the success of my business and other similar operators.  In a sense we are partners and we trust them as they do have our best interests in mind.\"<br><div>Brett Bauer, General Manager, Gasby's Convenience Stores</div>"];
	rand = parseInt(Math.random()*quotes_array.length);
	rand=(isNaN(rand))?0:rand;
	
	if(document.getElementById('quote')) {
	document.getElementById('quote').innerHTML = quotes_array[rand];
	}
	person_array = ["images/banner_person_1.gif",
					"images/banner_person_2.gif",
					"images/banner_person_3.gif",
					"images/banner_person_4.gif",
					"images/banner_person_5.gif",
					"images/banner_person_6.gif",	
					"images/banner_person_7.gif",	
					"images/banner_person_8.gif",	
					"images/banner_person_9.gif",	
					"images/banner_person_10.gif",	
					"images/banner_person_11.gif",	
					"images/banner_person_12.gif",	
					"images/banner_person_13.gif",	
					"images/banner_person_14.gif",	
					"images/banner_person_15.gif",		
					"images/banner_person_17.gif",		
					"images/banner_person_18.gif",		
					"images/banner_person_19.gif",	
					"images/banner_person_20.gif",	
					"images/banner_person_21.gif",
					"images/banner_person_22.gif",
					"images/banner_person_23.gif",
					"images/banner_person_24.gif",
					"images/banner_person_25.gif",
					"images/banner_person_26.gif",	
					"images/banner_person_27.gif",	
					"images/banner_person_28.gif",	
					"images/banner_person_29.gif",	
					"images/banner_person_30.gif",	
					"images/banner_person_31.gif",						
					"images/banner_person_32.gif"];
	
	rand_person = parseInt(Math.random()*person_array.length);
	rand_person=(isNaN(rand_person))?0:rand_person;
//	if(document.getElementById('banner_person')) {
//		document.getElementById('banner_person').style.backgroundImage = "url("+person_array[rand_person]+")";
//	}

	if(document.getElementById('map')) {
		tooltip.init ();
	}


}

t=0;
ot=0;

var bannerPic = new Array();
bannerPic[0] = '../images/cs_default.jpg';
bannerPic[1] = '../images/cs_automotive.jpg';
bannerPic[2] = '../images/cs_beverages_01.jpg';
bannerPic[3] = '../images/cs_candy_01.jpg';
bannerPic[4] = '../images/cs_food_02.jpg';
bannerPic[5] = '../images/cs_grocery.jpg';
bannerPic[6] = '../images/cs_ice_cream.jpg';
bannerPic[7] = '../images/cs_supplies.jpg';
bannerPic[8] = '../images/cs_tobacco_01.jpg';
bannerPic[9] = '../images/cs_deli.jpg';
bannerPic[10] = '../images/fs_default.jpg';
bannerPic[11] = '../images/fs_appetizers.jpg';
bannerPic[12] = '../images/fs_breads_02.jpg';
bannerPic[13] = '../images/fs_canned.jpg';
bannerPic[14] = '../images/fs_chemicals.jpg';
bannerPic[15] = '../images/fs_dairy.jpg';
bannerPic[16] = '../images/fs_desserts.jpg';
bannerPic[17] = '../images/fs_drygoods.jpg';
bannerPic[18] = '../images/fs_meats.jpg';
bannerPic[19] = '../images/fs_paper.jpg';
bannerPic[20] = '../images/fs_pastries.jpg';
bannerPic[21] = '../images/fs_produce.jpg';
bannerPic[22] = '../images/fs_smallwares.jpg';
bannerPic[23] = '../images/fs_supplies.jpg';
bannerPic[24] = '../images/fs_spices.jpg';
var p = bannerPic.length;
var bannerpreLoad = new Array();
for (i = 0; i < p; i++) {
	bannerpreLoad[i] = new Image();
	bannerpreLoad[i].src = bannerPic[i];
}

function swapon(i) {
	if(t){clearTimeout(t);}
	if(ot){clearTimeout(ot);}
  document.banner.src = bannerpreLoad[i].src;
}
function swapoff() {
		ot = setTimeout('swapoff2()',100);
		
}
function swapoff2() {
	if(t){
		t = setTimeout('runSlideShow()', slideShowSpeed);
	}
	document.banner.src = defaultImg;
}







/* menuDropdown.js - implements a dropdown menu based on a HTML list
 * Author: Dave Lindquist (http://www.gazingus.org)
 * Modified by: Nicolas Lesbats (nicolas lesbats at laposte net)
 * Version: 0.1b (2004-03-11)
 */

var maxWidth = 50;
/* maximum width of the submenus (in 'em' units) */

var borderBox  = false;
var horizontal = new Array();
var menuTop    = new Array();
var menuHeight = new Array();
var menuLeft   = new Array();
var menuWidth  = new Array();

//window.onload = function() { loadMenu(); }
if(window.attachEvent)
   window.attachEvent("onload", loadMenu);
else if (window.addEventListener)
   window.addEventListener("load", loadMenu, false);

function loadMenu() {
  if (!document.getElementById) return;
  var i = 0, j, root, submenus, node, li, link, division;
  while (true) {
    root = document.getElementById("menuList" + (i + 1));
    if (root == null)
      break;
    submenus = root.getElementsByTagName("ul");
    division = root.parentNode;

    if (document.createElement) {
      /* Win/IE5-6 trick: makes the whole width of the submenus clickable
       */
      for (j = 0; j < submenus.length; j++) {
        node = submenus.item(j);
        if (node.className == "menu" && node.getElementsByTagName("ul").length == 0) {
          li = document.createElement("li");
          node.appendChild(li);
          li.style.position = "absolute";
          li.style.visibility = "hidden";
        }
      }
      /* checks whether the 'width' property applies to the border box or
       * the content box of an element
       */
      if (i == 0) {
        li.style.display = "block";
        li.style.padding = "0";
        li.style.width   = "2px";
        li.style.border  = "1px solid";
        if (li.offsetWidth == 2)
          borderBox = true;
      }
    }

    initializeMenu(root, division, i);

    for (j = 0; j < submenus.length; j++) {
      node = submenus.item(j);
      if (node.className == "menu") {
        link = node.previousSibling;
        while (link != null) {
          if (link.className == "actuator") {
            initializeSubmenu(node, link, root, division);
            node.set();
            break;
          }
          link = link.previousSibling;
        }
      }
    }
    i++;
  }
}

function initializeMenu(root, div, index) {

  horizontal[index] = menuIsHorizontal(root);
  menuTop[index]    = div.offsetTop;
  menuHeight[index] = div.offsetHeight;
  menuLeft[index]   = div.offsetLeft;
  menuWidth[index]  = div.offsetWidth;

  div.horizontal = function() {
    return horizontal[index];
  }

  div.checkMove = function() {
    if (this.hasMoved()) this.resetMenu();
  }

  div.hasMoved = function() {
    if (menuTop[index]    == this.offsetTop    &&
        menuHeight[index] == this.offsetHeight &&
        menuLeft[index]   == this.offsetLeft   &&
        menuWidth[index]  == this.offsetWidth)
      return false;
    return true;
  }

  div.resetMenu = function() {
    horizontal[index] = menuIsHorizontal(root);
    menuTop[index]    = this.offsetTop;
    menuHeight[index] = this.offsetHeight;
    menuLeft[index]   = this.offsetLeft;
    menuWidth[index]  = this.offsetWidth;

    var submenus = root.getElementsByTagName("ul");
    for (var j = 0; j < submenus.length; j++) {
      var node = submenus.item(j);
      if (node.className == "menu") {
        node.style.right = "";
        node.style.left  = "";
        if (!window.opera)
          node.style.width = "";
        node.set();
      }
    }
  }
}

function menuIsHorizontal(root) {
  var first = firstElement(root, "LI");
  if (first != null) {
    var second = first.nextSibling;
    while (second != null) {
      if (second.tagName == "LI") {
        first  = firstElement(first,  "A");
        second = firstElement(second, "A");
        if (first != null && second != null)
          if (first.offsetLeft == second.offsetLeft)
            return false;
        return true;
      }
      second = second.nextSibling;
    }
  }
  return true;
}

function initializeSubmenu(menu, actuator, root, div) {

  var parent = menu.parentNode;

  parent.onmouseover = function() {
    div.checkMove();
    menu.style.visibility = "visible";
  }

  actuator.onfocus = function() {
    div.checkMove();
    menu.style.visibility = "visible";
  }

  parent.onmouseout = function() {
    menu.style.visibility = "";
  }

  var tags = menu.getElementsByTagName("a");
  var link = tags.item(tags.length - 1);
  if (!link.onblur)
    link.onblur = function() {
      var node = link.parentNode.parentNode;
      while (node != menu) {
        node.style.visibility = "";
        node = node.parentNode.parentNode;
      }
      menu.style.visibility = "";
    }

  if (parent.parentNode == root) {
    menu.set = function() {
      setLocation1(this, actuator, root, div);
    }
  } else {
    menu.set = function() {
      setLocation2(this, actuator, div);
    }
  }
}

function setLocation1(menu, actuator, root, div) {
  var first = firstElement(menu, "LI");
  if (first != null)
    if (first.offsetParent == menu)
      setWidth(menu);
  if (div.horizontal()) {
    if (actuator.offsetParent == menu.offsetParent) {
      menu.style.left = actuator.offsetLeft + "px";
      menu.style.top  = actuator.offsetTop  + actuator.offsetHeight + "px";
    } else {
      /* happens in Win/IE5-6 when some ancestors are 'static' and have their
       * 'width' or 'height' different than 'auto' */
      var parent = actuator.offsetParent;
      var top  = 0;
      var left = 0;
      while (parent != menu.offsetParent && parent != null) {
        top  = top  + parent.offsetTop;
        left = left + parent.offsetLeft;
        parent = parent.offsetParent;
      }
      menu.style.left = left + actuator.offsetLeft + "px";
      menu.style.top  = top  + actuator.offsetTop  + actuator.offsetHeight + "px";
    }
  } else {
    menu.style.top = actuator.offsetTop + "px";
    menu.style.left = (div.offsetWidth + actuator.offsetWidth) / 2 + "px";
  }
}

function setLocation2(menu, actuator, div) {
  if (menu.offsetParent != document.body)
    setWidth(menu);
  menu.style.top = actuator.offsetTop + "px";
  menu.style.left = actuator.offsetWidth + "px";
}

function setWidth(menu) {
  menu.style.right = - maxWidth + "em";
  var width  = 0;
  var height = 0;
  var items = menu.getElementsByTagName("a");
  for (var i = 0; i < items.length; i++) {
    var link = items.item(i);
    if (link.parentNode.parentNode == menu) {
      height = height + link.offsetHeight;
      if (link.offsetWidth > width)
        width = link.offsetWidth;
    }
  }
  if (borderBox)
    width = width + (menu.offsetHeight - height);
  menu.style.width = width + "px";
}

function firstElement(node, name) {
  var first = node.firstChild;
  while (first != null) {
    if (first.tagName == name)
      return first;
    first = first.nextSibling;
  }
  return null;
}

function updateClientGrpField() {
	document.forms[0].elements["clientGrp"].value = 
	
    document.forms[0].elements["clientGroups"].options[document.forms[0].elements["clientGroups"].selectedIndex].value;
	document.forms[0].elements["chainNum"].value = "";
}

function updateChainNumField() {
	document.forms[0].elements["chainNum"].value = 
	
        document.forms[0].elements["topChains"].options[document.forms[0].elements["topChains"].selectedIndex].value;
}

function updateCGChainNum(what, count) {
     value = document.forms[0].elements["topChains"].options[document.forms[0].elements["topChains"].selectedIndex].value;
	
    for (var i = 0, oldpos = -1; i<count-1; i++) {
        pos = value.indexOf('&',oldpos+1);
        data = value.substring(oldpos+1,pos);
		
		document.forms[0].elements["clientGrp"].value = value.substring(oldpos+1,pos);
		oldpos = pos;
    }
		
    document.forms[0].elements["chainNum"].value = value.substring(oldpos+1,value.length)
}

function updateSubChainNumField(chain) {
	var subChain = chain;	
	opener.document.forms[0].elements["chainNum"].value = subChain;
	self.close();
}

function updateEntNumField(entity) {
	var subEntity = entity;	
	opener.document.forms[0].elements["entityNum"].value = subEntity;
	self.close();
}

function lookupMidListEnt(cg, cn, et){
var cgroup = cg;
var chain = cn;
var entity = et;
path = opener.document.forms[0].elements["path"].value;
var url = path+"/MidList.do?CGRP="+cgroup+"&CHN="+chain+"&ENT="+entity;
document.getElementById('results').style.width = 500;
document.getElementById('results').style.height = 600;
document.getElementById('results').src = url;
}	
function lookupMidList(cg, cn){
var cgroup = cg;
var chain = cn;
path = opener.document.forms[0].elements["path"].value;
var url = path+"/MidList.do?CGRP="+cgroup+"&CHN="+chain;
document.getElementById('results').style.width = 500;
document.getElementById('results').style.height = 600;
document.getElementById('results').src = url;
}

function lookupEntMidList(cg, et){
var cgroup = cg;
var entity = et;
path = opener.document.forms[0].elements["path"].value;
var url = path+"/MidList.do?CGRP="+cgroup+"&ENT="+entity;
document.getElementById('results').style.width = 500;
document.getElementById('results').style.height = 600;
document.getElementById('results').src = url;
}	

function lookupSingleHierarchyEnt() {
cgroup = document.forms[0].elements["clientGrp"].value;
chainnum = document.forms[0].elements["chainNum"].value;
entityNum = document.forms[0].elements["entityNum"].value;
path = document.forms[0].elements["path"].value;
url = path+"/Hier.do?CGRP="+cgroup+"&CHN="+chainnum+"&ENT_CHAIN="+entityNum;
window.open(url,'MidList','width=850,height=650,status,scrollbars,resizeable=1')    
}

function lookupSingleHierarchy() {
cgroup = document.forms[0].elements["clientGrp"].value;
chainnum = document.forms[0].elements["chainNum"].value;
path = document.forms[0].elements["path"].value;
url = path+"/Hier.do?CGRP="+cgroup+"&CHN="+chainnum;
window.open(url,'MidList','width=850,height=650,status,scrollbars,resizeable=1')    
}

function lookupSubChainHierarchy(cg, chn) {
cgroup = cg;
chainnum = chn;
path = opener.document.forms[0].elements["path"].value;
url = path+"/Hier.do?CGRP="+cgroup+"&CHN="+chainnum;
window.open(url,'MidList','width=850,height=650,status,scrollbars,resizeable=1')
      
}
function lookupSubChainHierarchyEnt(cg, chn, et) {
cgroup = cg;
chainnum = chn;
entity = et;
path = opener.document.forms[0].elements["path"].value;
url = path+"/Hier.do?CGRP="+cgroup+"&CHN="+chainnum+"&ENT="+entity;
window.open(url,'MidList','width=850,height=650,status,scrollbars,resizeable=1')
      
}
function lookupEntityHierarchy() {
cgroup = document.forms[0].elements["clientGrp"].value;
topentity = document.forms[0].elements["entityNum"].value;
path = document.forms[0].elements["path"].value;
url = path+"/Hier.do?CGRP="+cgroup+"&ENT="+topentity;
window.open(url,'MidList','width=850,height=650,status,scrollbars,resizeable=1')
    
}

function printFrame(frameName)
{
   // test for nested frame first, and print if present
   if(window.frames[frameName].frames['report'])
   {
      window.frames[frameName].frames['report'].focus();
      window.frames[frameName].frames['report'].print();
      return;
   }
   
   // otherwise, print the iframe itself
   parent[frameName].focus();
   parent[frameName].print();
}
