function gi (id) { return document.getElementById(id) }
function gid (id,display) { return document.getElementById(id).style.display = (display?"block":"none"); }
function gicl (id,classname) { return document.getElementById(id).className = classname; }
function gt (id) { return document.getElementsByTagName(id) }
function gn (id) { return document.getElementsByName(id) }

function rozbal (classs){
	   $("#admin #right ."+classs).hide();
   }

$(document).ready(function(){
	$("#zalozka").mouseover(function(){
		$("#head").css("background-position","50% -297px");
   });
   $("#zalozka").mouseout(function(){
		$("#head").css("background-position","50% 0");
   });

   ////////////////////////////////////        kalkulačka
   $("#calc1").click(function(event){
	   $("#calc-krok1").hide("fast");
	   $("#flash").hide("fast");
	   $("#calc-krok2").show("fast");
	   event.preventDefault();
   })
   $("#calc1-ok").click(function(event){
	   if( (gi("calc-ztraty").value=="none" && (gi("calc-plocha").value)!=parseInt(gi("calc-plocha").value)) ){
		   alert("musíte zadat buď výkonovou ztrátu, nebo plochu vašeho domu jako celé číslo!");
		   return false;
	   }
	   if(gi("calc-bazen-ano").checked && (gi("calc-bazen-m").value)!=parseInt(gi("calc-bazen-m").value)){
		   alert("Plocha vašeho bazénu musí být číselný údaj!");
		   return false;
	   }
	   $("#calc-krok2").hide("fast");
	   $("#flash").show("normal");
	   $("#calc-krok3").show("normal");

	   var ztraty;
	   if(gi("calc-ztraty").value!="none"){
		   ztraty = gi("calc-ztraty").value;
	   }else{
			if(gi("calc-rekonstrukce").checked){
				ztraty = parseInt(gi("calc-plocha").value) * 70 / 1000;
			}else{
				ztraty = parseInt(gi("calc-plocha").value) * 100 / 1000; // novostavba
			}
	   }
	   if(gi("calc-tuv").checked){
		   var ztraty_tuv = 1;
	   }else{
		   var ztraty_tuv = 0;
	   }
	   var ztraty_bazen = 0;
	   if(gi("calc-bazen-ano").checked){
		   ztraty_bazen = parseInt(gi("calc-bazen-m").value) * 0.16;
	   }

	   var celk_ztraty = parseInt(ztraty)+parseInt(ztraty_tuv);
	   var ccc = parseInt(celk_ztraty)+parseInt(ztraty_bazen);

	   var cerp = "ATW54";
	   if(ccc <= 6)  cerp = "ATW14";
	   else if(ccc <= 7)  cerp = "ATW18";
	   else if(ccc <= 9)  cerp = "ATW24";
	   else if(ccc <= 11)  cerp = "ATW36";
	   else if(ccc <= 13)  cerp = "ATW45";

	   gi("calc-krok3").innerHTML = '\<a href="#" id="calc-nove" onclick="$(\'#calc-krok3\').hide(\'fast\'); $(\'#calc-krok1\').show(\'normal\'); return false;">Nové zadání...</a>\
<br><p>Tepelné ztráty vašeho domu jsou cca: <strong>' + celk_ztraty + 'kW</strong>	\n\
'+ (ztraty_bazen?"<br />Tepelné ztráty bazénu: <strong>"+ ztraty_bazen +"kW</strong>":"") +'	</p>\n\
\n\
<p>Doporučujeme využití tepelného čerpadla <strong>'+ cerp +'</strong>. Více info <a href="/tepelna_cerpadla/parametry">Zde</a></p>\n\
\n\
';

	   event.preventDefault();
   })
  /* $("#calc-nove").click(function(event){
	   $("#calc-krok3").hide("fast");
	   $("#calc-krok1").show("normal");
	   event.preventDefault();
   })*/
   $("#calc-ztraty").change(function(){
	   if(gi("calc-ztraty").value == "none"){
		   $(".calc-plocha input").removeAttr("disabled");
		   $(".calc-plocha").removeClass("disabled");
	   }else{
		   $(".calc-plocha input").attr("disabled","disabled");
		   $(".calc-plocha").addClass("disabled");
	   }
   })
   $(".calc-bazen-butt").change(function(){
	   if(document.getElementById("calc-bazen-ano").checked){
		   $("#calc-bazen").show();
	   }else{
		   $("#calc-bazen").hide();
	   }
   })

   /////////////////////////////////////     login
   $("#pozadavek").click(function(event){
	   $("#login-form-1").hide("normal");
	   $("#login-form-2").show("normal");
   })
   $("#pozadavek-zpet").click(function(event){
	   $("#login-form-1").show("normal");
	   $("#login-form-2").hide("normal");
   })
   $("#cerp_vice").click(function(event){
	   $("#cerp_vice").hide("slow");
	   $("#cerp_vice_info").show("normal");
   })
   $("#cerp_mene").click(function(event){
	   $("#cerp_vice").show("slow");
	   $("#cerp_vice_info").hide("normal");
   })
   //$("#anime_1").click(function(){
   /*
   var doba = 1500;
	   $("#anime_1").animate({left: "40", top: "0"},doba);
	   $("#anime_1 img").animate({width: "170", height: "150"},0).animate({width: "110", height: "110"},doba);
	   $("#anime_3").animate({fontSize: "19pt", left: "155", top: "25"},doba);
	   $("#anime_2").animate({left: "360", top: "20"},doba);
	   $("#anime_2 img").animate({width: "264", height: "107"},0).animate({width: "156", height: "63"},doba);
	   $("#anime_4").animate({fontSize: "19pt", left: "330", top: "70"},doba);
	   $("#anime_3").hover(function(){
			$("#anime_3").animate({fontSize: "17pt"},400).animate({fontSize: "18pt"},300);
			$("#anime_1 img").animate({width: "120", height: "120"},300).animate({width: "115", height: "115"},300);
	   })
	   $("#anime_3").mouseout(function(){
			$("#anime_3").animate({fontSize: "19pt"},200);
			$("#anime_1 img").animate({width: "110", height: "110"},200);
	   })
	   $("#anime_4").hover(function(){
			$("#anime_4").animate({fontSize: "17pt"},300).animate({fontSize: "18pt"},300);
			$("#anime_2 img").animate({width: "170", height: "68"},400).animate({width: "163", height: "65"},300);
	   })
	   $("#anime_4").mouseout(function(){
			$("#anime_4").animate({fontSize: "19pt"},200);
			$("#anime_2 img").animate({width: "156", height: "63"},200);
	   })
   //})
   */


   $(".tr0").mouseover(function(){ $(".tr0 td").addClass("bg3"); }); $(".tr0").mouseout(function(){ $(".tr0 td").removeClass("bg3"); })
   $(".tr1").mouseover(function(){ $(".tr1 td").addClass("bg3"); }); $(".tr1").mouseout(function(){ $(".tr1 td").removeClass("bg3"); })
   $(".tr2").mouseover(function(){ $(".tr2 td").addClass("bg3"); }); $(".tr2").mouseout(function(){ $(".tr2 td").removeClass("bg3"); })
   $(".tr3").mouseover(function(){ $(".tr3 td").addClass("bg3"); }); $(".tr3").mouseout(function(){ $(".tr3 td").removeClass("bg3"); })
   $(".tr4").mouseover(function(){ $(".tr4 td").addClass("bg3"); }); $(".tr4").mouseout(function(){ $(".tr4 td").removeClass("bg3"); })
   $(".tr5").mouseover(function(){ $(".tr5 td").addClass("bg3"); }); $(".tr5").mouseout(function(){ $(".tr5 td").removeClass("bg3"); })

   // administrace
   $(".del").click(function(event){
	   if(!confirm("opravdu chcete tuto polozku smazat?"))
		event.preventDefault();
   })


   
})



