/****************************************************
*   This file is used in place of SSI or PHP to 
*   control  & write headers, footers, and other content
*   that could normally be placed in an include.
*
*   There is a different function to write out each 
*   piece of content.
****************************************************/

var site = window.location.protocol+"//"+window.location.host;


//function that writes out common javascript files
function writeJS()
{
	document.write('<script type="text/javascript" src="/store/script/prototype.js"></script>');
	document.write('<script type="text/javascript" src="/javascript/editCountries.js"></script>');
   document.write('<script language="Javascript1.2" src="/amdexCustom.js"></script>');
   document.write('<script language="JavaScript" src="/javascript/amdexTreeData.js"></script>');
   document.write('<script language="JavaScript" src="/javascript/amdexTreeCatRec.js"></script>');
   document.write('<script language="JavaScript" src="/storeDrop.js"></script>');
	document.write('<script type="text/javascript" src="/javascript/menu.js"></script>');
	document.write('<script type="text/javascript" src="/store/script/util.js"></script>');
}

//this is the function that writes out the footer
function writeFooter()
{
   document.write("<div class=\"footerRow\">");   
   document.write("<img src=\"/images/makeITeasy.jpg\" align=\"left\" />");
   document.write("<span style=\"font-size:16px;\"><br /></span>");   
   document.write("<span style=\"text-align:center;\">");
   
   document.write('<a class="menubar" href="/">Home</a> &nbsp; | &nbsp;');
   if(GetCookie('ST') == '.order' || GetCookie('ST') == '.store')
   {
      document.write('<a class=menubar href="IW_User.m4p.pvx?;UID">User</a> &nbsp; | &nbsp;');
      if(GetCookie('ST') == '.order')
         document.write('<a class=menubar href="IW_Customer.m4p.pvx?;CUSTOMER">Customer</a> &nbsp; | &nbsp;');
      document.write('<a class=menubar href="IW_InquirySOHist.m4p.pvx?;SO_HIST_INQ_OPTIONS">Order Status</a> &nbsp; | &nbsp;');
      document.write('<a class=menubar href="IW_InquiryRMA.m4p.pvx?;RMA_INQ_OPTIONS">RMA Information</a> &nbsp; | &nbsp;');
   }
   document.write('<a class="menubar" href="'+site+'/store/">Shopping</a> &nbsp; | &nbsp;');
   document.write('<a class="menubar" href="/IW_ShoppingCartStore.m4p.pvx?;SC_STEP1?company=ACI"?comp=ACI>View Cart</a>');   
   document.write("<br /><br />");
   document.write(" &copy; 2006 Amdex, Inc. All Rights Reserved. | <a href=\"/legal_info.php\">Legal Information</a> | <a href=\"/privacy.php\">Privacy</a> | <a href=\"/rules.php\">Rules & Regulations</a> | <a href=\"/site_map.php\">Sitemap</a>");
   document.write("</div>");   
   document.write("</span>");
   
   var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
   document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
   try {
      var pageTracker = _gat._getTracker("UA-8324900-1");
      pageTracker._trackPageview();
   } catch(err) {}
   
}

