
function createLoginPopin(title, content)
{
	$(document.body).adopt(
		$$(
			new Element("div", 
				{
					id:"popin-wrapper",
					styles: { "height": window.getScrollSize().y.toInt() }
				}
			)
		),
		popin = 
			new Element("div", { id:"login-popin" }).adopt(
			    new Element("div", { id:"login-area" }).adopt(
				    $$(	new Element("div", { "id":"login-header" }) ).adopt(
				        $$(	new Element("img", { "src":"/images/units/login/ico_login.png" }) )
				        ,
				        $$(	new Element("div", { "class":"header", "html":title }) )
				        ,
				        $$(	new Element("div", { "id":"login-close-area" }) ).adopt(
					        $$(	new Element("a", { id:"login-close", href:"#", "html":"X" }) )
				        )	
				    )
				        ,
				        $$(	new Element("div", { "class":"clear" }) )
				    ,
				    $$(	new Element("form", { id:"login-form", "name":"login-form", "method":"post", "action":"/templates/Login.aspx" }) ).adopt(
				        $$(	new Element("div", { id:"login-form-div" }) ).adopt(
				            $$(	new Element("p", { "html":"Epostadress:" }) )
				            ,
				            $$(	new Element("input", { id:"login-mail", "type":"text", "tabindex":"1", "name":"login-mail" }) )
				            ,
				            $$(	new Element("p", { "html":"L&ouml;senord:" }) )
				            ,
				            $$(	new Element("input", { id:"login-password", "type":"password", "tabindex":"2", "name":"login-password" }) )
				            ,
				            $$(	new Element("input", { id:"login-auto", "type":"checkbox", "style":"display:none;", "name":"login-auto" }) )
				            ,
				            $$(	new Element("label", { "for":"login-auto", "html":"Kom ih&aring;g mig | ", "style":"display:none;" }) )
				            ,			            
				            $$(	new Element("br", { }) )
				            ,
				            $$(	new Element("a", { id:"login-forgot", "href":"/Glomt-losenordet", "html":"Gl&ouml;mt l&ouml;senordet?" }) )
				            ,
				            $$(	new Element("input", { 
				                                id:"login-button",
				                                "type":"submit",
				                                "class":"standard-button", 
				                                "style":"float:right;", 
				                                "value":"Logga in", 
				                                "tabindex":"3"
				                            }) )
				            ,
				            $$(	new Element("div", { "class":"clear" }) )
				        )
				    )
		        )
		    )
	    );
	
	$('login-close').addEvent("click", function(e) {
		e.stop();
		if($('login-popin')){
			$('login-popin').fade(0);
			DisposeLoginPopin();
		}
	});
	
	rePositionLoginPopin();
}

function DisposeLoginPopin()
{
	$('login-popin').setStyle('display','none');
	$('popin-wrapper').setStyle('display','none');
	$('login-popin').dispose();
	$('popin-wrapper').dispose();
}

function rePositionLoginPopin() {
	if ($("popin-wrapper"))
		$("popin-wrapper").setStyle("height", window.getScrollSize().y.toInt());
	if ($("login-popin"))
		$("login-popin").setStyle("left", window.getSize().x/2 - $("login-popin").getStyle("width").toInt()/2);
}