﻿//Addpersons
function addPersons(number){
	var sHTML ="";
	if(number>0){
		sHTML = "<table style='border:none; border-collapse:none;'><tr><td>Person #</td><td>Last Name</td><td>First Name</td></tr>";
	}
	for(var i = 1; i<= number;i++){
		var fName = "";
		var nName = "";
		if(document.getElementById("firstName"+i)){
			fName = document.getElementById("firstName"+i).value;
			nName = document.getElementById("lastName"+i).value;
		}
		var num=i+1;
		sHTML = sHTML + "<tr><td>"+num+"</td><td><input name='firstName"+i+"' id='firstName"+i+"' type='text' class='txtinput'  size='25' value='"+fName+"'>*</td><td><input name='lastName"+i+"' id='lastName"+i+"' type='text' class='txtinput'  size='25' value='"+nName+"'>*</td><tr>"
	
	}
	document.getElementById("addPersons").innerHTML = sHTML;
}

//change departureDate in packages
function changeDepartureDate(days){
	var arvDay;
	var arvMonth;
	var arvYear;
	
	arvDay = document.getElementById("arrivalDay").options[document.getElementById("arrivalDay").selectedIndex].text;
	arvMonth = document.getElementById("arrivalMonth").options[document.getElementById("arrivalMonth").selectedIndex].text;
	arvYear = document.getElementById("arrivalYear").options[document.getElementById("arrivalYear").selectedIndex].text;
	
	var departure;
	departure = Date.UTC(arvYear,arvMonth,arvDay,12,0,0);
	departure = departure + ((days-1)*(24*60*60*1000));
	
	var departureDate = new Date(departure);
	
	var depDay = departureDate.getDate();
	var depMonth = departureDate.getMonth();
	var depYear = departureDate.getFullYear();
	
	document.getElementById("divDepartureDate").innerHTML = depDay+"."+depMonth+"."+depYear;
}


//Popup for rooms and materials

function popRoom(hotelbezeichnung, stars, hoteldescription, roomID, bezeichnung, description, beds, price, path){
	var x = (screen.width/2) -250;
	var y = (screen.height/2) -150;
	Ausgabe = window.open("", "displayWindow", "height=300,width=500,menubar=no,toolbar=no,directories=no,scrollbars=no,resizable=no,status=no,location=no, left="+x+", top="+y);
	
	testseite = Ausgabe.document;
	
	
	
	sOuputHTML =  "<div style='margin-bottom:10px;'><b>"+hotelbezeichnung+"</b><br>"+stars+" Stars<br><br>"+hoteldescription+"</div><div style='float:left;padding-right:3px;'><img src ='"+path+"' alt='"+bezeichnung+"'><\/div><div><div><b>"+bezeichnung+"</b><\/div><div>"+beds+" Beds<\/div><div>Price Per Night: "+price+"<\/div>" + "<div style='float:left;padding-left:3px;'><div>"+description+"<\/div><\/div><\/div>";
	
	Inhalt = "<html><body style='font-family:arial;font-size:12px; background-color: #FFFFFF;'>"+sOuputHTML+"</body></html>";
	
	testseite.open();
	testseite.write(Inhalt);
	testseite.close();
}

function popMaterial(materialID, bezeichnung, parameterMatGr, parameterMat, path){
	var x = (screen.width/2) -250;
	var y = (screen.height/2) -150;
	Ausgabe = window.open("", "displayWindow", "height=300,width=500,menubar=no,toolbar=no,directories=no,scrollbars=no, resizable=no,status=no,location=no, left="+x+", top="+y);
	
	testseite = Ausgabe.document;
		
	sOuputHTML = "<div style='float:left;padding-right:3px;'><img src ='"+path+"' alt='"+bezeichnung+"' width='200px'><\/div>" + "<div style='float:left;'><div>"+bezeichnung+"<\/div>";
  
	for(var i = 0; i < parameterMatGr.length; i++){
	sOuputHTML = sOuputHTML + "<div>"+parameterMatGr[i]+":"+parameterMat[i]+"</div>";
	}
	sOuputHTML = sOuputHTML + "</div>"
	Inhalt = "<html><body style='font-family:arial;font-size:12px; background-color: #FFFFFF;'>"+sOuputHTML+"</body></html>";
	
	testseite.open();
	testseite.write(Inhalt);
	testseite.close();

}


//changeMaterialDate

function changeMaterialDate(num, FromDay, FromMonth, FromYear, ToDay, ToMonth, ToYear){
	window.location.href = "index.php?sid=5&bid=5&num="+num+"&fDay="+FromDay+"&fMonth="+FromMonth+"&fYear="+FromYear+"&tDay="+ToDay+"&tMonth="+ToMonth+"&tYear="+ToYear;
}


