
var utils = {
  
  app_path: null,
  
  init: function(app_path) {
    this.app_path = app_path;
  },
  
  
  
  switch_hover_img : function(element, hover_in) {
    
    img = null;
    if (element.is('img') || element.is('input'))
      img = element;
    else
      img = element.find('img');  // reflected images are wrapped in another element
    
    src = img.attr('src');
//    console.debug(element, hover_in, img, src);
    
    regex = /(.+)\/([\w-_]+)\.(\w+)$/;   // very basic regex, doesn't support parameters
    matches = regex.exec(src);
//    console.debug(matches);
    
    name = matches[2].replace(/_over/g, '');  // shouldn't be necessary in the case of hover_in but sometimes in firefox a weird _over_over case appears..
    new_src = '';
    if (hover_in) {
      new_src = matches[1] + '/' + name + '_over.' + matches[3];
    }
    else {
      new_src = matches[1] + '/' + name + '.' + matches[3];
    }
//    console.debug(new_src);
    img.attr('src', new_src);
  },
  
  
  
  change_item_pic: function(brand, filename, item_pic_selector) {
    src = utils.app_path + 'itemimg/' + brand + '/04/' + filename + '.jpg';
    if (item_pic_selector) { $(item_pic_selector).attr('src', src); }
    else { $('#item_pic img').attr('src', src); }
  }
  
};
