    // NOTE: it is ok to modify the following, as appropriate.
    var defaultAdults=2;
    var cellStyle=" class='textGeneral2'";
//     var childHelp="<b>Ηλικίες:</b>";
//     var adultHelp="";
//     var textRooms="<b>Δωμάτια:</b>&nbsp;";
//     var textAdults="<b>Ενήλικες:</b> (+18)&nbsp;";
//     var textChildren="<b>Παιδιά:</b> (0-17)&nbsp;";
//     var textChildError="Προσδιορίστε τις ηλικίες των παιδιών.";
    var pad='';
    // NOTE: On the following two; question marks ("?") get replaced with a numeric value
//     var textRoomX="Δωμάτιο ?:";
//     var textChildX="Παιδί ?:";
    //----------------------------------------------------------------------------------------

    var adultsPerRoom=new Array();
    var childrenPerRoom=new Array();
    var childAgesPerRoom=new Array();
    var numRooms=1;
    var maxChildren=0;

    adultsPerRoom[0]=defaultAdults;

    refresh();

    function setChildAge(room, child, age) {
        if (childAgesPerRoom[room] == null) {
            childAgesPerRoom[room] = new Array();
        }
        childAgesPerRoom[room][child] = age;
    }

    function setNumAdults(room, numAdults) {
        adultsPerRoom[room] = numAdults;
    }

    function setNumChildren(room, numChildren) {
        childrenPerRoom[room] = numChildren;
        refresh();
    }

    function setNumRooms(x) {
        numRooms = x;
        for (i = 0; i < x; i++) {
            if (adultsPerRoom[i] == null) {
                adultsPerRoom[i] = 2;
            }
            if (childrenPerRoom[i] == null) {
                childrenPerRoom[i] = 0;
            }
        }
        refresh();
        if (x > 3 && x < 9) window.location.href = "http://www.pamediakopes.gr/default.asp?la=1&pid=40";
        if (x == 9) window.location.href = "http://www.pamediakopes.gr/default.asp?la=1&pid=41";
    }

    function renderRoomSelect() {
        var x = '';
        x += '<select class="form2" name="numberOfRooms" id="numberOfRooms" onchange="setNumRooms(this.options[this.selectedIndex].value);">';
        for (var i = 1; i < 9; i++) {
            x += '<option value="'+i+'"'+(numRooms == i ? ' selected' : '')+'>' + i;
        }
        x += '<option value="9"'+(numRooms == 9 ? ' selected' : '')+'>9+';
        x += '</select>';
        return x;
    }

    function refresh() {
        maxChildren = 0;
        for (var i = 0; i < numRooms; i++) {
            if (childrenPerRoom[i] > maxChildren) {
                maxChildren = childrenPerRoom[i];
            }
        }

        var x = '';
        if (adultHelp.length > 0) {
            x = adultHelp + "<p>\n";
        }

        if (numRooms > 3) {
            x += textRooms;
            x += renderRoomSelect();

        } else {
            x += '<table border="0" cellspacing="2" cellpadding="0">\n';
            x += '<tr><td'+cellStyle+'>'+textRooms+pad+'</td>';
            if (numRooms > 1) {
                x += '<td'+cellStyle+'>&nbsp;</td>';
            }
            x += '<td'+cellStyle+'><nobr>'+textAdults+pad+'</nobr></td><td'+cellStyle+'><nobr>'+textChildren+pad+'</nobr></td></tr>\n';
            for (var i = 0; i < numRooms; i++) {
                x += '<tr><td'+cellStyle+'>';
                if (i == 0) {
                    x += renderRoomSelect();
                } else {
                    x += '&nbsp;';
                }
                x += '</td>';
                if (numRooms > 1) {
                    x += '<td'+cellStyle+'><nobr>'+getValue(textRoomX, i+1)+pad + '</nobr></td>';
                }
                x += '<td'+cellStyle+'>';
                x += buildSelect('room-' + i + '-adult-total', 'setNumAdults(' + i + ', this.options[this.selectedIndex].value)', 1, 4, adultsPerRoom[i]);
                x += '</td><td'+cellStyle+'>';
                x += buildSelect('room-' + i + '-child-total', 'setNumChildren(' + i + ', this.options[this.selectedIndex].value)', 0, 4, childrenPerRoom[i]);
                //x += buildSelect('room-' + i + '-child-total', '', 0, 6, childrenPerRoom[i]);
                x += '</td></tr>\n';
            }
            x += '</table>\n';

            var didHeader = false;
            for (var i = 0; i < numRooms; i++) {
                if (childrenPerRoom[i] > 0) {
                    if (!didHeader) {
                        x += '<table border="0" cellpadding="0" cellspacing="2">\n';
                        //x += '<tr><td'+cellStyle+' colspan="'+(maxChildren+1)+'">';
                        //x += '<br>';
                        //x += childHelp;
                        //x += '<br>';
                        //x += '</td></tr>\n<tr>';
                        x += '<td'+cellStyle+'>' + childHelp + '</td>';
                        for (var j = 0; j < maxChildren; j++) {
                            x += '<td'+cellStyle+'><nobr>'+getValue(textChildX, j+1)+pad+'</nobr></td>\n';
                        }
                        didHeader = true;
                    }
                    x += '</tr>\n<tr><td'+cellStyle+'><nobr>'+getValue(textRoomX, i+1)+pad+'</nobr></td>';
                    for (var j = 0; j < childrenPerRoom[i]; j++) {
                        x += '<td'+cellStyle+'>';
                        var def = -1;
                        if (childAgesPerRoom[i] != null) {
                            if (childAgesPerRoom[i][j] != null) {
                                def = childAgesPerRoom[i][j];
                            }
                        }
                        //x += '<select class="searchinput_txt" name="room-'+i+'-child-'+j+'-age" id="room-'+i+'-child-'+j+'-age" onchange="setChildAge('+i+', '+j+', this.options[this.selectedIndex].value);">';
                        x += '<select class="form2" name="room-'+i+'-child-ages" id="room-'+i+'-child-'+j+'-age" onchange="setChildAge('+i+', '+j+', this.options[this.selectedIndex].value);">';
                        x += '<option value="-1"'+(def == -1 ? ' selected' : '')+'>-?-';
                        x += '<option value="0"'+(def == 0 ? ' selected' : '')+'>&lt;1';
                        for (var k = 1; k <= 12; k++) {
                            x += '<option value="'+k+'"'+(def == k ? ' selected' : '')+'>'+k;
                        }
                        x += '</td>';
                    }
                    if (childrenPerRoom[i] < maxChildren) {
                        for (var j = childrenPerRoom[i]; j < maxChildren; j++) {
                            x += '<td'+cellStyle+'>&nbsp;</td>';
                        }
                    }
                    x += '</tr>\n';
                }
            }
            if (didHeader) {
                x += '</table>\n';
            }
        }

        document.getElementById("hot-search-params").innerHTML = x;
    }

    function buildSelect(name, onchange, min, max, selected) {
        var x = '<select class="form2" id="' + name + '" name="' + name + '"';
        if (onchange != null) {
            x += ' onchange="' + onchange + '"';
        }
        x +='>\n';
        for (var i = min; i <= max; i++) {
            x += '<option value="' + i + '"';
            if (i == selected) {
                x += ' selected';
            }

            x += '>' + i + '\n';
        }
        x += '</select>';
        return x;
    }

    function validateGuests(form) {
        if (numRooms < 3) {
            var missingAge = false;
            for (var i = 0; i < numRooms; i++) {
                var numChildren = childrenPerRoom[i];
                if (numChildren != null && numChildren > 0) {
                    for (var j = 0; j < numChildren; j++) {
                        if (childAgesPerRoom[i] == null || childAgesPerRoom[i][j] == null || childAgesPerRoom[i][j] == -1) {
                            missingAge = true;
                        }
                    }
                }
            }

            if (missingAge) {
                alert(textChildError);
                return false;
            } else {
                return true;
            }
        } else {
            return true;
        }
    }

    function submitGuestInfoForm(form) {
        if (!validateGuests(form)) {
            return false;
        }
        return true;
    }

    function getValue(str, val) {
        return str.replace(/\?/g, val);
    }

    function submitSearchForm(form) {
        if (form.city.value == "") {
            alert("Επιλέξτε πόλη (στα Αγγλικά)!");
            return false;
        }
		return submitGuestInfoForm(form);
    }

    function isBrowserSupp() {
        // Get the version of the browser
        version =  parseFloat( navigator.appVersion );

        if ( ( version >= 2.0 ) && ( version < 2.1 ) && ( navigator.appName.indexOf( "Netscape" ) != -1 ) ) {
            return false;
        } else {
            return true;
        }

        return true;
    }

    function isLeapYear( yrStr ) {
        var leapYear = false;
        var year = parseInt( yrStr, 10 );
        // every fourth year is a leap year
        if ( year % 4 == 0 ) {
            leapYear = true;
            // unless it's a multiple of 100
            if( year % 100 == 0 ) {
                leapYear = false;
                // unless it's a multiple of 400
                if( year % 400 == 0 ) {
                    leapYear=true;
                }
            }
        }
        return leapYear;
    }

    function getDaysInMonth( mthIdx, YrStr ) {
        // all the rest have 31
        var maxDays = 31
        // expect Feb. (of course)
        if( mthIdx == 1 ) {
            if( isLeapYear( YrStr ) ) {
                maxDays=29;
            } else {
                maxDays=28;
            }
        }

        // thirty days hath...
        if( mthIdx == 3 || mthIdx == 5 || mthIdx == 8 || mthIdx == 10 ) {
            maxDays=30;
        }
        return maxDays;
    }

    //the function which does some magic to the date fields
    // return non-zero if it is the last day of the month
    function adjustDate( mthIdx, Dt ) {
        var value = 0;

        var today = new Date()
        var theYear = parseInt( today.getYear(), 10 )

        if( mthIdx < today.getMonth() ) {
            theYear = ( parseInt( today.getYear(), 10 ) + 1 )
        }
        if( theYear < 100 ) {
            theYear = "19" + theYear
        } else {
            if( ( theYear - 100 ) < 10 ) {
                theYear = "0" + ( theYear - 100 )
            } else {
                theYear = ( theYear - 100 ) + ""
            }
            theYear = "20" + theYear
        }


        var numDays = getDaysInMonth( mthIdx, theYear );

        if( mthIdx == 1 ) {
            if( Dt.options.selectedIndex + 1 < numDays ) {
                return 0;
            } else {
                Dt.options.selectedIndex=numDays - 1;
                //check for leap year
                if( numDays == 29 ) {
                    return 99;
                } else {
                    return 1;
                }
            }
        }

        if( Dt.options.selectedIndex + 1 < numDays ) {
            value = 0;
        } else {
            if ( Dt.options.selectedIndex + 1 > numDays ) {
                Dt.options.selectedIndex--;
                value = 3;
            } else {
                //index is 31 or 30
                value = 2;
            }
        }
        return value;
    }

    //changes departure month when arrival month is changed
    function amadChange( inM, inD, outM, outD ) {
    
        if ( !isBrowserSupp() ) {
            return;
        }

        var res = adjustDate( inM.options.selectedIndex, inD );
        if( res != 0 ) {
               outD.options.selectedIndex = 0;
               if ( outM.options.selectedIndex == 11 ) {
                    outM.options.selectedIndex = 0
               } else {
                    outM.options.selectedIndex=inM.options.selectedIndex + 1;
                    outD.options.selectedIndex = 1;
               }
        } else {
            outM.options.selectedIndex = inM.options.selectedIndex;
            if (outD.options.selectedIndex <= inD.options.selectedIndex) {
                outD.options.selectedIndex = inD.options.selectedIndex + 2;
            }
        }
        return;
    }


    function dmddChange( outM, outD ) {
        if ( !isBrowserSupp() ) {
            return;
        }

        adjustDate( outM.options.selectedIndex, outD );
        return;
    }

	    function OpenCalendar(dayField, day, monthField, month, yearField, year, formName) {
        file = 'http://gr.hotels.com/util/calendar.jsp?geoCountry=gr&formName=myform';
        if ( dayField != null )
          file += '&dayField=' + dayField + '&day=' + day;
        if ( monthField != null )
          file += '&monthField=' + monthField + '&month=' + month;
        if ( yearField != null )
          file += '&yearField=' + yearField + '&year=' + year;
        window.open( file, "dates", 'width=200,height=200,resizable=1');

  
    }

    function loadDates()
    {

        var calendar = new Date();
        var calendar2 = new Date();
        var cal
        var cal2
        var date;
        var month;
        var year;
        var date2;
        var month2;
        var year2;

        //Here is the variable to change for to advance the arrival Date
         var advanceArrival = 14;

        //Here is the variable to change for to advance the departure Date
         var advanceDeparture = 16;


        //Set the arrival Days
        calendar.setDate(calendar.getDate()+ advanceArrival);
        date = calendar.getDate();
        month = calendar.getMonth();

        //Set the Departure Days
        calendar2.setDate(calendar2.getDate()+advanceDeparture);
        date2 = calendar2.getDate();
        month2 = calendar2.getMonth();
		
		if (document.forms['myform']) {
	        document.forms['myform'].arrivalMonth.value=month;
	        document.forms['myform'].arrivalDay.value=date;
	        document.forms['myform'].departureMonth.value=month2;
	        document.forms['myform'].departureDay.value=date2;
        }
    }
    loadDates();
