  function SwitchFrame(elemNameIn, elemNameOut) {
          var elemOut = document.getElementById(elemNameOut);
          var elemIn = document.getElementById(elemNameIn);
          if (elemNameOut == "music") {
             elemOut.style.top = -9000;
             elemIn.style.top = 0;
             elemIn.style.display = 'block';
          }else{
                elemIn.style.top = 0;
                elemOut.style.display = 'none';
                elemIn.style.display = 'block';
          }

          if (elemNameIn == "music") {
             elemIn.style.top = 0;
          }
          //doFrameAnimation(elemOut, elemIn, "out", 0, 0+(parseInt(elemOut.style.width)-50), 30, 10, 0.8);
  }

  function setOpacity(testObj,value) {
           value = parseInt(value);
           testObj.style.opacity = value/10;
           testObj.style.filter = 'alpha(opacity=' + value*10 + ')';
  }

  function doFrameAnimation(elem, elemIn, direction, startPos, endPos, steps, intervals, power) {
           elem.style.display = 'none';
           elemIn.style.display = 'block';
           /*if (elem.myInterval) { window.clearInterval(elem.myInterval); }
           var actStep = 0;
           if (direction == "in") { setOpacity(elem,0); }
           elem.style.display = 'block';
           elem.setAttribute('AnimationDirection','fw');
           //if (direction == "in") { elem.style.left = startPos; }

           elem.myInterval = window.setInterval(
                           function() {
                                      var animation = elem.getAttribute('AnimationDirection');
                                      if (direction == "in") {
                                         //elem.style.left = easeInOut(startPos, endPos, steps, actStep, power);
                                         setOpacity(elem, easeInOut(-3, 10, steps, actStep, power));
                                      }else{
                                         if (animation == "fw") {
                                               //elem.style.left = easeInOut(startPos, parseInt(startPos)+100, steps, actStep, 0.3);
                                         }else{
                                               //elem.style.left = easeInOut(startPos, -parseInt(elem.style.width), steps, actStep, power);
                                               setOpacity(elem,easeInOut(10, -3, steps, actStep, power));
                                         }
                                      }
                                      actStep++;
                                      if (actStep > steps) {
                                         if (direction == "out") {
                                           if (animation == "fw") {
                                              actStep = 0;
                                              elem.setAttribute('AnimationDirection','bk');
                                           }else{
                                                 window.clearInterval(elem.myInterval);
                                                 elem.style.display = 'none';
                                                 //elem.style.left = 0;
                                                 doFrameAnimation(elemIn, null, "in", 0+(parseInt(elemIn.style.width)-50), 0, 50, 10, 0.8);
                                           }
                                         }else{
                                           window.clearInterval(elem.myInterval);
                                         }
                                      }
                           },intervals);
           */
  }

  function easeInOut(minValue, maxValue, totalSteps, actualStep, power) {
           var delta = maxValue - minValue;
           var stepp = minValue+(Math.pow(((1 / totalSteps) * actualStep), power) * delta);
           return Math.ceil(stepp)
  }


  function easeMoving(elem, amount, maxmove) {
           if (elem.myInterval) { window.clearInterval(elem.myInterval); }
           var actStep = 0;
           startPos = parseInt(elem.style.left);
           endPos = parseInt(elem.style.left)+parseInt(amount);
           steps = 100;
           intervals = 10;
           power = 0.5;
           elem.myInterval = window.setInterval(
                           function() {
                                      if (endPos < parseInt(-maxmove)) {
                                         endPos = parseInt(-maxmove);
                                      }
                                      if (endPos > 0) {
                                         endPos = 0;
                                      }
                                      newleft = easeInOut(startPos, endPos, steps, actStep, power);
                                      elem.style.left = newleft;
                                      actStep++;
                                      if (actStep > steps) {
                                           window.clearInterval(elem.myInterval);
                                      }
                           },intervals);
  }
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
       function ImageLoaded(section) {
              document.getElementById(section+"_loading").style.display = 'none';
     }

     function ShowImage(section) {
              document.getElementById("hdn_frame").src = "actions.php?action=show_image&section="+section;
     }
     
     function CloseImage() {
              var pageBlocker = document.getElementById("page_blocker");
              pageBlocker.style.display = 'none';
     }
     
     function NavigateToPicture(id,section) {
              if (section == "3d") {
                 document.getElementById("3d_loading").style.display = 'block';
                 for (var i = 0; i < items_3d.length; i++) {
                     if (parseInt(items_3d[i]) == parseInt(id)) {
                        current_items_3d = i;
                     }
                 }
                 document.getElementById("hdn_frame").src = "actions.php?action=3d_load&id="+id+"&sub_action=show_image&section="+section;
              }else if (section == "2d") {
                      document.getElementById("2d_loading").style.display = 'block';
                      for (var i = 0; i < items_2d.length; i++) {
                          if (parseInt(items_2d[i]) == parseInt(id)) {
                             current_items_2d = i;
                          }
                      }
                      document.getElementById("hdn_frame").src = "actions.php?action=2d_load&id="+id+"&sub_action=show_image&section="+section;
              }
     }

        function NavigatePictures(direction,section) {
                 if (section == "2d") {
                   document.getElementById("2d_loading").style.display = 'block';
                   // direction is "fw" or "bk"
                   if (direction == "fw") {
                      if ((parseInt(current_items_2d)+1) > (parseInt(items_2d.length)-1)) {
                         current_items_2d = 0;
                      }else{
                         current_items_2d = (parseInt(current_items_2d)+1);
                      }
                   }else{
                      if ((parseInt(current_items_2d)-1) < 0) {
                         current_items_2d = (parseInt(items_2d.length)-1);
                      }else{
                         current_items_2d = (parseInt(current_items_2d)-1);
                      }
                   }
                   document.getElementById("hdn_frame").src = "actions.php?action=2d_load&id="+items_2d[current_items_2d];
                 }else if (section == "3d") {
                   document.getElementById("3d_loading").style.display = 'block';
                   // direction is "fw" or "bk"
                   if (direction == "fw") {
                      if ((parseInt(current_items_3d)+1) > (parseInt(items_3d.length)-1)) {
                         current_items_3d = 0;
                      }else{
                         current_items_3d = (parseInt(current_items_3d)+1);
                      }
                   }else{
                      if ((parseInt(current_items_3d)-1) < 0) {
                         current_items_3d = (parseInt(items_3d.length)-1);
                      }else{
                         current_items_3d = (parseInt(current_items_3d)-1);
                      }
                   }
                   document.getElementById("hdn_frame").src = "actions.php?action=3d_load&id="+items_3d[current_items_3d];
                 }
        }

        function DoScroll(direction,section) {
                 var myDiv = document.getElementById("image_container_"+section);
                 var divWidth = parseInt(myDiv.offsetWidth);
                 var maxmove = 722;
                 if (divWidth > 722) {
                    maxmove = divWidth-722;
                 }
                 if (direction == "left") {
                    easeMoving(myDiv,-300,maxmove)
                 }else{
                    easeMoving(myDiv,300,maxmove)
                 }
        }
