

function opacity(ids, opacStart, opacEnd, millisec) {
	//speed for each frame
	var speed = Math.round(millisec / 100);
	var timer = 0;
	var id_array = ids.split(",");
	

	//determine the direction for the blending, if start and end are the same nothing happens
	if(opacStart > opacEnd) {
		for(i = opacStart; i >= opacEnd; i--) {
		    var tmstr = "";
		    for(j=0; j<id_array.length; j++)
		        tmstr = tmstr + "changeOpac(" + i + ",'" + id_array[j] + "'); ";	
			setTimeout(tmstr,(timer * speed));
			timer++;
		}
	} else if(opacStart < opacEnd) {
		for(i = opacStart; i <= opacEnd; i++)
			{
		    var tmstr = "";
		    for(j=0; j<id_array.length; j++)
		        tmstr = tmstr + "changeOpac(" + i + ",'" + id_array[j] + "'); ";		    
			setTimeout(tmstr,(timer * speed));
			timer++;
			
		}
	}
}

function displayelem(ids, showit)
{
    var id_array = ids.split(",");
    
    if(showit == true)
    {
        for(icnt=0; icnt<id_array.length; icnt++)
            document.getElementById(id_array[icnt]).style.display = "block";
    }
    else
    {
        for(icnt=0; icnt<id_array.length; icnt++)
            document.getElementById(id_array[icnt]).style.display = "none";
    }       
   
}


//change the opacity for different browsers
function changeOpac(opacity, id) {

    try {
        var object = document.getElementById(id).style;

        if (object.opacity)
            object.opacity = (opacity / 100);
        if (object.MozOpacity)
            object.MozOpacity = (opacity / 100);
        if (object.KhtmlOpacity)
            object.KhtmlOpacity = (opacity / 100);
        if (object.filter)
            object.filter = "alpha(opacity=" + opacity + ")";
    }
    catch (Error)
	{ }
}

function shiftOpacity(id, millisec) {
	//if an element is invisible, make it visible, else make it ivisible
	if(document.getElementById(id).style.opacity == 0) {
		opacity(id, 0, 100, millisec);
	} else {
		opacity(id, 100, 0, millisec);
	}
}

function blendimage(divid, imageid, imagefile, millisec) {
	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++;
	}
}

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 fadeinhbutton(btnid)
{
    if(enabledbuttons[btnid] == false)
        return;
    opacity(btnid, 0, 100, 200);
}

function fadeouthbutton(btnid)
{
    if(enabledbuttons[btnid] == false)
        return;
    opacity(btnid, 100, 0, 200);
}

var enabledbuttons = new Array();

function setbuttonfadeenabled(id, state)
{
    enabledbuttons[id] = state;
}
 
 
function divHeight(divid) 
{
   // find the height of the DIV
   var scrollBox = document.getElementById(divid.toString());

   if(scrollBox.offsetHeight) 
   {
       boxHeight=scrollBox.offsetHeight;
   } 
   else 
   {
       try
        {
            boxHeight=document.defaultView.getComputedStyle(divid,"").getPropertyValue("height")
            boxHeight=eval(boxHeight.substring(0,boxHeight.indexOf("p")))
        }
        catch(err)
        {
        }
   }
   return boxHeight;
}
 
function startscroller(containterdivid, scrollerdivid)
{
   // Get the container specs
   var containerheight = divHeight(containterdivid);       
   
   // and the scroller specs
   var scrollerheight = divHeight(scrollerdivid);
    
   var scrollpos = 0;
    
   setTimeout("scrollit('" + scrollerdivid + "',0," + containerheight + "," + scrollerheight + ")", 60);
}
 
 
function scrollit(scrollerdiv, curpos, cheight, sheight)
{
 
   curpos--;
    
   // check to see if we need to start over
   if(curpos < (-sheight))
       curpos = cheight;
        
   document.getElementById(scrollerdiv.toString()).style.top = curpos.toString() + "px";
    
   setTimeout("scrollit('" + scrollerdiv + "'," + curpos + "," + cheight + "," + sheight + ")", 80);
    
}
 