// Assumes prototype and script.aculo.us are available.

var BLIND_OPT = { duration: 0.2 };
var defaultExpImgPath = "images/expanded.gif";
var defaultConImgPath = "images/contracted.gif";

// div (required): div element or id to display/hide.
// img (optional): image object to update.
// expImgPath (optional): image path to use if the icon should show as expanded.
// conImgPath (optional): image path to use if the icon should show as contracted.
function toggleBlind(div, img, expImgPath, conImgPath) {
	div = $(div);
	Element.extend(div);

	Effect.toggle(div, 'blind', BLIND_OPT);

	if(img) {	
		updateIcon(div, img, expImgPath, conImgPath);
	}
}


// div (required): div element or id to display.
// img (optional): image object to update.
// imgPath (optional): image path to use for expanded icon.
function blindDown(div, img, imgPath) {
	div = $(div);
	Element.extend(div);
	Effect.BlindDown(div, BLIND_OPT);
	var imageToUse = (imgPath) ? imgPath : defaultExpImgPath;
	if(img) { $(img).src = imageToUse; }	
}

// div (required): div element or id to hide.
// img (optional): image object to update.
// imgPath (optional): image path to use for contracted icon.
function blindUp(div, img, imgPath) {
	div = $(div);
	Element.extend(div);
	Effect.BlindUp(div, BLIND_OPT);
	var imageToUse = (imgPath) ? imgPath : defaultConImgPath;
	if(img) { $(img).src = imageToUse; }	
}


// div (required): div element or id to display/hide.
// img (optional): image object to update.
// expImgPath (optional): image path to use if the icon should show as expanded.
// conImgPath (optional): image path to use if the icon should show as contracted.
function toggleDiv(div, img, expImgPath, conImgPath) {
	div = $(div);
	Element.extend(div);
	$(div).toggle();

	if(img) {	
		updateIcon(div, img, expImgPath, conImgPath);
	}
}

// div (required): div element or id to check if visible.
// img (required): image object to update.
// expImgPath (optional): image path to use if the icon should show as expanded.
// conImgPath (optional): image path to use if the icon should show as contracted.
function updateIcon(div, img, expImgPath, conImgPath) {
	div = $(div);
	Element.extend(div);

	var eImg = (expImgPath) ? expImgPath : defaultExpImgPath;
	var cImg = (conImgPath) ? conImgPath : defaultConImgPath;

	if($(div).visible()) {
		$(img).src = cImg;
	} else {
		$(img).src = eImg;
	}
}

// hides the element.
function hide(el) {
	el = $(el);
	Element.extend(el);

	$(el).hide();
}

// displays the element.
function show(el) {
	el = $(el);
	Element.extend(el);

	$(el).show();
}

// returns true if the element is hidden.
function isHidden(el) {
	el = $(el);
	Element.extend(el);

	return !$(el).visible();
}

// returns true if the element is showing.
function isShown(el) {
	el = $(el);
	Element.extend(el);

	return $(el).visible();
}
	