//this is the function that writes out the header
function writeHeader()
{
   document.write('<div class="navContainer">');
   document.write('<div class="navTable">');
   document.write('<table border="0" cellpadding="0" cellspacing="0"><tr><td>');
   document.write('<a href="/index.php"><img border="0" src="/images/nav/nav_active_01.gif" alt="home" width="80" height="56"/></a>');
   document.write('<a href="'+site+'/store/"><img border=0 src="/images/nav/nav_active_02.gif" alt="store" width="126" height="56"/></a>');
   document.write('<a href="/cproducts.php"><img border=0 src="/images/nav/nav_main_03.gif" alt="computer products" width="120" height="56"/></a>');
   document.write('<a href="/remarketing.php"><img border=0 src="/images/nav/nav_main_04.gif" alt="remarketing" width="129" height="56"/></a>');
   document.write('<a href="/ms.php"><img border=0 src="/images/nav/nav_main_05.gif" alt="managed security" width="119" height="56"/></a></td>');
   document.write('<td style="background-image:url(/images/nav/nav_main_06.gif);width:206px;height:56px;">');
   //document.write('<form action="/sphider/search.php" method="get"><table cellspacing="0" cellpadding="0"><tr>');
   //document.write('<td valign="bottom"><input type="text" name="query" id="query" action="/sphider/include/js_suggest/suggest.php" columns="2" autocomplete="off" delay="1500" style="padding-top:1px;width:117px;border:1px solid #000;margin-left:10px;font-size:12px;"><input type="hidden" name="search" value="1"></td>');
   //document.write('<td><input type="image" src="/images/search_btn.jpg" style="margin-left:10px;"></td></tr></table>');
   document.write('</form></td></tr>');
   
   document.write('<tr><td colspan="2"><img src="/images/nav/nav_active_07.gif" width="780" height="20"/></td></tr></table></div>');
   document.write('<nobr><div class="subNav">');
   document.write('<a class="subNavItem" onMouseover="dropdownmenu(this, event, brands, \'125px\')" onMouseout="delayhidemenu()">Brands</a> | ');
   document.write('<a class="subNavItem" onMouseover="dropdownmenu(this, event, servers, \'125px\')" onMouseout="delayhidemenu()">Servers</a>  |  ');
   document.write('<a class="subNavItem" onMouseover="dropdownmenu(this, event, networking, \'135px\')" onMouseout="delayhidemenu()">Networking</a>  |  ');
   document.write('<a class="subNavItem" onMouseover="dropdownmenu(this, event, storage, \'135px\')" onMouseout="delayhidemenu()">Storage</a>  |  ');
   document.write('<a class="subNavItem" onMouseover="dropdownmenu(this, event, hardware, \'125px\')" onMouseout="delayhidemenu()">Hardware</a>|');
   
   document.write('<div id="softwrBtn" style="display:inline;"><a class="subNavItem" onMouseover="dropdownmenu(this, event, software, \'125px\')" onMouseout="delayhidemenu()">Software</a>|</div>');
   
   document.write('<a class="subNavItem" onMouseover="dropdownmenu(this, event, services, \'125px\')" onMouseout="delayhidemenu()">Services</a>| ');
   
   if(GetCookie('ST') == '.order' || GetCookie('ST') == '.store')
      document.write('<a class="subNavItemHAND" href="/logout.html" >Log Out</a>');
   else 
      document.write('<a class="subNavItemHAND" href="/uni_login.php">Log-In</a>');
      
   document.write('</div></nobr></div>');
}

//this is the function to write out the proper select menu depending on which 
//variation of the site the user is in... .store or .order
function writeCRSelect(z)
{
   var x = '';
        var st = GetCookie('ST');
   if(GetCookie('lp') != 'undefined' && z == undefined) {x = GetCookie('lp');}
   else if(z != 'undefined') {x = z;}   

   document.write("<form name=\"menu\">");
   document.write("<select id=\"menuoption\" name=\"menuoption\" size=\"1\" onChange=\"GoToLoc(this.value)\" style=\"font-size:10px;\">");
   document.write("<option>-- Customer Resources --");   

   if(st == '.order' || st == '.store'){
      document.write("<option value=\"/IW_User.m4p.pvx?;UID\">Update Personal Information");
      //if(st == '.order')
         document.write("<option value=\"/IW_Customer.m4p.pvx?;CUSTOMER\">Update Account Information");
      document.write("<option value=\"/IW_InquirySOHist.m4p.pvx?;SO_HIST_INQ_OPTIONS?NoSavedSettings=1\">View Order Status");
      document.write("<option value=\"/IW_InquiryRMA.m4p.pvx?;RMA_INQ_OPTIONS?NoSavedSettings=1\">View RMA Information");

      //document.write("<option value=\"IW_InquiryARInvoice.m4p.pvx?;INV_INQ_OPTIONS\">View Invoices");

      document.write("<option value=\"/IW_InquirySOOpen.m4p.pvx?;SO_INQ_OPTIONS?NoSavedSettings=1\">View Open Orders");
      //if(st == '.order')
         document.write("<option value=\"/IW_Customer.m4p.pvx?;CREDIT\">View Credit Information");
      document.write("<option value=\"/IW_Customer.m4p.pvx?;SHIP_TO_BROWSE\">View Shipping Information");
      document.write("<option value=\""+site+"/store/\">Shop Online");
      if(st == '.order')
         document.write("<option value=\"/IW_ShoppingCartOrder.m4p.pvx?;SUBMIT_SO\">View Shopping Cart");
      else
         document.write('<option value="/IW_ShoppingCartStore.m4p.pvx?;SC_STEP1?company=ACI">View Shopping Cart');
      document.write("<option value=\"/ticket_report.php\">Open a Ticket");
      document.write("<option value=\"/cra_form.php\">RA Request");
      
      //document.write("<option value=\"/iwwiaa.pvx?;help_toc\">Help");
   }
   else
   {
      document.write("<option value=\"/uni_login.php\">Log In");
      //document.write("<option value=\"/IW_User.m4p.pvx?;UID\">Account Information");
      document.write("<option value=\""+site+"/store/\">Shop Online");
   }

   document.write("</select>");
   document.write("</form>");
        var cr = document.getElementById('menuoption');
        for(x=0;x<cr.options.length;x++){
            if(location.href.indexOf(cr.options[x].value) > -1)
               cr.options[x].selected = true;
        }
}

