function itemImageClicked(index) {
 if (document.getElementById('imgmain_sprite')) {
  var xpos = - ((index - 1) % 3) * 420;
  var ypos = - Math.floor((index - 1) / 3) * 300;
  document.getElementById('imgmain_sprite').style.backgroundPosition = xpos + 'px ' + ypos + 'px';
 } else {
  document.getElementById('imgmain_img').src = document.getElementById('image'+index).innerHTML;
 }
 document.getElementById('imgmain_txt').innerHTML = document.getElementById('imageNote'+index).innerHTML;
}
function addToCartClicked() {
 f = document.forms['itemPageForm'];
 if (f.item_id.value != '') {
  if (f.curtainPriceCalculated.value == 'Y') {
   f.cart_action.value = 'PUT';
   f.action = f.cart_url.value;
   f.submit();
  } else if (f.curtainPriceCalculated.value == 'I') {
   alert($('MESG_INVALID_SPEC').innerHTML);
  } else {
   alert($('MESG_CALCULATE_BEFORE_CART').innerHTML);
  }
 }
}
function addSampleToCartClicked() {
 var form = $('itemPageForm');
 var samples = form.getInputs('checkbox','selectedRowInfo');
 if (samples.length != 0) {
  var selectedSamples = samples.findAll(function(checkbox){return checkbox.checked;});
  if (selectedSamples.length != 0) {
   form.cart_action.value = 'MPUT';
   form.action = form.cart_url.value;
   form.submit();
  }
 }
}
function addToListClicked() {
 f = document.forms['itemPageForm'];
 if (f.item_id.value != '') {
  f.action = f.list_url.value;
  f.submit();
 }
}
function catalog2OptionChanged() {
 f = document.forms['itemPageForm'];
 f.submit();
}
