﻿// JScript File

var pli = new Image();
pli.src = "/images/preload.gif";

function imageQueueInstance(){
    this.queue = new Array();
    return this;
}

function imageQueueZero(inst){
    arrayRemoveAll(inst.queue);
}

function imageQueueFind(inst, id){
    var q = inst.queue;
    for(var i = 0; i < q.length; i++){
        if(q[i].id == id)
        return q[i];
    }
    return null;
}

function imageQueueAdd(inst, id, largeIcon, url){
    if(imageQueueFind(inst, id))
        return;
    var q = inst.queue;
    var i = q.length;
    q[i] = new Array();
    q[i].id  = id;
    q[i].url = url;
    q[i].img = new Image();
    q[i].LargeIcon = largeIcon;
}

// showTip = 1, show ImageTip
// showTip = 0, do not show ImageTip
// showborder = 1, show border
// showborder = 0, do not show border
function imageQueueExecute(inst, showTip, showborder){
    var q = inst.queue;
    for(var i = 0; i < q.length; i++){
        var fcb = new function(){ imageQueueComplete(inst.queue[i], showTip, showborder); }
        q[i].img.onload = fcb;
        q[i].img.onerror = fcb;
        q[i].img.onabort = fcb;     
        q[i].img.src = q[i].url;
    }
}

function imageQueueComplete(qi, showTip, showborder){
   document.images[qi.id].src = qi.url;
   
   if (showTip == 1 && showborder == 1)
   {
        if (qi.LargeIcon != undefined)
        document.images[qi.id].onmouseover = function() {this.border=2; this.style.bordercolor="#fgef29"; Tip('<img src=' + qi.LargeIcon + " width='300'>", BGCOLOR, '#ffffff', JUMPHORZ, true, JUMPVERT, true);};
        else
            document.images[qi.id].onmouseover = function() {this.border=2; this.style.bordercolor="#fgef29";}; 
            
        document.images[qi.id].onmouseout = function() { this.border=0; UnTip();};
   }    
   else if (showTip == 1 && showborder == 0 && qi.LargeIcon != undefined)
   {
        document.images[qi.id].onmouseover = function() {Tip('<img src=' + qi.LargeIcon + " width='300'>", BGCOLOR, '#ffffff', JUMPHORZ, true, JUMPVERT, true);};
        document.images[qi.id].onmouseout = function() { this.border=0; UnTip();};
   }
   else if (showTip == 0 && showborder == 1)
   {
        document.images[qi.id].onmouseover = function() { this.border=2; this.style.bordercolor="#fgef29"; return true;};
        document.images[qi.id].onmouseout = function() { this.border=0; return true};
   }
   else if (showTip == 0 && showborder == 0)
        document.images[qi.id].onmouseover = function() { return;};
        
   }