function checkHotelReservation(frm, languageid) {
	if( (frm.reservationHotelID.tagName.toLowerCase()=="input" && frm.reservationHotelID.value=="14") || frm.reservationHotelID.options[frm.reservationHotelID.selectedIndex].value=="14") {
		var d; var m; var y; var n; var inDate; var outDate; var pack = "";
		if(frm.resDay) {
			d = frm.resDay.options[frm.resDay.selectedIndex].value;
			m = frm.resMonth.options[frm.resMonth.selectedIndex].value;
			y = frm.resYear.options[frm.resYear.selectedIndex].value;
			n = frm.resNights.options[frm.resNights.selectedIndex].value;
		} else if(frm.reservationDay) {
			d = frm.reservationDay.options[frm.reservationDay.selectedIndex].value;
			m = frm.reservationMonth.options[frm.reservationMonth.selectedIndex].value;
			y = frm.reservationYear.options[frm.reservationYear.selectedIndex].value;
			n = frm.reservationNights.options[frm.reservationNights.selectedIndex].value;
		}
		if(d) {
			inDate = new Date(y, m-1, d);
			outDate = new Date( inDate.getTime() + parseInt(n)*1000*60*60*24 );
		} else {
			if(frm.reservationNights) n = parseInt(frm.reservationNights.value);
			inDate = new Date(); outDate = new Date(inDate.getTime()+n*1000*60*60*24);
			pack = "&packageid=1";
		}
		frm.reset();
		return window.open("https://reservations.ihotelier.com/istay.cfm?hotelid=14832&languageid=" + languageid + "&DateIn=" + ( inDate.getMonth()+1 ) +"/"+ ( inDate.getDate() ) +"/"+ ( inDate.getYear() < 1000 ? inDate.getYear()+1900 : inDate.getYear() ) + "&DateOut=" + ( outDate.getMonth()+1 )  +"/"+  ( outDate.getDate() ) +"/"+ ( outDate.getYear() < 1000 ? outDate.getYear()+1900 : outDate.getYear() ) + pack );
	}
}

var rezervovat = function(form){

    var d = document.getElementById("day").options[document.getElementById("day").selectedIndex].value;
    var m = document.getElementById("month").options[document.getElementById("month").selectedIndex].value;
    var y = document.getElementById("year").options[document.getElementById("year").selectedIndex].value;
    var n = document.getElementById("nights").options[document.getElementById("nights").selectedIndex].value;

    Date.prototype.getRezervaceDateEnglish = function(){
        var year = new String(this.getFullYear()).substring(2,4);
        return ( this.getMonth()+1 )+"/"+ this.getDate() +"/"+year;
    }

    Date.prototype.getRezervaceDateEnglishUK = function(){
        var year = new String(this.getFullYear()).substring(2,4);
        return this.getDate()+"/"+ ( this.getMonth()+1 ) +"/"+year;
    }
    
    Date.prototype.getRezervaceDateSK = function(){
        return this.getDate()+"."+ ( this.getMonth()+1 ) +"."+this.getFullYear();
    }
    
    Date.prototype.getRezervaceDatePL = function(){
        var year = new String(this.getFullYear()).substring(2,4);
        return year+"-"+( (this.getMonth()<9?"0":"")+(this.getMonth()+1) )+"-"+(this.getDate()<10?"0":"")+this.getDate();
    }
    
    Date.prototype.getRezervaceDateES = function(){
        var year = new String(this.getFullYear()).substring(2,4);
        return this.getDate()+"/"+ ( (this.getMonth()<9?"0":"")+(this.getMonth()+1) ) +"/"+year;
    }
    
    Date.prototype.getRezervaceDateIT = function(){
        var year = new String(this.getFullYear()).substring(2,4);
        return this.getDate()+"/"+ ( (this.getMonth()<9?"0":"")+(this.getMonth()+1) ) +"/"+year;
    }

    Date.prototype.getRezervaceDate = function(){
		return this.getRezervaceDateEnglish();
    }
    
    var inDate = new Date();
    inDate.setDate(d);
    inDate.setMonth(m - 1);
    inDate.setYear(y);

    var netwrs = (form.propertyCode.options[form.propertyCode.selectedIndex].value.substring(0,4) == 'http' &&
        form.propertyCode.options[form.propertyCode.selectedIndex].value.indexOf('ihotelier.com')>=0);

    var params = '';
    form.inDate.value = inDate.getRezervaceDate();

    var outDate = new Date( inDate.getTime() + parseInt(n)*1000*60*60*24 );
    form.outDate.value = outDate.getRezervaceDate();

    if(form.propertyCode.options[form.propertyCode.selectedIndex].value.substring(0,4) == 'http' )
    {
    	if(lang=='cs') {
	    	var langID = 18;
	    } else {
	    	var langID = 1;
	    }
        if(netwrs) params = 'search/' 
        			+ lang + '/?FROM=' 
        			+ y +'-'+ m +'-'+ d + '&TO=' 
        			+ ( ( outDate.getYear() < 1000 ? outDate.getYear()+1900 : outDate.getYear() ) +'-'+ ( outDate.getMonth()+1 ) +'-'+ ( outDate.getDate() ) );
        if(netwrs) params = 'istay.cfm?hotelid=14832&languageid=' + langID + '&DateIn=' + m +'/'+ d +'/'+ y + '&DateOut=' + ( ( outDate.getMonth()+1 )  +'/'+  ( outDate.getDate() ) +'/'+ ( outDate.getYear() < 1000 ? outDate.getYear()+1900 : outDate.getYear() ) );			
        window.open(form.propertyCode.options[form.propertyCode.selectedIndex].value + params, '_blank');
        return false;
    }

	//chybova hlaska pro resportal
	//if(rxmatch=window.location.pathname.toString().match(/^[/]?([a-z]{2,2})/))
	//	window.open("/" + rxmatch[1] + "/resportal/", '_blank');
    //window.open("https://booking.oreahotels.com/listRoomTypes.do?action="+form.action.value+"&propertyCode="+form.propertyCode.options[form.propertyCode.selectedIndex].value+"&inDate="+form.inDate.value+"&outDate="+form.outDate.value+"&adults="+form.adults.value+"&children="+form.children.value+"&rooms="+form.rooms.value+"&cid="+form.cid.value, '_blank');
    window.open("https://booking.oreahotels.com/", '_blank');
    return false;
}
