<!--
ns4=(document.layers)?true:false;
ie4=(document.all)?true:false;
dom=(ns4|ie4)?false:true;
var groupArray = new Array();

var animArray = new Array();

var audioWindow = -1;
var videoWindow = -1;
var dwfWindow = -1;
var officeWindow = -1;
var bVideoWarningDone = false;
var bActiveXWarningDone = false;
var sCurrentOffice = "";

var browser_type = 0;
if (navigator.userAgent.toUpperCase().match(/MSIE/) != null) { browser_type = 1;
} else if (navigator.userAgent.toUpperCase().match(/FIREFOX/) != null) { browser_type = 2;
} else if (navigator.userAgent.toUpperCase().match(/NETSCAPE/) != null) { browser_type = 3;
} else { browser_type = 0;}
function getBrowserType(){
    return browser_type;
}

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();}
     if ((source.substr(1,2) == ':\\') || (source.substr(1,2) == ':/')) { source = 'file:///' + source; }
     var documentWindow=window.open(source,windowName,"width=" + w + ",height=" + h + "," + looks);
}
function viewDWF(fileName,width,height,inObjStr, dummy){
 htmlObjectID = document.getElementById(inObjStr);
 if (htmlObjectID.BackColor) {
   htmlObjectID.style.visibility = 'visible';
   htmlObjectID.SourcePath = GetAbsolutePath(fileName);
   htmlObjectID = document.getElementById(inObjStr + '_Close');
   htmlObjectID.style.visibility = 'visible';
 } else {
   if ((getBrowserType() == 2 || getBrowserType() == 3) && bActiveXWarningDone==false ) {
     alert('The ActiveX plugin has to be installed (or customized) on the web browser of your computer\nif you want to see this file correctly embedded in the browser window.\nFor more information, please visit this page:\n  http://www.multimaker.fi/info_en_rd.html \n\n\nTietokoneesi selaimeen täytyy olla asennettuna (tai räätälöitynä) ActiveX -liitäntä jos haluat,\nettä tämä tiedosto avautuu selainikkunaan upotettuna.\nLisätietoja saat tältä WWW-sivulta:\n   http://www.multimaker.fi/info_fi_rd.html');
     bActiveXWarningDone = true;
   }

   if ((fileName.substr(1,2) == ':\\') || (fileName.substr(1,2) == ':/')) { fileName = 'file:///' + fileName; }
   dwfWindow = window.open(fileName, "_blank", "width= 100 , height= 100");
 }
}

function hideDWFObject(inObjStr) {
htmlObjectID = document.getElementById(inObjStr);
htmlObjectID.sourcePath = "";
htmlObjectID.style.visibility = 'hidden';
htmlObjectID = document.getElementById(inObjStr + '_Close');
htmlObjectID.style.visibility = 'hidden';
}
function viewVideo(fileName,width,height,htmlObjectID,controls){
str ="viewVideo2('"+fileName+"',"+width+","+height +",'"+htmlObjectID+"','"+controls+"');";
setTimeout(str, 300);
}
function viewVideo2(fileName,width,height,inObjStr,controls){
   htmlObjectID = document.getElementById(inObjStr);
   if (htmlObjectID == null){
       alert('Page download is not completed yet. Press refresh (F5) and wait.')
   } else {
       if (htmlObjectID.uiMode) {         if (controls=='SHOWCONTROLS'){
           htmlObjectID.uiMode = 'mini';
         } else {
           htmlObjectID.uiMode = 'none';
         }
         htmlObjectID.style.visibility = 'visible';
         htmlObjectID.URL = fileName;
         htmlObjectID.controls.play();
         htmlObjectID = document.getElementById(inObjStr + '_Close');
         htmlObjectID.style.visibility = 'visible';
       } else {
         if (getBrowserType() == 1 && bVideoWarningDone==false) {
           alert('Windows Media Player 7 or later needs to be installed. Go to http://www.microsoft.com/windowsmedia');
           bVideoWarningDone = true;
         }
         if ((getBrowserType() == 2 || getBrowserType() == 3) && bActiveXWarningDone==false ) {
           alert('The ActiveX plugin has to be installed (or customized) on the web browser of your computer\nif you want to see this file correctly embedded in the browser window.\nFor more information, please visit this page:\n  http://www.multimaker.fi/info_en_rd.html \n\n\nTietokoneesi selaimeen täytyy olla asennettuna (tai räätälöitynä) ActiveX -liitäntä jos haluat,\nettä tämä tiedosto avautuu selainikkunaan upotettuna.\nLisätietoja saat tältä WWW-sivulta:\n   http://www.multimaker.fi/info_fi_rd.html');
           bActiveXWarningDone = true;
         }
         if ((fileName.substr(1,2) == ':\\') || (fileName.substr(1,2) == ':/')) { fileName = 'file:///' + fileName; }
         videoWindow = window.open(fileName, "_blank", "width= 100 , height= 100");
       }
   }
}

