<!--
var a,b,c,d,e,r,visa,transfer,rebate,week1,week2,room1,room2,total,price_of_course,cur_val,price_of_room;


function group()
{
  if (document.priceForm.typeofTuition.selectedIndex == 1)
  window.alert("A two to four week group course with max 6 participants and 20 lessons per week starts every week on Monday. Other group courses can start at any other time if you apply as a group with min 3 people. If you apply as a group of more than 4 students we will be happy to make an individual offer reflecting further discounts.");
}

function group_de()
{
  if (document.priceForm.typeofTuition.selectedIndex == 1)
  window.alert("2, 3 und 4-Wochen Gruppenkurse für Anfänger und Mittleres Niveau mit 20 Lektionen pro Woche starten jeden Montag. Spezielle Gruppenkurse sind auch möglich, wenn sich eine Gruppe (min 3 Personen) mit gleichen Kenntnissen gleichzeitig anmeldet. Melden Sie eine Gruppe von mehr als 4 Personen an, machen wir gerne eine individuelle Offerte.");
}

function group_fr()
{
  if (document.priceForm.typeofTuition.selectedIndex == 1)
  window.alert("Un cours de de group de 2, 3 oubien 4 semaines pour débutants et niveau intermédiaire avec 20 lecons par semaine commence chaque semaine le lundi. Des cours de groupes speciales sont aussi possibles si votre groupe (min 3 personnes avec des connaissances de Russe equivalentes) s'inscrit en même temps. Si vous êtes un groupe de plus de 4 personnes, nous pouvons vous offrir des prix encore plus favorables.");
}

function min2weeks()
{
if (document.priceForm.duration.value==1)
window.alert("The minumum length of stay is 2 weeks in order to guarantee an effective tuition. Please modify your input.");
}

function min2weeks_de()
{
if (document.priceForm.duration.value==1)
window.alert("Um einen optimalen Lerneffekt zu erzielen, haben wir die minimale Aufenthaltsdauer in Moskau auf 2 Wochen festgelegt. Bitte ändern und neu eingeben.");
}


function min2weeks_fr()
{
if (document.priceForm.duration.value==1) 
window.alert("Pour garantir un séjour optimal, la durée minimale est de 2 semaines. Veuillez corriger vos données.");
}

