﻿

var nf = new Object()
nf.objectsData=null;
nf.regObjectsData = function(objName) {
    var obj = document.getElementById(objName);
    this.objectsData = obj;
}

nf.player = null;
nf.playerObjName = "";
nf.regPlayerName = function(playerName) {
    this.playerObjName = playerName;
}
nf.regPlayer = function() {
    var obj = document.getElementById(this.playerObjName);

    if (obj == null) {
        obj = document.embeds[this.playerObjName]
    }

    this.player = obj;

    if (obj == null) {
        alert("Flash player not detected!")
    }

}
nf.titleObjName = "";
nf.titlePartObjName = "";
nf.playSourcesObjName = "";
nf.regPlayerTitle = function(titleName, titlePartName, soucesObjName) {
    this.titleObjName = titleName;
    this.titlePartObjName = titlePartName;
    this.playSourcesObjName = soucesObjName;
}
nf.ApplyPlaySources = function(text) {
    var obj = document.getElementById(nf.playSourcesObjName);
    if (obj != null) obj.innerHTML = text.split("&quot").join('"');
} 
nf.stringList = new Object();
nf.regStr = function(sm, objID, urlName) {
    this.stringList[sm.toString() + "_" + objID.toString()] = urlName;
}
nf.getStr = function(sm, objID) {
    return this.stringList[sm.toString() + "_" + objID.toString()];
}
nf.cmdList = new Object();
nf.regCPS = function(sm, _ui, _des, _tp, _t, _v, _f, _fs, _fsc, _in, _out) {

this.cmdList[sm.toString() + "_" + _ui.toString()] = { sm: sm, ui: _ui, cmd: 1, desc: _des, title: _t, descPart: _tp, video: _v,
        film: _f, source: _fs,
        scene: _fsc, timeIn: _in, timeOut: _out,
        selectedItem: 0
    }
}
nf.regCPF = function(sm, _ui, _des, _tp, _t, _v, _f, _fs) {
this.cmdList[sm.toString() + "_" + _ui.toString()] = { sm: sm, ui: _ui, cmd: 1, desc: _des, title: _t, descPart: _tp, video: _v,
        film: _f, source: _fs,
        scene: 0, timeIn: 0, timeOut: 0,
        selectedItem: 0
    }
}
nf.regCPI = function(sm, _ui, _des, _tp, _t, _v, _f, _fs, _si, _in, _out) {

    this.cmdList[sm.toString() + "_" + _ui.toString()] = { sm:sm, ui: _ui, cmd: 1, desc: _des, title: _t, descPart: _tp, video: _v,
        film: _f, source: _fs,
        scene: 0, timeIn: _in, timeOut: _out,
        selectedItem: _si
    }
}

nf.setTitle = function(sm, titleText, titlePartText) {
    var obj = document.getElementById(this.titleObjName);

    if (obj == null) {
        obj = document.embeds[this.titleObjName]
    }

    if (obj != null)
        obj.innerHTML = this.getStr(sm, titleText);

    obj = document.getElementById(this.titlePartObjName);
    if (obj == null) {
        obj = document.embeds[this.titlePartObjName]
    }

    if (obj != null)
        obj.innerHTML = this.getStr(sm, titlePartText);

}

nf.tabNameSI = "";
nf.tabIndexSI = -1;
nf.tabIndexSD = -1;
nf.regOnADF = function(tabName, tabIndex, tabIndex2) {
    this.tabIndexSI = tabIndex;
    this.tabNameSI = tabName;
    this.tabIndexSD = tabIndex2;
}
nf.ChangeTab = function() {
    var tabPanel = $find(this.tabNameSI);
    if (tabPanel != null && this.tabIndexSI!=-1) tabPanel.set_activeTabIndex(this.tabIndexSI);

}
nf.ChangeTabDesc = function() {
    var tabPanel = $find(this.tabNameSI);
    if (tabPanel != null && this.tabIndexSD!=-1) tabPanel.set_activeTabIndex(this.tabIndexSD);

}


nf.pfdCurentFilm = 0;
nf.pfdUsing = false;
nf.pfdPanelName = "";
nf.pfdUpdateTextName = "";
nf.pfdUpdate = function(film) {
    if (film == this.pfdCurentFilm) return;
    var updateText = $get(this.pfdUpdateTextName);
    if (updateText != null) { updateText.innerHTML = "Updating...";}

    var panel = $get(this.pfdPanelName);
    if (panel != null) __doPostBack(this.pfdPanelName, "update_film_description:" + film.toString());

    this.pfdCurentFilm = film;

    nf.ChangeTabDesc();
}
nf.regPFD = function(panelName, updateTextName) {
    this.pfdPanelName = panelName;
    this.pfdUpdateTextName = updateTextName;
    this.pfdUsing = true;
}
nf.updateScripts = new Array();
nf.regUpdateScript = function(valueName) {
    this.updateScripts.push(valueName);
}
nf.OnUpdate = function(sender, args) {

    try {
        for (var i = 0; i < nf.updateScripts.length; i++) {
            var hv = $get(nf.updateScripts[i].toString());
            us = hv.value;
            if (hv != null && hv.value.length > 0) {
                eval(us.toString().split("&xquot").join('"'));
            }
        }
    }
    catch (e) { }

}
nf.play = function(sm, cmd) {
    window.scrollTo(0, 180);
    this.regPlayer();
    if (this.player != null) {
        if (cmd.source > 0 )
            this.player.PlaySource(this.getStr(sm, cmd.title), this.getStr(sm, cmd.video),sm.toString()+"_"+ cmd.ui, cmd.source, cmd.timeIn, cmd.timeOut);
        else
            this.player.SetNoVideo(cmd.ui);
    }
    this.setTitle(sm, cmd.desc, cmd.descPart);
    if (this.pfdUsing) this.pfdUpdate(cmd.film)

}
nf.exec = function(sm, ui) {
    var cmd = this.cmdList[sm.toString() + "_" + ui.toString()];
    if (cmd.cmd == 1) nf.play(sm, cmd);
}
nf.nameASC = "";
nf.regASC = function(name) {
    this.nameASC = name;
}
nf.playerSaveClick = function(sm_ui, _in, _out) {
    var cmd = this.cmdList[sm_ui];
    if (cmd != null) {


        var panel = $get(this.nameASC);
        if (panel != null) __doPostBack(this.pfdPanelName, "add_scene:"
                                + cmd.film.toString() + ","
                                + cmd.source.toString() + ","
                                + cmd.selectedItem.toString() + ","
                                + _in.toString() + ","
                                + _out.toString()
                                );

        if (cmd.selectedItem != 0) {
            var nn = cmd.sm.toString() + "_" + "x" + cmd.ui.toString();
            if (this.cmdList[nn] == null) {
                this.cmdList[nn] = { sm: cmd.sm, ui: "x" + cmd.ui.toString(), cmd: 1, desc: cmd.desc, title: cmd.title, descPart: cmd.descPart, video: cmd.video,
                    film: cmd.film, source: cmd.source,
                    scene: 0, timeIn: 0, timeOut: 0,
                    selectedItem: 0
                }
            }
            nf.exec(cmd.sm, "x" + cmd.ui.toString());
        }

        nf.ChangeTab();


    }
}
nf.nameAFC = "";
nf.regAFC = function(name) {
    this.nameAFC = name;
}
nf.onAFC = function(film) {
    var panel = $get(this.nameAFC);
    if (panel != null) __doPostBack(this.pfdPanelName, "add_film:" + film.toString());
    nf.ChangeTab();

}

