﻿function popup(url)
{
    var width  = 600;
    var height = 720;
    var left   = (screen.width  - width)/2;
    var top    = (screen.height - height)/2;
    var params = 'width='+width+', height='+height;
    params += ', top='+top+', left='+left;
    params += ', directories=no';
    params += ', location=no';
    params += ', menubar=no';
    params += ', resizable=yes';
    params += ', scrollbars=yes';
    params += ', status=no';
    params += ', toolbar=no';
    newwin=window.open(url,'popwindow', params);
    if (window.focus) {newwin.focus()}
    return false;
}

$(document).ready(function(){
    $(".editable").each(function() {
        var tool = $(this);
        var instanceId = tool.attr("instanceId");
        var type = tool.attr("type");
        var parentInstanceId = tool.attr("parentInstanceId");
        var parentType = tool.attr("parentType");
        $("a", this).click(function(){
            OpenCmsWindow(instanceId, type, parentInstanceId, parentType, $(this).attr("action"));
            this.blur();
            return false;
        });
    });
   
    $("a.video").each(function() {
        // depends on jquery thickbox
        var t = this.title || this.name || null;
        var a = "/Media/Video/"+ $(this).attr("key") +"?KeepThis=true&TB_iframe=true&height=540&width=500";
        var g = this.rel || false;
        $(this).click(function() {
            tb_show(t,a,g);
            this.blur();
            return false;
        });
        $(this).css("cursor", "pointer");
        $(this).attr("href", "#");
    });
    
     $("a.glossary").each(function() {
        // depends on jquery thickbox
        var t = this.title || this.name || null;
        var a = "/Media/Glossary/"+ $(this).attr("key") +"?KeepThis=true&TB_iframe=true&height=340&width=500";
        var g = this.rel || false;
        $(this).click(function() {
            tb_show(t,a,g);
            this.blur();
            return false;
            });
        $(this).css("cursor", "pointer");
        $(this).attr("href", "#");
    });
    
      $("a.pagecopy").each(function() {
        // depends on jquery thickbox
        var t = this.title || this.name || null;
        var a = "/Media/EditablePage/"+ $(this).attr("key") +"?KeepThis=true&TB_iframe=true&height=640&width=540";
        var g = this.rel || false;
        $(this).click(function() {
            tb_show(t,a,g);
            this.blur();
            return false;
            });
        $(this).css("cursor", "pointer");
        $(this).attr("href", "#");
    });
    
     $("a.arrangement").each(function() {
        var t = this.title || this.name || null;
        var a = "/Arrangement/"+ $(this).attr("key");
        $(this).click(function() {
            popup(a);
            this.blur();
            return false;
            });
        $(this).css("cursor", "pointer");
        $(this).attr("href", "#");
    });
    
});