﻿var dlgObj = null;

$(function() {

    var dlgWidth = $(document).width();


    if (dlgWidth < 950) dlgWidth = 950;

    var dlgLeft = (($(document).width() - dlgWidth) / 2);

    // Change the overflow property of the body to hidden
    //$("body").css("overflow-y", "hidden");
    // $("body").css("overflow", "hidden");

    dlgObj = $('#dialog').dialog({

        //bgiframe: true,
       // left: dlgLeft,
        //width: (dlgWidth - 10),
        //resizable: false,
        autoOpen: false
    });

});

function ResizeDialog() {
    // var dlgWidth = $(document).width();
    //if (dlgWidth < 950) dlgWidth = 950;
    //var dlgLeft = (($(document).width() - dlgWidth) / 2);
    $('.ui-dialog').css("width",  "100%");
     $('.ui-dialog').css("left", "100%"); 
    
}

$(window).resize(function() { ResizeDialog(); });

function CloseDialog() {
    //$("body").css("overflow-y", "auto");
    //$("body").css("overflow", "auto");
    $('iframe').attr('src', '');
    $('#dialog').dialog('close');
    return false;
}

function ShowJustCuriousItem(location,id) {
    GetJustCuriousData(location,id);
}

function UpdateDialog(data) {
    $('div.title').html(data.Title);
    $('iframe').attr('src', data.Url);
    $('div.tagline').html(data.TagLine);
    $('div.pre-description').html(data.PreDescription);
    $('div.post-description').html(data.PostDescription);
    $('#ViewInNewWindowLink').attr("href", data.Url);

    // Change the overflow property of the body to hidden
    //$("body").css("overflow-y", "hidden");
    //$("body").css("overflow", "hidden");
    //$("body").css("overflow-x", "hidden");

    $('#dialog').dialog('open');

    $(".ui-corner-all").css('width', "100%");
    $(".ui-corner-all").css('left', "0");
}

function GetJustCuriousData(location,id) {

    $.getJSON("/" + location + "/justcurious/getdata", { Id: id }, function(data) {
        UpdateDialog(data);
    });
    
}