$(function(){
	$(".fg-button:not(.ui-state-disabled)")
	.hover(
		function(){ 
			$(this).addClass("ui-state-hover"); 
		},
		function(){ 
			$(this).removeClass("ui-state-hover"); 
		}
	)
	.mousedown(function(){
			$(this).parents('.fg-buttonset-single:first').find(".fg-button.ui-state-active").removeClass("ui-state-active");
			if( $(this).is('.ui-state-active.fg-button-toggleable, .fg-buttonset-multi .ui-state-active') ){ $(this).removeClass("ui-state-active"); }
			else { $(this).addClass("ui-state-active"); }	
	})
	.mouseup(function(){
		if(! $(this).is('.fg-button-toggleable, .fg-buttonset-single .fg-button,  .fg-buttonset-multi .fg-button') ){
			$(this).removeClass("ui-state-active");
		}
	});
	$('.deleteSet').click( function() {
		var theId = $(this).attr('id').substr(4);
		if(confirm("Are you sure you want to delete this entry?\n\nOk to continue, Cancel to abort.")) {
			$.post('/ajax/deletePhotoSet.php', { setName: theId  }, function(data) {
				top.location.reload(true);
			});			
		}
	});
});

function confirmCancel(uri) {
	if(confirm("Are you sure you want to cancel?\n\nOk to return to entry list, Cancel to continue editing."))
		top.location=uri;
}

function confirmDelete(uri, entryid) {
	if(confirm("Are you sure you want to delete this entry?\n\nOk to continue, Cancel to abort."))
		top.location=uri+'/edit/?requestType=delete&entryid='+entryid;
}

function save() {
	$('#progressBar').show();
	$('#editForm').submit();
}

function eventMemberJoinRequest() {
	$('#eventMemberJoinRequestForm').submit();
}

function friendRequest() {
	$('#friendRequestForm').submit();
}

function friendRequestApprove(uri, entryid) {
	top.location=uri+'?requestType=friendRequestApprove&entryid='+entryid;
}

function friendRequestDeny(uri, entryid) {
	top.location=uri+'?requestType=friendRequestDeny&entryid='+entryid;
}

function confirmFriendDelete(uri, entryid) {
	if(confirm("Are you sure you want to delete this Friend?\n\nOk to continue, Cancel to abort."))
		top.location=uri+'?requestType=friendDelete&entryid='+entryid;
}

function photoUpload() {
	$('#photoUploadForm').submit();
}

function commentPostApprove(uri, commentId, photoId, eventId) {
	top.location=uri+'?requestType=commentPostApprove&commentId='+commentId+'&photoId='+photoId+'&eventId='+eventId;
}

function commentPostDeny(uri, commentId, photoId, eventId) {
	top.location=uri+'?requestType=commentPostDeny&commentId='+commentId+'&photoId='+photoId+'&eventId='+eventId;
}

function confirmCommentDelete(uri, commentId, photoId, eventId) {
	if(confirm("Are you sure you want to delete this Comment?\n\nOk to continue, Cancel to abort."))
		top.location=uri+'?requestType=commentDelete&commentId='+commentId+'&photoId='+photoId+'&eventId='+eventId;
}

function formSubmit(formId) {
	$(formId).submit();
}

function confirmDeleteExtended(uri, requestType, vars, msg) {
	if(confirm(msg+"\n\nOk to continue, Cancel to abort."))
		top.location=uri+'?requestType='+requestType+'&'+vars;
}

function eventMemberRequestApprove(uri, entryid) {
	top.location=uri+'?requestType=eventMemberRequestApprove&eventMemberId='+entryid;
}

function eventMemberRequestDeny(uri, entryid) {
	top.location=uri+'?requestType=eventMemberRequestDeny&eventMemberId='+entryid;
}

function confirmEventMemberDelete(uri, entryid) {
	if(confirm("Are you sure you want to delete this Event Member?\n\nOk to continue, Cancel to abort."))
		top.location=uri+'?requestType=eventMemberDelete&eventMemberId='+entryid;
}