function hideVideoObject(inObjStr) {
htmlObjectID = document.getElementById(inObjStr);
htmlObjectID.controls.stop();
htmlObjectID.uiMode = 'invisible';
htmlObjectID.style.visibility = 'hidden';
htmlObjectID = document.getElementById(inObjStr + '_Close');
htmlObjectID.style.visibility = 'hidden';
}
function viewOffice(fileName,width,height,inObjStr){
  ok = 0;
  htmlObjectID = document.getElementById(inObjStr);
  if (getBrowserType() == 1) { ok = 1; }
  if (ok == 0) {
    if (htmlObjectID.HostName) { ok = 1;}
  }
  if (ok) {
    if (getBrowserType()==1) {
      if ( sCurrentOffice != "" && sCurrentOffice != inObjStr) {
        alert('Microsoft Internet Explorer ei voi avata samalle sivulle kahta upotettua Microsoft Office -dokumenttia yhtä aikaa.\nSivua ladataan uudelleen... \n\n\nMicrosoft Internet Explorer cannot open two embedded Microsoft Office documents at the same time on the same page.\nPage is reloading...');
        sCurrentOffice = "";
        window.location.href = window.location.href; 
        return;
      }
      sCurrentOffice = inObjStr;
    }
    try {
    htmlObjectID.style.visibility = 'visible';
    htmlObjectID.Caption = 'MultiMaker';
    htmlObjectID.Open(GetAbsolutePath(fileName),true);
    htmlObjectID = document.getElementById("DIV_ID_" + inObjStr);
    htmlObjectID.style.visibility = 'visible';
    htmlObjectID = document.getElementById(inObjStr + '_Close');
    htmlObjectID.style.visibility = 'visible';
    }
    catch (ex) {
        if (ex.name != 'TypeError') alert(description);
        htmlObjectID.style.visibility = 'hidden';
        return;
    }
  } else {
    if ((getBrowserType() == 2 || getBrowserType() == 3) && bActiveXWarningDone==false ) {
      alert('The ActiveX plugin has to be installed (or customized) on the web browser of your computer\nif you want to see this file correctly embedded in the browser window.\nFor more information, please visit this page:\n  http://www.multimaker.fi/info_en_rd.html \n\n\nTietokoneesi selaimeen täytyy olla asennettuna (tai räätälöitynä) ActiveX -liitäntä jos haluat,\nettä tämä tiedosto avautuu selainikkunaan upotettuna.\nLisätietoja saat tältä WWW-sivulta:\n   http://www.multimaker.fi/info_fi_rd.html');
      bActiveXWarningDone = true;
    }

    if ((fileName.substr(1,2) == ':\\') || (fileName.substr(1,2) == ':/')) { fileName = 'file:///' + fileName; }
    officeWindow = window.open(fileName, "_blank", "width=100, height=100");
  }
}
function hideOfficeObject(inObjStr) {
   htmlObjectID = document.getElementById(inObjStr);
   htmlObjectID.Close();
   htmlObjectID.style.visibility = 'hidden';
   htmlObjectID = document.getElementById(inObjStr + '_Close');
   htmlObjectID.style.visibility = 'hidden';
}
function GetDirFromPath (path){
   var bslash = path.lastIndexOf ('\\');
   var slash = path.lastIndexOf ('/');
   if (bslash == -1 || slash > bslash)
       bslash = slash;
   if (bslash == -1)
   {
     return '';
   }
   else
   {
      return path.substring (0, bslash);
   }
}
function GetAbsolutePath (rel)
{
   var curPath = document.location.href;
   curPath = ReplaceAll (curPath, 'file://///', '');
   curPath = ReplaceAll (curPath, 'file:////', '');
   curPath = ReplaceAll (curPath, 'file:///', '');
   curPath = ReplaceAll (curPath, 'file://', '');
   curPath = ReplaceAll (curPath, '/', '\\');
   if (curPath.length >= 2)
   {
       if (curPath.substr (1, 1) == '|')
       {
           curPath = curPath.substr (0, 1) + ':' + curPath.substr (2);
       }
       if (curPath.substr (1, 1) != ':')
       {
           curPath = '\\\\' + curPath;
       }
   }
   var qm = curPath.indexOf('?');
   if (qm != -1)
       curPath = curPath.substr (0,qm);
   curPath = unescape (curPath);
   var root = GetDirFromPath (curPath);
   if (rel.length > 2 && rel.substr (0, 2) == './') rel = rel.substr (2);
   var absPath = root + '\\' + ReplaceAll (rel, '/', '\\');
   return absPath;
}
function ReplaceAll (str, src, trg)
{
   var s = str;
   var start = 0;
   while(true)
   {
       var ind = s.indexOf(src, start);
       if (ind == -1)
       {
           break;
       }
       s = s.substring (0, ind) + trg + s.substr (ind + src.length);
       start = ind + trg.length;
   }
   return s;
}


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, myImageID){
    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 && RelativeValue==-1) {
            var lAskel = (myLeft - modifyLeft) / (10 * Time);
            var tAskel = 0;
        } else if (myTop != 0 && myLeft == 0 && myTop != currentTop && RelativeValue==-1) {
            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,false,myImageID);
            }
        } 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 + ", false, '" + myImageID + "');", 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,false,myImageID);
            }
        } 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';
                element.width = myWidth + 'px';
                element.height = myHeight + 'px';
                if (typeof(myImageID) != 'undefined' && myImageID != '') {
                   document.all[myImageID].width = myWidth + 'px';
                   document.all[myImageID].height = myHeight + 'px';
                }
            } else {
                element.top = myTop;
                element.left = myLeft;
                element.width = myWidth;
                element.height = myHeight;
                if (typeof(myImageID) != 'undefined' && myImageID != '') {
                   document.all[myImageID].width = myWidth;
                   document.all[myImageID].height = myHeight;
                }
            }
        }
}
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;
        }
    }
}
function myClose() {
    if (audioWindow != -1) {
        audioWindow.close();
    }
   if (videoWindow != -1) {
        videoWindow.close();
    }
    if (dwfWindow != -1) {
        dwfWindow.close();
    }
    if (officeWindow != -1) {
        officeWindow.close();
    }
}
//-->


