// Get the window's current size
window.size = function() {
  var h = 0;
  var w = 0;
  if (!window.innerWidth) {
    // IE
    if (!(document.documentElement.clientWidth == 0)) {
      //strict mode
      w = document.documentElement.clientWidth;
      h = document.documentElement.clientHeight;
    } else {
      //quirks mode
      w = document.body.clientWidth;
      h = document.body.clientHeight;
    }
  } else {
    // others
    w = window.innerWidth;
    h = window.innerHeight;
  }
  return { 'width':w, 'height':h};
}

// Open signin modal dialog
function openSignin() {
  Dialog.info($('signin').innerHTML, { className: 'alphacube',
				       title: 'Sign In',
				       width: 300,
				       height: 180,
				     });
}

// Attempt to signin
function doSignin() {
  // Display progress spinner
  $('signin-progress').show();
  // Start the AJAX request
  new Ajax.Request('/ajax/signin',
                   { parameters: $('signin-form').serialize(true),
		     onSuccess: function() {
		       $('signin-links').hide();
		       $('signout-links').show();
		       $('signin-progress').hide();
		       Dialog.closeInfo();
		     },
		     onFailure: function(transport) {
		       $('signin-error').innerHTML = transport.responseText;
		       $('signin-progress').hide();
                     }
		   });
  return false;
}

function validateScreen(screen, resultDiv) {
        var request = new Ajax.Updater(resultDiv, '/ajax/screenCheck',
                                       {'parameters': {'screen': screen}});
	return false;
}
