var dept_menu = new Array("all departments","Pens","Watches","Watch Winders & Cases","Pen Cases & Accessories","Wallets, Folios, Briefcases","Men's Shop","Refills","Corporate Gifts");
var dept_value = new Array("","PENS","WATCH","WATAC","PENAC","LEATH","MENAC","REFIL","CORP");
var cat_menu = new Array(new Array("all categories","select dept first"),new Array("all categories","Fountain Pen","Ballpoint","Pen Case","Rollerball","Highlighter","Inkwell","Pen Set","Pencil",""),new Array("all sizes","Small (<30mm)","Medium (30-36mm)","Large (37-44mm)","Extra Large (>44mm)","Accessories",""),new Array("all categories","Watch Case","Watchwinder",""),new Array("all categories","Pen Case","Pen Stand","Cleaning Product","Pouch","Pen with case",""),new Array("all categories","Billfold","Briefcase","CC Holder","Card Case","Coin Holder","Notebook","Document Holder","Keyholder","Key Ring","Money clip","Notepad","Portfolio","Wallet",""),new Array("all categories","Ashtray","Bracelet","Card Case","Cigar Case","Cigar Cutter","Cufflink","Cufflink Holder","Clock","Jewelry Box","Key Ring","Lighter","Lighter Case","Set","Money Clip","Tie Jewelry","Valet",""),new Array("all categories","Bottle","Cartridges","Deskset Pen","Flint","Gas","Rollerball","Nib","Paper","Cartridge Filler",""),new Array("all categories","Fountain Pen","Ballpoint","Pen Case","Rollerball","Highlighter","Inkwell","Pen Set","Pencil","Pen Case","Pen Stand","Cleaning Product","Pouch","Pen with case","Small","Medium","Large","Extra Large","Accessories","Ashtray","Bracelet","Card Case","Cigar Case","Cigar Cutter","Cufflink","Cufflink Holder","Clock","Jewelry Box","Key Ring","Lighter","Lighter Case","Set","Money Clip","Tie Jewelry","Valet","Billfold","Briefcase","CC Holder","Card Case","Coin Holder","Notebook","Document Holder","Keyholder","Key Ring","Money clip","Notepad","Portfolio","Wallet"));
var cat_value = new Array(new Array("","none"),new Array("","Fountain Pen","Ballpoint","Pen Case","Rollerball","Highlighter","Inkwell","Pen Set","Pencil","none"),new Array("","Small","Medium","Large","Extra Large","Accessories","none"),new Array("","Watch Case","Watchwinder","none"),new Array("","Pen Case","Pen Stand","Cleaning Product","Pouch","Pen with case","none"),new Array("","Billfold","Briefcase","CC Holder","Card Case","Coin Holder","Notebook","Document Holder","Keyholder","Key Ring","Money clip","Notepad","Portfolio","Wallet","none"),new Array("","Ashtray","Bracelet","Card Case","Cigar Case","Cigar Cutter","Cufflink","Cufflink Holder","Clock","Jewelry Box","Key Ring","Lighter","Lighter Case","Set","Money Clip","Tie Jewelry","Valet","none"),new Array("","Bottle","Cartridges","Deskset Pen","Flint","Gas","Rollerball","Nib","Paper","Cartridge Filler","none"),new Array("","Fountain Pen","Ballpoint","Pen Case","Rollerball","Highlighter","Inkwell","Pen Set","Pencil","Pen Case","Pen Stand","Cleaning Product","Pouch","Pen with case","Small","Medium","Large","Extra Large","Accessories","Ashtray","Bracelet","Card Case","Cigar Case","Cigar Cutter","Cufflink","Cufflink Holder","Clock","Jewelry Box","Key Ring","Lighter","Lighter Case","Set","Money Clip","Tie Jewelry","Valet","Billfold","Briefcase","CC Holder","Card Case","Coin Holder","Notebook","Document Holder","Keyholder","Key Ring","Money clip","Notepad","Portfolio","Wallet"));
var brand_menu = new Array(new Array("all brands","most popular brands","-----------------------","Amodex","Aston Leather","Aurora","Azimuth","Ball","Bill Blass","Bosca","Bulova","Caran d' Ache","Conklin","Conway Stewart","Cross","David Donahue","David Oscarson","Delta","Dragon","Dunhill","Ebel","Fortis","Gene Burke","Glycine","Graf von Faber-Castell","Graham","Grayson Tighe","J. Herbin","Jorg Gray","Lamy","Libelle","Longines","Luminox","M-Clip","Momentum","Mondaine","Montblanc","Montegrappa","Monteverde","Namiki","Noodler's","Officina Del Tempo","Omas","Orbita","Oris","Parker","Pelikan","Perrelet","Pilot","Porsche Design","Private Reserve","Rado","Raymond Weil","S.T. Dupont","Sailor","Schmidt","Seiko","Stipula","TechnoMarine","TF Est. 1968","Tibaldi","Tissot","Tonino Lamborghini","Tutima","Venlo","Veraet","Victorinox Swiss Army","Visconti","Vox Luxury","Waterford","Waterman","Wolf Designs","World Lux"),new Array("all brands","most popular brands","-----------------------","Aurora","Bill Blass","Caran d' Ache","Conklin","Conway Stewart","Cross","Delta","S.T. Dupont","Gene Burke","Grayson Tighe","Graf von Faber-Castell","Lamy","Libelle","Montblanc","Montegrappa","Monteverde","Namiki","Noodler's","Omas","Parker","Pelikan","Porsche Design","Stipula","Visconti","Waterford","Waterman","World Lux"),new Array("all brands","most popular brands","-----------------------","Azimuth","Ball","Bulova","Ebel","Fortis","Graham","Jorg Gray","Longines","Luminox","Momentum","Mondaine","Montegrappa","Officina Del Tempo","Oris","Perrelet","Rado","Raymond Weil","Seiko","TechnoMarine","Tissot","Tutima","Veraet","Victorinox Swiss Army"),new Array("all brands","most popular brands","-----------------------","Orbita","Venlo","Vox Luxury","Wolf Designs"),new Array("all brands","most popular brands","-----------------------","Amodex","Aston Leather","Montblanc","Montegrappa","Namiki","Venlo","Vox Luxury","World Lux"),new Array("all brands","most popular brands","-----------------------","Bosca","Montblanc"),new Array("all brands","most popular brands","-----------------------","Aston Leather","David Donahue","S.T. Dupont","M-Clip","Montblanc","Montegrappa","Porsche Design","TF Est. 1968","Venlo","Vox Luxury","World Lux"),new Array("all brands","most popular brands","-----------------------","Aurora","Bosca","Caran d' Ache","Cross","Dunhill","S.T. Dupont","Graf von Faber-Castell","J. Herbin","Lamy","Montblanc","Montegrappa","Monteverde","Namiki","Noodler's","Omas","Parker","Pelikan","Pilot","Porsche Design","Private Reserve","Schmidt","Stipula","Tonino Lamborghini","Visconti","Waterman"),new Array("all brands","most popular brands","-----------------------","Amodex","Aston Leather","Aurora","Azimuth","Ball","Bill Blass","Bosca","Bulova","Caran d' Ache","","Conklin","Conway Stewart","Cross","David Donahue","Delta","David Oscarson","Dragon","Dunhill","S.T. Dupont","Ebel","Fortis","Gene Burke","Graham","Grayson Tighe","Graf von Faber-Castell","Jorg Gray","J. Herbin","Lamy","Libelle","Longines","Luminox","M-Clip","Momentum","Montblanc","Mondaine","Montegrappa","Monteverde","Namiki","Noodler's","Officina Del Tempo","Omas","Orbita","Oris","Parker","Pelikan","Perrelet","Pilot","Porsche Design","Private Reserve","Rado","Raymond Weil","Schmidt","Seiko","Stipula","TechnoMarine","TF Est. 1968","Tibaldi","Tissot","Tonino Lamborghini","Tutima","Venlo","Veraet","Victorinox Swiss Army","Visconti","Vox Luxury","Waterford","Waterman","World Lux","Wolf Designs"));
var brand_value = new Array(new Array("","pop","none","AMOD","ASTO","AURO","AZIM","BALL","BILL","BOSC","BULO","CARA","CONK","CONW","CROS","DAVD","DOSC","DELT","DRAG","DUNH","EBEL","FORT","GENE","GLYC","GVFC","GRAH","GTIG","JHER","JGRA","LAMY","LIBE","LONG","LUMI","MCLP","MOME","MOND","MONB","MONG","MONV","NAMI","NOOD","OFFD","OMAS","ORBI","ORIS","PARK","PELI","PERR","PILO","PORS","PRIV","RADO","RAYM","DUPO","SAIL","SCHM","SEIK","STIP","TECH","TF68","TIBA","TISS","TLAM","TUTI","VENL","VERA","VICT","VISC","VOXL","WATF","WATM","WOLF","WLUX"),new Array("","pop","none","AURO","BILL","CARA","CONK","CONW","CROS","DELT","DUPO","GENE","GTIG","GVFC","LAMY","LIBE","MONB","MONG","MONV","NAMI","NOOD","OMAS","PARK","PELI","PORS","STIP","VISC","WATF","WATM","WLUX"),new Array("","pop","none","AZIM","BALL","BULO","EBEL","FORT","GRAH","JGRA","LONG","LUMI","MOME","MOND","MONG","OFFD","ORIS","PERR","RADO","RAYM","SEIK","TECH","TISS","TUTI","VERA","VICT"),new Array("","pop","none","ORBI","VENL","VOXL","WOLF"),new Array("","pop","none","AMOD","ASTO","MONB","MONG","NAMI","VENL","VOXL","WLUX"),new Array("","pop","none","BOSC","MONB"),new Array("","pop","none","ASTO","DAVD","DUPO","MCLP","MONB","MONG","PORS","TF68","VENL","VOXL","WLUX"),new Array("","pop","none","AURO","BOSC","CARA","CROS","DUNH","DUPO","GVFC","JHER","LAMY","MONB","MONG","MONV","NAMI","NOOD","OMAS","PARK","PELI","PILO","PORS","PRIV","SCHM","STIP","TLAM","VISC","WATM"),new Array("","pop","none","AMOD","ASTO","AURO","AZIM","BALL","BILL","BOSC","BULO","CARA","CHRO","CONK","CONW","CROS","DAVD","DELT","DOSC","DRAG","DUNH","DUPO","EBEL","FORT","GENE","GRAH","GTIG","GVFC","JGRA","JHER","LAMY","LIBE","LONG","LUMI","MCLP","MOME","MONB","MOND","MONG","MONV","NAMI","NOOD","OFFD","OMAS","ORBI","ORIS","PARK","PELI","PERR","PILO","PORS","PRIV","RADO","RAYM","SCHM","SEIK","STIP","TECH","TF68","TIBA","TISS","TLAM","TUTI","VENL","VERA","VICT","VISC","VOXL","WATF","WATM","WLUX","WOLF"));
function createRequestObject() {
  
  FORM_DATA = new Object();
    // The Object ("Array") where our data will be stored.
  
  separator = ',';
    // The token used to separate data from multi-select inputs
  
  query = '' + this.location;
    // Get the current URL so we can parse out the data.
    // Adding a null-string '' forces an implicit type cast
    // from property to string, for NS2 compatibility.
    
  query = query.substring((query.indexOf('?')) + 1);
    // Keep everything after the question mark '?'.
  
  if (query.length < 1) { return false; }  // Perhaps we got some bad data?
  
  keypairs = new Object();
  numKP = 1;
    // Local vars used to store and keep track of name/value pairs
    // as we parse them back into a usable form.
    
  while (query.indexOf('&') > -1) {
    keypairs[numKP] = query.substring(0,query.indexOf('&'));
    query = query.substring((query.indexOf('&')) + 1);
    numKP++;
      // Split the query string at each '&', storing the left-hand side
      // of the split in a new keypairs[] holder, and chopping the query
      // so that it gets the value of the right-hand string.
  }

  keypairs[numKP] = query;
    // Store what's left in the query string as the final keypairs[] data.
  
  for (i in keypairs) {
    keyName = keypairs[i].substring(0,keypairs[i].indexOf('='));
      // Left of '=' is name.
    keyValue = keypairs[i].substring((keypairs[i].indexOf('=')) + 1);
      // Right of '=' is value.
    while (keyValue.indexOf('+') > -1) {
      keyValue = keyValue.substring(0,keyValue.indexOf('+')) + ' ' + keyValue.substring(keyValue.indexOf('+') + 1);
        // Replace each '+' in data string with a space.
    }
    
    keyValue = unescape(keyValue);
      // Unescape non-alphanumerics
      
    if (FORM_DATA[keyName]) {
      FORM_DATA[keyName] = FORM_DATA[keyName] + separator + keyValue;
        // Object already exists, it is probably a multi-select input,
        // and we need to generate a separator-delimited string
        // by appending to what we already have stored.
    } else {
      FORM_DATA[keyName] = keyValue;
        // Normal case: name gets value.
    }
  }

  return FORM_DATA;
}


