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

	//determine the direction for the blending, if startxi
	// and end are the same nothing happens
	if(opacStart > opacEnd) {
		for(i = opacStart; i >= opacEnd; i--) {
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
			timer++;
		} 
	} else {
		if (opacStart < opacEnd) {
			for(i = opacStart; i <= opacEnd; i++) {
				setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
				timer++;
			}
		}
	}
} 

// Recupere la valeur de l'opacite de l'objet
function getOpacity(id) {
	obj = returnObjById(id);
	if (obj.filters) {
		return obj.filters.alpha.opacity;
	} else {
		return obj.style.opacity * 100;
	}
}

//change the opacity for different browsers
function changeOpac(opacity, id) {
    obj = returnObjById(id);
		if (obj.filters) {
    	obj.filters.alpha.opacity = opacity ;
		} else {
    	obj.style.opacity = (opacity / 100);
		}
}

function currentOpac(id, opacEnd, millisec) {
    //standard opacity is 100
    var currentOpac = getOpacity(id);
    
    //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)
} 

// Change ...
function toggleBookmarksSection(id) {
	var itm = null;

	idCat='cat-'+id;
	idImg='icon-'+id;

	itm = document.getElementById(idCat) ;

	if (!itm) return;

	if (itm.style.display == "none" ) {
			itm.style.display = "block" ;
			document.getElementById(idImg).src = TEMPLATEPATH+"/images/below.gif";
	} else {
			itm.style.display = "none" ;
			document.getElementById(idImg).src = TEMPLATEPATH+"/images/right.gif";
	}
}
