	function InvokeAction(A)
	{
		var Pos = document.forms[0].action.indexOf("Action=") + 7;
		document.forms[0].action = document.forms[0].action.substring(0, Pos) + A;
		document.forms[0].submit();
	}

function ajaxObject(url, callbackFunction) {
  var that=this;
  this.updating = false;

  this.update = function(passData,postMethod) {
    if (that.updating==true) { return false; }
    that.updating=true;
    var AJAX = null;
    if (window.XMLHttpRequest) {
      AJAX=new XMLHttpRequest();
    } else {
      AJAX=new ActiveXObject("Microsoft.XMLHTTP");
    }
    if (AJAX==null) {
      return false;
    } else {
      AJAX.onreadystatechange = function() {
        if (AJAX.readyState==4) {
          that.updating=false;
          that.callback(AJAX.responseText,AJAX.status,AJAX.responseXML);
          delete AJAX;
        }
      }
      var timestamp = new Date();
      if (postMethod=='POST') {
        var uri=urlCall+'?'+timestamp.getTime();
        AJAX.open("POST", uri, true);
        AJAX.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        AJAX.send(passData);
      } else {
        var uri=urlCall+'?'+passData+'&timestamp='+(timestamp*1);
        AJAX.open("GET", uri, true);
        AJAX.send(null);
      }
      return true;
    }
  }
  var urlCall = url;
  this.callback = callbackFunction || function () { };
}

	var timeout       = 500;
	var closetimer		= 0;
	var ddmenuitem    = 0;

	function jsddm_open()
	{	jsddm_canceltimer();
		jsddm_close();
		ddmenuitem = $(this).find('ul').eq(0).css('display', 'block');}

	function jsddm_close()
	{	if(ddmenuitem) ddmenuitem.css('display', 'none');}

	function jsddm_timer()
	{	closetimer = window.setTimeout(jsddm_close, timeout);}

	function jsddm_canceltimer()
	{	if(closetimer)
		{	window.clearTimeout(closetimer);
			closetimer = null;}}

	$(document).ready(function()
	{	$('#jsddm > li').bind('mouseover', jsddm_open);
		$('#jsddm > li').bind('mouseout',  jsddm_timer);});

	document.onclick = jsddm_close;

	function Rollon(RollId)
	{
		document.getElementById(RollId).style.BackgroundImage = 'Images/HeadermenuBGhover.jpg';
	}

	function Rolloff(RollId)
	{
		document.getElementById(RollId).style.BackgroundImage = 'Images/HeadermenuBG.jpg';
	}

	function SetCosts()
	{
		this.SetIngredientsTotalCost();
		this.SetPersonellCost();
		this.SetMargeLossCost();
		this.SetTotalCosts();
		this.SetMargeProfit();
		this.SetVatCost();
		this.SetFinalCosts();
		this.SetCostInKilo();
		this.SetPortionPrice();
	}
	function SetIngredientsTotalCost()
	{
		var hiddenField = document.getElementById('IngredientsCost').value.toString().replace(",", ".");
		var costIngredients = parseFloat(hiddenField).toFixed(2);
		document.getElementById('CostIngredients').innerHTML = costIngredients.replace(".", ",");
	}
	function SetPersonellCost()
	{
		var personellPrice = document.getElementById('PersonellPrice').value.replace(",", ".");
		var minutes = document.getElementById('PersonellMinutes').value.replace(",", ".");

		var costPersonell = parseFloat((minutes / 60) * personellPrice).toFixed(2);
		document.getElementById('CostPersonell').innerHTML = costPersonell.replace(".", ",");
	}
	function SetMargeLossCost()
	{
		var lossPercentage = document.getElementById('MargeLossPercentage').value.replace(",", ".");
		var costIngredients = document.getElementById('CostIngredients').innerHTML.replace(",", ".");
		var costMargeLoss = parseFloat((costIngredients / 100) * lossPercentage).toFixed(2);
		document.getElementById('CostMargeLoss').innerHTML = costMargeLoss.replace(".", ",");
	}
	function SetTotalCosts()
	{
		var ingredientsTotalCost = document.getElementById('CostIngredients').innerHTML.replace(",", ".");
		var personellCost = document.getElementById('CostPersonell').innerHTML.replace(",", ".");
		var margeLossCost = document.getElementById('CostMargeLoss').innerHTML.replace(",", ".");
		var totalCosts = parseFloat(parseFloat(ingredientsTotalCost) + parseFloat(personellCost) + parseFloat(margeLossCost)).toFixed(2);
		document.getElementById('CostTotal').innerHTML = totalCosts.replace(".", ",");
	}
	function SetMargeProfit()
	{
		var costTotal = document.getElementById('CostTotal').innerHTML.replace(",", ".");
		var margeProfitPercentage = document.getElementById('MargeProfitPercentage').value.replace(",", ".");
		var percentageLeft = (100 - margeProfitPercentage);
		var costProfit;
		if (percentageLeft != 0)
			costProfit = parseFloat((costTotal / percentageLeft) * 100).toFixed(2);
		else
			costProfit = costTotal;
		costProfit = parseFloat(costProfit - costTotal).toFixed(2);
		document.getElementById('CostProfit').innerHTML = costProfit.toString().replace(".", ",");
	}
	function SetVatCost()
	{
		var vatPercentage = 6;
		var totalCost = document.getElementById('CostTotal').innerHTML.replace(",", ".");
		var costProfit = document.getElementById('CostProfit').innerHTML.replace(",", ".");

		var costVAT = parseFloat((parseFloat(parseFloat(totalCost) + parseFloat(costProfit)) / 100) * vatPercentage).toFixed(2);
		document.getElementById('CostVAT').innerHTML = costVAT.replace(".", ",");

	}
	function SetFinalCosts()
	{
		var costProfit = document.getElementById('CostProfit').innerHTML.replace(",", ".");
		var totalCost = document.getElementById('CostTotal').innerHTML.replace(",", ".");
		var costVat = document.getElementById('CostVAT').innerHTML.replace(",", ".");
		var finalCost = parseFloat(parseFloat(totalCost) + parseFloat(costVat) + parseFloat(costProfit)).toFixed(2);
		document.getElementById('FinalCost').innerHTML = finalCost.replace(".", ",");
	}

	function SetCostInKilo()
	{
		var productWeight = "0" + document.getElementById('WeightInGram').value;
		var totalCostWithProfit = "0" + document.getElementById('CostProfit').innerHTML.replace(",", ".");
		var totalCostVAT = "0" + document.getElementById('CostVAT').innerHTML.replace(",", ".");
		var totalCost = parseFloat(totalCostWithProfit + totalCostVAT).toFixed(2);
		var costInKilo = parseFloat(0).toFixed(2);
		var finalCost = document.getElementById('FinalCost').innerHTML.replace(",", ".");
		if (productWeight != 0)
			costInKilo = parseFloat(parseFloat(1000 / productWeight) * parseFloat(finalCost)).toFixed(2);

		document.getElementById('CostUnit').innerHTML = costInKilo.toString().replace(".", ",");
	}

	function SetPortionPrice()
	{
		var CostUnit = document.getElementById('CostUnit').innerHTML.replace(",", ".");
		var portionPrice = parseFloat(parseFloat(CostUnit) / 2.5).toFixed(2);
		document.getElementById('PortionPrice').innerHTML = portionPrice.toString().replace(".", ",");

	}
	
	function SetFilter(FilterName, FilterValue)
	{
		if (document.getElementById(FilterName) != null)
		{
			document.getElementById(FilterName).value = FilterValue;
			document.getElementById(FilterName).form.submit();
		}
	}
	
	/*function ShowAllFilter(FilterName, FilterValue)
	{
		if (document.getElementById("ShowAll_" + FilterName) != null)
		{
			document.getElementById("ShowAll_" + FilterName).value = FilterValue;
			document.getElementById("ShowAll_" + FilterName).form.submit();
		}
	}*/
	
	function ShowAllFilter(FilterName)
	{
		$("#" + FilterName + "_Filter").toggle();
		$("#" + FilterName + "_Footer a").toggle();
	}
