<!--
ns4=(document.layers)?true:false;
ie4=(document.all)?true:false;
dom=(ns4|ie4)?false:true;
var groupArray = new Array();

var animArray = new Array();

function getLeft(elementID){

   if (ie4) {
      if(isNaN(document.all[elementID].style.left)){
         return Number(document.all[elementID].style.left.substr(0, document.all[elementID].style.left.length -2));
      } else {
         return document.all[elementID].style.left;
      }
   } else if (dom){
      return Number(document.getElementById(elementID).style.left.substr(0, document.getElementById(elementID).style.left.length -2));
   } else if (ns4) {
      return Number(document.layers[elementID].left);
   }
   return 0;
}

function getTop(elementID){

   if (ie4) {
      if(isNaN(document.all[elementID].style.top)){
         return Number(document.all[elementID].style.top.substr(0, document.all[elementID].style.top.length-2));
      } else {
         return document.all[elementID].style.top;
      }
      } else if (dom){
         return Number(document.getElementById(elementID).style.top.substr(0, document.getElementById(elementID).style.top.length -2));
      } else if (ns4) {
         return Number(document.layers[elementID].top);
      }
      return 0;
}

function startAnimation(elementID,path,looped,startAtX, startAtY, relativeValues){

   for(i=0;i<animArray.length;i++){
      if(animArray[i].targetElement==elementID){
         animArray[i].stop();
      }
   }
   if(relativeValues){
      startAtX = getLeft(elementID);
      startAtY = getTop(elementID);
   }

   animArray[animArray.length]=new animationPath(startAtX,startAtY,path,looped,0,elementID,'animArray[' + (animArray.length) + ']');
   animArray[animArray.length-1].play();
}

function stopAnimation(elementID){
   for(i=0;i<animArray.length;i++){
      if(animArray[i].targetElement==elementID){
         animArray[i].stop();
      }
   }
}

function animationPath(iPathStartX, iPathStartY,aPointArray,bLoop,iPointIndex,sTargetElement,pathName){
    this.pathStartX = iPathStartX;
    this.pathStartY = iPathStartY;
    this.pointArray = aPointArray;
    this.pointIndex = iPointIndex;
    this.looped = bLoop;
    this.targetElement = sTargetElement;
    this.play = playAnim;
    this.pathName = pathName;
    this.stop=stopAnim;
    this.stopped=false;
}

function playAnim(){

  if(this.stopped==true){return false;}

  moveElement(this.targetElement,this.pathStartX+this.pointArray[this.pointIndex],this.pathStartY+this.pointArray[this.pointIndex+1],0,0,false,'00000000-0000-0000-0000-000000000000',0,false);

  this.pointIndex=this.pointIndex+2;
   if(this.pointIndex<this.pointArray.length){
      setTimeout(this.pathName +".play();",100);
   }
   if(this.looped && this.pointIndex>=this.pointArray.length){
      this.pointIndex=0;
      setTimeout(this.pathName + ".play();",100);
   }

   if(!this.looped && this.pointindex>=this.pointArray.length){
      this.stopped=true;
   }
}

function stopAnim(){
   this.stopped=true;
}
function showElement(myDiv, gID, ApplyToGroup){
    if(ns4)
    {
        var element=document.layers[myDiv];
    } else if(ie4)
    {
        var element = document.all[myDiv].style;
    } else if (dom)
    {
        var element = document.getElementById(myDiv).style;
    }
    for (i=1; i<=ArrayNumber; i++){
        if (groupArray[i][0] == gID){
            var FoundIt = i;
            var Index = groupArray[i][0];
        }
    }
    if (Index == gID && ApplyToGroup == true) {
        for (j=1; j<=groupArray[FoundIt].length-1; j++){
            myDiv = groupArray[FoundIt][j];
            showElement(myDiv,-1);
        }
    } else {
        element.visibility = 'visible';
    }
}
function hideElement(myDiv, gID, ApplyToGroup){
    if(ns4)
    {
        var element=document.layers[myDiv];
    } else if(ie4)
    {
        var element = document.all[myDiv].style;
    } else if (dom)
    {
        var element = document.getElementById(myDiv).style;
    }
    for (i=1; i<=ArrayNumber; i++){
        if (groupArray[i][0] == gID){
            var FoundIt = i;
            var Index = groupArray[i][0];
        }
    }
    if (Index == gID && ApplyToGroup == true) {
        for (j=1; j<=groupArray[FoundIt].length-1; j++){
            myDiv = groupArray[FoundIt][j];
            hideElement(myDiv,-1);
        }
    } else {
        element.visibility = 'hidden';
    }
}
function doVoid(){
var v=0;}

