﻿function NotifyJavascriptEnabled() {
    $.ajax({
        type: "POST",
        url: "/JavascriptNotifier.asmx/JavascriptEnabled",
        data: "{}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        error: function(xhr, statusText, errorThrown) {
        alert('error ' + xhr.status + '\n - ' + xhr.responseText); 
        },
        success: function(msg) { }
    });

}

function isdefined(variable) {
    try{
        var len = variable.length;
        if(len>0){
            return true;
        }
    }catch(e){
    }
    return (typeof (window[variable]) == "undefined") ? false : true;
}


function GetTableMarkup(placeid,hid, date, nights) {

    if (isdefined(hid) == false) {
        hid = '';
    }
    if (isdefined(date) == false) {
        date = '';
    }
    if (isdefined(nights) == false) {
        nights = 7;
    }
    if (isdefined(placeid) == false) {
        placeid = '';
    }
    $.ajax({
        type: "POST",
        url: "/Markup.asmx/GetTableMarkup",
        data: "{'placeid':'" + placeid + "','hid':'" + hid + "','date':'" + date + "','nights':" + nights + "}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        error: function(xhr, statusText, errorThrown) {
        alert('error ' + xhr.status + '\n - ' + xhr.responseText); 
        },
        success: function(msg) {
            $('#HotelAvailability').html(msg.d);
        }
    });

}

function querySt(ji) {
    hu = window.location.search.substring(1);
    gy = hu.split("&");
    for (i = 0; i < gy.length; i++) {
        ft = gy[i].split("=");
        if (ft[0] == ji) {
            return ft[1];
        }
    }
}

function saveAndRedirect(page,method,redirect,businessName) {
    $.ajax({
        type: "POST",
        url: page + "/" + method,
        data: "{'buisnessName':'" + businessName + "'}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        error: function(xhr, statusText, errorThrown) {
            alert('error ' + xhr.status + '\n - ' + xhr.responseText);
        },
        success: function(msg) {
            window.location = redirect;
        }
    });
}
