function HashMap() {
    this.i = 0;
    this.names = new Array();
    this.values = new Array();

    this.set = _hashmap_set;
    this.get = _hashmap_get;
}

function _hashmap_set(name, value) {
    // Reset existing first
    for(var j=0;j<this.i;j++) {
        if(this.names[j] == name) {
            this.values[j] = value;
            return;
        }
    }
    // Doesn't exist, so add new entry
    this.names[this.i] = name;
    this.values[this.i] = value;
    this.i++;
}

function _hashmap_get(name) {
    for(var j=0;j<this.i;j++) {
        if(this.names[j] == name) {
            return this.values[j];
        }
    }
    return null;
}
// --------------------------------------------------------

function ImageHandler() {
    // Attributes
    this.map = new HashMap();
    this.agt = navigator.userAgent.toLowerCase();
    this.is_ie5 = (this.agt.indexOf("msie 5.0")!=-1);
    this.is_ie5_5 = (this.agt.indexOf("msie 5.5") !=-1);
    this.is_ie6 = (this.agt.indexOf("msie 6.")!=-1);
    this.fade_time = 0.7;

    this.preload = _imagehandler_preload;
    this.load = _imagehandler_load;
    this.swap = _imagehandler_swap;
    this.fade = _imagehandler_fade;
    this.setFade = _imagehandler_set_fade;
}

function _imagehandler_preload(name, src) {
    img = new Image();
    img.src = src;
    this.map.set(name, img);
}

function _imagehandler_load(target, to, src) {
    if(!this.map.get(to)) {
        this.preload(to, src);
    }
    this.swap(target, to);
}

function _imagehandler_swap(target, to) {
    if(document.images) {
        img = document.images[target];
        ref = this.map.get(to);
        if(img && ref) {
            img.src = ref.src;
        }
    }
}

function _imagehandler_fade(target, to) {
    if(document.images) {
        img = document.images[target];
        ref = this.map.get(to);
        if(img && ref) {
            if((this.is_ie5_5 || this.is_ie6) && img.style) {
                img.style.filter = "progid:DXImageTransform.Microsoft.Fade(overlap=1.00,duration="+this.fade_time+")";
                img.filters[0].apply();
                img.src = this.map.get(to).src;
                img.filters[0].play();
            }
            else {
                img.src = ref.src;
            }
        }
    }
}

function _imagehandler_set_fade(t) {
    this.fade_time = t;
}

function changeBg(id,style){
	var prefix1="bgIcon";
	var prefix2="bgMenuItem";
	id1 = prefix1+id;
	id2 = prefix2+id; 
	document.getElementById(id1).className = style;
	document.getElementById(id2).className = style;
	}
//-------------------------------------------

if(typeof ImgH == "undefined") {
    ImgH = new ImageHandler();
}

//left navigation bar
ImgH.preload("homeIN", "images/homeON.gif");
ImgH.preload("homeOUT", "images/home.gif");

ImgH.preload("contractorsIN", "images/professionalteamON.gif");
ImgH.preload("contractorsOUT", "images/professionalteam.gif");

ImgH.preload("lettingplanIN", "images/lettingplanON.gif");
ImgH.preload("lettingplanOUT", "images/lettingplan.gif");

ImgH.preload("locationIN", "images/locationON.gif");
ImgH.preload("locationOUT", "images/location.gif");

ImgH.preload("requestbrochuresIN", "images/requestbrochureON.gif");
ImgH.preload("requestbrochureOUT", "images/requestbrochure.gif");

ImgH.preload("downloadIN", "images/downloadON.gif");
ImgH.preload("downloadOUT", "images/download.gif");

ImgH.preload("projectupdatesIN", "images/projectupdateON.gif");
ImgH.preload("projectupdatesOUT", "images/projectupdates.gif");

ImgH.preload("pressIN", "images/pressON.gif");
ImgH.preload("pressOUT", "images/press.gif");