//function that writes proper search select box
function writeSSelect()
{
   document.write("<select name=\"category\" tabindex=\"4\" class=\"formentry\" style=\"position:absolute;top:68px;left:10px;font-family:arial,sans-serif;font-size:10px;_font-size:10px;\">");
   document.write("<option value=\"*\" selected>-- Entire Store --");
   document.write("<option value=\"BRANDS\">Brands");
   document.write("<option value=\"SERVR\">Servers");
   document.write("<option value=\"NETWRK\">Networking");
   document.write("<option value=\"STRAGE\">Storage");
   document.write("<option value=\"HARDWR\">Hardware");
   document.write("<option value=\"SOFTWR\">Software");
   
   document.write("<option value=\"SERVC\">Services");
   document.write("</select>");
}

//function that writes the proper view cart button
function writeVCButton()
{
   if(GetCookie('ST') == '.order')
      document.write("<a href=\"/IW_ShoppingCartOrder.m4p.pvx?;SUBMIT_SO\">");
   else
      document.write("<a href=\"/IW_ShoppingCartStore.m4p.pvx?;SC_STEP1?company=ACI\">");
      
   document.write("<img src=\"/images/viewcart.png\" style=\"padding-top:15px;border:0;\"/></a>");
}

//function that will write resource links
function writeRLinks()
{
   if(GetCookie('ST') == '.order')
   {
      document.write('<span style="position:absolute;top:30px;_top:30px;left:25px;">&middot; <a class="menubar" href="/IW_InquirySOHist.m4p.pvx?;SO_HIST_INQ_OPTIONS">Order Status</a></span>');
      document.write('<span style="position:absolute;top:45px;_top:45px;left:25px;">&middot; <a class="menubar" href="/ticket_report.php">Open a Ticket</a></span>');
      document.write('<span style="position:absolute;top:60px;_top:60px;left:25px;">&middot; <a class="menubar" href="/cra_form.php">RA Request</a></span>');
   }
   else if(GetCookie('ST') == '.store')
   {
      document.write('<span style="position:absolute;top:30px;_top:30px;left:25px;">&middot; <a class="menubar" href="/IW_InquirySOHist.m4p.pvx?;SO_HIST_INQ_OPTIONS">Order Status</a></span>');
      document.write('<span style="position:absolute;top:45px;_top:45px;left:25px;">&middot; <a class="menubar" href="/ticket_report.php">Open a Ticket</a></span>');
      document.write('<span style="position:absolute;top:60px;_top:60px;left:25px;">&middot; <a class="menubar" href="/cra_form.php">RA Request</a></span>');
   }
   else
   {
      document.write('<span style="position:absolute;top:30px;_top:30px;left:25px;">&middot; <a class="menubar" href="/uni_login.php">Order Status</a></span>');
      document.write('<span style="position:absolute;top:45px;_top:45px;left:25px;">&middot; <a class="menubar" href="/ticket_report.php">Open a Ticket</a></span>');
      document.write('<span style="position:absolute;top:60px;_top:60px;left:25px;">&middot; <a class="menubar" href="/cra_form.php">RA Request</a></span>');
   }
}

//function that hides or displays shopping cart feedback
function checkSCF(){
   var fbDiv = document.getElementById('scFeedback');
   var multi = document.getElementById('feedBackMulti');
   var srch  = document.getElementById('feedBackSearch');

   if(multi.innerHTML==''&&srch.innerHTML=='')
      fbDiv.style.display = 'none';
   else
      fbDiv.style.display = 'block';
}

//function that writes why amdex or greeting in upper right
function writeGreet()
{
   if(GetCookie('ST') == '.order' || GetCookie('ST') == '.store')
   {
      user = GetCookie('user');
      if(!user){
      	user = GetCookie('email');
      	user = user.substring(0,user.indexOf('@'));
      }
      //user = user.substring(0,user.indexOf(':'));
      //alert(user);
      
      document.write('<div style="position:relative;width:181px;height:50px;_margin-bottom:15px;text-align:center;">');
      document.write('<img src="/images/welcome.png" style="position:absolute;left:0px;top:0px;" width="181" height="50" />');
      document.write('<span style="width:181px;position:relative;top:30px;text-align:center;color:#da2626;font-weight:bold;font-size:12px;">' + user + '</span>');
      
      document.write('</div>');
   }
   else {document.write('<div><img src="/images/ads/ad_phone3.gif" style="_margin-bottom:15px;border:0;" width="180" height="60"/></div>');}
}

