/*
	Rotate Featured Communities
*/


rotateCommunities = function( duration ) {
	var items = document.getElementById( "box-1" ).getElementsByTagName('dl'); /* array containing all communities*/
	for (var i=0;i<items.length;i++) {
		if (items[i].className == "current") {
			var currentItem = items[i];
			break;
		};
	};
	
	if (NiceDOM.node_after(currentItem) != null) {
		var nextItem = NiceDOM.node_after(currentItem);
	} else {
		var nextItem = items[0];
	};

	var options = Object.extend({
		from: 1.0,
		to:   0.0,
		afterFinish: function(effect) { 
			currentItem.className = "";
			nextItem.className = "current";
			var innerOptions = Object.extend({
				from: 0.0,
				to:   1.0,
				afterFinish: function(effect) { 
					timer = setTimeout( "rotateCommunities("+duration+")" , duration );
				} 
			}, arguments[1] || {});
			new Effect.Opacity("communities",innerOptions);
		} 
	}, arguments[1] || {});
	new Effect.Opacity("communities",options);
};

/*
	Show thumb
*/

function thumb( sImageURL, oSource ) {
	// let's set mouseover/out effect first
	img = oSource.getElementsByTagName('img')[0];
	img.src = 'images/btn_dollar_over.gif';
	// let's attach mouseout event handler to the source link
	oSource.onmouseout = function( ) {
		img = this.getElementsByTagName('img')[0];
		if (oSource.getElementsByTagName('strong')[0]) {
			this.removeChild(oSource.getElementsByTagName('strong')[0]);
		}
	img.src = 'images/btn_dollar.gif';
	}
	// Ok, it's time to show the thumb
	if (!oSource.getElementsByTagName('strong')[0]) {
		tW = document.createElement('strong');
		tW.className = 't';
		t = document.createElement('img');
		t.src = sImageURL;
		t.alt = '';
		tW.appendChild(t);
		oSource.appendChild(tW);
	}
}
