var if_control = {
	'inside_banner':{'showing':0,'last':0,'on_screen':0},
	'feature_1':{'showing':0,'last':0,'on_screen':0},
	'feature_2':{'showing':0,'last':0,'on_screen':0},
	'feature_3':{'showing':0,'last':0,'on_screen':0}
};

function next_item(item) {
	var was_showing = if_control[item]['showing'];
	var last_item   = if_control[item]['last'];
	var item_showing;
	
	//only "figure out" the next item to show if we have something on screen already. otherwise show the one we were supposed to be showing.
	if (!if_control[item]['on_screen']) {
		item_showing = was_showing;
	} else {
		item_showing = (was_showing == last_item) ? 0 : was_showing+1;
	}
	var selected_item = $('#' + item + '_choices img:eq(' + item_showing + ')');
	var item_img = $('#' + item + ' img');
	item_img.attr('src', selected_item.attr('src'));
	item_img.attr('alt', selected_item.attr('alt'));
	item_img.attr('title', selected_item.attr('alt')); //AND DO IT RIGHT FIGHT!!!!!
	if_control[item]['showing'] = item_showing;
	if_control[item]['on_screen'] = 1;

	//unbind hover/click stuff, attempt to attempt to get the link for new banner, and if we got it, set its stuff up.
	item_img.unbind('click');
	item_img.unbind('mouseover');
	item_img.unbind('mouseout');
	var link_href = selected_item.parent('a').attr('href');
	if (link_href) {
		item_img.bind('click', function(){ 
			window.parent.location.href = link_href;
		});
		item_img.bind('mouseover', function(){ 
			 this.style.cursor = 'pointer';
		});
		item_img.bind('mouseout', function(){ 
			 this.style.cursor = 'default';
		});
	}
	
	//alert('for item: ' + item + ' you should be looking at choice #: ' + item_showing + ' which would come from ' + selected_item.attr('src') );
}
	
$(function(){ 

	for (var item in if_control) {
		var item_count = $('#' + item + '_choices img').length;
		if_control[item]['showing'] = Math.floor(Math.random()*item_count);
		if_control[item]['last']    = item_count - 1;
		next_item(item);
		$('#' + item).show();
		if_control[item]['interval_id'] = setInterval("next_item('" + item + "')", 15000);
	}

});