/* My javascript file */

function change_img(img_to_change, image_file) {
	document.body.style.cursor = 'progress';	
	var img = document.getElementById(img_to_change);
	img.src = image_file;
 	img.onload = function () {
		document.body.style.cursor = 'auto';
	}
}

function changePhotoZoom(element_id, up, step) {
	changeWidth(element_id, up, step);
}


// Adjust the width attribute of given element by step percentage
// of the current width.  Increases width if up is 'true', decreases
// otherwise.
function changeWidth(element_id, up, step) {
	var elem = document.getElementById(element_id);
	var width = parseInt(elem.width); 

	if (up == 'true')
		width += width * (parseInt(step) / 100); //percentage of current width
	else
		width -= width * (parseInt(step) / 100); //percentage of current width

	//This shouldn't happen, but just in case.
	if (width < 0)
		width = 0;

	elem.style.width = width+"px";
} 

// Toggle the visibility of an element
function toggleVisible(element_id) {
	var elem = document.getElementById(element_id);
	var visible = elem.style.display; 

	if (visible == 'block')
		visible = 'none';
	else
		visible = 'block';

	elem.style.display = visible;
} 
