var ktimer;
function product_colors(off) { 
  if ((document.getElementById("product_colors").style.display == "none" || document.getElementById("product_colors").style.display == "") && off == null) {
    document.getElementById("product_colors").style.display = "block";
    product_trends(1);
  }
  else document.getElementById("product_colors").style.display = "none";
}
function product_trends(off) { 
  if ((document.getElementById("product_trends").style.display == "none" || document.getElementById("product_trends").style.display == "") && off == null) {
    document.getElementById("product_trends").style.display = "block";
    product_colors(1);
  }
  else document.getElementById("product_trends").style.display = "none";
}
function shopshow(a) {
  if (ktimer) clearTimeout(ktimer);
  var id = document.getElementById("shop");
  id.style.display = "block";
  pos=Position.get(a);
  if (pos.left+300 > document.body.offsetWidth)
    pos.left -= 200;
  Position.set(id,pos); 

}
function shophide() {
  var id = document.getElementById("shop");
  id.style.display = "none";
  refersh();
}
function refersh() {
  var str = $("#shopform").serialize();
  $.post(url+"/kosar/"+$("#szall").val(), str, function(data){
    $("#shop").html(data); 
    if (document.getElementById("alert")) alert(document.getElementById("alert").innerHTML);
    if ($("#shopform2").length != null)
      simplerefersh(2);
  });
}
function shopremove(id) {
  $.get(url+"/kosar/termek/torles/"+id, {}, function(data){ 
    document.getElementById("shop").innerHTML = data; 
    if ($("shopform2") != null)
      simplerefersh(2);
  });
}
function shopremovecoupon(id) {
  $.get(url+"/kosar/kupon/torles/"+id, {}, function(data){ 
    document.getElementById("shop").innerHTML = data; 
    if ($("shopform2") != null)
      simplerefersh(2);
  });
}
function shopremove2(id) {
  $.get(url+"/kosar2/termek/torol/"+id, {}, function(data){ 
    document.getElementById("shopform2").innerHTML = data; 
    if ($("shopform") != null)
      simplerefersh(1);
  });
  return false;
}
function shopremovecoupon2(id) {
  $.get(url+"/kosar2/kupon/torol/"+id, {}, function(data){ 
    document.getElementById("shopform2").innerHTML = data; 
    if ($("shopform") != null)
      simplerefersh(1);
  });
  return false;
}
function refersh2() {
  var str = $("#shopform2").serialize();
  $.post(url+"/kosar2/"+$("#szall").val(), str, function(data){
    $("#order_summary").html(data);
    if ($("#shopform"))
      simplerefersh(1);
  });
}
function simplerefersh(id) {
  if (id == 1) {
    $.get(url+"/kosar/"+$("#szall").val(), {}, function(data){ 
      $("#shop").html(data);
    });
  }
  else {
    $.get(url+"/kosar2/"+$("#szall").val(), {}, function(data){ 
      $("#order_summary").html(data);
    });
  }
}
function shopadd(form) {
  var str = $("#"+form).serialize();
  $.post(url+"/kosar", str, function(data){
    $("#shop").html(data);
    if (document.getElementById("alert")) alert(document.getElementById("alert").innerHTML);
    if ($("#shopform2") != null)
      simplerefersh(2);
  });
}
function timerstop() { clearTimeout(ktimer); }
function shophidet() { ktimer = setTimeout('shophide()',1000); }