//processBooking Funcitons

function NextPage(){
	document.forms[0].submit();
}
function NextPage2(){
	document.forms[1].submit();
}
function PreviousPage(ID, num){
	if(num == "none"){
		num2 = "";
	}
	else{
		num2 = "&num="+num;
	}
	window.location.href = "index.php?sid=5&bid="+ID+num2;
}
function SkipPage(ID){
	window.location.href = "index.php?sid=5&bid="+ID+"&skip=1";
}




function Storno(ID){
	window.location.href = "index.php?sid=8&admin=6&Storno="+ID;
}

function AdminDeleteRoom(ID){
	var abfrage = confirm("Wollen Sie wirklich löschen?");
	if(abfrage == true)
		window.location.href = "index.php?sid=8&admin=1&DRId="+ID;
}

function AdminHotelDeleteRoom(ID){
	var abfrage = confirm("Wollen Sie wirklich löschen?");
	if(abfrage == true)
		window.location.href = "index.php?sid=9&DRId="+ID;
}

function AdminReserveRoom(ID, startDay, startMonth, startYear, endDay, endMonth, endYear){
	window.location.href = "index.php?sid=8&admin=1&RId="+ID+"&startYear="+startYear+"&startMonth="+startMonth+"&startDay="+startDay+"&endYear="+endYear+"&endMonth="+endMonth+"&endDay="+endDay;
}
function AdminHotelReserveRoom(ID, startDay, startMonth, startYear, endDay, endMonth, endYear){
	window.location.href = "index.php?sid=9&RId="+ID+"&startYear="+startYear+"&startMonth="+startMonth+"&startDay="+startDay+"&endYear="+endYear+"&endMonth="+endMonth+"&endDay="+endDay;
}

function AdminDeleteMaterial(ID){
	var abfrage = confirm("Wollen Sie wirklich löschen?");
	if(abfrage == true)
		window.location.href = "index.php?sid=8&admin=4&DRId="+ID;
}

function AdminReserveMaterial(ID, startDay, startMonth, startYear, endDay, endMonth, endYear){
	window.location.href = "index.php?sid=8&admin=4&RId="+ID+"&startYear="+startYear+"&startMonth="+startMonth+"&startDay="+startDay+"&endYear="+endYear+"&endMonth="+endMonth+"&endDay="+endDay;
}
function AdminDeleteCar(ID){
	var abfrage = confirm("Wollen Sie wirklich löschen?");
	if(abfrage == true)
		window.location.href = "index.php?sid=8&admin=3&DRId="+ID;
}

function AdminReserveCar(ID, startDay, startMonth, startYear, endDay, endMonth, endYear){
	window.location.href = "index.php?sid=8&admin=3&RId="+ID+"&startYear="+startYear+"&startMonth="+startMonth+"&startDay="+startDay+"&endYear="+endYear+"&endMonth="+endMonth+"&endDay="+endDay;
}

function ChangeBooking(ID){
	window.location.href = "index.php?sid=8&admin=6&SRId="+ID;
}

function ChangeRoom(ID){
	window.location.href = "index.php?sid=5&bid=2&SRId="+ID;
}

function selectedChangeRoom(ID,SID){
	window.location.href = "index.php?sid=5&bid=2&SRId="+ID+"&SSId="+SID;
}

function ChangeMaterial(ID){
	window.location.href = "index.php?sid=5&bid=5&SRId="+ID;
}

function selectedChangeMaterial(ID){
	window.location.href = "index.php?sid=5&bid=5&SSId="+ID;
}

function ChangeLesson(ID){
	window.location.href = "index.php?sid=5&bid=6&SLId="+ID;
}

function selectedChangeLesson(ID,SID){
	window.location.href = "index.php?sid=5&bid=6&SRId="+ID+"&SSId="+SID;
}

function ChangeCar(ID){
	window.location.href = "index.php?sid=5&bid=4&SRId="+ID;
}

function changeRoom(ID){
	window.location.href = "index.php?sid=5&bid=4&SSId="+ID;
}

function SelectRoom(ID) {
	window.location.href = "index.php?sid=5&bid=2&status=select&hid="+ID+"&price=undefined";
}

function RemoveRoom(ID) {
	window.location.href = "index.php?sid=5&bid=2&status=remove&hid="+ID;
}

function SelectCar(ID) {
	window.location.href = "index.php?sid=5&bid=4&status=select&hid="+ID;
}

function RemoveCar(ID) {
	window.location.href = "index.php?sid=5&bid=4&status=remove&hid="+ID;
}

function SelectMat(ID, start, end) {
	window.location.href = "index.php?sid=5&bid=5&status=select&hid="+ID+"&startDate="+start+"&endDate="+end;
}

