// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults

/**
* Toggles the display between two elements.
*/
function swapVisible(id1, id2){
	$(id1).toggle();
	$(id2).toggle();
}


/**
* This function will take in a css class_string and either a single exception id or an array of exceptionIds.
* The function will then find all the elements with the classname
* and set their displays to none. 
* After which it will display the display area with the id passed in.
* 
*/
function toggleAreasByClass(classname, exceptionIds){
	elements = $$(classname);
	elements.each(function(item) {
		$(item).hide();										 	
	});
	
	if (Object.isString(exceptionIds)){
		exceptionIds = exceptionIds.split(',');
	}	
	exceptionIds.each(function(id){
		$(id).show();
	})
}

/**
* Will blindUp all other areas that are not already hidden and that are not the exception. 
*/
function toggleBlindAreasByClass(classname, exception){
	// Get all payment areas by class.
	areas = $$(classname);
	areas.each(function(item) {
		if (item.visible() && item.id != (exception)){
			Effect.BlindUp(item,{duration:0.2});
		}
	});
	if (!$(exception).visible()){
		Effect.BlindDown($(exception),{duration:0.2});
	}
}