function mktime() {
    var d = new Date(), r = arguments, i = 0,
        e = ['Hours', 'Minutes', 'Seconds', 'Month', 'Date', 'FullYear'];
 
    for (i = 0; i < e.length; i++) {        if (typeof r[i] === 'undefined') {
            r[i] = d['get' + e[i]]();
            r[i] += (i === 3); // +1 to fix JS months.
        } else {
            r[i] = parseInt(r[i], 10);            if (isNaN(r[i])) {
                return false;
            }
        }
    }    
    // Map years 0-69 to 2000-2069 and years 70-100 to 1970-2000.
    r[5] += (r[5] >= 0 ? (r[5] <= 69 ? 2e3 : (r[5] <= 100 ? 1900 : 0)) : 0);
    
    // Set year, month (-1 to fix JS months), and date.    // !This must come before the call to setHours!
    d.setFullYear(r[5], r[3] - 1, r[4]);
    
    // Set hours, minutes, and seconds.
    d.setHours(r[0], r[1], r[2]); 
    // Divide milliseconds by 1000 to return seconds and drop decimal.
    // Add 1 second if negative or it'll be off from PHP by 1 second.
    return (d.getTime() / 1e3 >> 0) - (d.getTime() < 0);
}

function strtotime (str, now) {
    var i, match, s, strTmp = '', parse = '';
 
    strTmp = str;    strTmp = strTmp.replace(/\s{2,}|^\s|\s$/g, ' '); // unecessary spaces
    strTmp = strTmp.replace(/[\t\r\n]/g, ''); // unecessary chars
 
    if (strTmp == 'now') {
        return (new Date()).getTime()/1000; // Return seconds, not milli-seconds  
        } else if (!isNaN(parse = Date.parse(strTmp))) {
        return (parse/1000);
    } else if (now) {
        now = new Date(now*1000); // Accept PHP-style seconds
    } else {        now = new Date();
    }
 
    strTmp = strTmp.toLowerCase();
     var __is =
    {
        day:
        {
            'sun': 0,            'mon': 1,
            'tue': 2,
            'wed': 3,
            'thu': 4,
            'fri': 5,            'sat': 6
        },
        mon:
        {
            'jan': 0,            'feb': 1,
            'mar': 2,
            'apr': 3,
            'may': 4,
            'jun': 5,            'jul': 6,
            'aug': 7,
            'sep': 8,
            'oct': 9,
            'nov': 10,            'dec': 11
        }
    };
 
    var process = function (m) {        var ago = (m[2] && m[2] == 'ago');
        var num = (num = m[0] == 'last' ? -1 : 1) * (ago ? -1 : 1);
 
        switch (m[0]) {
            case 'last':            case 'next':
                switch (m[1].substring(0, 3)) {
                    case 'yea':
                        now.setFullYear(now.getFullYear() + num);
                        break;                    case 'mon':
                        now.setMonth(now.getMonth() + num);
                        break;
                    case 'wee':
                        now.setDate(now.getDate() + (num * 7));                        break;
                    case 'day':
                        now.setDate(now.getDate() + num);
                        break;
                    case 'hou':                        now.setHours(now.getHours() + num);
                        break;
                    case 'min':
                        now.setMinutes(now.getMinutes() + num);
                        break;                    case 'sec':
                        now.setSeconds(now.getSeconds() + num);
                        break;
                    default:
                        var day;                        if (typeof (day = __is.day[m[1].substring(0, 3)]) != 'undefined') {
                            var diff = day - now.getDay();
                            if (diff == 0) {
                                diff = 7 * num;
                            } else if (diff > 0) {                                if (m[0] == 'last') {diff -= 7;}
                            } else {
                                if (m[0] == 'next') {diff += 7;}
                            }
                            now.setDate(now.getDate() + diff);                        }
                }
                break;
 
            default:                if (/\d+/.test(m[0])) {
                    num *= parseInt(m[0], 10);
 
                    switch (m[1].substring(0, 3)) {
                        case 'yea':                            now.setFullYear(now.getFullYear() + num);
                            break;
                        case 'mon':
                            now.setMonth(now.getMonth() + num);
                            break;                        case 'wee':
                            now.setDate(now.getDate() + (num * 7));
                            break;
                        case 'day':
                            now.setDate(now.getDate() + num);                            break;
                        case 'hou':
                            now.setHours(now.getHours() + num);
                            break;
                        case 'min':                            now.setMinutes(now.getMinutes() + num);
                            break;
                        case 'sec':
                            now.setSeconds(now.getSeconds() + num);
                            break;                    }
                } else {
                    return false;
                }
                break;        }
        return true;
    };
 
    match = strTmp.match(/^(\d{2,4}-\d{2}-\d{2})(?:\s(\d{1,2}:\d{2}(:\d{2})?)?(?:\.(\d+))?)?$/);    if (match != null) {
        if (!match[2]) {
            match[2] = '00:00:00';
        } else if (!match[3]) {
            match[2] += ':00';        }
 
        s = match[1].split(/-/g);
 
        for (i in __is.mon) {            if (__is.mon[i] == s[1] - 1) {
                s[1] = i;
            }
        }
        s[0] = parseInt(s[0], 10); 
        s[0] = (s[0] >= 0 && s[0] <= 69) ? '20'+(s[0] < 10 ? '0'+s[0] : s[0]+'') : (s[0] >= 70 && s[0] <= 99) ? '19'+s[0] : s[0]+'';
        return parseInt(this.strtotime(s[2] + ' ' + s[1] + ' ' + s[0] + ' ' + match[2])+(match[4] ? match[4]/1000 : ''), 10);
    }
     var regex = '([+-]?\\d+\\s'+
        '(years?|months?|weeks?|days?|hours?|min|minutes?|sec|seconds?'+
        '|sun\\.?|sunday|mon\\.?|monday|tue\\.?|tuesday|wed\\.?|wednesday'+
        '|thu\\.?|thursday|fri\\.?|friday|sat\\.?|saturday)'+
        '|(last|next)\\s'+        '(years?|months?|weeks?|days?|hours?|min|minutes?|sec|seconds?'+
        '|sun\\.?|sunday|mon\\.?|monday|tue\\.?|tuesday|wed\\.?|wednesday'+
        '|thu\\.?|thursday|fri\\.?|friday|sat\\.?|saturday))'+
        '(\\sago)?';
     match = strTmp.match(new RegExp(regex, 'gi')); // Brett: seems should be case insensitive per docs, so added 'i'
    if (match == null) {
        return false;
    }
     for (i = 0; i < match.length; i++) {
        if (!process(match[i].split(' '))) {
            return false;
        }
    } 
    return (now.getTime()/1000);
}

