﻿// JScript File
/* ATL HJAIA2008 JavaScript file v1.0 
   Written by ChaoLi (webmaster@atlanta-airport.com), Raul Romero

   Copyright (c) 2008-2009 City of Atlanta, Department of Aviation (http://www.atlanta-airport.com)
   Date: 2009-02-01  
   Purposes for this file: to zoom link photos like FishEye
   Inspired by http://www.theplaceforitall.com/googlex/ GoogleEx
   
   
   Here is the simple how-to for updating
   (1), make changes on b=new z(x) and s=new z() lines
   (2), make sure the onLoad="ae()" in the <body> tag
   (3), update the origianl images in controls/wucFishEye.ascx file
   (4), keep all fish eye images in /images/fisheyes/ folder 
   */
k=document;
v=Date;
x=false;
z=Array;
af=Math.floor;
ag=RegExp;
b=new z(5);
s=new z("null","opt1","opt2","opt3","opt4"); 
aa=new z(4);
ab=10;
t=0;
u=0;
n=0;
o=new v();
h=5;
m=385;
c=0;
w=x;
var title;
var firstHoverOccurred=x;
m=385;
p=0;
function d(ac) { c = ac; o = new v(); setTimeout("gidle()", 10); 
 if (title.style.visibility!="visible")  title.style.visibility="visible"; 
   }
function e(ac) { c = 0; w = x; o = new v(); setTimeout("gidle()", 20); 
if (title.style.visibility!="hidden") title.style.visibility="hidden";   
}
function ae() {
    for (var j = 1; j < b.length; j++) 
        { b[j] = 225; }

    title = k.getElementById('imageTitle');
    for (i = 0; i < b.length; i++) {
        aa[i] = new Image(); 
        aa[i].src = "images/fisheye/" + s[i + 1] + ".gif"; //change this
         }
    setTimeout("gidle()", 57);
}
function gidle() {
    var l = 0; for (var i = 1; i < b.length; i++) {
        var imagename = "image" + i; 
        var imageElem = k.getElementById(imagename);
        if (c != i) {
            if (b[i] > 225) {
                b[i] -= h; 
                    if (b[i] <= 225)
                        { 
                        b[i] = 225; 
                        imageElem.src = "images/fisheye/"+ s[i] + "_small.gif"; } //change this
                    if (b[i] < 225) {    
                        alert(b[i]); }
                imageElem.width = b[i]; 
                imageElem.height = b[i]*.44; 
               if (c == 0) {
                    var g = af(255 - 255 * (b[i] - 225) / 225);
                    // title.style.color = "rgb(" + g + "," + g + "," + g + ")"; //no color change at this moment
                } 
                p = 1;
            } 
            l += b[i];
        }
    }
    if (c != 0 && b[c] < 293) {
        imagename = "image" + c; 
        imageElem = k.getElementById(imagename);
        if (w == x) {
            w = true; 
            if (c < 6) {
                var y = 360 - (c - 1) * 293;
                //title.innerHTML = k.getElementById(imagename).alt + '<img src="images/fisheye/cleardot.gif" width="' + y + '" height="1"/>';//disable the variable location
                title.innerHTML = k.getElementById(imagename).alt ;//+ '<img src="images/fisheye/cleardot.gif" width="' + y + '" height="1"/>';
            }
            else { 
                var y = (c - 7) * 293 + 293; 
                //title.innerHTML = '<img src="images/fisheye/cleardot.gif" width="' + y + '" height="1"/>' + k.getElementById(imagename).alt;//disable the variable location
                title.innerHTML = k.getElementById(imagename).alt;
             }
        }
        b[c] += h; p = 1; 
        if (b[c] > 293) { b[c] = 293; }
        l += b[c];
        if (l < m) { b[c] += m - l; 
        if (b[c] > 70) { b[c] = 70; } 
        l = m;
         }
        var g = af(255 - 255 * (b[c] - 225) / 225);
        //title.style.color = "rgb(" + g + "," + g + "," + g + ")";//no color change at this moment
	
	    if (b[c] < 225) {   b[c]=255; }
        imageElem.width = b[c]; 
        imageElem.height = b[c] * .444;
        
        k.getElementById(imagename).src = "images/fisheye/" + s[c] + ".gif"; //change this
        
    } 
    m = l; 
    var ad = new v(); 
    ab = ad.getTime() - o.getTime(); 
    o = ad; 
    t += ab; 
    u++; 
    n = t / u; 
    h = 5;
    if (u > 4) {
        if (n > 30)
        { h = 10; }
        if (n > 60)
        { h = 15; }
        if (n > 90)
        { h = 20; }
    }
    if (p) 
    { setTimeout("gidle()", 20); 
    p = 0 
    } 
} 
