CSAg = window.navigator.userAgent; CSBVers = parseInt(CSAg.charAt(CSAg.indexOf("/")+1),10);
function IsIE() { return CSAg.indexOf("MSIE") > 0;}
function CSIEStyl(s) { return document.all.tags("div")[s].style; }
function CSNSStyl(s) { return CSFindElement(s,0); }
function CSFindElement(n,ly) { if (CSBVers < 4) return document[n];
        var curDoc = ly ? ly.document : document; var elem = curDoc[n];
        if (!elem) { for (var i=0;i<curDoc.layers.length;i++) {
                elem = CSFindElement(n,curDoc.layers[i]); if (elem) return elem; }}
        return elem;
}

function CSSetStylePos(s,d,p) { if (IsIE()) { if (d == 0) CSIEStyl(s).posLeft = p; else CSIEStyl(s).posTop = p; }
        else { if (d == 0) CSNSStyl(s).left = p; else CSNSStyl(s).top = p; } }
function CSGetStylePos(s,d) { if (IsIE()) { if (d == 0) return CSIEStyl(s).posLeft; else return CSIEStyl(s).posTop; }
        else { if (d == 0) return CSNSStyl(s).left; else return CSNSStyl(s).top; }}

function CSSlideObj (layer,start,end,ticks,startTime) {
        this.layer=layer;this.start=start;this.end=end;this.ticks=ticks;this.startTime=startTime;
}


function CSScriptInit() {
if(typeof(skipPage) != "undefined") { if(skipPage) return; }
idxArray = new Array;
for(var i=0;i<CSInit.length;i++)
        idxArray[i] = i;
CSAction2(CSInit, idxArray);


}

function CSScriptExit() {
idxArray = new Array;
for(var i=0;i<CSExit.length;i++)
        idxArray[i] = i;
CSAction2(CSExit, idxArray);


}
CSStopExecution = false;
CSInit = new Array;

CSExit = new Array;

CSStopExecution = false;

function CSAction(array) {
        return CSAction2(CSAct, array);
}
function CSAction2(fct, array) {
        var result;
        for (var i=0;i<array.length;i++) {
                if(CSStopExecution) return false;
                var actArray = fct[array[i]];
                if(actArray == null) return false;
                var tempArray = new Array;
                for(var j=1;j<actArray.length;j++) {
                        if((actArray[j] != null) && (typeof(actArray[j]) == "object") && (actArray[j].length == 2)) {
                                if(actArray[j][0] == "VAR") {
                                        tempArray[j] = CSStateArray[actArray[j][1]];
                                }
                                else {
                                        if(actArray[j][0] == "ACT") {
                                                tempArray[j] = CSAction(new Array(new String(actArray[j][1])));
                                        }
                                else
                                        tempArray[j] = actArray[j];
                                }
                        }
                        else
                                tempArray[j] = actArray[j];
                }
                result = actArray[0](tempArray);
        }
        return result;
}
CSAct = new Object;

CSIm = new Object();
function CSIShow(n,i) {
        if (document.images) {
                if (CSIm[n]) {
                        var img = (!IsIE()) ? CSFindElement(n,0) : document[n];
                        if (img && typeof(CSIm[n][i].src) != "undefined") {img.src = CSIm[n][i].src;}
                        if(i != 0)
                                self.status = CSIm[n][3];
                        else
                                self.status = " ";
                        return true;
                }
        }
        return false;
}
function CSILoad(action) {
        im = action[1];
        if (document.images) {
                CSIm[im] = new Object();
                for (var i=2;i<5;i++) {
                        if (action[i] != '') { CSIm[im][i-2] = new Image(); CSIm[im][i-2].src = action[i]; }
                        else CSIm[im][i-2] = 0;
                }
                CSIm[im][3] = action[5];
        }
}

function CSClickReturn () {
        var bAgent = window.navigator.userAgent;
        var bAppName = window.navigator.appName;
        if ((bAppName.indexOf("Explorer") >= 0) && (bAgent.indexOf("Mozilla/3") >= 0) && (bAgent.indexOf("Mac") >= 0))
                return true; // dont follow link
        else return false; // dont follow link
}

