    function jumpMenu(targ,selObj,restore){
        eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
		if (restore) selObj.selectedIndex=0;
    }
	
    function refreshParent() {
        window.opener.location.href = window.opener.location.href;
        if (window.opener.progressWindow) 
        window.opener.progressWindow.close();
        window.close();
    }
      
    var win = null;
    function NewWindow(mypage,myname,w,h,scroll){
        LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
        TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
        settings = 'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable';
        win = window.open(mypage,myname,settings);
    }  
  
    function getWindowScroll(w) {
        if (!w) {
        if (document.documentElement && document.documentElement.scrollTop) { return document.documentElement.scrollTop; }
        else if (document.body.scrollTop) { return document.body.scrollTop; }
        else if (window.pageYOffset) { return window.pageYOffset; }
        } else {
        if (w.document.documentElement && w.document.documentElement.scrollTop) {  return w.document.documentElement.scrollTop; }
        else if (w.document.body.scrollTop) { return w.document.body.scrollTop; }
        else if (w.pageYOffset) { alert( w.pageYOffset ); return w.pageYOffset; }
        }
        return( 0 );
    }

    function isAvailable(date) {
        var dateAsString = date.getFullYear().toString() + "-" + (date.getMonth() + 1).toString() + "-" + date.getDate();
        var result = $.inArray(dateAsString, bookedDays) == -1 ? [true] : [false];
        return result
    }

    $(document).ready(function () {
        if ($("#arrivalDP").length > 0) {
            $("#arrivalDP").datepicker({
                altField: "#" + arrivalDate,
                altFormat: "dd.mm.yy",
                minDate: 0,
                maxDate: "+1Y",
                beforeShowDay: isAvailable,
                defaultDate: arrivalDefaultDate,
                onSelect: changeDepartureDate
            });

            $("#departureDP").datepicker({
                altField: "#" + departureDate,
                altFormat: "dd.mm.yy",
                minDate: 1,
                maxDate: "+1Y",
                beforeShowDay: isAvailable,
                defaultDate: departureDefaultDate,
                onSelect: changeArrivalDate
            });

        }
    });

    function changeDepartureDate() {
        var arrivalDate = $("#arrivalDP").datepicker("getDate")
        var departureDate = $("#departureDP").datepicker("getDate")

        if (days_between(departureDate, arrivalDate) < 1) {
            arrivalDate.dateAdd("d", 1)
            $("#departureDP").datepicker("setDate", arrivalDate)
        }
    }

    function changeArrivalDate() {
        var arrivalDate = $("#arrivalDP").datepicker("getDate")
        var departureDate = $("#departureDP").datepicker("getDate")
        if (days_between(departureDate, arrivalDate) < 1) {
            departureDate.dateAdd("d", -1)
            $("#arrivalDP").datepicker("setDate", departureDate)
        }
    }

    function days_between(date1, date2) {
        var ONE_DAY = 1000 * 60 * 60 * 24
        var date1_ms = date1.getTime()
        var date2_ms = date2.getTime()
        var difference_ms = date1_ms - date2_ms
        return Math.round(difference_ms / ONE_DAY)
    }

    function dateAddExtention(p_Interval, p_Number) {


        var thing = new String();


        //in the spirt of VB we'll make this function non-case sensitive
        //and convert the charcters for the coder.
        p_Interval = p_Interval.toLowerCase();

        if (isNaN(p_Number)) {

            //Only accpets numbers 
            //throws an error so that the coder can see why he effed up    
            throw "The second parameter must be a number. \n You passed: " + p_Number;
            return false;
        }

        p_Number = new Number(p_Number);
        switch (p_Interval.toLowerCase()) {
            case "yyyy":
                {// year
                    this.setFullYear(this.getFullYear() + p_Number);
                    break;
                }
            case "q":
                {        // quarter
                    this.setMonth(this.getMonth() + (p_Number * 3));
                    break;
                }
            case "m":
                {        // month
                    var tempDate = new Date(this.getTime());
                    tempDate.setDate(1);
                    tempDate.setMonth(this.getMonth() + p_Number);
                    var maxDaysMonth = daysInMonth(tempDate.getMonth(), tempDate.getYear())
                    if (this.getDate() > maxDaysMonth) {
                        this.setDate(maxDaysMonth)
                    }
                    this.setMonth(this.getMonth() + p_Number);
                    break;
                }
            case "y":        // day of year
            case "d":        // day
            case "w":
                {        // weekday
                    this.setDate(this.getDate() + p_Number);
                    break;
                }
            case "ww":
                {    // week of year
                    this.setDate(this.getDate() + (p_Number * 7));
                    break;
                }
            case "h":
                {        // hour
                    this.setHours(this.getHours() + p_Number);
                    break;
                }
            case "n":
                {        // minute
                    this.setMinutes(this.getMinutes() + p_Number);
                    break;
                }
            case "s":
                {        // second
                    this.setSeconds(this.getSeconds() + p_Number);
                    break;
                }
            case "ms":
                {        // second
                    this.setMilliseconds(this.getMilliseconds() + p_Number);
                    break;
                }
            default:
                {

                    //throws an error so that the coder can see why he effed up and
                    //a list of elegible letters.
                    throw "The first parameter must be a string from this list: \n" +
                    "yyyy, q, m, y, d, w, ww, h, n, s, or ms. You passed: " + p_Interval;
                    return false;
                }
        }
        return this;
    }
    Date.prototype.dateAdd = dateAddExtention;