function createMenus () {

    var FORM_DATA = createRequestObject();

    var dept = document.searchForm.dept;
    var cat = document.searchForm.cat;
    var brand = document.searchForm.brand;

    document.searchForm.dept.selected = 0;
    for ( var i=0; i < dept_menu.length; i++ ) {
         dept.options[i] = new Option(dept_menu[i],dept_value[i],null,null);
         if (FORM_DATA["dept"] == dept_value[i]) {
           document.searchForm.dept.selectedIndex = i;
         }

    var sel = document.searchForm.dept.selectedIndex;
    var deptval = dept_value[sel];

	if (deptval == 'WATCH') 
		{
		document.all.watch1.style.display = 'block';
		document.all.watch2.style.display = 'block';
		}

    }

	document.searchForm.brand.selected = 0;
    for ( var i=0; i < brand_menu[sel].length; i++ ) {
         brand.options[i]  = new Option(brand_menu[sel][i],brand_value[sel][i],null,null);
         if (FORM_DATA["brand"] == brand_value[sel][i]) {
           document.searchForm.brand.selectedIndex = i;
         }

    }


    document.searchForm.cat.selected = 0;
    for ( var i=0; i < cat_menu[sel].length; i++ ) {
         cat.options[i]  = new Option(cat_menu[sel][i],cat_value[sel][i],null,null);
         if (FORM_DATA["cat"] == cat_value[sel][i]) {
           document.searchForm.cat.selectedIndex = i;
         }

    }

}   

