﻿function ModalDialogShow(fileName, title, description) {
    var args = 'width=340,height=460,left=100,top=100,toolbar=false,location=false,status=false,menubar=false,scrollbars=false,resizable=false';
    var popup = '<html><head><title>' + title + '</title><body bgcolor="#6ebe44" style="margin-right: auto; margin-left: auto">';
    popup += '<div style="background: url\(\'/Popup/PopupTop.bmp\'\) no-repeat; width: 340px; height: 50px;"></div>';
    popup += '<div style="text-align: center; width: 340px;"><embed src="/mediaplayer/player.swf" allowfullscreen="true" allowscriptaccess="never" width="320" height="260" flashvars="file=' + fileName + '&autostart=true" /></div>';
    popup += '<div style="background: url\(\'/Popup/PopupBottom.bmp\'\) no-repeat; width: 340px; height: 135px;"><div style="padding: 20px;"><div style="font-family: Calibri; font-size: 1em; color: #0066cc">' + title + '</div><div style="font-family: Calibri; font-size: 1em; color: #231f20">' + description + '</div></div></div>';
    popup += '</body></html>';

    ModalDialogWindow = window.open("", "PopupVideoWindow", args);
    ModalDialogWindow.document.open();
    ModalDialogWindow.document.write(popup);
    ModalDialogWindow.document.close();
    ModalDialogWindow.focus();
}

function ModalDialogShowWMVPlayer(fileName, title, description) {
    var args = 'width=340,height=460,left=100,top=100,toolbar=false,location=false,status=false,menubar=false,scrollbars=false,resizable=false';
    var popup = '<html><head><title>' + title + '</title><script type="text/javascript" src="/mediaplayer/wmvplayer/silverlight.js"></script><script type="text/javascript" src="/mediaplayer/wmvplayer/wmvplayer.js"></script></head>';
    popup += '<body bgcolor="#6ebe44" style="margin-right: auto; margin-left: auto">';
    popup += '<div style="background: url\(\'/Popup/PopupTop.bmp\'\) no-repeat; width: 340px; height: 50px;"></div>';
    popup += '<div style="text-align: center; width: 340px;"><div name="mediaspace" id="mediaspace"></div></div>';
    popup += '<script type="text/javascript">var cnt = document.getElementById("mediaspace");var src = \'/mediaplayer/wmvplayer/wmvplayer.xaml\';var cfg = { file:\'' + fileName + '\', height:\'260\', width:\'320\' };var ply = new jeroenwijering.Player(cnt,src,cfg);</script>';
    popup += '<div style="background: url\(\'/Popup/PopupBottom.bmp\'\) no-repeat; width: 340px; height: 135px;"><div style="padding: 20px;"><div style="font-family: Calibri; font-size: 1em; color: #0066cc">' + title + '</div><div style="font-family: Calibri; font-size: 1em; color: #231f20">' + description + '</div></div></div></body>';
    popup += '</html>';

    ModalDialogWindow = window.open("", "PopupVideoWindow", args);
    ModalDialogWindow.document.open();
    ModalDialogWindow.document.write(popup);
    ModalDialogWindow.document.close();
    ModalDialogWindow.focus();
}

function ModalDialogShowWindowsMediaPlayer(fileName, title, description) {
    var args = 'width=340,height=460,left=100,top=100,toolbar=false,location=false,status=false,menubar=false,scrollbars=false,resizable=false';
    var popup = '<html><head><title>' + title + '</title><body bgcolor="#6ebe44" style="margin-right: auto; margin-left: auto">';
    popup += '<div style="background: url\(\'/Popup/PopupTop.bmp\'\) no-repeat; width: 340px; height: 50px;"></div>';
    popup += '<div style="text-align: center; width: 340px;"><OBJECT ID="MediaPlayer" WIDTH="320" HEIGHT="260" CLASSID="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95" STANDBY="Loading Windows Media Player components..." TYPE="application/x-oleobject"><PARAM NAME="FileName" VALUE="' + fileName + '"><PARAM name="autostart" VALUE="true"><PARAM name="ShowControls" VALUE="false"><param name="ShowStatusBar" value="false"><PARAM name="ShowDisplay" VALUE="false"><EMBED TYPE="application/x-mplayer2" SRC="videofilename.wmv" NAME="MediaPlayer" WIDTH="320" HEIGHT="260" ShowControls="0" ShowStatusBar="0" ShowDisplay="0" autostart="1"> </EMBED></OBJECT></div>';
    popup += '<div style="background: url\(\'/Popup/PopupBottom.bmp\'\) no-repeat; width: 340px; height: 135px;"><div style="padding: 20px;"><div style="font-family: Calibri; font-size: 1em; color: #0066cc">' + title + '</div><div style="font-family: Calibri; font-size: 1em; color: #231f20">' + description + '</div></div></div>';
    popup += '</body></html>';

    ModalDialogWindow = window.open("", "PopupVideoWindow", args);
    ModalDialogWindow.document.open();
    ModalDialogWindow.document.write(popup);
    ModalDialogWindow.document.close();
    ModalDialogWindow.focus();
}
    
function set_cookie(name, value, exp_y, exp_m, exp_d, path, domain, secure) {
    var cookie_string = name + "=" + escape(value);

    if (exp_y) {
        var expires = new Date(exp_y, exp_m, exp_d);
        cookie_string += "; expires=" + expires.toGMTString();
    }

    if (path)
        cookie_string += "; path=" + escape(path);

    if (domain)
        cookie_string += "; domain=" + escape(domain);

    if (secure)
        cookie_string += "; secure";

    document.cookie = cookie_string;
}

function get_cookie(cookie_name) {
    var results = document.cookie.match('(^|;) ?' + cookie_name + '=([^;]*)(;|$)');

    if (results)
        return (unescape(results[2]));
    else
        return null;
}

function setOnClickEvent(obj, eventFunction) {
    obj.onclick = Function(eventFunction);
}

function fontSizer(size) {
    var newSize = size;
    var anchorElements = document.getElementById("textResize").getElementsByTagName("a");
    for (var i = 0; i < anchorElements.length; i++) {
        var linkTag = anchorElements[i];
        switch (i) {
            case 0:
                linkTag.className = "textNormal";
                break;
            case 1:
                linkTag.className = "textLarge";
                break;
        }
    }
    var pageContainer = document.getElementById("pageContainer");
    switch (newSize) {
        case "large":
            pageContainer.style.fontSize = "16px";
            anchorElements[1].className += " currentSize";
            set_cookie('fontsize', 'large', null, null, null, '/');
            break;
        default:
            pageContainer.style.fontSize = "12px";
            anchorElements[0].className += " currentSize";
            set_cookie('fontsize', 'normal', null, null, null, '/');
            break;
    }
}

function convertTextSizerToJS() {
    var anchorElements = document.getElementById("textResize").getElementsByTagName("a");
    var sizeValue = "";
    for (var i = 0; i < anchorElements.length; i++) {
        var linkTag = anchorElements[i];
        switch (i) {
            case 0:
                sizeValue = "normal";
                break;
            case 1:
                sizeValue = "large";
                break;
        }
        setOnClickEvent(linkTag, "fontSizer('" + sizeValue + "')");
    }

    var fontsize = get_cookie('fontsize');
    
    if ((fontsize == null) || (fontsize == "normal")) {
        fontSizer('normal');
    }
    else if (fontsize == "large") {
        fontSizer('large');
    }
}

convertTextSizerToJS();