var UbiInterface = {

	divArray : new Array,
	imgArray : new Array,

// ------------------------------------------------------

	init : function() {
		UbiInterface.initLinks();
		UbiInterface.initDivs();
	},

// ------------------------------------------------------

	initLinks : function() {
		 if(td = document.getElementById('records')) {
			 var ls = td.getElementsByTagName('a');
			 for(i = 0; i < ls.length; i++) {
		 			UbiEvent.addEvent(ls[i], 'click', UbiInterface.handleClick, false);
		 	}
		}
	},

// ------------------------------------------------------

	initDivs : function() {
		 if(td = document.getElementById('content')) {
		 	var ds = td.getElementsByTagName('div');
		 	for(i = 0; i < ds.length; i++) {
		 			UbiInterface.divArray.push(ds[i]);
		 	}
		 }
	},

// ------------------------------------------------------

	clearImgBorders : function() {
		 if(td = document.getElementById('records')) {
		 	var ds = td.getElementsByTagName('img');
		 	for(i = 0; i < ds.length; i++) {
		 			ds[i].style.borderColor = "#d6d6cf";
		 	}
		 }
	},

// ------------------------------------------------------

	handleClick : function(e) {
		var target = UbiEvent.getTarget(UbiEvent.getEvent(e));
		var targetDiv = document.getElementById(target.className+'_div');
		UbiInterface.clearImgBorders();
		for(i = 0; i < UbiInterface.divArray.length; i++) {
			if(UbiInterface.divArray[i] != targetDiv && UbiInterface.divArray[i].style.display == '') {
				new Effect.BlindUp(UbiInterface.divArray[i], {duration: 0.7, queue: 'front'});
			}
		}
		new Effect.BlindDown(targetDiv, {duration: 0.7, queue: 'back'});
		target.style.borderColor = "#888";
		
		UbiInterface.cancelBubbling(e);
	},

// ------------------------------------------------------

	cancelBubbling : function(e) {
		if(window.event) {
			window.event.cancelBubble = true;
			window.event.returnValue = false;
		}
		if(e && e.stopPropagation && e.preventDefault) {
			e.stopPropagation();
			e.preventDefault();
		}
	}


// ------------------------------------------------------

};

UbiEvent.addEvent(window, 'load', UbiInterface.init, false);