function GoBack () {
    setTimeout("history.back();",10);
}
function imageSwap(myDiv,myElement,newImage, Trans, Speed){
    if(ns4)
    {
        document.layers[myDiv].document.images[myElement].src=newImage;
    } else
        if (ie4) {
            if (Trans != -1) { 
                if(isNaN(document.all[myDiv].style.top)){ 
                    document.all[myDiv].filters.item(0).Apply();
                    document.all[myDiv].filters.item(0).Transition=Trans;
                    document.images[myElement].src=newImage;
                    document.all[myDiv].filters(0).play(Speed);
                } else {
                    document.images[myElement].src=newImage
                }
            } 
            if (Trans == -1) { 
                document.images[myElement].src=newImage; 
            }
        } else if (dom) {
            var element = document.getElementById(myDiv).style;
            document.images[myElement].src=newImage;
        }
}
function showFile(windowName,source,w,h,looks){
     if(documentWindow && document.images){documentWindow.focus();}
     var documentWindow=window.open(source,windowName,"width=" + w + ",height=" + h + "," + looks);
}
function preLoad(){
   if(document.images){
      if(typeof(document.myImages)=='undefined'){
         document.myImages = new Object();
      }
      document.myImages.listImages = new Array();
      var picNum=preLoad.arguments.length;
      for(i=0;i<picNum;i++){
         document.myImages.listImages[i]=new Image();
         document.myImages.listImages[i].src = preLoad.arguments[i];
      }
   }
}