//function that will output correct meta tags depending on current category
function writeMeta(x)
{
   if(x == 'STRAGE') {document.write("<meta name=\"keywords\" content=\"storage,disk drives,used disk drives,storage drives,used storage devices,tape drives,used tape drives,controllers,used controllers,hbas,used hbas,storage networking,used storage networking,nas appliances,used nas appliances,nas,used nas,tape libraries,used tape libraries,cabinets,enclosures,media,accessories,fiber disk drives,used fiber disk drives,scsi hot swappable,scsi non hot swappable,scsi,ide,sata,ata,scsi arrays,fiber arrays,dlt, sdlt, super dlt,dat,dds,ait,lto,lto ultrium,fiber hbas,scsi hbas,raid,raid controllers,sata hbas,ata hbas,fiber switches,fiber routers,fiber gbics,hot swap scsi,hot swap sata,hot swap external,hot swap rackmount,auto dlt,auto sdlt,auto ait,auto lto ultrium,auto dds,auto data\">");}
   else if(x == 'BRANDS') {document.write("<meta name=\"keywords\" content=\"hp,new hp,used hp,refurbished hp,hewlett packard, new hewlett packard,refurbished hewlett packard,used hewlett packard,compaq,new compaq,used compaq,refurbished compaq,f5,new f5,used f5,refurbished f5,extreme,new extreme,used extreme,refurbished extreme,juniper,new juniper,used juniper,refurbished juniper,nortel,used nortel,refurbished nortel,new nortel,cisco,used cisco,refurbished cisco,new cisco,digital,used digital,refurbished digital,microsoft,new microsoft,used microsoft,microsoft software,refurbished microsoft,watchguard,watch guard,new watchguard,used watchguard,refurbished watchguard,new watch guard,refurbished watch guard,used watch guard\">");}
   else if(x == 'SERVR') {document.write("<meta name=\"keywords\" content=\"alpha,alpha servers,new alpha servers,used alpha servers,ds series,alpha ds series,es series,alpha es series,gs series,alpha gs series,used alpha gs series,used alpha es series,used alpha ds series,hp 9000,hp9000 servers,rp 3000 series,rp 4000 series,rp 5000 series,rp 7000 series,rp 8000 series,rp4000 series,rp5000 series, rp3000 series,rp7000 series,rp8000 series,hp integrity,hp integrity servers,hp integrity blades,integrity blades,rx 1600 series,rx 2600 series,rx 4600 series,rx 5600 series,rx1600 series,rx2600 series,rx4600 series,rx5600 series,proliant, proliant servers,proliant bl series,proliant dl series,proliant ml series\">");}
   else if(x == 'NETWRK') {document.write("<meta name=\"keywords\" content=\"networking,network,network adapaters,switch,switches,router,routers,gbic,nic,nics,10/100 nics,gigabit nics,fiber nics,atm interface cards,ethernet,scsi,ethernet adapters,token ring adapters,hub,10/100 switches,gigabit switches,modular switch chassis,switch modules,network security,firewall,vpn,intrusion detection,ssl,ssl appliances,wan,lan,routing,multi-protocol routers,router modules,bridges,frame relay,terminal servers,wireless,wireless lan,wireless routing,wireless routers,wireless access points,wireless antennas,wireless bridges,wireless wan,ip telephony,network cables,ethernet cable,rj45\">");}
   else if(x == 'HARDWR') {document.write("<meta name=\"keywords\" content=\"hardware,computer hardware,network hardware,cabinets,racks,cabinets / racks,20u,29u,30u,39u,40+ u,cables,a/v cables,audio visual cables,network cables,fiber cables,scsi cables,printer cables,memory,computer memory,server memory,hp integrity memory,alpha memory,proliant memory,workstation memory,network memory,printer memory,simm,dimm,monitors,lcd,crt,ascii terminals,crt monitors,lcd monitors,lcd displays,rackmount lcds,system chassis,hp integrity chassis,alpha chassis,proliant chassis,hp 9000 chassis,printers,laser printers,color laser printers,line printers,dot matrix,dot matrix printers,multifunction printers,ink,ink cartridges,toner,toner cartridges,cpu,processors,itanium processors,alpha processors,pa-risc,pa-risc processors,p4,pentium 4,pentium 4 processors,pentium 4 cpu,opteron processors,xeon processors,spare parts,chassis,power supplies,chassis parts,electronic parts,workstations,itanium workstations,alpha workstations,pa-risc workstations,pentium workstations,kvm,4 port kvm, 8 port kvm,kvm cables,500va,1000va,cd-rom,cd rom,dvd-rom,dvd rom,cd-rw,cd rw,dvd-rw,dvd rw,dvd+rw,video cards,sound cards,plasma displays,projectors\">");}
   else if(x == 'SERVC') {document.write("<meta name=\"keywords\" content=\"guarddog,guard dog,warranty,warranty uplifts,installation,network installation,server installation,data center installation,storage installation,software support\">");}
}

