﻿$(document).ready(function() {
    var actualHeight = new String((($('.prisgraf_con').height()) - 51) + 'px');
    $('.hover_area').css("height", actualHeight);
});
$('.prisgraf_con img').load(function() {
    var actualHeight = new String((($('.prisgraf_con').height()) - 51) + 'px');
    $('.hover_area').css("height", actualHeight);

});

$(function() {
    var mouseout_hover_area = function() { $(".prisgraf_info_box").remove(); $(".cursor").remove(); }
    $('.hover_area')
		.mouseout(mouseout_hover_area);
});

function showInfo(coord_x, coord_y, pris, dato, varetekst) {
    $(".prisgraf_con").append('<div class="cursor"></div>');
    var cursorXCoord = coord_x - 21;
    var cursorYCoord = coord_y - 21;
    $('.cursor').css({ left: cursorXCoord, top: cursorYCoord });

    var theInfoBox = '<div class="prisgraf_info_box"><div class="prisgraf_varetekst">' + varetekst + '</div><div class="prisgraf_dato">' + dato + '</div><div class="prisgraf_pris">' + pris + '</div></div>';
    $(".prisgraf_con").append(theInfoBox);
    var infoboxXCoord = coord_x + 7;
    var infoboxYCoord = coord_y - 72;
    $('.prisgraf_info_box').css({ left: infoboxXCoord, top: infoboxYCoord });
}

function updateDato(dropdown, fraDatoId, tilDatoId) {
    var dateValue = $(dropdown).val();

    var dates = dateValue.split(";");

    if (dates.length > 1) {
        $("#" + fraDatoId).val(dates[0]);
        $("#" + tilDatoId).val(dates[1]);
    }
}
