// Use the Prototype blind functions and some class setting to create a curtain up and down
// effect got elements.  Assume the element is display:none;
function blind(idtoblind) {

	if($(idtoblind).hasClassName('blinddown')) {

		$(idtoblind).addClassName('blindup');
		$(idtoblind).removeClassName('blinddown');

		Effect.BlindUp(idtoblind, {duration: 1.0});

	} else {

		$(idtoblind).addClassName('blinddown');
		$(idtoblind).removeClassName('blindup');

		Effect.BlindDown(idtoblind, {duration: 1.0});
	}

	return false;

}


function getURLPrefix() {
	
	var loc = new String(window.parent.document.location);
	
	if (loc.indexOf("https://")!= -1)
		prefix = "https://";
	else
		prefix = "http://";
		
	return prefix;
}


function AddSelectOption(selectObj, text, value, isSelected) {
	
    if (selectObj != null && selectObj.options != null)
    {
        selectObj.options[selectObj.options.length] = 
            new Option(text, value, false, isSelected);
    }
}

function roundNumber(num, dec) {
	var result = Math.round(num*Math.pow(10,dec))/Math.pow(10,dec);
	return result;
}

function positionElementBelowParent(parent_id, id) {
	
	var left 	= $(parent_id).cumulativeOffset().left;
	var top		= $(parent_id).cumulativeOffset().top;
	var height	= $(parent_id).getHeight();

	// Set the real top to be top+height
	var realtop = height + top;

	// Set the position of the id
	$(id).style.position= "absolute";
	$(id).style.top		= realtop +"px";
	$(id).style.left	= left +"px";
	
	$(id).show();
}