//function to strip out characters from a string
function hyphStrip(x)
{

   x = x.replace(/^R1/,'');
   while(x.indexOf('-') > -1){
      x = x.replace(/-/,'');
   }
   while(x.indexOf('/') > -1){
      x = x.replace('/','');
   }
   return x;

}

//function to write meta tags for item page
function writeMetaItem(x,c)
{
   var itemHyph = x;
   var itemNoHyph = hyphStrip(itemHyph);
   var itemCond = "";
   var itemMFR = "";
   
   if(c.substring(0,2) == 'R1') {itemCond = "refurbished,used,refub";}
   else {itemCond = "new,factory sealed";}

   document.write("<meta name=\"keywords\" content=\"" + itemHyph + "," + itemNoHyph + "," + itemCond + "\">");
}

function writeMenu(z) {
    var x = "";
    var st = GetCookie("ST");
    if (GetCookie("lp") != "undefined" && z == undefined) {
        x = GetCookie("lp");
    } else if (z != "undefined") {
        x = z;
    }
    document.write("<table cellspacing=\"0px\" class=\"menuTable\"><tr><td class=\"titleRow\">Customer Resources</td></tr>");
    if (st == ".order" || st == ".store") {
        document.write("<tr><td class=\"menuField\"><a class=\"customerMenu\" href=\"/IW_User.m4p.pvx?;UID\">Update Personal Information</a></td></tr>");
        document.write("<tr><td class=\"menuField\"><a class=\"customerMenu\" href=\"/IW_Customer.m4p.pvx?;CUSTOMER\">Update Account Information</a></td></tr>");
        document.write("<tr><td class=\"menuField\"><a class=\"customerMenu\" href=\"/IW_InquirySOHist.m4p.pvx?;SO_HIST_INQ_OPTIONS?NoSavedSettings=1\">View Order Status / History</a></td></tr>");
        document.write("<tr><td class=\"menuField\"><a class=\"customerMenu\" href=\"/IW_InquiryRMA.m4p.pvx?;RMA_INQ_OPTIONS?NoSavedSettings=1\">View RMA Information</a></td></tr>");
        document.write("<tr><td class=\"menuField\"><a class=\"customerMenu\" href=\"/IW_InquirySOOpen.m4p.pvx?;SO_INQ_OPTIONS?NoSavedSettings=1\">View Open Orders</a></td></tr>");
        document.write("<tr><td class=\"menuField\"><a class=\"customerMenu\" href=\"/IW_Customer.m4p.pvx?;CREDIT\">View Credit Information</a></td></tr>");
        document.write("<tr><td class=\"menuField\"><a class=\"customerMenu\" href=\"/IW_Customer.m4p.pvx?;SHIP_TO_BROWSE\">View Shipping Information</a></td></tr>");
        document.write("<tr><td class=\"menuField\"><a class=\"customerMenu\" href=\""+site+"/store/\">Shop Online");
        if (st == ".order") {
            document.write("<tr><td class=\"menuField\"><a class=\"customerMenu\" href=\"/IW_ShoppingCartOrder.m4p.pvx?;SUBMIT_SO\">View Shopping Cart</a></td></tr>");
        } else {
            document.write("<tr><td class=\"menuField\"><a class=\"customerMenu\" href=\"/IW_ShoppingCartStore.m4p.pvx?;SC_STEP1?company=ACI\">View Shopping Cart</a></td></tr>");
        }
        document.write("<tr><td class=\"menuField\"><a class=\"customerMenu\" href=\"/ticket_report.php\">Open a Ticket</a></td></tr>");
        document.write("<tr><td class=\"menuField\"><a class=\"customerMenu\" href=\"/cra_form.php\">RA Request</a></td></tr>");
    } else {
        document.write("<tr><td class=\"menuField\"><a class=\"customerMenu\" href=\"/uni_login.php\">Log In</a></td></tr>");
        document.write("<tr><td class=\"menuField\"><a class=\"customerMenu\" href=\""+site+"/store/\">Shop Online</a></td></tr>");
    }
    document.write("</table>");
}