function RemoveMat(ID) {
	window.location.href = "index.php?sid=5&bid=5&status=remove&hid="+ID;
}

function AddLesson(ID,PID, firstMonth, firstDay, firstYear, firstHour, firstMinute) {
	window.location.href = "index.php?sid=5&bid=6&add=1&ALID="+ID+"&ALPID="+PID+"&firstMonth="+firstMonth+"&firstDay="+firstDay+"&firstYear="+firstYear+"&firstHour="+firstHour+"&firstMinute="+firstMinute;
}

function RemoveLesson(ID) {
	window.location.href = "index.php?sid=5&bid=6&remove=1&RLID="+ID;
}

function adminChangeHotel(ID){
	window.location.href = "index.php?sid=8&admin=1&SSID="+ID;
}

function adminChangeRoom(ID,RID){
	window.location.href = "index.php?sid=8&admin=1&SSID="+ID+"&SRId="+RID;
}

function hotelChangeRoom(ID,RID){
	window.location.href = "index.php?sid=9&SSID="+ID+"&SRId="+RID;
}

function DeleteHotel(ID){
	var abfrage = confirm("Wollen Sie wirklich löschen?");
	if(abfrage == true)
		window.location.href = "index.php?sid=8&admin=1&DelID="+ID;
}
function DeleteRoom(ID, RID){
	var abfrage = confirm("Wollen Sie wirklich löschen?");
	if(abfrage == true)
		window.location.href = "index.php?sid=8&admin=1&SSID="+ID+"&DelID="+RID;
}

function adminChangeTransfer(ID){
	window.location.href = "index.php?sid=8&admin=2&STId="+ID;
}

function DeleteTransfer(ID){
	var abfrage = confirm("Wollen Sie wirklich löschen?");
	if(abfrage == true)
		window.location.href = "index.php?sid=8&admin=2&DelID="+ID;
}

function adminChangeCar(ID){
	window.location.href = "index.php?sid=8&admin=3&SRId="+ID;
}

function DeleteCar(ID){
	var abfrage = confirm("Wollen Sie wirklich löschen?");
	if(abfrage == true)
		window.location.href = "index.php?sid=8&admin=3&DelID="+ID;
}

function adminChangeLesson(ID){
	window.location.href = "index.php?sid=8&admin=5&SSId="+ID;
}

function DeleteLesson(ID){
	var abfrage = confirm("Wollen Sie wirklich löschen?");
	if(abfrage == true)
		window.location.href = "index.php?sid=8&admin=5&DelID="+ID;
}

function adminChangeLessonPrice(LID, ID){
	window.location.href = "index.php?sid=8&admin=5&SSId="+LID+"&SPId="+ID;
}

function DeleteLessonPrice(LID, ID){
	var abfrage = confirm("Wollen Sie wirklich löschen?");
	if(abfrage == true)
		window.location.href = "index.php?sid=8&admin=5&SSId="+LID+"&DelPriceID="+ID;
}

function adminChangeMatGroup(ID){
	window.location.href = "index.php?sid=8&admin=4&SSID="+ID;
}

function adminChangeMaterial(ID,RID){
	window.location.href = "index.php?sid=8&admin=4&SSID="+ID+"&SRId="+RID;
}
function adminChangeParameter(ID,RID){
	window.location.href = "index.php?sid=8&admin=4&SSID="+ID+"&SPId="+RID;
}
function adminChangeInput(ID,RID){
	window.location.href = "index.php?sid=8&admin=4&SSID="+ID+"&SIId="+RID;
}
function adminChangeMaterialGroupPrice(ID,RID){
	window.location.href = "index.php?sid=8&admin=4&SSID="+ID+"&SMGPId="+RID;
}

function DeleteMatGroup(ID){
	var abfrage = confirm("Wollen Sie wirklich löschen?");
	if(abfrage == true)
		window.location.href = "index.php?sid=8&admin=4&DelID="+ID;
}
function DeleteMaterial(ID, RID){
	var abfrage = confirm("Wollen Sie wirklich löschen?");
	if(abfrage == true)
		window.location.href = "index.php?sid=8&admin=4&SSID="+ID+"&DelID="+RID;
}

function DeleteCustomer(ID){
	var abfrage = confirm("Wollen Sie wirklich löschen?");
	if(abfrage == true)
		window.location.href = "index.php?sid=8&admin=0&DelID="+ID;
}

function adminChangeCustomer(ID){
	window.location.href = "index.php?sid=8&admin=0&SSId="+ID;
}

function orderMaterial(direction,ID, RID)
{
		window.location.href = "index.php?sid=8&admin=4&SSID="+ID+"&orderID="+RID+"&direction="+direction;
}