function calculate()
{ 
  a=document.priceForm.typeofCourse.selectedIndex;
  b=document.priceForm.duration.value;
  c=document.priceForm.accomodation.selectedIndex;
  d=document.priceForm.typeofTuition.selectedIndex;
  e=document.priceForm.typeofProg.selectedIndex;
  var selection=document.priceForm.currency;
  f=selection.options[selection.selectedIndex].value;

r=5;
adj=1;

if (f=="GBP") {curr=adj*0.95; currtext="£ ";}
if (f=="USD") {curr=adj*1.56; currtext="$ ";}
if (f=="CAN") {curr=adj*1.70; currtext="Can ";}
if (f=="AUS") {curr=adj*2.00; currtext="Aus$ ";}
if (f=="EUR") {curr=adj; currtext="Euro ";}
if (f=="YEN") {curr=adj*158; r=100; currtext="Yen ";}
if (f=="RUR") {curr=adj*50; r=100; currtext="Ru ";}
if (f=="SFR") {curr=adj*1.60; r=5; currtext="SFr ";}

  
if (b==0) {b=2;}
if (b==1) {b=2;}

  if (c==0) room1=round(140*curr,r);
  if (c==1) room1=round(180*curr,r);
  if (c==2) room1=round(160*curr,r);
  if (c==3) room1=round(560*curr,r);
  if (c==4) room1=0;

if (b>4)
 {
  if (c==0) room2=round(120*curr,r);
  if (c==1) room2=round(160*curr,r);
  if (c==2) room2=round(140*curr,r);
  if (c==3) room2=round(560*curr,r);
  if (c==4) room2=0;
 }
 
 if (d == 0)
  {
  if (e == 0)
   {
    if (a == 0)  week1=2*round(300*curr,r)-round(250*curr,r);
    if (a == 1)  week1=round(300*curr,r);
    if (a == 2)  week1=round(250*curr,r);
   if (b>4)
    { 
    if (a == 0)  week2=2*round(290*curr,r)-round(240*curr,r);
    if (a == 1)  week2=round(290*curr,r);
    if (a == 2)  week2=round(240*curr,r);
    }
   }
  if (e == 1)
   {
    if (a == 0)  week1=2*round(400*curr,r)-round(320*curr,r);
    if (a == 1)  week1=round(400*curr,r);
    if (a == 2)  week1=round(320*curr,r);
   if (b>4) 
    { 
    if (a == 0)  week2=2*round(370*curr,r)-round(300*curr,r);
    if (a == 1)  week2=round(370*curr,r);
    if (a == 2)  week2=round(300*curr,r);
    }
   }
  }

if (d == 1)
  {
  if (e == 0)
   {
    if (a == 0)  week1=2*round(200*curr,r)-round(170*curr,r);
    if (a == 1)  week1=round(200*curr,r);
    if (a == 2)  week1=round(170*curr,r);
   if (b>4) 
    { 
    if (a == 0)  week2=2*round(190*curr,r)-round(160*curr,r);
    if (a == 1)  week2=round(190*curr,r);
    if (a == 2)  week2=round(160*curr,r);
    }
   }
  if (e == 1)
   {
    if (a == 0)  week1=2*round(250*curr,r)-round(200*curr,r);
    if (a == 1)  week1=round(250*curr,r);
    if (a == 2)  week1=round(200*curr,r);
   if (b>4) 
    { 
    if (a == 0)  week2=2*round(230*curr,r)-round(190*curr,r);
    if (a == 1)  week2=round(230*curr,r);
    if (a == 2)  week2=round(190*curr,r);
    }
   }
  }
 
if (b<5)
{
 price_of_course=b*week1;
 price_of_room=b*room1;
}

if ((b>4) && (b<15))
 {
 price_of_course=4*week1+(b-4)*week2;
 price_of_room=4*room1+(b-4)*room2;
 }
if (b>=15)
 {
 price_of_course=4*week1+11*week2+(b-15)*week2*0.9;
 price_of_room=4*room1+11*room2+(b-15)*room2*0.9;
 }  
 if (b>=32)  
 {
 price_of_course=4*week1+11*week2+17*week2*0.9+(b-32)*week2*0.8;
 price_of_room=4*room1+11*room2+17*room2*0.9+(b-32)*room2*0.8;
 }
 visa=0;
 if (document.priceForm.visacheck.checked) visa=40;
 fee=98;
 transfer=0; transfer1=0; transfer2=0;
 if (document.priceForm.transfercheck1.checked) 
 {
   if (d==0) transfer1=50;
   if (d==1) transfer1=50;
 }

 if (document.priceForm.transfercheck2.checked) 
 {
   if (d==0) transfer2=40;
   if (d==1) transfer2=40;
 }


 transfer1=round(transfer1*curr,r);
 transfer2=round(transfer2*curr,r);
 transfer=transfer1+transfer2;
 fee=round(fee*curr,r);
 visa=round(visa*curr,r);
 price_of_course=round(price_of_course,r);
 price_of_room=round(price_of_room,r);
 total=price_of_course+price_of_room+visa+transfer+fee;
 document.priceForm.Course.value=currtext+price_of_course+".-";
 document.priceForm.Room.value=currtext+price_of_room+".-";
 document.priceForm.Visa.value=currtext+visa+".-";
 document.priceForm.Transfer.value=currtext+transfer+".-";
 document.priceForm.Fee.value=currtext+fee+".-";
 document.priceForm.Total.value=currtext+total+".-";
} 


// This function rounds up the value to the next decimal

function round(cur_val,r)
{
rest=cur_val%r;
 if (rest>r/2) rest=rest-r;
cur_val=cur_val-rest;
return cur_val;
}
// -->

function AdjustfirstDate()
{
var today = new Date();
var year = parseInt(today.getYear(),10)
var day = today.getDay();
var month = today.getMonth() +1;
var date = today.getDate();

if (year<2000) year=year+1900;
if (year==2011) yearId=0;
if (year==2012) yearId=1;
if (year==2013) yearId=2;
if (year==2014) yearId=3;


weeksad = 6;
nbDays1 = weeksad*7-day+1;
form1 = "Course_";
form2 = "_from";
getnewDate(month, date, yearId, nbDays1, form1, form2);

AdjustFields() 
}

function getDaysInMonth(month, yearindex)
{
// all the rest have 31
var maxDays=31
// except Feb
if (month==2)
        {
        if (yearindex==1)
                {
                maxDays=29;
                }
        else 
                {
                maxDays=28;
                }
        }

if (month==4 || month==6 || month==9 || month==11)
        {
        maxDays=30;
        }
return maxDays;
}

function getnewDate(oldMonth, oldDay, oldYearIndex, nbDays, thisform1, thisform2) 

