var CKEDITOR_BASEPATH = '/site-resources/scripts/ckeditor-1/';

$(document).ready(function() {
	if ($('#ckeditor').size())
	{
		//$('#ckeditor').ckeditor();
	}
	if ($( "#datepicker" ).size())
	{
		$( "#datepicker" ).datetimepicker({
			"dateFormat":"dd/mm/yy"
		});
	}

	// the faculty page
    var tabContainers = $('div#tabs > div');
    
    $('div#tabs ul#facultymenu a').click(function () {
        tabContainers.hide().filter(this.hash).show();
        
        $('div#tabs ul#facultymenu a').removeClass('selected');
        $(this).addClass('selected');
        
        return false;
    }).filter(':first').click();
})

function dialogDelete(url)
{
  var a = this; 
  $('#dialogDelete').dialog({
        buttons: {
          "Yes": function() {
                 $.get(url, function(data) {
                 	window.location.reload();
                 }); 
          },
           "No": function() {
           		$(this).dialog("close");
          }
        },
        resizable: false,
        modal: true
  });
}

function dialogConfirmUnsubscribe()
{
  var a = this;
  $('#dialogConfirmUnsubscribe').dialog({
        buttons: {
          "Yes": function() {
				$(this).dialog("close");
				$("#unsubscribeForm").submit();
          },
           "No": function() {
           		$(this).dialog("close");
          }
        },
        resizable: false,
        modal: true
  });
}

function dialog(dialogtitle, p, url)
{
  var a = this;
  $('#dialog p').html(p);
  $('#dialog').dialog({
		title: dialogtitle,
		width: 450,
		minHeight: 100,
		height: 'auto',
        buttons: {
          "Yes": function() {
                window.location.href = url;
          },
           "No": function() {
           		$(this).dialog("close");
          }
        },
        resizable: false,
        modal: true
  });
}

function dialogAjax(dialogtitle, p, url)
{
  var a = this;
  $('#dialog p').html(p);
  $('#dialog').dialog({
		title: dialogtitle,
		width: 450,
		minHeight: 100,
		height: 'auto',
        buttons: {
          "Yes": function() {
                 $.get(url, function(data) {
                 	window.location.reload();
                 }); 
          },
           "No": function() {
           		$(this).dialog("close");
          }
        },
        resizable: false,
        modal: true
  });
}

function attendedclick(invitation_id, user_id, attended)
{
	$.post('/admin/invitations/attended', {'invitation_id':invitation_id, 'user_id':user_id, 'attended':attended}, function(data) {
		$('#attended-'+user_id).html(data);
	})
}
