$(document).ready(function(){
  setInterval('checkLogin()',30000);
  $("#free-review").click(function(){
    $("#disclaimer").dialog({
      bgiframe: true,
      resizable: false,
      height:300,
      width: 500,
      modal: true,
      overlay: {
        backgroundColor: '#000',
        opacity: 0.5
      },
      buttons: {
        'I Agree': function() {
          $(this).dialog('close');
          window.location='/attend_a_lecture.php';
        },
        Cancel: function() {
          $(this).dialog('destroy');
        }
      }
    });
    return false;
  });
});
function checkLogin()
{
  uid = getCookie('UserId');
  sid = getCookie('PHPSESSID');
  $.post('/check-auth.php',{'user_id':uid ,'sid':sid},function(data){
    if(data == 'false')
    {
      alert("A duplicate login has been detected.  You will now be logged out.");
      window.location="/index.php?action=logout";
    }
  });
}
function getCookie(name)
{
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
}
