/*
This script is a workaround to fix an error discovered in IE browsers. 

Problem: Once a state and city combo has been selected and the page has
been submitted, IE will not recognize the SELECTED state
of the city dropdown in the form. Instead, IE will reset the dropdown 
to the first value in the array for the chosen states cities.

Solution: On submission of the form, the SELECTED city is determined via
JS. This value is then cookied. On subsequent page load, the cookied value
is passed back to a JS function to set the SELECTED state on the city
dropdown. This appears to solve the IE issue.

This has been modified to handle the same bug that was discovered
on the accessory page.
*/


// set the cookie with the value of the SELECTED index
function setSelected(page) {
  if(page == 'retail'){
    var holdVal = document.forms['retailSelect'].elements['cities'].selectedIndex;
    document.cookie = "retail_selected=" + holdVal;
  } else {
    var holdVal = document.forms['accessorySelect'].elements['category'].selectedIndex;
    document.cookie = "accessory_selected=" + holdVal;
  } 
}

// parse and return the cookie value  
function getCookie(cookie_name) {
var results = document.cookie.match ( cookie_name + '=(.*?)(;|$)' );
if ( results )
  return ( unescape ( results[1] ) );
else
  return 0;
}

