$(document).ready(function(){
		$(".pop").colorbox({width:"60%", height:"80%", iframe:true});
		$("a[rel='colorbox']").colorbox({transition:'fade',width: '65%', height: '75%'});	
				$("#pc-name").change(function() {
			if ($(this).val() == "") {
				$("#pc-name").val("Name");
			}
		});

		resetCreateCharacter();	
		$("#pc-name").focus(function() {
			$("#pc-name").css('color', '#000');
			if ( $("#pc-name").val() == "Name") {
				$("#pc-name").val("");
			}
		});

		var tooltip_options = { 
		bordercolor: '#ccc', // tooltip border color
		bgcolor: '#000', //Tooltip background color
		fontcolor : '#fff', //Tooltip Font color
		fontsize : '12px'}; 
		$('.hiddenhint').tooltip(tooltip_options);
		$('.hiddenhint-data').hide();
		$('.hiddenhint').text('');
		$('.hiddenhint').html(' <img src="/img/question.png" alt="tool tip" /> ');			

		/*$("#create-submit").click(function() {
			$(this).attr("disabled", true);				
			$(this).css("background-color", "#ccc");
			$(this).val("Creating ...");
			return true;
		});*/
		
		$(function() {$("#tabs").tabs(); });

		$('.confirm').click(function() {
			if (confirm('You are about to do something drastic. Are you sure you want to continue')) {
				return true;
			}
			return false;
		});


		//Player Menu
	    var menu = $('#masthead-player-menu');
		var menubtn = $('#masthead-player');

		//If some one clicks on the name
		$(menubtn).mouseenter(function() {
			showhide(menu);
		});

		//If the mouse leaves the menu collapse it after a brief delay
		$(menu).mouseleave(function() {
			setTimeout(showhide, 1200);
		});
	
		//Sets the position of the menu
		function pos(menu) {
			$(menu).position({
				 my: "left top",
				 at: "left bottom",
				 of:  menubtn, //this, // or $("#otherdiv)
				 collision: "fit"
			});
		}

		function showhide() {
			$(menu).stop().toggle(0, function() {
				if ($(menu).css('display') == 'none') {
					$(menubtn).css('background', 'transparent');	
				} else {
					$(menubtn).css('background', '#ccc');	
				}				
			});
		}

		//Menu moves with the window
		$(window).resize(function(){
				pos(menu);
		});
		pos(menu);	

});
function showCreateSuccess(url)
{
		$('.add-character').hide();
		message = '<ul><li class="green">Character Created</li>';
		message += '<li>View your new <a href="/character_sheets/'+url+'">character</a>.</li>';
		message += '<li>Create a new <a href="#" onclick="resetCharacterForm();" class="show-create-form">character</a>.</li></ul>';
		$('#create-character-success').html(message);
		$('#create-character-success').show();	
}
function resetCreateCharacter() {
			$("#pc-name").val("Name");
			$("#pc-name").css('color', '#ccc');
			$("#PlayerCharacterCharacterSheetId").val("");
}
function resetCharacterForm() {
				$('#create-character-success').hide();
				$('#create-character-success').html("");
				$('.add-character').show();
				return false;
}

