
/*
var mediaObject = {
	thumbSrc: '',
	mediaSrc: '',
	launchMedia: function() {},
	closeMedia: function() {}
};
*/

/* class mediaObject */
function mediaObject() {
	var thumbSrc;
	var mediaSrc;
	launchMedia = function() {}
	closeMedia = function() {}
	isCollection = function() {}
	launchCollection = function() {}
	closeCollection = function () {}
}

function galleryObject() {
	init() = function() {}
	var collections = new Array();
}

function photoObject() {
}
photoObject.prototype = new mediaObject();

function videoObject() {
}
videoObject.prototype = new mediaObject();




var evilNode;
var FADE_INTERVAL;
function fadeSiblings(targetElem, parentContainer) {
	evilNode = targetElem.parentNode;
	if (!parentContainer) { parentContainer = targetElem.parentNode.parentNode; }
	evilNode.treeHead = parentContainer;
	FADE_INTERVAL = setInterval('gradually();', 25);
	evilNode.style.backgroundColor = "#e8e8e8";
	COLLECTION_INTERVAL = setInterval('loadCollection();', 25);
	var subSet = evilNode.getElementsByTagName('UL')[0];
	subSet.style.backgroundColor = "#e8e8e8";
	this.onmouseup = function() {
		COLLECTION_INTERVAL = window.setTimeout('alert(closeCollection);', 25);
	}
}

function loadCollection() {
	var subSet = evilNode.getElementsByTagName('UL')[0];
	var height = parseInt(subSet.style.height);
	if (!height) { height = 0; }
	if (height < 100) {
		height += 10;
	} else {
		clearTimeout(COLLECTION_INTERVAL);
	}
	subSet.style.height = height+'px';
}

function closeCollection() {
		alert('what?');
	var subSet = evilNode.getElementsByTagName('UL')[0];
	var height = parseInt(subSet.style.height);
	if (!height) { height = 0; }
	if (height > 0) {
		height -= 10;
	} else {
		clearTimeout(COLLECTION_INTERVAL);
	}
	subSet.style.height = height+'px';
	return "ok";
}

function gradually() {
	var parentContainer = evilNode.treeHead;
	var done = 0;
	for (var i=0; i<parentContainer.childNodes.length; i++) {
		if (parentContainer.childNodes[i] == evilNode) {
			var alpha = getOpacity(parentContainer.childNodes[i].firstChild);
			if (alpha < 1) {
				changeOpacity(parentContainer.childNodes[i].firstChild,5);
			}
		} else if (parentContainer.childNodes[i].tagName == 'LI') {
			var alpha = getOpacity(parentContainer.childNodes[i].firstChild);
			if (alpha > 0.3) {
				changeOpacity(parentContainer.childNodes[i].firstChild,-5);
			} else {
				done++;
			}
		}
	}
	if (done >= (parentContainer.childNodes.length-1)) {
		clearTimeout(FADE_INTERVAL);
	}
}

function changeOpacity(oElem, oVal) {
	var alpha = getOpacity(oElem);
	if (alpha <= 1) { alpha = alpha*100; }
	alpha += oVal;
	setOpacity(oElem, alpha);
}

function setOpacity(oElem, oVal) {
	if (oElem.style.filters) {
		oElem.style.filters.alpha.opacity = oVal;
	} else if (oElem.style.MozOpacity) {
		oElem.style.MozOpacity = (oVal/100);
	} else {
		oElem.style.MozOpacity = (oVal/100);
	}
}

function getOpacity(oElem) {
	if (oElem.style.filters) {
		return oElem.style.filters.alpha.opacity;
	} else if (oElem.style.MozOpacity) {
		return oElem.style.MozOpacity;
	} else {
		return "1";
	}
}