function updateMenus (reset) {
    var sel = document.searchForm.dept.selectedIndex;
    if (reset == 1) {
      sel = 0;
      document.searchForm.text.value = "";
      document.searchForm.dept.selectedIndex = 0;
      document.searchForm.cat.selectedIndex = 0;
      document.searchForm.brand.selectedIndex = 0;
      document.searchForm.minprice.selectedIndex = 0;
      document.searchForm.maxprice.selectedIndex = 0;
      document.searchForm.color.selectedIndex = 0;
      for (i = 0; i < document.searchForm.length; i++) {
          // if the element is a radio button or a checkbox then uncheck the Object if it is checked
          if (document.searchForm.elements[i].type == 'radio' || document.searchForm.elements[i].type == 'checkbox')
               document.searchForm.elements[i].checked = false;
      }

    }

    var deptval = dept_value[sel];

	if (deptval == 'WATCH') 
		{
		document.all.watch1.style.display = 'block';
		document.all.watch2.style.display = 'block';
		}
	else
		{
		document.all.watch1.style.display = 'none';
		document.all.watch2.style.display = 'none';
		}

    var temp1_menu = cat_menu[sel];
    var temp1_value = cat_value[sel];
    var temp2_menu = brand_menu[sel];
    var temp2_value = brand_value[sel];
   
    document.searchForm.cat.length = temp1_menu.length;

    for ( var i = 0; i < temp1_menu.length; i++ ) {
        document.searchForm.cat.options[i].text  = temp1_menu[i];
        document.searchForm.cat.options[i].value = temp1_value[i];
    }
    document.searchForm.cat.selectedIndex=0;

    document.searchForm.brand.length = temp2_menu.length;
    for ( var i = 0; i < temp2_menu.length; i++ ) {
        document.searchForm.brand.options[i].text  = temp2_menu[i];
        document.searchForm.brand.options[i].value = temp2_value[i];
    }
    document.searchForm.brand.selectedIndex=0;

}

