var xmlhttp;


// Viser priser for resort
function room_price(www_site_id, currency_id, resort_id, room_id, period_from, period_to, pax, pax_age, details) {

    if (details == 1) {
        if (document.getElementById("RoomPrice_Details_" + room_id).innerHTML == "") {
            document.getElementById("RoomPrice_Details_" + room_id).style.display = "";
            document.getElementById("RoomPrice_Details_" + room_id).innerHTML = loadinghtml();
        }
        else {
            document.getElementById("RoomPrice_Details_" + room_id).innerHTML = "";
            document.getElementById("RoomPrice_Details_" + room_id).style.display = "none";
            return false;
        }

    }
    else {
    document.getElementById("RoomPrice_" + room_id).innerHTML = loadinghtml();
    }
    var xmlhttp = GetXmlHttpObject();
    if (xmlhttp == null) {
        alert("Browser does not support HTTP Request");
        return;
    }
    var url = "include/room_price.asp";
    url = url + "?www_site_id=" + www_site_id;
    url = url + "&currency_id=" + currency_id;
    url = url + "&resort_id=" + resort_id;
    url = url + "&room_id=" + room_id;
    url = url + "&period_from=" + period_from;
    url = url + "&period_to=" + period_to;
    url = url + "&pax=" + pax;
    url = url + "&pax_age=" + pax_age;
    url = url + "&details=" + details;
    url = url + "&sid=" + Math.random();
    // document.getElementById("RoomPrice_" + room_id).innerHTML = url;
    if (details == 1) {
        xmlhttp.onreadystatechange = function stateChanged() { if (xmlhttp.readyState == 4) { document.getElementById("RoomPrice_Details_" + room_id).innerHTML = xmlhttp.responseText; } }
    }
    else {
    xmlhttp.onreadystatechange = function stateChanged() { if (xmlhttp.readyState == 4) { document.getElementById("RoomPrice_" + room_id).innerHTML = xmlhttp.responseText; } }
    }



    xmlhttp.open("GET", url, true);
    xmlhttp.send(null);
}

function toggleField(field_id) {
    if (document.getElementById(field_id).style.display == "none") {
        document.getElementById(field_id).style.display = "";
    }
    else {
        document.getElementById(field_id).style.display = "none";
    }
}

function loadinghtml() {
    return "<div class='loading'><img src='/loading.gif' alt='Loading page' /></div>";
}

//function remove_room(Resort_ID, Room_ID) {
//    var atbody = document.getElementById("atbody" + Resort_ID);
//    var atr = document.getElementById("atr" + Room_ID);
//    atbody.removeChild(atr);
//}

// Generel AJAX-funktionalitet


function GetXmlHttpObject()
{
if (window.XMLHttpRequest)
  {
  // code for IE7+, Firefox, Chrome, Opera, Safari
  return new XMLHttpRequest();
  }
if (window.ActiveXObject)
  {
  // code for IE6, IE5
  return new ActiveXObject("Microsoft.XMLHTTP");
  }
return null;
}


