
$(document).ready(function(){
	
	var iH = $("#content2").height();
	$("#side2_b").css('min-height',iH+'px');
	$("#side_b").css('min-height',iH+'px');
	$(".treeviewRecords").show();
	
	$(".clickToggle").hover( function (){
		$(this).find('.clickContent').each(function() { $(this).slideDown('fast'); });
		$(this).find('.uvodNabidkaBasket').each(function() { $(this).css("display","block"); });
	}, function() {
		$(this).find('.clickContent').each(function() { $(this).slideUp('fast'); });
		$(this).find('.uvodNabidkaBasket').each(function() { $(this).css("display","none"); });
	});	

});

function getCookieData(){ // decompile data from cookie
cookieContent=getCookie(cookieName)
if(!cookieContent){return}

retrievedData=cookieContent

return retrievedData;

}

function showExtendedPrice(){
	  var allVals = [];
	  var extsum = 0;
	  var totalsum = 0;
	  $('#div1002 label').each(function() {
		  $(this).css("color","black");
	  });  
      $('#div1002 :checked').each(function() {
		   extsum = extsum + parseFloat($(this).attr("value2"));
		   var id = $(this).attr("id").substring(4,$(this).attr("id").length);
		   $("#cbl"+id).css("color","red");
      });
	  $("input#priceExt").val(extsum);
	  totalsum = parseFloat($("#ks").val())*parseFloat($("#priceVal").val());

	  
	  extsum = parseFloat($("#ks").val())*extsum;
	  
	  
	  cenacelkem = totalsum+extsum;
	  $(".wholePrice").find('span').each(function() { $(this).html(cenacelkem + ",- Kč"); });
}

function updateIngrediencies(){
	if(isObject("div940")){
	  var ingr = "";
	  $('#div940 label').each(function() {
		  $(this).css("color","black");
	  });  
      $('#div940 :checked').each(function() {
		   
		   var id = $(this).attr("id").substring(4,$(this).attr("id").length);
		   ingr = ingr + $("#cbl"+id).html() + ", ";
		   $("#cbl"+id).css("color","red");
      });
	  
	   $("#text-ingredience").val(ingr);
	};
}


  

// An adaptation of Dorcht's cookie functions.

function setCookie(name, value, expires, path, domain, secure){
if (!expires){expires = new Date()}
document.cookie = name + "=" + escape(value) + 
((expires == null) ? "" : "; expires=" + expires.toGMTString()) +
((path == null) ? "" : "; path=" + path) +
((domain == null) ? "" : "; domain=" + domain) +
((secure == null) ? "" : "; secure")

}

function getCookie(name) {
var arg = name + "="
var alen = arg.length
var clen = document.cookie.length
var i = 0
while (i < clen) {
var j = i + alen
if (document.cookie.substring(i, j) == arg){
return getCookieVal(j)
}
i = document.cookie.indexOf(" ", i) + 1
if (i == 0) break
}
return null
}

function getCookieVal(offset){
var endstr = document.cookie.indexOf (";", offset)
if (endstr == -1)
endstr = document.cookie.length
return unescape(document.cookie.substring(offset, endstr))
}

function deleteCookie(name,path,domain){
document.cookie = name + "=" +
((path == null) ? "" : "; path=" + path) +
((domain == null) ? "" : "; domain=" + domain) +
"; expires=Thu, 01-Jan-00 00:00:01 GMT"
}

