jQuery(function($) {

	var height = $(document).height();
	var width = $(document).width();
	
	function getUrlVars()
	{
		var vars = [], hash;
		var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
		for(var i = 0; i < hashes.length; i++)
		{
			hash = hashes[i].split('=');
			vars.push(hash[0]);
			vars[hash[0]] = hash[1];
		}
		
		return vars;
	
	}
	
	
	var showLogin = getUrlVars()["showlogin"];
	
	if (showLogin == 'true'){
		
		$('div.mask').css({'width' : width });
		$('div.mask').css({'height' : height });
		
		var box_width = $('div.modal').width();
		var position_x = width-box_width;
		var position_x = position_x/2;
		
		
		var box_height = $('div.modal').height();
		var position_y = height-box_height;
		var position_y = position_y/4;
		
		$('div.modal').css({'left' : position_x});
		$('div.modal').css({'top' : position_y});
	
		$('div.mask').show();
		$('div.modal').show();
		
	}
	
	if (showLogin == 'trueerror'){
		
		$('div.mask').css({'width' : width });
		$('div.mask').css({'height' : height });
		
		var box_width = $('div.modal').width();
		var position_x = width-box_width;
		var position_x = position_x/2;
		
		
		var box_height = $('div.modal').height();
		var position_y = height-box_height;
		var position_y = position_y/4;
		
		$('div.modal').css({'left' : position_x});
		$('div.modal').css({'top' : position_y});
	
		$('div.mask').show();
		$('div.modal').show();
		
	}
	
	
	$('a.login-click').live("click", function(event) {
			
		$('div.mask').css({'width' : width });
		$('div.mask').css({'height' : height });
		
		var box_width = $('div.modal').width();
		var position_x = width-box_width;
		var position_x = position_x/2;
		
		
		var box_height = $('div.modal').height();
		var position_y = height-box_height;
		var position_y = position_y/4;
		
		$('div.modal').css({'left' : position_x});
		$('div.modal').css({'top' : position_y});
	
	
		$('div.mask').show();
		$('div.modal').show();
	
	});
	
	
	$('div.mask').live("click", function(event) {
		$('div.mask').hide();
		$('div.modal').hide();
	});
	
	$('a.close-modal').live("click", function(event) {
		$('div.mask').hide();
		$('div.modal').hide();
	});

});
