﻿function renderFlash(swfPath, width, height, bgColor){
    document.write( "<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http:\/\/fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0\" width=\""+width+"\" height=\""+height+"\" id=\"feature\">" + 
    " <param name=\"allowScriptAccess\" value=\"sameDomain\" />" + 
    " <param name=\"movie\" value=\""+swfPath+"\" />" + 
    " <param name=\"quality\" value=\"high\" />" + 
    " <param name=\"bgcolor\" value=\""+bgColor+"\" />" + 
    " <embed src=\""+swfPath+"\" quality=\"high\" bgcolor=\""+bgColor+"\" width=\""+width+"\" height=\""+height+"\" name=\"feature\" allowScriptAccess=\"sameDomain\" type=\"application/x-shockwave-flash\" pluginspage=\"http:\/\/www.macromedia.com/go/getflashplayer\" />" + 
    "</object>");
}
function renderMovie(src, width, height, autoplay, controller){
    if(src.indexOf(".mov")>-1) renderQT(src, width, height, autoplay, controller)
    else renderMP(src, width, height, autoplay, controller)
}
function renderQT(src, width, height, autoplay, controller){
    if(!width) width=320
    if(!height) height=240
    if(!controller) controller=false
    if(!autoplay) autoplay=true
    if(controller) height=height+16
 
    document.write( "<object classid=\"clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B\" bgcolor=\"black\" width=\""+width+"\"height=\""+height+"\" codebase=\"http:\/\/www.apple.com/qtactivex/qtplugin.cab\">" + 
    " <param name=\"SRC\" value=\""+src+"\">" + 
    " <param name=\"AUTOPLAY\" value=\""+autoplay+"\">" + 
    " <param name=\"CONTROLLER\" value=\""+controller+"\">" + 
    " <param name=\"BGCOLOR\" value=\"white\">" + 
    " <embed src=\""+src+"\" width=\""+width+"\" height=\""+height+"\" autoplay=\""+autoplay+"\" controller=\""+controller+"\" pluginspage=\"http:\/\/www.apple.com/quicktime/download/\"></embed>" + 
    "</object>");
}
 
 
function renderMP(src, width, height, autoplay, controller){
    if(!width) width=320
    if(!height) height=240
    if(!autoplay) autoplay=1
    else autoplay=0
 
    if(controller){
        height=height+48;
        controller=1
    }else controller=0
 
    document.write( "<object id=\"MediaPlayer\" autoplay=\""+autoplay+"\" width=\""+width+"\" height=\""+height+"\" classid=\"CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95\" codebase=\"http:\/\/activex.microsoft.com\/activex\/controls\/mplayer\/en/nsmp2inf.cab#Version=5,1,52,701\" standby=\"Loading Microsoft Windows Media Player components...\" type=\"application\/x-oleobject\">" + 
    "    <param name=\"src\" value=\""+src+"\">" + 
    "    <param name=\"ShowControls\" value=\""+controller+"\">" + 
    "    <param name=\"ShowDisplay\" value=\"0\">" + 
    " <embed type=\"application/x-mplayer2\" " + 
    "     src=\""+src+"\"" + 
    "     name=\"MediaPlayer\"" + 
    "     width=\""+width+"\"" + 
    "     height=\""+height+"\"" + 
    "  autoplay="+autoplay+"" + 
    "  showcontrols=\""+controller+"\"" + 
    "  showdisplay=\"0\"" + 
    "  >" + 
    "  </embed>" + 
    "</object>");
}


// the fallowing code is added by Richard, starting at : 2005-03-03 ...
var zooma = new Object();

// Richard A. 2005-03-03
zooma.currentPageName = '';
zooma.changePage = function(id, inc) {
    var sel = document.getElementById(id);
    var currentindex=-1;
    for(currentindex=0;currentindex<sel.options.length;currentindex++) {
        if(sel.options[currentindex].value==zooma.currentPageName) {break;}
    }
    // check if this page is the last or first ...
    if((currentindex==-1) || (inc==1 && (currentindex==sel.options.length-1)) || (inc==-1 && (currentindex==0))) {return;}
    if(sel.options[currentindex+inc].value==null || (sel.options[currentindex+inc].value=='')) {return;}

    window.location.href = sel.options[currentindex+inc].value;
}

// Richard A. 2005-03-03
zooma.gotoSelectUrl = function(sel) {
    var url = sel.options[sel.options.selectedIndex].value;
    url = (url=='' || (url==null))?'':url;
    if(url!='') {
        window.location.href = sel.options[sel.options.selectedIndex].value;
    }
}

/*zooma.open_XmasWindow = function(url) {
    var strName = 'pfaffCalendar';
    window.open(url,strName,'width=538,height=555,scrollbars=no,resizable=no,left=100,top=100');
}*/

// Richard A. 2005-03-07
zooma.setMediaWindow = function() {
    /*
        resizes the window and layers, to make
        the media appear in the middle with some margin
    */
    var pageMarginWidth=60, pageMarginHeight=100;
    var contentMarginWidth=10, contentMarginHeight=10;
    var frm = document.getElementById("frmMediaProperties");
    var w = parseInt(frm.width.value);
    var h = parseInt(frm.height.value);
    window.resizeTo(w+pageMarginWidth, h+pageMarginHeight);
    var pageLayer = document.getElementById("pagemedia");
    pageLayer.style.width = w+contentMarginWidth+"px";
    window.focus();
}

// Richard A. 2005-03-07
zooma.openMediaWindow = function(url) {
    var strName = 'MediaWindow';
    window.open(url,strName,'width=800,height=500,scrollbars=no,resizable=no,left=100,top=100');
}
zooma.openExpWindow = function(url) {
    var strName = 'MediaWindow';
    window.open(url,strName,'width=840,height=500,scrollbars=no,resizable=no,left=100,top=100');
}
zooma.openSelectWindow = function(url) {
    var strName = 'MediaWindow';
    window.open(url,strName,'width=700,height=525,scrollbars=no,resizable=no,left=100,top=100');
}
zooma.open2170Window = function(url) {
    var strName = 'MediaWindow';
    window.open(url,strName,'width=872,height=553,scrollbars=no,resizable=no,left=100,top=100');
}
function openXmasWindow(str) {
    var strName = 'MediaWindow';
    window.open(url,strName,'width=620,height=620,scrollbars=no,resizable=no,left=100,top=100');
}

// Programmed 2002-08-20 by Richard Appelgren (c) 
// usage : 
// var theValue = request.querystring("test2")); 
var request = new Object();
request.querystring = function(skey) { 
    var val="", qs, arr = [], nr, key = skey+"="; 
    if(window.location.href.indexOf("?")>-1) { 
        qs = window.location.href.substring(window.location.href.indexOf("?")+1); 
        arr = qs.split("&"); 
        for(var i=0;i<arr.length;i++) { 
            nr = arr[i].lastIndexOf(key); 
            if(nr>-1) { 
                val = arr[i].substring(nr+key.length); 
                break; 
            } 
        } 
    } 
    return val; 
}
