var IE = document.all?true:false;
if (!IE)
    document.captureEvents(Event.MOUSEMOVE);
document.attachEvent("onmousemove", getMouseXY);
var mouseX = 0;
var mouseY = 0;

function Season(name, period, price) {
    this.name = name;
    this.period = period;
    this.price = price;
}

function getMouseXY(e) {
    if (IE) { // grab the x-y pos.s if browser is IE
        mouseX = event.clientX + document.body.scrollLeft;
        mouseY = event.clientY + document.body.scrollTop;
    } else {  // grab the x-y pos.s if browser is NS
        mouseX = e.pageX;
        mouseY = e.pageY;
    }
    if (mouseX < 0) {
        mouseX = 0;
    }
    if (mouseY < 0) {
        mouseY = 0;
    }
    return true;
}

function hideRoomDetails(div) {
    div.innerHTML = "";
    return true;
}

function showRoomDetails(dest, roomName, perNightPriceLbl,seasonLbl, periodLbl,  seasons, width, isAbsolute) {

//            alert(width);
    if (dest.innerHTML == "") {
        var html;
        html = createRoomDetailsTable(roomName, perNightPriceLbl,seasonLbl, periodLbl, seasons, width);

        html = surroundByBorderedTable(html);

        dest.innerHTML = html;

        if(isAbsolute == true){
//            dest.style.position = 'absolute';
//            dest.style.left = parseInt(width);
//            dest.style.left = parseInt(width)*(-1);
//            alert(dest.style.left);
//            dest.style.left = -dest.style.left;
        }  else {
            dest.style.position = 'relative';
        }

    } else if (isAbsolute == true && (dest.style.left != mouseX + 2 || dest.style.top != mouseY - 250)) {
//        alert("fff");
//        dest.style.left = mouseX + 2;
//        dest.style.top = mouseY - 250;
    }
    return true;
}

function surroundByBorderedTable(object) {
    closableTable = object;
//    closableTable = "<table class=\"borderedOutsetDiv\" >";
//    closableTable += "	<tr>";
//    closableTable += "		<td>" + object + "</td>";
//    closableTable += "	</tr>";
//    closableTable += "</table>";
    return closableTable;
}

function createRoomDetailsTable(roomName, perNightPriceLbl, seasonLbl, periodLbl, seasons, width) {


    var html = "<table width=\"" + width + "\" class=\"absTarifTable\" cellspacing=\"0\" cellpadding=\"5\">";
//            alert(html);
    html += "<tr><td colspan=\"2\" class=\"absTarifHeaderCell\" align=\"center\"><span class=\"headerWhiteFont\">" + roomName + "</span></td></tr>"

    for (i = 0; i < seasons.length; i++) {
        var season = seasons[i];
        if (season != null) {
            html += "<tr><td colspan=\"2\" class=\"headerFont\" align=\"left\">" + seasonLbl + ": " + season.name + "</td></tr>"
            html += "<tr><td width=\"40%\" valign=\"top\" class=\"label\">" + periodLbl + ": </td><td width=\"60%\" class=\"normalBlackText\">" + season.period + "</td></tr>"
            html += "<tr><td class=\"label\">" + perNightPriceLbl + ": </td><td class=\"normalBlackText\"> Eur. " + season.price + "</td></tr>"
            html += "<tr><td colspan=\"2\">&nbsp;</td></tr>"
        }
    }


    html += "</table>"
    return html;
}