$(document).ready(function($) {
	
	// inline textbox hint
	$('.hint').click(function(){if($(this).attr('title')==$(this).val()){$(this).val('');}else{$(this).select();}});$('.hint').blur(function(){if($(this).val()==''){$(this).val($(this).attr('title'));}});
	
	if($("a.facebox").length){
		$('a.facebox').facebox({
			loadingImage : '/assets/shared/stylesheets/images/loading.gif',
			closeImage   : '/assets/shared/stylesheets/images/closelabel.png'
		});
	}

	/*
		Validate form submition for tickets page
		@location: views/event/show.php
	*/
	if($(".validation").length){
		$(".validation").validationEngine();
	}
	
	// show a confirm dialog box
	$('.confirm_action').live("click",function(){
		var answer = confirm($(this).attr('title'));
		if (answer){
			window.location = $(this).attr('href');
		}
		else{
			return false;
		}
	});
	
	// tabs generator
	if($("#tabs").length){
		$( "#tabs" ).tabs();
	}
	
	// no double submit
	$(".single_submit").live("click",function(){
		var that = $(this);
		$(this).hide();
		$(this).after('<img id="single_submit_waiting" src="/assets/shared/stylesheets/images/loading.gif" />');
		window.submit_timout = window.setTimeout(function(){$("#single_submit_waiting").remove();$(that).val('Retry');$(that).show();}, 5000);
	});
	
	if($("img.more_info[title]").length){
		// Match all <A/> links with a title tag and use it as the content (default).
		$('img.more_info[title]').qtip({
			style: {
				classes: 'ui-tooltip-dark ui-tooltip-shadow'
			},
			show: {
			      event: 'click mouseenter'
			   },
			hide: {
			            delay: 400,
			            fixed: true
			        },
		});
	}
});
