function add_to_cart(str){
   AjaxRequest.get(
    {
     'url':'templates/add_to_cart.php?typ=' + str
     ,'onSuccess':function(req){
	//document.getElementById('div_cart').innerHTML = req.responseText;
	//alert('added to cart:' + req.responseText);
	//alert('added to cart');
	//document.getElementById('_default').submit();
	window.location = "http://czech-transport.com/index.php?menu_id=cart"
      }
     ,'onError': function(){
	alert('error occured');
      }
    }
   );
}

function add_to_cart2(str, form_subid){
   AjaxRequest.get(
    {
     'url':'templates/add_to_cart2.php?typ=' + str + '&form_subid=' + form_subid
     ,'onSuccess':function(req){
//	window.location = loc;
	document.getElementById('_default').submit();
      }
     ,'onError': function(){
	alert('error occured');
      }
    }
   );
}

 function oe(i, dest){
  document.getElementById('order_edit_'+dest).value = i;
  document.getElementById('form_order_edit_'+dest).submit();
 }

 function od(i){
  document.getElementById('order_delete').value = i;
  document.getElementById('form_orders').submit();
 }

 function send_order(){
  document.getElementById('order_send').value = 1;
  document.getElementById('form_orders').submit();
 }

 function pay_order(){
  document.getElementById('order_pay').value = 1;
  document.getElementById('form_orders').submit();
 }

 function change_details(id, txt, txt2){
  var el = document.getElementById("summary_table_"+id);
  el.className = (el.className == "hidden" ? "visible" : "hidden");
  document.getElementById("det_but_"+id).innerHTML="<a href='#'>" + txt + "</a>";
  document.getElementById("det_but_"+id).onclick = function() {change_details(id, txt2, txt); };
 }

 function country_change(e, val){
// else{
// 	update_delivery_opt(val);
// }

   AjaxRequest.get(
    {
     'url':'templates/menu_shopcart_udt.php?id=' + e.value
     ,'onSuccess':function(req){
// alert(req.responseText);
	switch (e.name){
		case 'country':
			cal_delivery_date.disabledDatesExpression = '';
			cal_delivery_date.addDisabledDates(null, req.responseText);
			if (val == 'undefined' || !val)
				document.getElementById('delivery_date').value = '';
			else{
				document.getElementById('delivery_date').value = val;
				update_delivery_opt(val);
			}
		break;
		case 'country_eu':
			cal_delivery_date_eu.disabledDatesExpression = '';
			cal_delivery_date_eu.addDisabledDates(null, req.responseText);
			if (val == 'undefined' || !val)
				document.getElementById('delivery_date_eu').value = '';
			else{
				document.getElementById('delivery_date_eu').value = val;
				update_delivery_opt_eu(val);
			}
		break;
		default:
			cal_delivery_date_prg.disabledDatesExpression = '';
			cal_delivery_date_prg.addDisabledDates(null, req.responseText);
			document.getElementById('delivery_date_prg').value =  ((val == 'undefined' || !val) ? '' : val);
		break;
	}
      } 
     ,'onError': function(){
	alert('error occured');
      }
    }
   );
 }

function delivery_dest_change(e, txt, price, val){

 document.getElementById("fieldset_delivery_addr_home").className = "hidden";
 document.getElementById("fieldset_delivery_addr_prg_hotel").className = "hidden";
 document.getElementById("fieldset_delivery_addr_eu_hotel").className = "hidden";

 switch (e.value){
  case 'home_addr' :
   document.getElementById("fieldset_delivery_addr_home").className = "visible";
   country_change(document.getElementById("country"), val);
   document.getElementById("table_way_of_delivery").innerHTML = '';
  break;
  case 'hotel_prague' :
   document.getElementById("fieldset_delivery_addr_prg_hotel").className = "visible";
   country_change(false, val);
   document.getElementById("table_way_of_delivery").innerHTML = "<tr><th id='th_delivery_type'><label for='delivery_type'></label></th><td id='td_delivery_type' colspan='1'><table><tr><td>" + txt + " " + price + " EUR<input type='radio' name='delivery_type' id='prgkurir' value='prgkurir_" + price + "' checked /><br /></td></tr></table></td></tr>";
  break;
  case 'hotel_europe' :
   document.getElementById("fieldset_delivery_addr_eu_hotel").className = "visible";
   country_change(document.getElementById("country_eu"), val);
   document.getElementById("table_way_of_delivery").innerHTML = '';
  break;
 }
}
function _checkout()
{
 if (document.getElementById('pay_way_csob').checked)
	document.getElementById('form_csob').submit();
 else
	document.getElementById('form_pp').submit();
}
function update_delivery_opt(tmpDate){


var e = document.getElementById("country");
var country_id = e.options[e.selectedIndex].value;

   AjaxRequest.get(
    {
     'url':'templates/menu_shopcart_udo.php?date=' + tmpDate + '&country_id=' + country_id
     ,'onSuccess':function(req){
// 	alert(req.responseText);
	document.getElementById("table_way_of_delivery").innerHTML = req.responseText;
      }
     ,'onError': function(){
	alert('error occured');
      }
    }
   );
 //alert(tmpDate);
}

function update_delivery_opt_eu(tmpDate){

var e = document.getElementById("country_eu");
var country_id = e.options[e.selectedIndex].value;

   AjaxRequest.get(
    {
     'url':'templates/menu_shopcart_udo.php?date=' + tmpDate + '&country_id=' + country_id
     ,'onSuccess':function(req){
// 	alert(req.responseText);
	document.getElementById("table_way_of_delivery").innerHTML = req.responseText;
      }
     ,'onError': function(){
	alert('error occured');
      }
    }
   );
}