function showCad(myCad,w,h){
    cadWindow=window.open("","cadWindow","location=no,toolbar=no,status=no,width=w,height=h");
        cadWindow.document.write("<html><HEAD><TITLE>CADWindow</TITLE></HEAD><body>");
        if(ns4)
        {
      cadWindow.document.write("<EMBED SRC=\"" + myAudio + "\" HIDDEN=TRUE AUTOPLAY=TRUE>");
        } else if(ie4){
        cadWindow.document.write("<BGSOUND SRC=\"" + myAudio + "\">");
        }
        cadWindow.document.write("<P>Audio</P></body></html>");
        cadWindow.document.close();
}
function playAudio(myAudio,looped){
    audioWindow=window.open("","audioWindow","location=no,toolbar=no,status=no,width=10,height=10");
        audioWindow.document.write("<html><HEAD><TITLE>AudioWindow</TITLE></HEAD><body>");
        if(ns4)
        {
           audioWindow.document.write("<EMBED SRC=\"" + myAudio + "\" LOOP=" + looped + " HIDDEN=TRUE AUTOPLAY=TRUE>");
        } else if (dom){
           audioWindow.document.write("<OBJECT DATA=\"" + myAudio + "\" LOOP=" + looped + " HIDDEN=TRUE AUTOPLAY=TRUE>");
        } else if(ie4){
           if (looped==true) {
               audioWindow.document.write("<BGSOUND SRC=\"" + myAudio + "\"LOOP=INFINITE>");
           } else {
               audioWindow.document.write("<BGSOUND SRC=\"" + myAudio + "\">");
           }
        }
        audioWindow.document.write("<P>Audio</P></body></html>");
        audioWindow.document.close();
        if(document.images)audioWindow.blur();
}
function moveElement(myDiv,myLeft,myTop,myWidth,myHeight,RelativeValue,gID,Time, ApplyToGroup){
    if (Time != 0 && Time != -1) {
       var currentLeft = getLeft(myDiv);
       var currentTop = getTop(myDiv);
        if (RelativeValue) {
            modifyLeft=0; modifyTop=0;
        } else {
            modifyLeft=currentLeft; modifyTop=currentTop;
        }

        if (myTop == 0 && myLeft != 0 && myLeft != currentLeft) {
            var lAskel = (myLeft - modifyLeft) / (10 * Time);
            var tAskel = 0;
        } else if (myTop != 0 && myLeft == 0 && myTop != currentTop) {
            var lAskel = 0;
            var tAskel = (myTop - modifyTop) / (10 * Time);
        } else {
            var lAskel = (myLeft - modifyLeft) / (10 * Time);
            var tAskel = (myTop - modifyTop) / (10 * Time);
        }

        var NewMyLeft = 0;
        var NewMyTop = 0; 
 
        for (i=1; i<=ArrayNumber; i++){
            if (groupArray[i][0] == gID){
                var FoundIt = i;
                var Index = groupArray[i][0];
            }
        }
        if (Index == gID && ApplyToGroup == true) {
            for (j=1; j<=groupArray[FoundIt].length-1; j++){
                myDiv = groupArray[FoundIt][j];
                moveElement(myDiv,myLeft,myTop,myWidth,myHeight,RelativeValue,-1,Time);
            }
        } else {
            for (i=1; i<=10*Time; i++){
                if (i == 1) { 
                    NewMyLeft = Number(currentLeft) + Number(lAskel); 
                    NewMyTop = Number(currentTop) + Number(tAskel); 
                } else {
                    NewMyLeft = NewMyLeft + lAskel;
                    NewMyTop = NewMyTop + tAskel;
                }
 
                setTimeout("moveElement('" + myDiv + "'," + NewMyLeft + "," + NewMyTop + "," + myWidth + "," + myHeight + "," + RelativeValue + ",'" + gID + "'," + -1 + ");", i*25);
            }//for
        }
        return false;
    }//if
    if(ns4){ 
        var element=document.layers[myDiv];
    } else if (dom) {
        var element = document.getElementById(myDiv).style;
    } else if (ie4) {
        var element = document.all[myDiv].style;
    }
        for (i=1; i<=ArrayNumber; i++){
            if (groupArray[i][0] == gID){
                var FoundIt = i;
                var Index = groupArray[i][0];
            }
        }
        if (Index == gID && ApplyToGroup == true) {
            for (j=1; j<=groupArray[FoundIt].length-1; j++){
                myDiv = groupArray[FoundIt][j];
                moveElement(myDiv,myLeft,myTop,myWidth,myHeight,RelativeValue,-1,0);
            }
        } else if (RelativeValue == true) {
            if (ns4 && Time != -1) {
                newLeft = element.left;
                myLeft = newLeft + myLeft;
                newTop = element.top;
                myTop = newTop + myTop;
            } else {
                if (Time == -1) { 
                } else {
                    newLeft = getLeft(myDiv);
                    newTop = getTop(myDiv);
                    myLeft=Number(newLeft) + Number(myLeft);
                    myTop=Number(newTop) + Number(myTop);
                }
            }
        } else {
            if (myTop == 0 && myLeft != 0) {
                element.left = myLeft;
                myTop=getTop(myDiv);
            } else if (myTop != 0 && myLeft == 0 ) {
                element.top = myTop;
                myLeft = getLeft(myDiv);
            }
        }
        if (typeof(ApplyToGroup) == 'undefined' || ApplyToGroup == false) {
            if (dom){
                element.top = myTop + 'px';
                element.left = myLeft + 'px';
            } else {
                element.top = myTop;
                element.left = myLeft;
            }
        }
}
function changeText(myDiv, Text) { 
    if(ns4){ 
        var element=document.layers[myDiv];
    } else if (dom) {
        var elementti = document.getElementById(myDiv);
        if (elementti != null) {
            var element = document.getElementById(myDiv).style;
            elementti.innerHTML = Text;
        }
    } else if (ie4) {
        if (document.all[myDiv] != null) {
            var element = document.all[myDiv].style;
            document.getElementById(myDiv).innerHTML = Text;
        }
    }
}
//-->

