function IntresBooker(){}
IntresBooker.prototype.baseAddr = "https://varaamo3.matkaverkko.fi/scripts/matkavekka/fi/Intres4.dll/oma_matkat?";
IntresBooker.prototype.type = "AS";
IntresBooker.prototype.country = "FIN";
IntresBooker.prototype.adults = 2;
IntresBooker.prototype.children = 0;
IntresBooker.prototype.infants = 0;
IntresBooker.prototype.filter = "EI_RAJAUSTA";
IntresBooker.prototype.operator = "PIILOAGENTTI";
IntresBooker.prototype.winopts = null;
IntresBooker.prototype.priceGroup = "N0";

IntresBooker.prototype.openBooker = function(input1, input2, input3, priceGroup){
	var winAddr = null;
	
	if(this.type == "AS"){
		var queryOpts = new Array();
			queryOpts.push("tyyppi=" + this.type);
			queryOpts.push("maa=" + this.country);
			queryOpts.push("Valittu_Aikuisia=" + this.adults);
			queryOpts.push("Valittu_Lapsia=" + this.children);
			queryOpts.push("Valittu_IlmLapsia=" + this.infants);
			
			if(priceGroup != null && priceGroup != "")
				queryOpts.push("Valittu_HinnastoRyhma=" + priceGroup);
			else
				queryOpts.push("Valittu_HinnastoRyhma=" + this.priceGroup);
			
			if(input1 != null && input2 != null && input3 != null){
				queryOpts.push("CLASS1=" + input1);
				queryOpts.push("CLASS2=" + input2);
				queryOpts.push("CLASS3=" + input3);
			}
			queryOpts.push("Valittu_Rajaus=" + this.filter);
		
		winAddr = this.baseAddr + queryOpts.join("&");
	}
	else if(this.type == "AG"){
		var queryOpts = new Array();
			queryOpts.push("TYYPPI=" + this.type);
			queryOpts.push("MAA=" + this.country);
			
			if(input1 != null && input2 != null && input3 != null){
				queryOpts.push("AGNRO=" + input1);
				queryOpts.push("USERNAME=" + input2);
				queryOpts.push("PASSWORD=" + input3);
			}
			
			queryOpts.push("OPER=" + this.operator);
			queryOpts.push("VALITTU_AIKUISIA=" + this.adults);
		
		winAddr = this.baseAddr + queryOpts.join("&");
	}
	
	if(winAddr != null){
		var winInstance = window.open(winAddr);
		return winInstance;
	}
	else{
		return null;
	}
}
