﻿//open a popup window
function openWindow(theURL,winName,features) {
  window.open(theURL,winName,features);
}

// Reset the styles on RadEditor Controls
function RadEditorOnClientLoad(editor, args)
{
  var style = editor.get_contentArea().style;
  style.backgroundImage = "none";
  style.backgroundColor = "white";
  style.color = "black";
  style.fontFamily = "Arial";
  style.fontSize = 15 + "px";
}
        
        
$(document).ready(function() {

    $(".OverlayTrigger").overlay({
        color: '#ccc',
        start: {
            top: 300
        },
        expose: {
            color: '#333',
            opacity: 0.7,
            closeSpeed: 300
        }
    });


    /***********************/
    /*  AJAX Preview Item  */
    /***********************/
    
    var ItemPreviewOverlayApi = "";

    if (!$("#ItemPreviewContentPlaceHolder").length) {
    
        $(".SectionMenu").append("<div id=\"AjaxItemPreviewOverlay\"><div id=\"ItemPreviewContentPlaceHolder\"></div></div>");

        // Create and overlay for the item to go into
        var ItemPreviewOverlayApi = $("#AjaxItemPreviewOverlay").overlay({
        top: 'center',
            api: true,
            absolute: true,
            expose: {
                color: '#333',
                loadSpeed: 1,
                opacity: 0.9
            }
        });
    }
    
    // AJAX request to get the item preview
    
    $(".AjaxItemPreviewTrigger").live("click", function(){
      ItemPreviewOverlayApi.load();

        $.ajax({
            type: "POST",
            url: "AjaxItemService.asmx/GetItemPreviewHtml",
            data: $(this).attr("rel"),
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function(msg) {
                $("#ItemPreviewContentPlaceHolder").html(msg.d);
            },
            error: function(msg) {
                //  TO DO: handle the error
                  alert(msg.responseText);
            }
        });
        return false;
    });

});