function CSButtonReturn () {
        var bAgent = window.navigator.userAgent;
        var bAppName = window.navigator.appName;
        if ((bAppName.indexOf("Explorer") >= 0) && (bAgent.indexOf("Mozilla/3") >= 0) && (bAgent.indexOf("Mac") >= 0))
                return false; // follow link
        else return true; // follow link
}

function CSBrowserSwitch(action) {
        var bAgent        = window.navigator.userAgent;
        var bAppName        = window.navigator.appName;

        var isNS                = (bAppName.indexOf("Netscape") >= 0);
        var isIE                = (bAppName.indexOf("Explorer") >= 0);
        var isWin                = (bAgent.indexOf("Win") >= 0);
        var isMac                = (bAgent.indexOf("Mac") >= 0);

        var vers                = 0;
        var versIdx        = (bAgent.indexOf("Mozilla/"));

        if(versIdx >= 0)
                {
                var sstr        = bAgent.substring(versIdx + 8, versIdx + 9);
                vers                = parseInt(sstr) - 2;
                }

        var url                = action[1];
        var platform        = action[2];

        var versVec;
        if(platform)
                {
                if(isNS && isMac) versVec = action[3];
                if(isIE && isMac) versVec = action[4];
                if(isNS && isWin) versVec = action[5];
                if(isIE && isWin) versVec = action[6];
                }
        else
                {
                if(isNS) versVec = action[3];
                if(isIE) versVec = action[4];
                }

        if(vers > (versVec.length-1))
                vers = versVec.length-1;
        if(versVec[vers] == 0)
                {
                location                        = url;
                CSStopExecution        = true;
                }
}



function CSAutoStartScene(action) { CSStartSeq (action[1]); }


function CSGetLayerPos(action) {
        var layer = action[1];
        var x                = CSGetStylePos(layer, 0);
        var y                = CSGetStylePos(layer, 1);
        return new Array(x, y);
}
function CSGetFormElementValue(action) {
        var form = action[1];
        var elem = action[2];
        return document.forms[form].elements[elem].value;
}
CSImages=new Array();
function CSPreloadImage(action) {
        if (document.images) { CSImages[CSImages.length]=new Image(); CSImages[CSImages.length-1].src=action[1]; }
}
function CSRandomImg(action) {
        if (document.images) {
                var img = null;
                var whichone = Math.floor((Math.random() * 10)) % 3
                if(!IsIE()) img = CSFindElement(action[1],0);
                else img = document.images[action[1]];
                img.src = action[whichone+2]
        }
 }
function CSSetImageURL(action) {
        var img = null;
        if (document.images) {
                if (!IsIE()) img = CSFindElement(action[1],0);
                else img = document.images[action[1]];
                if (img) img.src = action[2];
        }
}
function CSGoBack1() { history.back() }
function CSGotoLink(action) {
        if (action[2].length) {
                var hasFrame=false;
                for(i=0;i<parent.frames.length;i++) { if (parent.frames[i].name==action[2]) { hasFrame=true; break;}}
                if (hasFrame==true)
                        parent.frames[action[2]].location = action[1];
                else
                        window.open (action[1],action[2],"");
        }
        else location = action[1];
}

