/*
#############################################################
#                                                           #
#   © IT Media                                              #
#   info@itmedia.lv                                         #
#   www.itmedia.lv                                          #
#                                                           #
#############################################################
*/


  hs.graphicsDir = '/js/graphics/';
  hs.outlineType = null;

  function tobasket(){  	var str = "action=tobasket";  	$("#description .count").each(function(){      str+="&";      str+=$(this).attr("name");
      str+="=";
      str+=$(this).val();  	});
  	$.ajax({      type:"POST",
      url:"?",
      data:str,
      success:updatebasket  	});
    return false;
  }

  function updatebasket(data){  	if(data!="false"){      var info = $('#successalert').html();
      alert(info);
      $('#basket').html(data);
      $("#gobasket").css("display","inline");
  	}  }

  function showsubmit(what){  	if(parseInt(what.value)>0){      $('#sbmt').css("display","");  	}  }

  function o(url,w,h){
    window.open(url,'','height='+h+',width='+w+',scrollbars=yes,resizable=no,toolbar=no,location=no,status=no,menubar=no');
    return false;
  }

  function savecaddr(addr){  	$.get('?caddr='+addr);  }

  function saveaddr(addr){    $.get('?addr='+addr)  }

  function confdrop(url,obj,ask){  	if(confirm(ask)){      $.get(url+'&ajax');      $("#"+obj).css("display","none");  	}
  	return false;  }

  function setprice(price,id){  	$('#sprice_'+id).val(price);  }

  function calendar(month,year){  	$("#overlay").css("display","");  	$("#calendar").css("display","");    $("#calendar").html('<img src="/images/load_calendar.gif" alt="" />');
    $("#calendar").load("?month="+month+"&year="+year);
    return false;
  }

  function hidecal(){  	$("#overlay").css("display","none");
  	$("#calendar").css("display","none");  	return false;  }

  function usedate(d){  	$("#dateto").html(' - '+d);
  	$.get("?setdateto="+d);
  	return hidecal();  }

  function showhide(id){  	var obj = $("#"+id);
  	if(obj.css("display")=="none"){      obj.css("display","");  	}else{      obj.css("display","none");  	}
  	return false;  }

  function editcmt(id){  	$("#cf-"+id).css("display","");
  	$("#overlay").css("display","");
  	$("#overlay").click(function(){      closecmt(id);  	});
  	return false;  }

  function closecmt(id){  	$("#cf-"+id).css("display","none");
  	$("#overlay").css("display","none");
  	return false;  }

  function savecmt(txt,id){  	$.post("?ajax",{action:"savecmt",comment:txt,item:id});
  	if(txt){
  	  $("#ucmt_"+id).html("<br />("+txt+")");
  	}else{      $("#ucmt_"+id).html("");  	}  }

  function maincmt(txt){  	$.post("?ajax",{action:"maincmt",comment:txt});  }

  function recount(cnt,id){  	if(window.c){
	  clearTimeout(c);
	}  	c = window.setTimeout(function(){  	  $.post("?",{action:"recount",count:cnt,item:id},function(data){        if(data){          var n = new Array();
          n=data.split(",");
          $("#sum_"+id).html(n[0]);
          $("#allsum").html(n[1]);
          $("#vat").html(n[2]);
          $("#allsumvat").html(n[3]);        }  	  });
    },500);  }
