function switchImage(imgName, imgSrc)
{
	if (document.images){
	    if (imgSrc!=''){
	      document.images[imgName].src=imgSrc;
	    }
	}
}
function currentOpac(id, opacEnd, millisec) {
    //standard opacity is 100
    var currentOpac = 100;
    //if the element has an opacity set, get it
    if(document.getElementById(id).style.opacity < 100) {
        currentOpac = document.getElementById(id).style.opacity * 100;
    }
    //call for the function that changes the opacity
    opacity(id, currentOpac, opacEnd, millisec)
}
function fadeimage(divid, imageid, imagefile, millisec, divID, newDivID, image_anchor) {
    var speed = Math.round(millisec / 100);
    var timer = 0;
    
    //set the current image as background
    document.getElementById(divid).style.backgroundImage = "url(" + document.getElementById(imageid).src + ")";
    
    //make image transparent
    changeOpac(0, imageid);
    
    //make new image
    document.getElementById(imageid).src = imagefile;

    //fade in image
    for(i = 0; i <= 100; i++) {
        setTimeout("changeOpac(" + i + ",'" + imageid + "')",(timer * speed));
        timer++;
    }
    
    if (divID!=''){
		document.getElementById(divID).innerHTML=document.getElementById(newDivID).innerHTML;
	}
    
    if (image_anchor!='')
    {
		window.location=String(window.location).replace(/\#.*$/, '') + '#' + image_anchor;
	}
    
}
function changeOpac(opacity, id) {
    var object = document.getElementById(id).style;
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";
}

//Preload images
function preLoadImages(parImageArray) 
{
	image_count=parImageArray.length;
	
	if(image_count>0)
	{
		imageObj=new Image();
		
		for(i=0; i<image_count; i++) {
			imageObj.src=parImageArray[i];
		}
	}
} 