﻿// JScript File
// Move an element directly on top of another element (and optionally
// make it the same size)
function Cover(bottom, top, ignoreSize) {
    var location = Sys.UI.DomElement.getLocation(bottom);
    var contentLocation = Sys.UI.DomElement.getLocation($get('ctl00_divContent'));
    
    top.style.position = 'absolute';
    
    top.style.top = (location.y - contentLocation.y - 30) + 'px';
    top.style.left = (location.x - contentLocation.x - 15) + 'px';
    if (!ignoreSize) {
        top.style.height = bottom.offsetHeight + 'px';
        top.style.width = bottom.offsetWidth + 'px';
    }
}
function moveToCenter(objElement) {
    var location = Sys.UI.DomElement.getLocation(objElement);
    var contentLocation = Sys.UI.DomElement.getLocation($get('ctl00_divContent'));            
    var intWindowHeight = window.innerHeight ? window.innerHeight : document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.clientHeight;
    var intWindowWidth = window.innerWidth ? window.innerWidth : document.documentElement.clientWidth ? document.documentElement.clientWidth : document.body.clientWidth;
    var X = ((intWindowWidth - parseInt($get('divInfo').style.width))/2) - contentLocation.x;
    var Y = ((intWindowHeight - parseInt($get('divInfo').style.height))/2) - contentLocation.y + document.documentElement.scrollTop;
    
    animate(objElement,'top',location.y ,Y, 300, 25);
    animate(objElement,'left',location.x ,X, 300, 25);
}

function animate(elm,prop,begin,end,duration,fps) {
    if(!duration) duration=1000;
    if(!fps) fps = 12;

    var change       = end-begin;
    var interval     = Math.ceil(1000/fps);
    var totalFrames  = Math.ceil(duration/interval);
    var step         = change/totalFrames;
        
    for(i=1;i<=totalFrames;i++) {
       (function() {
          var n=i;
          function innerChangeWidth() {
             var increase=begin+(step*n);
             unit=(prop=='opacity') ? '' : 'px';
             if(window.attachEvent && !unit) { 
                  increase*=100; 
                  elm.style.zoom = 1;
                  elm.style.filter = "alpha(opacity=" + increase + ")";
             } else {
                 elm.style[prop]  = increase+unit; 
             }
         }
         timer = setTimeout(innerChangeWidth,interval*n);
       })();
   }
}
function setImage(strImageURL, strTitle){
    $get('ctl00_Content1_imgBig').src = strImageURL;
    $get('ctl00_Content1_lblCaption').innerHTML = strTitle;
}
