// Hide object with given id.
function id_hide(id) {
  obj = document.getElementById(id);
  obj.style.display = 'none';
  return true;
}

// Show object with given id.
function id_show(id) {
  obj = document.getElementById(id);
  obj.style.display = 'block';
  return true;
}

// Dont allow customer to buy less than minimum quantity.
function checkMinQuantity(obj) {
  //if(parseInt(obj.value) <  parseInt(obj.title) ) {
  // JTS 08.01.07 - force int check and modulus
  if(parseInt(obj.value)%parseInt(obj.title)!=0 ) {
    obj.value = obj.title*Math.ceil(obj.value/obj.title);
    //obj.value = obj.title
    //JTS 08.01.07 - must be a modulus of min qty
    alert("Bliver rettet til nærmeste " + obj.title);
    return false;
  }
  return true;
}

// Submit order.
function buyProduct(f, id, cPath, add) {
  obj = document.getElementById('product' + id);
  addToRequest = '&';
  if (add != '') {
    addToRequest = '&' + add;
  }
  window.location = f+"?cPath=" + cPath + addToRequest + "sort=2a&action=buy_now&products_id=" + id + "&quantity=" + obj.value;

  return true;
}

// Redirect
function redirectProduct(id, enc, info) {
  // product_info.php
  if (info != undefined)
  {
    // check that the product_id send is the right one..
    var real_id = jQuery("#variantTabel input:checked")[0].value;
    if (!isNaN(real_id) && id != real_id)
    {
      var str = unescape(enc);
      var s = '=' + id + '&';
      var r = '=' + real_id + '&';
      enc = escape(str.replace(s, r));
    }
    var obj = document.getElementById('cart_quantity');
    window.location = "/catalog/template.php?filename=requestAccount.php&ref=" + enc + "%26amount=" + obj.value;

    return true;
  }
  else // product_listing.php
  {
    var obj = document.getElementById('product' + id);
    window.location = "/catalog/template.php?filename=requestAccount.php&ref=" + enc + "%26amount=" + obj.value;

    return true;
  }
}
$(function() {
 $('.slideshow').cycle({fx: 'fade', timeout : 6000});

 if($('.paymenttypebox .newItemInCart').length) {
   $('.paymenttypebox')
    .fadeOut(100).fadeIn(100)
    .fadeOut(100).fadeIn(100)
    .fadeOut(100).fadeIn(100)
    .fadeOut(100).fadeIn(100)
   ;
 }
});