/**
 * Name: index_default.js
 * Version: 1.0
 *
 * Created By: Colorado Correctional Industries [USA]
 *             http://www.coloradoci.com
 *             Arkansas Valley Correctional Facility (AVCF)
 *
 * Web Master: Sandy Gray (sandra.gray@doc.state.co.us)
 *
 * Project: index_default [VBScript/UEStudioProjects]
 * Programmer: WEB1
 * Revision: 22
 *
 * Edited Date: 3/11/2010 4:01:09 PM
 */

var index_default = {};

/**
 * THE DOCROOT WILL BE REMOVED ONCE THIS SITE IS DONE.
 */
var docRoot;
(function() {
  var root = location.protocol+"//"+location.host+"/";
  if (location.toString().match(/intranet/i)) root = root+""+location.pathname.split(/\//)[0]+"/";
  if (location.toString().match(/92\.40\.66\.30/i)) root = root+""+location.pathname.split(/\//)[0]+"/";
  if (location.toString().match(/92\.40\.66\.29/i)) root = root+"/";
  docRoot = root;
//    docRoot = "http://coloradoci2/";
  if (location.toString().match(/\.com/i)) {
    docRoot = "http://www.coloradoci.com/";
  }
})();

/**
 * This javascript page here deals with the navigational system of the site as well as the header.
 * This page also displays the images that display on the main page.
 */
var msie = navigator.userAgent.match(/msie/i);
var opera = navigator.userAgent.match(/opera/i);
var safari = navigator.userAgent.match(/safari/i);
var firefox = navigator.userAgent.match(/firefox/i);
var netscape = navigator.userAgent.match(/navigator/i);
var N_states = "AL,AK,AZ,AR,CA,CO,CT,DE,DC,FL,GA,ID,IL,IN,IA,KS,KY,LA,ME,MD,MA,MI,MN,MS,MO,MT,NE,NV,NH,NJ,NM,NY,NC,ND,OH,OK,OR,PA,RI,SC,SD,TN,TX,UT,VT,VA,WA,WV,WI,WY".split(",");

index_default.ordering_error = false;
index_default.ordering_error_message = "<div align=center><strong style='color:red'><u>ATTENTION: OUR EMAIL SYSTEM IS DOWN!</u></strong></div><div style=text-indent:10><strong>Our online ordering system, and all other online forms are not available at this time. Please contact our Beth or Amanda to place an order at 303-370-2209.<strong></div>";
/**
 * FUNCTION FOR ALL OF THE PDFS TO OPEN UP IN A STANDARD WINDOW.
 */
index_default.popUpPDFWin = function(links, name) {
  var N_data = [];
  N_data.push("<html>");
  N_data.push("  <head><title>"+name+"</title></head>");
  N_data.push("  <frameset>");
  N_data.push("     <frame src='"+links+"' frameborder='no' />");
  N_data.push("  </frameset>");
  N_data.push("</html>");

  var greenPDF = window.open("", "", "width=850,height=550,status=no,resizable=yes,menubar=no,toolbar=no,alwaysRaised=yes,addressbar=no");
  greenPDF.document.write(N_data.join(''));
  greenPDF.document.close();
};

index_default.popUpSWFWin = function( links, name ) {
  var N_data = [];
  N_data.push("<html>");
  N_data.push("  <head><title>"+name+"</title></head>");
  N_data.push("  <frameset>");
  N_data.push("     <frame src='"+links+"' frameborder='no' />");
  N_data.push("  </frameset>");
  N_data.push("</html>");

  var movieStage = window.open("", "", "width=640,height=476,status=no,resizable=yes,menubar=no,toolbar=no,alwaysRaised=yes,addressbar=no");
  movieStage.document.write(N_data.join(''));
  movieStage.document.close();
};
//temp popup panel only the size changes from popUpSWFWin
index_default.popUp3DWin = function( links, name ) {
  var N_data = [];
  N_data.push("<html>");
  N_data.push("  <head><title>"+name+"</title></head>");
  N_data.push("  <frameset>");
  N_data.push("     <frame src='"+links+"' frameborder='no' />");
  N_data.push("  </frameset>");
  N_data.push("</html>");

  var movieStage = window.open("", "", "width=500,height=500,status=no,resizable=yes,menubar=no,toolbar=no,alwaysRaised=yes,addressbar=no,");
  movieStage.document.write(N_data.join(''));
  movieStage.document.close();
};

index_default.initMain = function(args1) {
  if (index_default.ordering_error && obj('messages')) {
    //obj('messages').innerHTML += ordering_error_message;
  }

  document.body.disabled = true;
  index_default.loadMainMenu();
  index_default.headerInfo();
  if (args1 =="main") index_default.rightNav();
  index_default.footerInfo();
  if ((args1 == "main") || (args1 == "aboutUs") || (args1 == "agreements") || (args1 == "")) playMessage(args1);
  //if ((args1== "main") || (args1 == "")) mytimeoutImages = setTimeout(function(){ getNewPictures(); }, 18000);
  index_default.initCache();
};

index_default.initCache = function() {
  document.body.disabled = false;
  var query = document.location.search.substring(1);

  if (parent.frame_data) {
    sciquest.initiate();
    return false;
  }

  Cache.initiate(index_default.prepData);
};

index_default.loadMainMenu = function() {
  index_default.include(docRoot+"bin-js/Menu.js");
  if (!window.Menu) return false;
  Menu.load("navBar");
};

/**
 * OBJ FUNCTION FOR ALL PAGES.
 */
obj = function() {return document.getElementById(arguments[0])};

/**
 * Strings for the top message display. THIS AREA WILL ALSO
 * BE USED FOR THE COOKIE SYSTEM.
 */
var textSites = {
  "main": "Welcome to Colorado Correctional Industries|where we Build Opportunity!|Thanks for visiting us!|Try our quality products!|",
  "aboutUs": "CCi is committed to|putting out a quality product|at the best price possible.||",
  "agreements": "CCi is a proud part|of the State Awards.|To better serve you |and keep funds in Colorado.|",
  "survey": "CCi would like to |hear your comments|and complaints|about our site and company.|"
};

var MessageArrayPos = 0;
var arrayPos = 0;
var mytimeoutmessage;

playMessage = function( site ) {
  if (textSites[site].split("|").length-1 < arrayPos) arrayPos = 0;

  /**
   * This just puts the information into the proper area. I did this
   * because when the catalog system gets redone this will need to be hidden.
   */
  //if (sites = "main") obj("footer").innerHTML = "This is for a later."

  clearTimeout(mytimeoutmessage);
  mytimeout = 0;
  obj("mainMessage").innerHTML = textSites[site].split("|")[MessageArrayPos];
  if (MessageArrayPos == textSites[site].split("|").length-1) MessageArrayPos = 0;
  else MessageArrayPos++;
  if (arrayPos == 4) {
    clearTimeout(mytimeoutmessage);
    //if (MessageArrayPos == 4) obj("mainMessage").innerHTML = "We Build Opportunity!";
  }
  mytimeoutmessage = setTimeout("playMessage('"+site+"')", 4000);
}

/**
 *End of Message Function.
 */


/**
 * This script here is the main navigational system and header bar for the entire site.
 */
index_default.headerInfo = function() {
  var headInfo = "<table cellpadding=0 cellspacing=0 width=800 height=75 background="+docRoot+"images/flag3.jpg>";
  //headInfo += " <img width=800 height=100 src="+docRoot+"images/small_flag.jpg style=position:absolute;z-index:-1>";
  headInfo += " <tr>";
  headInfo += "  <td valign=top width=100 style='padding-left:10;padding-top:5'><img style=z-index:1;position:absolute; id=cci src="+docRoot+"images/cciHeader.gif onclick='index_default.checkAdmin(event);' /></td>";
  headInfo += "  <td width=410 valign='center' align=center id='mainMessage' style=z-index:2; class=forthheaderB></td>";
  headInfo += "  <td align=center width=290 valign=top>";
  headInfo += "   <div width=290 align='right' style=padding-right:25px;padding-top:5>";
  headInfo += "    <span>";
  headInfo += "     <span class=smallLinks onclick=document.location='"+docRoot+"index.html' onmouseover=\"this.style.color='#c8b24d'\" onmouseout=\"this.style.color='#0f3e5b'\">HOME &nbsp;</span>";
  headInfo += "     &nbsp;<span class=smallLinks onclick=\"index_default.login()\" onmouseover=\"this.style.color='#c8b24d'\" onmouseout=\"this.style.color='#0f3e5b'\">LOGIN</span>";
  headInfo += "     &nbsp;<span id='span_viewcart' class=smallLinks onclick=\"index_default.goToCart()\" onmouseover=\"this.style.color='#c8b24d'\" onmouseout=\"this.style.color='#0f3e5b'\">VIEW CART</span>";
  headInfo += "     &nbsp;<span class=smallLinks onclick=document.location='"+docRoot+"administrator/programs/customer/login_customer.html' onmouseover=\"this.style.color='#c8b24d'\" onmouseout=\"this.style.color='#0f3e5b'\">YOUR ACCOUNT</span>";
  headInfo += "    </span>";
  headInfo += "   </div>";
  headInfo += "   <div class=darkfifthheader style='padding-top:2px;padding-bottom:3; cursor: pointer' onclick=\"location='"+docRoot+"bin-htm/custServ.html?intro'\" onmouseover=\"this.style.color='#c8b24d'\" onmouseout=\"this.style.color='#0f3e5b'\">Customer Service 1-800-685-7891</div>";
  if (msie) headInfo += "   <div width=290 style=padding-left:10;>";
  else headInfo += "   <div width=290 align='right' style=padding-right:25px;padding-top:5;>";
  headInfo += "     <input type=text id=search value='' style='border:solid 1px lightgray' title='search for product: name, one-word description...' />";
  headInfo += "     <span id='span_search' class=fifthheaderB style='cursor:pointer;width:60px;padding:10 0 2 0;' onclick='index_default.searchFor()' onmouseover=\"this.style.color='#c8b24d';\" onmouseout=\"this.style.color='#0f3e5b';\">";
  headInfo += "      Search";
  headInfo += "     </span>";
  headInfo += "   </div>";
  headInfo += "  </td>";
  headInfo += " </tr>";
  headInfo += "</table>";

  obj("header").innerHTML = headInfo;

  obj('search').onkeyup = function(e) {
    if (!e) try{e=event;}catch(e){};
    //e = e || event;
    var keyPressed = e.which || window.event.keyCode;

    if (keyPressed == 13) {
      index_default.searchFor();
    }
    else if (obj('search').value.match(/debug/i)) {
      index_default.include(docRoot+"bin-js/Cache.debug.js");
    }
  };
}

// Search for products...
index_default.searchFor = function(returndata) {
  Cache.data.general.search = obj("search").value;

  var c = document.createElement("form");
  c.method = "POST";
  c.action = docRoot+"bin-php/search.php";

  var a = document.createElement("input");
  a.type = "hidden";
  a.name = "search";
  a.value = obj('search').value;
  c.appendChild(a);
  document.body.appendChild(c);

  setTimeout(function(){c.submit();}, 1000);
};

index_default.insertBodyWrapper = function() {
  var N_html = [];
  N_html.push("<table width='800' align='center' bgcolor='#ffffff' border='0' cellpadding='0' cellspacing='0'>");
  N_html.push(" <!-- These are the two rows that need to be inserted for the display of the header and navigational system. -->");
  N_html.push(" <tr><td id='header' width='100%'>&nbsp;</td></tr>");
  N_html.push(" <tr><td><div id='navBar' style='position: relative; height: 20px'></div></td></tr>");
  N_html.push(" <tr><td bgcolor='#e9e9e9' height='2'></td></tr>");
  N_html.push(" <tr><td height='10'></td></tr>");
  N_html.push("</table>");
  var headObj = document.createElement("div");
  headObj.innerHTML = N_html.join("");
  var bodyFirstChild = document.body.firstChild;
  document.body.insertBefore(headObj, bodyFirstChild);

  var N_html = [];
  N_html.push("<table width='800' align='center' bgcolor='#ffffff' border='0' cellpadding='0' cellspacing='0'>");
  N_html.push(" <tr><td id='footer' align='center' colspan='2'>&nbsp;</td>");
  N_html.push("</table><br><br><br><br><br><br><br><br><br><br>");
  var headObj = document.createElement("div");
  headObj.innerHTML = N_html.join("");
  document.body.appendChild(headObj);
};


/**
 * This is the main button to display down
 * the side of the nav bar.       *
 */
/**
 * var headers = ["Customer Service:","Product Listings:","Online Products:","CCi Services:","General Info:","Agriculture:manufacturers/agriculture/index.html","Contact Us:"];
 *
 * index_default.toggleThisMenu = function( id ) {
 *   index_default.toggleSubMenu();
 *   for (var i = 0; i < headers.length; i++) {
 *     obj("buttonsTable"+i).style.display = "none";
 *   }
 *   if (id && obj("buttonsTable"+id).innerHTML.match(/sideButtons/i)) {
 *     obj("buttonsTable"+id).style.display = "block";
 *   }
 * };
 *
 * index_default.toggleSubMenu = function( tdObj, id ) {
 *   if (id) {
 *     this.id1 = id.split(/_/)[0];
 *   }
 *   var N_sideButtons = document.getElementsByTagName("div");
 *   for (var i = 0; i < N_sideButtons.length; i++) {
 *     if (N_sideButtons[i].id) {
 *       if (N_sideButtons[i].id.match(/sideButtons/i)) {
 *         N_sideButtons[i].style.display = "none";
 *       }
 *     }
 *   }
 *   if (id) {
 *     obj("sideButtons"+id).style.display = "block";
 *     obj("sideButtons"+id).style.left = tdObj.offsetWidth+10;
 *     obj("sideButtons"+id).style.top = tdObj.offsetTop-1;
 *   }
 * };
 *
 * index_default.watchMenu = function(ticking) {
 *   if (!this.clock) this.clock = 5;
 *   if (!ticking) {
 *     clearTimeout(this.timeout);
 *     this.clock = 5;
 *   }
 *   this.clock--;
 *   if (this.clock) this.timeout = setTimeout("index_default.watchMenu(1)", 1000);
 *   else if (ticking && !this.clock) index_default.toggleThisMenu();
 *   //status = this.clock
 * };
 */

index_default.rightNav = function() {
  var rightNavT = " <br><table width=150 cellpadding=0 cellspacing=0 border=0 >";
  //rightNavT += " <tr><td style='height:5px'></td><tr>";
  rightNavT += " <tr><th class=sideBarBlocks>QUICK SHOPPER</th><tr>";
  var shopNowProds;
  shopNowProds = "Desks|../catalogs/bin-html/onlineProds.html?desks;all,Seating/Chairs|../catalogs/bin-html/onlineProds.html?seating;office,Files & Storage|../catalogs/bin-html/onlineProds.html?filing/Storage;all,Tables|../catalogs/bin-html/onlineProds.html?tables;computer,DOC BDUs|../catalogs/bin-html/onlineProds.html?apparel;DOC BDUs,Flags|../catalogs/bin-html/onlineProds.html?apparel;flags,Lounge Chairs|../catalogs/bin-html/onlineProds.html?seating;lounge,Dormitory Products|../manufacturers/furniture/dormitory.html?dormitory;all,Printer Cartridges|../bin-htm/greenInk.html?intro,Computer Accessories|../catalogs/bin-html/onlineProds.html?computer accessories;keyboards";

   //shopNowProds = "Air Filtration|filters/index.html?filterProds,Apparel|apparel/index.html?all,DOC BDUs|apparel/index.html?bdu,Dormitory Furniture|furniture/index.html?dormFurn,File Systems|files/index.html?fileProds,Lounge Furniture|furniture/index.html?laungeProds,Office Furniture|furniture/index.html?officeProds,Plastic Bags|bags/index.html?bagProds,Seating|seating/index.html?seatingProds,Hon/Allsteel|honFiling/index.html?honProds";
  var tmp = shopNowProds.split(",");
  for (var i=0;i < tmp.length;++i){
    var tmpName = tmp[i].split("|");
    if (tmpName[0]=="Modular Office Systems") rightNavT += " <tr><td class=sideBarLinkSmall onclick=\"document.location='"+docRoot+"manufacturers/"+tmpName[1]+"'\" onmouseover=\"this.style.color='#c8b24d'\" onmouseout=\"this.style.color='#0f3e5b'\">"+tmpName[0]+"</td></tr>";
    else rightNavT += " <tr><td class=sideBarLinks onclick=\"document.location='"+docRoot+"manufacturers/"+tmpName[1]+"'\" onmouseover=\"this.style.color='#c8b24d'\" onmouseout=\"this.style.color='#0f3e5b'\">"+tmpName[0]+"</td></tr>";
  }
  rightNavT += "</table>";


//  rightNavT += " <table width=150 cellpadding=0 cellspacing=0 border=0 >";
//  rightNavT += " <tr><td style='height:5px'></td><tr>";
//  rightNavT += " <tr><th class=sideBarBlocks>QUICK SHIP</th><tr>";
//  var quickShip = {};
//  quickShip = ",";
//  var tmpQS = quickShip.split(",");
//  for (var i=0;i < tmpQS.length;++i){
//    var tmpNameQS = tmpQS[i].split("|");
//    rightNavT += " <tr><td class=sideBarLinks onclick=\"document.location='"+docRoot+"manufacturers/"+tmpNameQS[1]+"'\" onmouseover=\"this.style.color='#c8b24d'\" onmouseout=\"this.style.color='#0f3e5b'\">"+tmpNameQS[0]+"</td></tr>";
//  }
//  rightNavT += "</table>";

  rightNavT += " <table width=150 cellpadding=0 cellspacing=0 border=0 >";
  rightNavT += " <tr><td style='height:5px'></td><tr>";
  rightNavT += " <tr><th class=sideBarBlocks>CUSTOMER SERVICE</th><tr>";

  wareHouse = "Customer Services|/bin-htm/custServ.html?intro,New Customer|ordering/bin-php/application.php,Service Request|bin-php/cust_serv_form.php";
  var tmpWH = wareHouse.split(",");
  for (var i=0;i < tmpWH.length;++i){
    var tmpNameWH = tmpWH[i].split("|");
    if (tmpNameWH[0]=="Contact Customer Service") rightNavT += " <tr><td class=sideBarLinkSmall onclick=\"location='"+docRoot+tmpNameWH[1]+"'\" onmouseover=\"this.style.color='#c8b24d'\" onmouseout=\"this.style.color='#0f3e5b'\">"+tmpNameWH[0]+"</td></tr>";
    else rightNavT += " <tr><td class=sideBarLinks onclick=\"location='"+docRoot+tmpNameWH[1]+"'\" onmouseover=\"this.style.color='#c8b24d'\" onmouseout=\"this.style.color='#0f3e5b'\">"+tmpNameWH[0]+"</td></tr>";
  }
  rightNavT += "</table>";

  /**
   * Videos paths will have to be fixed to link right.
   */

  rightNavT += " <table width=150 cellpadding=0 cellspacing=0 border=0 >";
  rightNavT += " <tr><td style='height:5px'></td><tr>";
  rightNavT += " <tr><th class=sideBarBlocks>PROMOTIONS</th><tr>";
  var highLights = {};
  highLights = "Discontinued Seating|/catalogs/bin-html/onlineProds.html?seating;dis,Denver Sales Items|manufacturers/show/denSales.html?intro";
  var tmpHL = highLights.split(",");
  for (var i=0;i < tmpHL.length;++i){
    var tmpNameHL = tmpHL[i].split("|");
    rightNavT += " <tr><td class=sideBarLinks onclick=\"document.location='"+docRoot+""+tmpNameHL[1]+"'\" onmouseover=\"this.style.color='#c8b24d'\" onmouseout=\"this.style.color='#0f3e5b'\">"+tmpNameHL[0]+"</td></tr>";
  }
  rightNavT += "</table>";
  /**
   * PERSONNEL
   */
  rightNavT += " <table width=150 cellpadding=0 cellspacing=0 border=0 >";
  rightNavT += " <tr><td style='height:5px'></td><tr>";
  rightNavT += " <tr><th class=sideBarBlocks>PROJECTS & NEWS</th><tr>";
  var highLights = {};
  highLights = "Customer Drawings|serviceproviders/mosprojects/index.html,Completed Projects|bin-htm/comProjects.html?intro_album,CCi Newsletter|bin-pdf/newsLetter.pdf,CCi Video Collection|movies/webMovies/flashdvd.swf,S.W.I.F.T. Videos|movies/swiftFLV/flashdvd.swf";
  var tmpHL = highLights.split(",");
  for (var i=0;i < tmpHL.length;++i){
    var tmpNameHL = tmpHL[i].split("|");
    if (tmpNameHL[0] == "CCi Newsletter") rightNavT += " <tr><td class=sideBarLinks onclick=\"index_default.popUpPDFWin('"+docRoot+"/"+tmpNameHL[1]+"', 'CCi Newsletter')\" onmouseover=\"this.style.color='#c8b24d'\" onmouseout=\"this.style.color='#0f3e5b'\"><img src='images/pdf_logo.gif'> "+tmpNameHL[0]+"</td></tr>";
    else if (tmpNameHL[0] == "CCi Video Collection") rightNavT += " <tr><td class=sideBarLinks onclick=\"index_default.popUpSWFWin('"+docRoot+"/"+tmpNameHL[1]+"', 'CCi Movies')\" onmouseover=\"this.style.color='#c8b24d'\" onmouseout=\"this.style.color='#0f3e5b'\"><img src='images/movie.gif'> "+tmpNameHL[0]+"</td></tr>";
    else if (tmpNameHL[0] == "S.W.I.F.T. Videos") rightNavT += " <tr><td class=sideBarLinks onclick=\"index_default.popUpSWFWin('"+docRoot+"/"+tmpNameHL[1]+"', 'CCi Movies')\" onmouseover=\"this.style.color='#c8b24d'\" onmouseout=\"this.style.color='#0f3e5b'\"><img src='images/movie.gif'> "+tmpNameHL[0]+"</td></tr>";
    else rightNavT += " <tr><td class=sideBarLinks onclick=\"document.location='"+docRoot+""+tmpNameHL[1]+"'\" onmouseover=\"this.style.color='#c8b24d'\" onmouseout=\"this.style.color='#0f3e5b'\">"+tmpNameHL[0]+"</td></tr>";
  }
  rightNavT += "</table>";
  /**
   * PROGRAMS
   */
  rightNavT += " <table width=150 cellpadding=0 cellspacing=0 border=0 >";
  rightNavT += " <tr><td style='height:5px'></td><tr>";
  rightNavT += " <tr><th class=sideBarBlocks>PROGRAMS</th><tr>";
  var highLights = {};
  highLights = "Dog Program|serviceproviders/puppy/index.html?intro,Wild Horse Program|serviceproviders/whip/index.html?intro";
  var tmpHL = highLights.split(",");
  for (var i=0;i < tmpHL.length;++i){
    var tmpNameHL = tmpHL[i].split("|");
   rightNavT += " <tr><td class=sideBarLinks onclick=\"document.location='"+docRoot+""+tmpNameHL[1]+"'\" onmouseover=\"this.style.color='#c8b24d'\" onmouseout=\"this.style.color='#0f3e5b'\">"+tmpNameHL[0]+"</td></tr>";
    if (tmpNameHL[0] == "Dog Program") rightNavT += " <tr><td style=text-indent:5 class=sideBarLinkSmall onclick=location='serviceproviders/puppy/index.html?contact' onmouseover=\"this.style.color='#c8b24d'\" onmouseout=\"this.style.color='#0f3e5b'\">(719) 269-4650</td></tr>";
    if (tmpNameHL[0] == "Wild Horse Program")rightNavT += " <tr><td style=text-indent:5 class=sideBarLinkSmall onclick=location='serviceproviders/whip/index.html?contact' onmouseover=\"this.style.color='#c8b24d'\" onmouseout=\"this.style.color='#0f3e5b'\">(719) 269-5601</td></tr>";
  }
  rightNavT += "</table>";

  rightNavT += " <table width=150 cellpadding=0 cellspacing=0 border=0 >";
  rightNavT += " <tr><td style='height:5px'></td><tr>";
  rightNavT += " <tr><th class=sideBarBlocks>STATE AWARDS</th><tr>";
  rightNavT += " <tr><td class=sideBarLinks onclick=\"document.location='"+docRoot+"bin-htm/stateAgreement.html?mos'\" onmouseover=\"this.style.color='#c8b24d'\" onmouseout=\"this.style.color='#0f3e5b'\">State Awards</td></tr>";
  rightNavT += "</table>";

  obj('navTableR').innerHTML = rightNavT;
};

index_default.footerInfo = function() {
  var footerTmp = "Home|index.html,About Us|bin-htm/aboutUs.html?intro,CCi Mission|bin-htm/aboutUs.html?mission,Contact Us|bin-php/directory.php,State Awards|bin-htm/stateAgreement.html?mos";
  var tmp = footerTmp.split(",");
  var footer = "<table width=100% cellpadding=0 cellspacing=0 border=0>";
  footer += " <tr><td style='height:5px' bgcolor=#E9E9E9></td><tr>";
  footer += " <tr><td style='height:5px' ></td><tr>";
  footer += " <tr><td align=center>";
  for (var i = 0; i < tmp.length; i++) {
    var tmpName = tmp[i].split("|");
    footer += " &nbsp;<span style'font:normal 10pt wingdings'>|</span>&nbsp;<u><span class=sideBarLinks onclick=\"document.location='"+docRoot+""+tmpName[1]+"'\" onmouseover=\"this.style.color='#c8b24d'\" onmouseout=\"this.style.color='#0f3e5b'\">"+tmpName[0]+"</span></u>&nbsp;";
  }
  footer += " </td<tr>";
  footer += "</table>";
  obj('footer').innerHTML = footer;
};

/**
 * This is for the display of the images on the home page. Right now it is for
 * the green later it can become the hot items.
 *
 */
/**
 * var GreenVerbage = {};
 * //GreenVerbage["flag"] = "<p>Colorado Correctional Industries is a company dedicated to our customers and their satisfaction. Correctional Industries is a division of the Colorado Department of Corrections employing inmates to produce quality goods and services for sale to public and private entities, saving Colorado tax payers money.</p>";
 *  GreenVerbage["enviro2"] = "<p>Colorado Correctional Industries is helping clean up our environment. CCi is going green to protect the Colorado we love. CCi has a listing of green products and policies. View our link below for more information on products, policies, manufacturers and CCi's commitment to green.</p>";
 *  GreenVerbage["swift2"] = "<p>CCi helps protect Colorado wild lands and forests with our State Wild land Inmate Fire Team (SWIFT) program. In addition to fighting wildfires, the crew is trained to perform forest management projects such as thinning, chipping, contour felling, trial construction and maintenance, and other reclamation or rehabilitation projects.</p>";
 *  GreenVerbage["recycle2"] = "<p>CCi's recycling plant located within the Canon City Complex is another example of our commitment to greening our environment. Initial efforts began in 1987 and have expanded over the years, increasing recyclables, collection sites and partnerships. During calendar year 2006, CCi reduced landfill waste by recycling: <br><span style='font:normal 10pt wingdings'>n</span> 38 1/2 Tons aluminum <br><span style='font:normal 10pt wingdings'>n</span> 487 tons cardboard<br><span style='font:normal 10pt wingdings'>n</span> 868 tons office/newspaper<br><span style='font:normal 10pt wingdings'>n</span> 30 tons Plastics<br><span style='font:normal 10pt wingdings'>n</span> 427 1/2 tons scrap metal<br></p>";
 *  GreenVerbage["bear2"] = "<p>CCi's patent-pending locking system on bear-proof containers eliminates the need for drivers to exit their vehicles and unlock dumpsters. The time saved on this alone helps save fuel also. <br><a href=manufacturers/metal/bearCan/VideoJukebox.html>To view our video click here.</a></p>";
 *  GreenVerbage["surplus2"] = "<p>CCi's Surplus Properties Program provides an opportunity to extend the useful life of products and vehicles rather than adding to our landfills. Numerous furniture items including case goods, seating, and filing are available for purchase at extremely reasonable prices. Vehicles are also available. CCi is committed to aiding our environment and our Surplus Property Program supports this commitment.</p>";
 *
 * var arrayPos = 0;
 * var mytimeoutImages;
 * //var green;
 * var groupPos = [];
 *
 * getNewPictures = function( step ) {
 *  clearTimeout(mytimeoutImages);
 *
 *  var textInfo = "enviro2:swift2:recycle2:surplus2:bear2";
 *  var tmp = textInfo.split(":");
 *  var green = tmp[arrayPos];
 *  if (step) {
 *   if (arrayPos == tmp.length) arrayPos = 0;
 *   green = tmp[arrayPos]
 *   arrayPos++;
 *  }
 *  if (arrayPos == tmp.length) {
 *   arrayPos = 0;
 *   green = tmp[arrayPos];
 *  }
 *  obj("hoopImages").innerHTML = "<img src="+docRoot+"images/hoop/"+green+".jpg >";
 *  arrayPos++;
 *
 *   if (green != "recycle" ) mytimeoutImages = setTimeout(function(){getNewPictures(green);}, 32000);
 *   else mytimeoutImages = setTimeout(function(){getNewPictures(green);}, 45000);
 *
 * // obj("hoopImages").innerHTML = "<img src="+docRoot+"images/hoop/"+green+".jpg >";
 * // obj("text").innerHTML = GreenVerbage[green];
 *  if (arrayPos == tmp.length) {
 *   if (groupPos == tmp.length-1) groupPos = 0;
 *   else ++groupPos
 *   green = tmp[groupPos];
 *   arrayPos = 0;
 *    if (green != tmp[3] ) mytimeout = setTimeout(function(){getNewPictures(green);}, 32000);
 *    else mytimeout = setTimeout(function(){getNewPictures(green);}, 45000);
 *   return false;
 *  }
 */

/**
 *backup: D:
 * obj("greenlink").innerHTML = "<div onclick=\"document.location='manufacturers/greenpolicies/index.html?intro'\" onmouseover=this.style.color='blue' onmouseout=this.style.color='#0f3e5b' >Click this link to view more of our Green Policies.</div>";
 * obj("forwardBtn").innerHTML = "<input type=button value='Next' onclick=\"getNewPictures('','next')\" style='curson:pointer;font:bold 9pt tahoma;width:60px;height:22px;cursor:pointer;color:#ffffff;background-color:#396e8e'>";
 *};
 */

index_default.goToCart = function() {
  var ordertype = "";
  if (Cache.data.CART.ordertype) ordertype = "_"+Cache.data.CART.ordertype;
  if (Cache.data.general.blankorder) ordertype = "_blank";
  Cache.data.CART.checkout = false;

  setTimeout(
    function() {
      document.location = docRoot+"ordering/shoppingcart"+ordertype+".html";
    }, 1000
  );
};

index_default.checkAdmin = function(e) {
  if (!e) try{e=event;}catch(e){};

  parent.location = docRoot + "index.html";
  if (e.altKey && e.ctrlKey) {
    parent.document.location = docRoot+"administrator/";
  }
}

index_default.login = function() {
  document.location = docRoot+"ordering/login_order.html";
};

A_GET = {};
(GET = function() {
  if (location.search) {
    var N_query = document.location.search.substring(1).split('&');
    for (var i in N_query) {
      N_query[i] = N_query[i].toString().replace(/\+/g, '%20');
      N_query[i] = decodeURIComponent(N_query[i]);
      var s = N_query[i].search(/\=/);
      var key_ = N_query[i].substring(0, s);
      A_GET[key_] = N_query[i].substring(s+1);
    }
  }
})();
//###########################################################################
//###########################################################################
//###########################################################################

index_default.prepData = function() {
  if (!Cache.data || (Cache.data && !Cache.data.CART)) {
    Cache.data = {
      general: {
        registerinfo: "||||||||||||||||||||||||||||||||||||||"
      },
      CART: {
        products: {}
      },
      A_fabricSamples: {},
      A_fabricSamplesUserData: {
        name: "",
        business: "",
        address1: "",
        address2: "",
        city: "",
        state: "",
        zip: "",
        phone: "",
        fax: "",
        email: ""
      }
    }
  }

  if (Cache.data.general.search && obj("search")) obj("search").value = Cache.data.general.search;

  if (window.fabricSamplesUserData && specialURL == 'samplerequestform') fabricSamplesUserData();
  if (window.samplerequestform && specialURL == 'samplerequestform') {
    samplerequestform();
    obj("sample_name").focus();
  }

  if (window.selectedSamples && specialURL == 'selectedSamples') selectedSamples();
  if (window.shoppingcart) shoppingcart.initiate();
  if (window.amc) amc.initiate();
};

/**
 * Instead of loading every possible javascript module you may need,
 * just load then as you need them!
 *
 * Example of use:
 *  index_default.include("../bin-data/DOC_Facilities.js");
 *  if (!window.DOC_Facilities) return false;
 */
index_default.include = function(js) {
  if (!index_default.include.callers) {
    index_default.include.callers = {};
  }
  if (index_default.include.callers[js]) return true;
  index_default.include.callers[js] = index_default.include.caller;

  var O_script = document.createElement("script");
  var runCaller = function() {
    // MSIE - onreadystatechange
    if (O_script.readyState && O_script.readyState != "loaded") return;
    // Re-run the caller's function.
    index_default.include.callers[js]();
  };

  // Create [loaded] triggers to the <script> element.
  if (document.addEventListener) O_script.addEventListener("load", runCaller, false);
  else O_script.attachEvent("onreadystatechange", runCaller);

  O_script.setAttribute("src", js);
  document.body.appendChild(O_script);
  //setTimeout(function(){document.body.appendChild(O_script);}, 1000)
};

/**
 * index_default.HTTP
 * Send an HTTP POST/GET request to the specified URL, using the names and
 * values of the properties of the values object as the body of the request.
 * Parse the server's response according to its content type and pass
 * the resulting value to the callback function.
 * If an HTTP error occurs, a null is returned to the callback.
 *
 * EXAMPLE:
 *   index_default.HTTP('GET', 'test.txt', returnFunction);
 *
 *   var values = {};
 *     values.productno1 = 11111;
 *     values.productno2 = 22222;
 *     values.productno3 = 33333;
 *   index_default.HTTP('POST', 'post.php', values, returnFunction);
 *
 *   function returnFunction(data) { alert(data); };
 */
index_default.HTTP = function(method, URL, values, callback) {
  method = method.toUpperCase();
  if (method == "GET") callback = values;

  var request;
  try { request = new XMLHttpRequest(); }catch(e){};
  try { request = new ActiveXObject("Msxml2.XMLHTTP"); }catch(e){};
  try { request = new ActiveXObject("Microsoft.XMLHTTP"); }catch(e){};

  request.onreadystatechange = function() {
    if (request.readyState==1){
      if (obj("productDisplay")) obj("productDisplay").innerHTML= "<div style='text-align:center;font:bold 12pt Arial;padding-top:100'>[ PLEASE STAND BY LOADING PAGE... ]</div>";
    }
    if (request.readyState == 4 && request.status == 200) {
      if (callback) callback(request.responseText, URL);
    }
  }
  request.open(method, URL);

  var send = null;
  if (method == "POST") {
    // The header tells the server how to interpret the body of the request.
    request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");

    // Encode the properties of the values object and send them as
    // the body of the request.
    var pairs = [];
    for (var name in values) {
      //alert(name+":"+values[name])
      var value = values[name].toString();
      var pair = encodeURIComponent(name).replace(/%20/g, "+") + '=' +
        encodeURIComponent(value).replace(/%20/g, "+");
      pairs.push(pair);
    }

    send = pairs.join('&');
  }
  request.send(send);
};

index_default.debug = function ( str, folder ) {
   var values = {};
     values.action = 'debug';
     values.str = str;
     values.folder = folder;
   index_default.HTTP('POST', 'bin-php/generalpurpose.php', values);
};

//#######################################################################
var sciquest = {};
sciquest.initiate = function () {
  sciquest.active = 1;

  if (!parent.frame_data.A_cookies) {
    parent.frame_data.A_cookies = {
      'sciquest': A_GET.sciquest,
      'Cache_userid': A_GET.sciquest
    };
  }

  Cache.userid = parent.frame_data.A_cookies.sciquest;
  Cookies.make('sciquest', Cache.userid);
  Cookies.make('Cache_userid', Cache.userid);

  Cache.initiate(index_default.prepData);

  Cache.sciquest_header = setInterval(function(){
    if (Cache.data && Cache.data.general) {
      clearInterval(Cache.sciquest_header);
      var who = Cache.data.general.registerinfo.split('|')[3];
      var O_ = document.createElement('div');
      O_.setAttribute('id', 'sciquest-body');
      with(O_.style) {
        position = 'absolute';
        top = '0px';
        left = '180px';
        padding = '10px';
        height = '200px';
      }
      var str = "<span style='font: bold 10pt tahoma'>Colorado State University ("+who+")</span>";
      str += "&nbsp;<img src='"+docRoot+"/images/sciquest.jpg' width='30' />";
      O_.innerHTML = str;
      obj('header').appendChild(O_);
    }
  }, 100);
};

//#######################################################################
/**
 * Name: Cache.js
 * DETAIL:
 */
var Cache = {
  userid: "",
  JSON: "",
  data: {},
  cookie: {
    jar: {}
  }
};

Cache.initiate = function( incommingText ) {
  if (!Cache.initiate.tried) {
    Cache.initiate.tried = false;
  }

  // Initiating Cache through [index_default.initCache()].
  if (incommingText instanceof Function) {
    Cache.initiate.callback = incommingText;
    incommingText = "";
  }

  if (!navigator.cookieEnabled) {
    alert("Browser [cookies] need to be turned on!");
    return false;
  }

  if (sciquest.active) {
    index_default.debug("location:"+location+"\r\ndocument.cookie:"+document.cookie+"\r\n\r\nCache:\r\n"+incommingText, "sciquest");
  }

  // Initiating Cache through [index_default.initCache()].
  if (!incommingText && !Cache.initiate.tried) {
    if (!Cookies.get("Cache_userid") || Cache.userid) {
      if (Cache.userid) {
        Cookies.make("Cache_userid", Cache.userid);
      }
      else {
        Cookies.make("Cache_userid", new Date().getTime());
      }
    }

    Cache.userid = Cookies.get("Cache_userid");
    if (Cache.userid) {
      Cookies.make("Cache_userid", Cache.userid);
    }
    else {
      Cookies.make("Cache_userid", new Date().getTime());
    }
    Cache.userid = Cookies.get("Cache_userid");

    index_default.debug('Cache.userid:'+Cache.userid, 'sciquest');

  	if (parent.frame_data) {
  		Cache.userid = parent.frame_data.A_cookies.sciquest;
  	}

    var values = {
      action: "getcache",
      userid: Cache.userid
    };

    Cache.HTTP(values, Cache.initiate);
    Cache.initiate.tried = true;
    return;
  }

  // Previous use of this function sent out for possible stored Cache data.
  Cache.JSON = incommingText;

  try {
    eval("Cache.data ="+Cache.JSON);
  }catch(e){alert("Cache.initiate->eval(Cache.JSON)\n"+Cache.JSON)}

  setInterval("Cache.checkForChanges();", 250);
  if (Cache.initiate.callback) {
    Cache.initiate.callback();
  }
  Cookies.make();
};

Cache.HTTP = function(A_data, callback ) {
  var request = null;
  try { request = new XMLHttpRequest(); } catch(e) {};
  try { request = new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) {};
  try { request = new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) {};

  if (callback) {
    request.onreadystatechange = function() {
      if ((request.readyState == 4) && (request.status == 200)) {
        callback(request.responseText);
      }
    }
  }

  request.open("POST", docRoot+"bin-cgi/cache.cgi");
  request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");

  var pairs = [];
  for (var name in A_data) {
    var pair = encodeURIComponent(name).replace(/%20/g, "+") + '=' +
      encodeURIComponent(A_data[name]).replace(/%20/g, "+");
    pairs.push(pair);
  }

  request.send(pairs.join('&'));
};

Cache.checkForChanges = function() {
  //status = "sciquest: "+document.cookie+":"+(new Date());
  var newJSON = "Cache.data="+Cache.toJSON(Cache.data);
  var oldJSON = Cache.JSON;

	if (parent.frame_data) {
		//Cache.userid = parent.frame_data.A_cookies.sciquest;
	}
  else if (Cache.userid != Cookies.get("Cache_userid")) {
    Cookies.make("Cache_userid", Cache.userid);
    newJSON = "";
  }

  if (newJSON != oldJSON) {
    var values = {
      action: "setcache",
      userid: Cache.userid,
      JSON: newJSON
    };
    Cache.HTTP(values);
  }

    //status = "Cache.data="+Cache.toJSON(Cache.data);;
  Cache.JSON = newJSON;
};

Cache.toJSON = function(O_) {
  var str = "";
  var firstitem = true;

  if (O_ == null || O_ == undefined) return str+O_;

  if (typeof O_ == "number" || typeof O_ == "boolean") {
    str += O_;
  }
  else if (typeof O_ == "string") {
    O_ = O_.replace(/\\/g, "\\\\");
    O_ = O_.replace(/"/g, "&quot;");
    O_ = O_.replace(/["']/g, "\\$&");
    O_ = O_.replace(/\n/g, "\\n");
    O_ = O_.replace(/\r/g, "\\r");
    str += "\""+O_+"\"";
  }
  else if (O_.constructor == Array) {
    str += "[";
    for (var i = 0; i < O_.length; i++) {
      if (!firstitem) str += ", ";
      str += arguments.callee(O_[i]);
      firstitem = false;
    }
    str += "]";
  }
  else if (typeof O_ == "object") {
    str += "{";
    for (var p in O_) {
      if (!firstitem) str += ", ";
      str += "\""+p+"\": "+arguments.callee(O_[p]);
      firstitem = false;
    }
    str += "}";
  }

  return str;
};

/**
 * Name: Cookies.js
 * Type: object module
 * Edited Date: 2008-02-13
 *
 * DETAIL:
 * cookies maximum size is 5000 characters.
 * This includes encodeURIComponent the name and expiration information.
 * You are only allowed 20 cookies max.
 * The 5000 characters must be divided between those 20.
 *
 * cookies are stored by the directory name an html file is stored within.
 * This means that if different server scripts or html scripts are in:
 *   - orders/bin-php
 *   - generalSites/bin-php
 *     OR
 *   - bin-htm/index.html
 *   - bin-htm/friendlysites.htm
 *
 *   THEY ARE CONSIDERED THE SAME AND USE THE SAME 20 COOKIE/5000
 *   CHARACTER DATA
 *   (bin-php) for the first and (bin-htm) for the second.
 *   EACH PAGE DOES NOT HAVE ITS OWN COOKIES.
 *   Directory names represent any and all across an ENTIRE web-site.
 *
 *   THIS module set cookies such that there is one set for the entire site.
 *   That is, all files and directories will share access to the same cookies
 *
 * Each cookie does not have 4KB of storage.
 * They collectively store 4KB, which translates to about 5000 characters.
 */
var Cookies = {};

// VARIABLES
// programming for three basic browsers

Cookies.jar = {};

Cookies.get = function(name) {
  if (!navigator.cookieEnabled) {
    alert('COOKIES are needed but are turned off....');
    return;
  }
  return (Cookies.jar[name])?Cookies.jar[name]:null;
};

Cookies.make = function(name, value) {
  if (name) {
    name = name.toString().replace(/^\s*/, '').replace(/\s*$/, '');
  }
  if (value) {
    value = value.toString().replace(/^\s*/, '').replace(/\s*$/, '');
  }

  if (!navigator.cookieEnabled) {
    alert('COOKIES are needed but are turned off....');
    return;
  }
  if (name) Cookies.jar[name] = value;
  var cookieSizes = 0;

  var nextyear = new Date();
  nextyear.setFullYear(nextyear.getFullYear()+1);

  delete Cookies.jar[''];
  //var N_ = [];
  for (var cookieName in Cookies.jar) {
    var thisCookie = '';
    if (cookieName.match(/^(path|expire|max-age)$/i)) continue;
    var thisCookie = cookieName+"="+escape(encodeURIComponent(Cookies.jar[cookieName])||null);
    cookieSizes += thisCookie.length;
    if (cookieSizes > 5000) {
      alert('COOKIES -> You have exceeded your cookie character max-size of 5000 with: ['+cookieSizes+']!');
      break;
    }
    else {
      if (sciquest.active) {
        document.cookie = thisCookie+"; path=/; expires="+nextyear.toGMTString()+"; domain=.sciquest.com"
      }
      document.cookie = thisCookie+"; path=/; expires="+nextyear.toGMTString();
      //N_.push(thisCookie);
    }
  }
  //document.cookie = N_.join(";")+"; path=/; expires="+nextyear.toGMTString();
  //document.cookie = N_.join(";")+"; path=/; max-age="+(86400*365); //3600:(1)hour; 86400:(1)day
  //alert(N_.join("; ")+"\n\n"+document.cookie)
  Cookies.collect();
};

Cookies.toss = function(name) {
  if (!navigator.cookieEnabled) {
    alert('COOKIES are needed but are turned off....');
    return;
  }

  if (!name) {
    Cookies.jar = {};
    var N_ = [];
    N_.push("path=/");
    var nextyear = new Date();
    nextyear.setFullYear(nextyear.getFullYear()-1);
    N_.push('expires='+nextyear.toGMTString());
    document.cookie = N_.join(';');
  }
  else {
    delete Cookies.jar[name];
  }

  Cookies.make();
  Cookies.collect();
};

Cookies.list = function() {
  Cookies.collect();
  var N_ = [];
  for (var KEY in Cookies.jar) {
    N_.push(KEY+":"+Cookies.jar[KEY]);
  }
  alert(N_.join("\n"));
};

Cookies.collect = function() {
  Cookies.jar = {};
  //alert('X:'+document.cookie)
  var N_cookies = document.cookie.split(/;\s*/);
  for (var i = 0; i < N_cookies.length; i++) {
    var s = N_cookies[i].search(/\=/);
    var key = N_cookies[i].substring(0, s);
    var value = unescape(decodeURIComponent(N_cookies[i].substring(s+1)));
    if (key && (value != "undefined")) {
      Cookies.jar[key] = value;
    }
  }
};

(function() {
  Cookies.collect();
})()