function date1(format, timestamp) {
    var that = this,
        jsdate, f, formatChr = /\\?([a-z])/gi, formatChrCb,
        // Keep this here (works, but for code commented-out  below for file size reasons)
        tal= [],
        _pad = function (n, c) {
            if ((n = n + "").length < c) {
                return new Array((++c) - n.length).join("0") + n;
            } else {                return n;
            }
        },
        txt_words = ["Sun", "Mon", "Tues", "Wednes", "Thurs", "Fri", "Satur",
        "January", "February", "March", "April", "May", "June", "July",        "August", "September", "October", "November", "December"],
        txt_ordin = {
            1: "st",
            2: "nd",
            3: "rd",            21: "st", 
            22: "nd",
            23: "rd",
            31: "st"
        }; 
    formatChrCb = function (t, s) {
        return f[t] ? f[t]() : s;
    };
    f = {
    	    // Day        
    		    d: function () { // Day of month w/leading 0; 01..31
    	            return _pad(f.j(), 2);
    	        },
    	        D: function () { // Shorthand day name; Mon...Sun
    	            return f.l().slice(0, 3);        },
    	        j: function () { // Day of month; 1..31
    	            return jsdate.getDate();
    	        },
    	        l: function () { // Full day name; Monday...Sunday     
    	        	return txt_words[f.w()] + 'day';
    	        },
    	        N: function () { // ISO-8601 day of week; 1[Mon]..7[Sun]
    	            return f.w() || 7;
    	        },        S: function () { // Ordinal suffix for day of month; st, nd, rd, th
    	            return txt_ordin[f.j()] || 'th';
    	        },
    	        w: function () { // Day of week; 0[Sun]..6[Sat]
    	            return jsdate.getDay();        },
    	        z: function () { // Day of year; 0..365
    	            var a = new Date(f.Y(), f.n() - 1, f.j()),
    	                b = new Date(f.Y(), 0, 1);
    	            return Math.round((a - b) / 864e5) + 1;        },
 
    // Week
        W: function () { // ISO-8601 week number
            var a = new Date(f.Y(), f.n() - 1, f.j() - f.N() + 3),    
                b = new Date(a.getFullYear(), 0, 4);
            return 1 + Math.round((a - b) / 864e5 / 7);
        },
 
    // Month    
        F: function () { // Full month name; January...December
            return txt_words[6 + f.n()];
        },
        m: function () { // Month w/leading 0; 01...12
            return _pad(f.n(), 2);        },
        M: function () { // Shorthand month name; Jan...Dec
            return f.F().slice(0, 3);
        },
        n: function () { // Month; 1...12   
        	return jsdate.getMonth() + 1;
        },
        t: function () { // Days in month; 28...31
            return (new Date(f.Y(), f.n(), 0)).getDate();
        }, 
    // Year
        L: function () { // Is leap year?; 0 or 1
            var y = f.Y(), a = y & 3, b = y % 4e2, c = y % 1e2;
            return 0 + (!a && (c || !b));       
           },
        o: function () { // ISO-8601 year
            var n = f.n(), W = f.W(), Y = f.Y();
            return Y + (n === 12 && W < 9 ? -1 : n === 1 && W > 9);
        },        Y: function () { // Full year; e.g. 1980...2010
            return jsdate.getFullYear();
        },
        y: function () { // Last two digits of year; 00...99
            return (f.Y() + "").slice(-2);        },
 
    // Time
        a: function () { // am or pm
            return jsdate.getHours() > 11 ? "pm" : "am";        },
        A: function () { // AM or PM
            return f.a().toUpperCase();
        },
        B: function () { // Swatch Internet time; 000..999          
            var H = jsdate.getUTCHours() * 36e2, // Hours
                i = jsdate.getUTCMinutes() * 60, // Minutes
                s = jsdate.getUTCSeconds(); // Seconds
            return _pad(Math.floor((H + i + s + 36e2) / 86.4) % 1e3, 3);
        },        g: function () { // 12-Hours; 1..12
            return f.G() % 12 || 12;
        },
        G: function () { // 24-Hours; 0..23
            return jsdate.getHours();        },
        h: function () { // 12-Hours w/leading 0; 01..12
            return _pad(f.g(), 2);
        },
        H: function () { // 24-Hours w/leading 0; 00..23   
        	return _pad(f.G(), 2);
        },
        i: function () { // Minutes w/leading 0; 00..59
            return _pad(jsdate.getMinutes(), 2);
        },        s: function () { // Seconds w/leading 0; 00..59
            return _pad(jsdate.getSeconds(), 2);
        },
        u: function () { // Microseconds; 000000-999000
            return _pad(jsdate.getMilliseconds() * 1000, 6);        },
 
    // Timezone
        e: function () { // Timezone identifier; e.g. Atlantic/Azores, ...
// The following works, but requires inclusion of the very large// timezone_abbreviations_list() function.
/*              var abbr = '', i = 0, os = 0;
            if (that.php_js && that.php_js.default_timezone) {
                return that.php_js.default_timezone;
            }            if (!tal.length) {
                tal = that.timezone_abbreviations_list();
            }
            for (abbr in tal) {
                for (i = 0; i < tal[abbr].length; i++) {                    os = -jsdate.getTimezoneOffset() * 60;
                    if (tal[abbr][i].offset === os) {
                        return tal[abbr][i].timezone_id;
                    }
                }            }
*/
            return 'UTC';
        },
        I: function () { // DST observed?; 0 or 1            // Compares Jan 1 minus Jan 1 UTC to Jul 1 minus Jul 1 UTC.
            // If they are not equal, then DST is observed.
            var a = new Date(f.Y(), 0), // Jan 1
                c = Date.UTC(f.Y(), 0), // Jan 1 UTC
                b = new Date(f.Y(), 6), // Jul 1      
                d = Date.UTC(f.Y(), 6); // Jul 1 UTC
            return 0 + ((a - c) !== (b - d));
        },
        O: function () { // Difference to GMT in hour format; e.g. +0200
            var a = jsdate.getTimezoneOffset();            return (a > 0 ? "-" : "+") + _pad(Math.abs(a / 60 * 100), 4);
        },
        P: function () { // Difference to GMT w/colon; e.g. +02:00
            var O = f.O();
            return (O.substr(0, 3) + ":" + O.substr(3, 2));        },
        T: function () { // Timezone abbreviation; e.g. EST, MDT, ...
// The following works, but requires inclusion of the very
// large timezone_abbreviations_list() function.
/*              var abbr = '', i = 0, os = 0, default = 0;            if (!tal.length) {
                tal = that.timezone_abbreviations_list();
            }
            if (that.php_js && that.php_js.default_timezone) {
                default = that.php_js.default_timezone;                for (abbr in tal) {
                    for (i=0; i < tal[abbr].length; i++) {
                        if (tal[abbr][i].timezone_id === default) {
                            return abbr.toUpperCase();
                        }                    }
                }
            }
            for (abbr in tal) {
                for (i = 0; i < tal[abbr].length; i++) {                    os = -jsdate.getTimezoneOffset() * 60;
                    if (tal[abbr][i].offset === os) {
                        return abbr.toUpperCase();
                    }
                }            }
*/
            return 'UTC';
        },
        Z: function () { // Timezone offset in seconds (-43200...50400)      
        	return -jsdate.getTimezoneOffset() * 60;
        },
 
    // Full Date/Time
        c: function () { // ISO-8601 date.         
        	return 'Y-m-d\\Th:i:sP'.replace(formatChr, formatChrCb);
        },
        r: function () { // RFC 2822
            return 'D, d M Y H:i:s O'.replace(formatChr, formatChrCb);
        },        U: function () { // Seconds since UNIX epoch
            return Math.round(jsdate.getTime() / 1000);
        }
    };
    this.date1 = function (format, timestamp) {        that = this;
        jsdate = (
            (typeof timestamp === 'undefined') ? new Date() : // Not provided
            (timestamp instanceof Date) ? new Date(timestamp) : // JS Date()
            new Date(timestamp * 1000)); // UNIX timestamp (auto-convert to int)        
        return format.replace(formatChr, formatChrCb);
    };
    return this.date1(format, timestamp);
}

