var dept_menu = new Array("all departments","Pens","Watches","Watch Winders & Cases","Pen Cases & Accessories","Wallets, Folios, Briefcases","Men's Shop","Refills","Corporate Sales");
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","Desk Set","Highlighter","Rollerball","Pencil","Pen Set",""),new Array("all sizes","Small (<30mm)","Medium (30-36mm)","Large (37-44mm)","Extra Large (>44mm)",""),new Array("all categories","Watch Case","Watchwinder","Watchwinder Case",""),new Array("all categories","Pen Case","Pen Stand","Cleaning Product","Inkwell","Pouch","Pen with case",""),new Array("all categories","Billfold","Briefcase","CC Holder","Card Case","Carry on Bag","Wallet","Coin Holder","Notebook","Document Holder","Shoulder Bag","Purse","Keyholder","Key Ring","Luggage","Money clip","Notepad","Portfolio","Passport",""),new Array("all categories","Ashtray","Belt","Cigar Case","Cufflink","Cufflink Holder","Knife","Key Ring","Lighter","Lighter Case","Money Clip","Valet",""),new Array("all categories","Bottle","Deskset Pen","Flint","Gas","Rollerball","Nib","Paper",""),new Array("all categories","Fountain Pen","Ballpoint","Desk Set","Highlighter","Rollerball","Pencil","Pen Set","Pen Case","Pen Stand","Cleaning Product","Inkwell","Pouch","Pen with case","Small","Medium","Large","Extra Large","Ashtray","Belt","Cigar Case","Cufflink","Cufflink Holder","Knife","Key Ring","Lighter","Lighter Case","Money Clip","Valet","Billfold","Briefcase","CC Holder","Card Case","Carry on Bag","Wallet","Coin Holder","Notebook","Document Holder","Shoulder Bag","Purse","Keyholder","Key Ring","Luggage","Money clip","Notepad","Portfolio","Passport"));
var cat_value = new Array(new Array("","none"),new Array("","Fountain Pen","Ballpoint","Desk Set","Highlighter","Rollerball","Pencil","Pen Set","none"),new Array("","Small","Medium","Large","Extra Large","none"),new Array("","Watch Case","Watchwinder","Watchwinder Case","none"),new Array("","Pen Case","Pen Stand","Cleaning Product","Inkwell","Pouch","Pen with case","none"),new Array("","Billfold","Briefcase","CC Holder","Card Case","Carry on Bag","Wallet","Coin Holder","Notebook","Document Holder","Shoulder Bag","Purse","Keyholder","Key Ring","Luggage","Money clip","Notepad","Portfolio","Passport","none"),new Array("","Ashtray","Belt","Cigar Case","Cufflink","Cufflink Holder","Knife","Key Ring","Lighter","Lighter Case","Money Clip","Valet","none"),new Array("","Bottle","Deskset Pen","Flint","Gas","Rollerball","Nib","Paper","none"),new Array("","Fountain Pen","Ballpoint","Desk Set","Highlighter","Rollerball","Pencil","Pen Set","Pen Case","Pen Stand","Cleaning Product","Inkwell","Pouch","Pen with case","Small","Medium","Large","Extra Large","Ashtray","Belt","Cigar Case","Cufflink","Cufflink Holder","Knife","Key Ring","Lighter","Lighter Case","Money Clip","Valet","Billfold","Briefcase","CC Holder","Card Case","Carry on Bag","Wallet","Coin Holder","Notebook","Document Holder","Shoulder Bag","Purse","Keyholder","Key Ring","Luggage","Money clip","Notepad","Portfolio","Passport"));
var brand_menu = new Array(new Array("all brands","most popular brands","-----------------------","Accutron","Alpina","Amodex","Arnold & Son","Aston Leather","Aurora","Ball","Bill Blass","Bosca","Bulova","Caran d' Ache","Cartier","Chronoswiss","Citizen","Clerc","Conway Stewart","Cross","David Donahue","David Oscarson","Dragon","Dunhill","Ebel","Faber Castell","Fisher","Fortis","Gene Burke","Girard-Perregaux","Glycine","Graham","Grayson Tighe","Hartmann","Lamy","Longines","Luminox","Marlen","Martin Braun","Maurice Lacroix","McKlein","Momentum","Mondaine","Montblanc","Montegrappa","Montrek","Namiki","Noodler's","Noon Solar","Omas","Orbita","Oris","Parker","Pelikan","Pierre DeRoche","Pilot","Porsche Design","Private Reserve","Rado","Raymond Weil","Retro 1951","Rotring","S.T. Dupont","Schmidt","Seiko","Stipula","Swiss Army","Swiss Military Hanowa","TechnoMarine","Tissot","Tonino Lamborghini","Tony Perotti","Tutima","Venlo","Visconti","Vox Luxury","Waterford","Waterman","William Henry Studio","Wolf Designs","World Lux"),new Array("all brands","most popular brands","-----------------------","Aurora","Bill Blass","Caran d' Ache","Cartier","Chronoswiss","Cross","David Oscarson","Dunhill","S.T. Dupont","Faber Castell","Grayson Tighe","Lamy","Montblanc","Montegrappa","Namiki","Omas","Parker","Pelikan","Porsche Design","Stipula","Visconti","Waterford","Waterman","William Henry Studio","World Lux"),new Array("all brands","most popular brands","-----------------------","Alpina","Ball","Ebel","Fortis","Glycine","Graham","Swiss Military Hanowa","Luminox","Maurice Lacroix","Martin Braun","Momentum","Mondaine","Montrek","Oris","Rado","Raymond Weil","Seiko","Swiss Army","TechnoMarine","Tissot","Tutima"),new Array("all brands","most popular brands","-----------------------","Orbita","Venlo","Vox Luxury","Wolf Designs"),new Array("all brands","most popular brands","-----------------------","Amodex","Aston Leather","Montblanc","Namiki","Stipula","Venlo"),new Array("all brands","most popular brands","-----------------------","Aston Leather","Bosca","Cross","Hartmann","McKlein","Montblanc","Tony Perotti"),new Array("all brands","most popular brands","-----------------------","Aston Leather","David Donahue","Dunhill","S.T. Dupont","Montblanc","Porsche Design","Swiss Army","Venlo","Vox Luxury","William Henry Studio","World Lux"),new Array("all brands","most popular brands","-----------------------","Aurora","Bosca","Caran d' Ache","Cartier","Cross","Dunhill","S.T. Dupont","Faber Castell","Fisher","Lamy","Montblanc","Montegrappa","Namiki","Noodler's","Omas","Parker","Pelikan","Pilot","Porsche Design","Private Reserve","Rotring","Schmidt","Visconti","Waterman"),new Array("all brands","most popular brands","-----------------------","Alpina","Amodex","Aston Leather","Aurora","Ball","Bill Blass","Bosca","Caran d' Ache","Cartier","Chronoswiss","Conway Stewart","Cross","David Donahue","David Oscarson","Dragon","Dunhill","S.T. Dupont","Ebel","Faber Castell","Fisher","Fortis","Glycine","Graham","Grayson Tighe","Swiss Military Hanowa","Hartmann","Lamy","Longines","Luminox","Maurice Lacroix","Martin Braun","McKlein","Momentum","Montblanc","Mondaine","Montegrappa","Montrek","Namiki","Noodler's","Noon Solar","Omas","Orbita","Oris","Parker","Pierre DeRoche","Pelikan","Pilot","Porsche Design","Private Reserve","Rado","Raymond Weil","Rotring","Schmidt","Seiko","Stipula","Swiss Army","TechnoMarine","Tissot","Tony Perotti","Tutima","Venlo","Visconti","Vox Luxury","Waterford","Waterman","William Henry Studio","World Lux","Wolf Designs"));
var brand_value = new Array(new Array("","pop","none","ACCU","ALPI","AMOD","ARNS","ASTO","AURO","BALL","BILL","BOSC","BULO","CARA","CART","CHRO","CITI","CLER","CONW","CROS","DAVD","DOSC","DRAG","DUNH","EBEL","FABE","FISH","FORT","GENE","GIPE","GLYC","GRAM","GTIG","HART","LAMY","LONG","LUMI","MARL","MART","MALA","MCKL","MOME","MOND","MONB","MONG","MREK","NAMI","NOOD","NOON","OMAS","ORBI","ORIS","PARK","PELI","PDRO","PILO","PORS","PRIV","RADO","RAYM","RETR","ROTR","DUPO","SCHM","SEIK","STIP","SWIS","HANO","TECH","TISS","TLAM","TONY","TUTI","VENL","VISC","VOXL","WATF","WATM","WHSC","WOLF","WLUX"),new Array("","pop","none","AURO","BILL","CARA","CART","CHRO","CROS","DOSC","DUNH","DUPO","FABE","GTIG","LAMY","MONB","MONG","NAMI","OMAS","PARK","PELI","PORS","STIP","VISC","WATF","WATM","WHSC","WLUX"),new Array("","pop","none","ALPI","BALL","EBEL","FORT","GLYC","GRAM","HANO","LUMI","MALA","MART","MOME","MOND","MREK","ORIS","RADO","RAYM","SEIK","SWIS","TECH","TISS","TUTI"),new Array("","pop","none","ORBI","VENL","VOXL","WOLF"),new Array("","pop","none","AMOD","ASTO","MONB","NAMI","STIP","VENL"),new Array("","pop","none","ASTO","BOSC","CROS","HART","MCKL","MONB","TONY"),new Array("","pop","none","ASTO","DAVD","DUNH","DUPO","MONB","PORS","SWIS","VENL","VOXL","WHSC","WLUX"),new Array("","pop","none","AURO","BOSC","CARA","CART","CROS","DUNH","DUPO","FABE","FISH","LAMY","MONB","MONG","NAMI","NOOD","OMAS","PARK","PELI","PILO","PORS","PRIV","ROTR","SCHM","VISC","WATM"),new Array("","pop","none","ALPI","AMOD","ASTO","AURO","BALL","BILL","BOSC","CARA","CART","CHRO","CONW","CROS","DAVD","DOSC","DRAG","DUNH","DUPO","EBEL","FABE","FISH","FORT","GLYC","GRAM","GTIG","HANO","HART","LAMY","LONG","LUMI","MALA","MART","MCKL","MOME","MONB","MOND","MONG","MREK","NAMI","NOOD","NOON","OMAS","ORBI","ORIS","PARK","PDRO","PELI","PILO","PORS","PRIV","RADO","RAYM","ROTR","SCHM","SEIK","STIP","SWIS","TECH","TISS","TONY","TUTI","VENL","VISC","VOXL","WATF","WATM","WHSC","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;

}
