priceList = new Array( new Array(226,410,600,400,800,600), new Array(501,1030,350,200,550,400), new Array(1226,103,1150,850,1350,1050), new Array(103,129,700,500,900,700), new Array(129,226,800,600,1000,800), new Array(501,1030,350,200,550,350), new Array(1201,1218,500,300,700,500), new Array(1218,1226,700,500,900,700)); function dateStruct(day, month, year){ function print(){ return this.day+"."+this.month+"."+this.year; } function nextMonth(){ this.month++; if(this.month==13){ this.month=1; this.year++; } } function nextDay(){ if(this.day<28){this.day++;return;} if(this.day==31){this.day=1;this.nextMonth();return;} if(this.day==30 && (this.month==4 || this.month==6 || this.month==9 || this.month==11)){this.day=1;this.nextMonth();return;} if(this.month==2){ if(this.day==28 && this.year%4!=0){this.day=1;this.nextMonth();return;} if(this.day==29){this.day=1;this.nextMonth();return;} } this.day++ }; function getNum(){ ret = (this.month*100+parseInt(this.day)); return ret; } function inRange(from, to){ number = this.getNum(); if(from<=number && number < to)return true; if(from>to){ if(from <= number && number > to)return true; if(from >= number && number < to)return true; } return false; } function getPrice(hint){ number = this.getNum(); if(hint!=null){ if(this.inRange(priceList[hint][0],priceList[hint][1]))return new priceStruct(priceList[hint][2],priceList[hint][3], hint,priceList[hint][4], priceList[hint][5]); if(this.inRange(priceList[(hint+1)%priceList.lenght][0],priceList[(hint+1)%priceList.lenght][1]))return new priceStruct(priceList[hint][2],priceList[hint][3],(hint+1)%priceList.lenght,priceList[hint][4], priceList[hint][5]); } for(x=0;x
"); price = 0; days=0; toNum = dateTo.getNum(dateTo); while(dateFrom.getNum()<=toNum){ days++; win.document.writeln("Den "+days+". - "+dateFrom.print()+":"); dayPrice = dateFrom.getPrice(); if(dayPrice==null)break; if(dayPrice.isSomer){ win.document.writeln(" Zaklad (leto):"+dayPrice.price1+"*"+dospeli+" + "+dayPrice.price2+"*"+deti); price += dayPrice.price1*dospeli + dayPrice.price2*deti; if(polopenze){ price += 140*dospeli + 90*deti; win.document.writeln(" Polopenze:"+ 140+"*"+dospeli+" + "+90+"*"+deti); } if(dospeli+deti<2 && dospeli+deti>0){ price += 100; win.document.writeln(" Penalizace:"+ 100); } } else{ win.document.writeln(" Zaklad (zima):"+dayPrice.price1+"*"+dospeli+" + "+dayPrice.price2+"*"+deti+"*"+0.9); price += dayPrice.price1*dospeli + Math.round(dayPrice.price2*deti*0.9); if(polopenze){ price += 140*(dospeli+deti); win.document.writeln(" Polopenze:"+ 140+"*"+dospeli+" + "+140+"*"+deti); } if(dospeli+deti<2 && dospeli+deti>0){ price += 140; win.document.writeln(" Penalizace:"+ 140); } } dateFrom.nextDay(); win.document.writeln("
"); } if(days<3)price*=1.3; object = document.getElementById("priceField"); object.innerHTML=Math.floor(price); }