var menu	= {
	swap	: function(this_div) {
		var cat	= document.getElementById('category');
		var loc	= document.getElementById('location');
		if(this_div == cat.id) {
			loc.style.display	= 'none';
			cat.style.display	= 'block';
		}
		else {
			cat.style.display	= 'none';
			loc.style.display	= 'block';
		}
	}
};

function hider(div_name) {
	var this_div	= document.getElementById(div_name);
	if(this_div.style.display == 'none') {
		this_div.style.display	= 'block';
	}
	else {
		this_div.style.display	= 'none';
	}
}

function redirect(url) {
	window.location	= $("base").attr("href") + url;
}

function make_search(str) {
	str	= encodeURI(str);
	url	= 'browse/event_search/' + str;
	redirect(url);
}

function advance_search() {
	var keywords	= document.getElementById('keyword_search').value;
	url	= "browse/event_search_advanced/?keywords=" + encodeURI(keywords);
	redirect(url);
}

function clear_quick_search_box() {
	var search_box	= document.getElementById('quick_search_keywords');
	if(search_box.value == "Search Artist, Team or Venue") {
		search_box.value = '';
	}
}

function check_empty_quick_search_box() {
	var search_box	= document.getElementById('quick_search_keywords');
	var new_val	= search_box.value.replace(/\s+/, '')
	if(new_val.length == 0) {
		search_box.value = "Search Artist, Team or Venue";
	}

}

(function($) {
	$.fn.myRotator	= function(image_data) {
		var current_key	= this.children("a").attr('this_key');
		if(!current_key) {
			current_key	= 0;
			var this_string	= '<a href="'+image_data[current_key]['URL']+'" this_key="'+current_key+'"><img src="'+image_data[current_key]['IMAGE']+'" alt="'+image_data[current_key]['ALT']+'" /></a>';
			this.html(this_string);
		}
		else {
			current_key	= parseInt(current_key) + 1;
			if(current_key > (image_data.length - 1)) current_key	= 0;
			this.children("a").attr("this_key", current_key).children("img").attr("src", image_data[current_key]['IMAGE']).attr("alt", image_data[current_key]['ALT']);
		}
	}
})(jQuery);