if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){ //test for MSIE x.x;
 var ieversion=new Number(RegExp.$1) // capture x.x portion and store as a number
}

if  (ieversion < 7) {
} else {
$(document).ready(function() {
  //handle the event triggers for the new select menus
  //and prevent the dropdown from opening normally
  $('select.select_new').mousedown(
    function(e){block_select(e,this);}  
  ).focus(
    function(e){block_select(e,this);}  
  ).click(
    function(e){block_select(e,this);}
  ).dblclick(
    function(e){block_select(e,this);}
  );
  $("select.select_new").mousedown(function(event){
    var sel = $(this);
    sel.find('option').each(function(e){
      if(this.value && !this.selected){$(this).remove();}
    });
    //display our DIV
    var div = $("div.dropdown[sel="+sel.attr('id')+"]");
    var pos = sel.offset();
    div.css({"top":20,"left":0,"position":"absolute","z-index":1001});
    div.show();
    block_select(event,this);
  });
  //convert every select field in the DOM with the class "select_new" into the new select format
  $('select.select_new').each(function(){
    var str = "";
    var select = this.id;
    $(this).wrap("<div style='position: relative;text-align:left;'></div>");
    //convert all the "option" tags into selectable DIVs
    $(this).find("option").each(function(){
      var image = $(this).attr('img');
      var link = $(this).attr('link');
      var val = $(this).attr('value');
      var label = $(this).text();
      //avoid selected the default select option used for labeling
      if(val){
        if(this.selected){cla='selected';}else{cla='unselected';}
        //append our div formating to the str variable which will be output to the browser after the iteration
        str += "\n<div class='selectitem "+cla+"' value='"+val+"'><img src='"+image+"'><div class='label'>"+label+"</div><div class='link'><a href='"+link+"'>size & info</a></div></div>\n";;
        if(!this.selected){$(this).remove();}
      }
    });
    $(this).after("\n<div class='dropdown' sel='"+select+"'>"+str+"<div style='clear:both;'></div></div>\n");
  });
  //event to trigger when a select item is chosen
  $("div.selectitem").mousedown(function(){
    //get product label, value, and select field id into variables
    var label = $(this).find('.label').html();
    var val = $(this).attr('value');
    var sel = $(this).parent().attr('sel');
    $("select.select_new[id="+sel+"]").append('<option value='+val+' selected>'+label+'</option>');
    //need both event triggers below to reinitiate dynamic form validation
    $("select.select_new[id="+sel+"]").focus();
    $("select.select_new[id="+sel+"]").blur();
    //style selected and unselected DIVs
    $("div.dropdown[sel="+sel+"] > div.selectitem").removeClass("selected");
    $(this).addClass("selected");
    //hide the div containing select options
    $("div.dropdown[sel="+sel+"]").fadeOut();

    var sPath = window.location.pathname;
    var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);

    if (sPage == "hoodie-custom.htm") {
       checkHoodyOptions('product');
    } else if (sPage == "tshirt-girls-custom2.htm") {
       checkKidOptions('product'); 
    } else if (sPage == "sweatpant-custom.htm") {
       checkSweatpantOptions('product') ;
    } else {
       checkOptions('product');
    }

   
  }).hover(function(){
    $(this).addClass("hover");  
  },function(){
    $(this).removeClass("hover");
  });

  
  //hide select options DIV if user mouses out of the area
  $("div.dropdown").mouseleave(function(){$(this).hide();});
});

function block_select(ev,el){
  ev.preventDefault();
  el.focus();
  el.blur();
}

}