/*
function koupit(id, count, flush) {
	if (count) count = count.value;
	if (!count) count = 1;
	if (!flush) flush = 0;
	getData(url + "inc/ajax/abasket.php?id=" + id + "&count=" + count + "&flush=" + flush + "&preurl=" + url, "basket");
	if (show_window_after_buy == 1 && flush != 1) alert(window_after_buy_text);
	var loc = document.location.href;
	if (loc.match("basket") != null) document.location.href = url + "?loc=basket";
}
*/
function checkkoupit(id, count, corpus, fill) {

  //alert( document.getElementById('corpus').name);
  if (corpus == -1 || fill == -1)
  {
    alert("Nebyly vybrány všechny parametry!");
  }
  else
  {
    koupit(id, count, corpus, fill);
  }
}

function koupit(id, count, corpus, fill, flush) {
	if (count) count = count.value;
	if (!count) count = 1;
	if (!corpus) corpus = 0;
	if (!fill) fill = 0;
	if (!flush) flush = 0;
	getData(url + "inc/ajax/abasket.php?id=" + id + "&count=" + count + "&corpus=" + corpus + "&fill=" + fill + "&flush=" + flush + "&preurl=" + url, "basket");
	if (show_window_after_buy == 1 && flush != 1) alert(window_after_buy_text);
	var loc = document.location.href;
	if (loc.match("basket") != null) document.location.href = url + "?loc=basket";
}

function varianta(menu, row) 
{
	var product = menu.options[menu.selectedIndex].value;
	var dataSource = url + "inc/ajax/avariants.php?id=" + product;

  if(XMLHttpRequestObject) {
    XMLHttpRequestObject.open("GET", dataSource, true);
    XMLHttpRequestObject.onreadystatechange = function()
    {
      if (XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status == 200) {
	  	  var obsah = XMLHttpRequestObject.responseText;
	  	  var items = obsah.split("|");
	  	  document.getElementById('product_link'+row).innerHTML = items[0];
		  document.getElementById('product_price'+row).innerHTML = items[1];
		  document.getElementById('product_buy'+row).innerHTML = items[2];
      }
    }
    XMLHttpRequestObject.send(null);
  }
}