function reservation(){
	var start_date = document.getElementById("get_date").value;
	//var nigth = document.getElementById("get_night").value;
	var depart_date = document.getElementById("get_depart_date").value;

	if(isNaN(start_date) == false){
		var D = new Date();
		// узнаем дату
		var Day = D.getDate();
		// узнаем месяц
		var Month = D.getMonth() + 1;
		// узнаем год
		var Year = D.getFullYear();
		// покажем
		start_date = Month + "/" + Day + "/" + Year;
	}	
    
	if(isNaN(depart_date) == false){
		var arr = start_date.split("/");
		var sd = mktime(0, 0, 0, arr[0], arr[1], arr[2]);
	    var last_date = strtotime('+ 1 day', sd); 
	    depart_date = date1('m/d/Y', last_date);
	}	
	
	var adults = document.getElementById("get_adults").value;
	var children = document.getElementById("get_children").value;
    
	$src = "https://gc.synxis.com/rez.aspx?Hotel=26021&Chain=10166&start=1&src=&arrive="+start_date+"&depart="+depart_date+"&adult="+adults+"&child="+children;
	window.open($src,"","");
}

function reservation2(st_date,dp_date){
	if(isNaN(dp_date) == true){
		var arr = dp_date.split("-");
		var sd = mktime(0, 0, 0, arr[1], arr[2], arr[0]);
	    var dt_date1 = strtotime('+1 day', sd); 
	    var depart_date = date1('m/d/Y', dt_date1);
	}
	
	if(isNaN(st_date) == true){
		arr = st_date.split("-");
		sd = mktime(0, 0, 0, arr[1], arr[2], arr[0]);
		var start_date = arr[1] + "/" + arr[2] + "/" + arr[0];
	}
	
	if(isNaN(start_date) == false){
		var D = new Date();
		// узнаем дату
		var Day = D.getDate();
		// узнаем месяц
		var Month = D.getMonth() + 1;
		// узнаем год
		var Year = D.getFullYear();
		// покажем
		start_date = Month + "/" + Day + "/" + Year;
	}	
    
	if(isNaN(depart_date) == false){
		var arr = start_date.split("/");
		var sd = mktime(0, 0, 0, arr[0], arr[1], arr[2]);
	    var last_date = strtotime('+ 1 day', sd); 
	    depart_date = date1('m/d/Y', last_date);
	}	
	
	$src = "https://gc.synxis.com/rez.aspx?Hotel=26021&Chain=10166&start=1&src=&arrive="+start_date+"&depart="+depart_date;
	window.open($src,"","");
}
