﻿function openWindow(url) {
  window.open(url, "",
    "top=0,left=0,height=600,width=800,resizable,scrollbars,status,toolbar,location")
}
function checkSignedIn(url) {
  if ($.cookie.read('signin') == 'true') {
    document.location.replace(url);
  }
  else {
    //Not signed in
    openSigninDialog(url);
  }
}
function openSigninDialog(url) {
  var $html =
    "<div>" +
    "<p/>Enter password:" +
    "<input type='password' id='signin' />" +
    "<div id='message'></div>" +
    "<button onclick='btnSignIn(\"" + url + "\")' type='submit'>Sign In</button>" +
    "<br/><br/>" +
    "<span style='color:blue;font-size:8 pt;'>To obtain password, contact Fr. Richard at rjano@aol.com or 1-541-726-7309.</span>" +
    "</div>";
  var $dialog = $('<div></div>').html($html);
  $dialog.dialog({
    close: function(event, ui) { document.location.reload(); },
    width: 400,
    height: 350,
    title: 'Member Sign In'
  });
}
function btnSignIn(url) {
  if ($.trim($('#signin').attr('value')) == "") {
    document.getElementById('message').innerHTML = "You must enter a password.";
    document.getElementById('message').style.color = "red";
    document.getElementById('signin').focus();
  }
  else if (String($('#signin').attr('value')).toLowerCase() == "slava") {
    $.cookie.write('signin', 'true');
    document.location.replace(url);
  }
  else {
    document.getElementById('message').innerHTML = "Not correct password.";
    document.getElementById('message').style.color = "red";
    document.getElementById('signin').focus();
  }
}
function setCount(type) {
  $.ajax("count.php?type="+type);
}