{
var month=oldMonth;
var yearindex=oldYearIndex;
var day = nbDays + oldDay;

while (day <= 0)
        {
        month = month -1;
        if (month < 1)
                {
                month = 12;
                yearindex = yearindex - 1;
                }
        daysinMonth = getDaysInMonth(month, yearindex);
	nbDays = nbDays + daysinMonth;
	day = nbDays + oldDay;
        }

daysinMonth = getDaysInMonth(month, yearindex);

while  (day > daysinMonth) 
        {
        nbDays = nbDays - daysinMonth;
	month = month + 1;
        if (month == 13)
                {
		month = 1;
		yearindex = yearindex + 1;
		}
	daysinMonth = getDaysInMonth(month, yearindex);
        day = nbDays + oldDay;
        }

var year=yearindex+2011;

weekday=getweekday(year, month, day);

thisforma = thisform1+"month"+thisform2;

for (var i = 0; i < document.priceForm.elements.length; i++) {
      if (document.priceForm.elements[i].name == thisforma) p=i;
   }

document.priceForm.elements[p].selectedIndex=month-1;
document.priceForm.elements[p+1].selectedIndex=day-1;
document.priceForm.elements[p+2].selectedIndex=yearindex;
document.priceForm.elements[p+3].value=weekday;
}

function getweekday(year, month, day)
{
var thisday = new Date(year,month-1,day);
d=thisday.getDay();

if (d == 0) weekday = "Sun";
if (d == 1) weekday = "Mon";
if (d == 2) weekday = "Tue";
if (d == 3) weekday = "Wed";
if (d == 4) weekday = "Thu";
if (d == 5) weekday = "Fri";
if (d == 6) weekday = "Sat";

return weekday;
}

function aw(d)

{
if (d==1) 
{
formname="Course_weekday_to";
var month=document.priceForm.Course_month_to.selectedIndex + 1;
var day=document.priceForm.Course_day_to.selectedIndex + 1;
var year=document.priceForm.Course_year_to.selectedIndex + 2011;
}

if (d==2) 
{
formname="Acco_weekday_from";
var month=document.priceForm.Acco_month_from.selectedIndex + 1;
var day=document.priceForm.Acco_day_from.selectedIndex + 1;
var year=document.priceForm.Acco_year_from.selectedIndex + 2011;
}

if (d==3) 
{
formname="Acco_weekday_to";
var month=document.priceForm.Acco_month_to.selectedIndex + 1;
var day=document.priceForm.Acco_day_to.selectedIndex + 1;
var year=document.priceForm.Acco_year_to.selectedIndex + 2011;
}

if (d==4) 
{
formname="Visa_weekday_from";
var month=document.priceForm.Visa_month_from.selectedIndex + 1;
var day=document.priceForm.Visa_day_from.selectedIndex + 1;
var year=document.priceForm.Visa_year_from.selectedIndex + 2011;
}

if (d==5) 
{
formname="Visa_weekday_to";
var month=document.priceForm.Visa_month_to.selectedIndex + 1;
var day=document.priceForm.Visa_day_to.selectedIndex + 1;
var year=document.priceForm.Visa_year_to.selectedIndex + 2011;
}

weekday=getweekday(year, month, day);

for (var i = 0; i < document.priceForm.elements.length; i++) {
      if (document.priceForm.elements[i].name == formname) p=i;
   }
document.priceForm.elements[p].value=weekday;

}

function AdjustFields() 
{
var nbWeeks=document.priceForm.duration.value;
var oldmonth=document.priceForm.Course_month_from.selectedIndex + 1;
var oldday=document.priceForm.Course_day_from.selectedIndex + 1;
var oldyearIndex=document.priceForm.Course_year_from.selectedIndex;

oldyear=2011+yearId;

//check if given date is possible
check = getDaysInMonth(oldmonth, oldyearIndex);
if (oldday > check) 
	{
	oldday = check;
	document.priceForm.Course_day_from.selectedIndex=check -1;
}


nbDays = 0;
form1 = "Course_";
form2 = "_from";

getnewDate(oldmonth, oldday, oldyearIndex, nbDays, form1, form2);

nbDays = nbWeeks*7-3;
form1 = "Course_";
form2 = "_to";
getnewDate(oldmonth, oldday, oldyearIndex, nbDays, form1, form2);

nbDays = -1;
form1 = "Acco_";
form2 = "_from";
getnewDate(oldmonth, oldday, oldyearIndex, nbDays, form1, form2);

nbDays = nbWeeks*7-1;
form1 = "Acco_";
form2 = "_to";
getnewDate(oldmonth, oldday, oldyearIndex, nbDays, form1, form2);

nbDays = -4;
form1 = "Visa_";
form2 = "_from";
getnewDate(oldmonth, oldday, oldyearIndex, nbDays, form1, form2);

nbDays = nbWeeks*7;
form1 = "Visa_";
form2 = "_to";
getnewDate(oldmonth, oldday, oldyearIndex, nbDays, form1, form2);
}

// -->