function CSNSStartDrag (ev) {
        var clickInMe = false;
        if (ev.target != this) {
                for (var i=0;i<this.images.length;i++) {
                        if (this.images[i] == ev.target) { clickInMe = true; break;}
                        }
                }
        else clickInMe = true;
        if (clickInMe)
                {
                this.captureEvents(Event.MOUSEMOVE|Event.MOUSEUP);
                this.onmousemove=CSNSDoDrag;
                this.theLayer.x= ev.pageX;
                this.theLayer.y= ev.pageY;
                this.routeEvent(ev);
                return false;
                }
   this.onmousemove=null;this.releaseEvents(Event.MOUSEMOVE|Event.MOUSEUP);
        this.routeEvent(ev);
   return true;
}
function CSNSStopDrag (ev) {
   this.onmousemove=null;this.releaseEvents(Event.MOUSEMOVE|Event.MOUSEUP);return false;
}
function CSNSDoDrag (ev) {
        this.theLayer.layer.moveBy(ev.pageX-this.theLayer.x, ev.pageY-this.theLayer.y);
        this.theLayer.x = ev.pageX;
        this.theLayer.y = ev.pageY;
        this.routeEvent(ev);
}
function CSIEStartDrag () {
        if(gCSIEDragObject != null && (gCSIEDragObject.tagName==event.srcElement.tagName))
                event.returnValue=false;
}
function CSIEStopDrag () { gCSIEDragObject=null; document.onmousemove=null; }
function CSIEMouseDown () {
        if(event.button==1) {
                dragLayer = event.srcElement;
                while (dragLayer!=null)
                        {
                        if ((dragLayer.dragObj == null) && (dragLayer.tagName == "DIV"))
                                break;
                        if (dragLayer.dragObj != null)
                                break;
                        dragLayer=dragLayer.parentElement;
                        }

                if (dragLayer == null) return;
                if (dragLayer.dragObj!=null && dragLayer.dragObj.canDrag) {
                        gCSIEDragObject = dragLayer;
                        gCSIEDragObject.dragObj.x=event.clientX;
                        gCSIEDragObject.dragObj.y=event.clientY;
                        document.onmousemove = CSIEMouseMove;
                }
        }
}
function CSIEMouseMove () {
        gCSIEDragObject.dragObj.layerObj.style.pixelLeft+=(event.clientX-gCSIEDragObject.dragObj.x);
        gCSIEDragObject.dragObj.layerObj.style.pixelTop+=(event.clientY-gCSIEDragObject.dragObj.y);
        gCSIEDragObject.dragObj.x=event.clientX;
        gCSIEDragObject.dragObj.y=event.clientY;
        event.returnValue = false;
        event.cancelBubble = true;
}
var gDragArray = new Array();
function CSDrag(action) { gDragArray[gDragArray.length] = new CSSetupDrag(action[1]); }

function CSStartWipe (action)
{
        var el=CSCreateTransElement (action[1], action[2]);
        if (el==null) return;
        var dir=action[3];
        if (dir=="_inLeft") {el.steps=el.clipRect.width/el.maxValue; el.modus="in";}
        else if (dir=="_inRight") {el.steps=el.clipRect.width/el.maxValue; el.modus="in";}
        else if (dir=="_outLeft") {el.steps=el.clipRect.width/el.maxValue; el.modus="out";}
        else if (dir=="_outRight") {el.steps=el.clipRect.width/el.maxValue; el.modus="out";}
        else if (dir=="_inTop") {el.steps=el.clipRect.height/el.maxValue; el.modus="in";}
        else if (dir=="_inBottom") {el.steps=el.clipRect.height/el.maxValue; el.modus="in";}
        else if (dir=="_outTop") {el.steps=el.clipRect.height/el.maxValue; el.modus="out";}
        else if (dir=="_outBottom") {el.steps=el.clipRect.height/el.maxValue; el.modus="out";}
        else if (dir=="_inCenter") {el.HSteps=el.clipRect.width/el.maxValue; el.VSteps=el.clipRect.height/el.maxValue; el.modus="in";}
        else if (dir=="_outCenter") {el.HSteps=el.clipRect.width/el.maxValue; el.VSteps=el.clipRect.height/el.maxValue; el.modus="out";}
        if (el.modus=="") return;
        el.currentValue=0;
        el.dir=action[3];
        CSStartFunction(CSDoWipe,el);
}


function initArray() {
this.length = initArray.arguments.length;
for (var i = 0; i < this.length; i++)
this[i+1] = initArray.arguments[i];
}


function CSActionGroup (action) {
        for(var i=1;i<action.length;i++) { CSAction(new Array(action[i])); }
}
function CSCallAction(action)
{
        CSAction(new Array(action[1]));
}
function CSCallFunction(action)
{
        var str = action[1];
        str += "(";
        str += action[2];
        str += ");"

        return eval(str);
}
function CSConditionAction(action) {
        if (action[1]) {
                if (CSAction(new Array(action[1])) == true) {
                        if (action[2]) CSAction(new Array(action[2]));
                } else if (action[3]) CSAction(new Array(action[3]));
        }
}
function CSIdleObject (action) {
        this.conditionAction = action[2];
        this.trueAction = action[3];
        this.falseAction = action[4];
        this.exitIdleIfTrue = action[1];
        this.lastState = false;
}
function CSIdleAction(action) {
        idleObj = new CSIdleObject (action);
        CSStartFunction (CSDoIdle,idleObj);
}






