$(document).ready(function() {

    $('#modalwindow').corner("round 14px");

    signInWithAlwaysmath();

	$('a[name=SignIn]').click(function(e) {
		//Cancel the link behavior
		e.preventDefault();

		var id = $('#modalwindow');

		//Get the screen height and width
		var maskHeight = $(document).height();
		var maskWidth = $(window).width();

		//Set heigth and width to mask to fill up the whole screen
		$('#mask').css({'width':maskWidth,'height':maskHeight});

		//transition effect
		$('#mask').show();
		$('#mask').fadeTo("slow",0.4);

		//Get the window height and width
		var winH = $(window).height();
		var winW = $(window).width();

		//Set the popup window to center
		$(id).css('top',  winH/2-$(id).height()/2);
		$(id).css('left', winW/2-$(id).width()/2);

		//transition effect
		$(id).show();
	});

	//if close button is clicked
	$('#modalwindow .CloseImg').click(function (e) {
		//Cancel the link behavior
		e.preventDefault();

		$('#mask').hide();
		$('#modalwindow').hide();

        document.forms["signin_form"].reset();
	});

	//if mask is clicked
	$('#mask').click(function () {
		$(this).hide();
		$('#modalwindow').hide();

        document.forms["signin_form"].reset();
	});
});

function signInWithAlwaysmath () {
  $('#signin_part').load("alwaysmath_login.php");
}

function signInWithOpenid () {
  $('#signin_part').load("openid_login.php");
}

function signInWithFacebook () {
  $('#signin_part').load("facebook_test.html");
}