function showLogin()
{
	var d = document.getElementById('loginform');
	d.innerHTML = '<h2>User Login</h2><form action="http://www.kwango.com/login/index.php" method="post"><input type="hidden" name="do" value="login"><label for="username">Username</label> <input name="username" type="text" maxlength="100"><br> <label for="password">Password</label> <input name="password" type="password"><br><button type="submit">Submit</button></form><ul><li><a href="javascript:showForgotten();" >Forgotten your password?</a></li><li><a href="javascript:showCreate();">Create an account</a></li></ul></form>';
}

function showForgotten()
{
	var d = document.getElementById('loginform');
	d.innerHTML = '<h2>Forgotten Password</h2><form action="http://www.kwango.com/login/index.php" method="post"><input type="hidden" name="do" value="remind"><label for="username">Username</label><input name="username" type="text" maxlength="100"><br><button type="submit">Submit</button></form><ul><li><a href="javascript:showLogin();">Login</a></li><li><a href="javascript:showCreate();">Create an account</a></li></ul></form>';
}

function showCreate()
{
	var d = document.getElementById('loginform');
	d.innerHTML = '<h2>Create a new user</h2><form action="http://www.kwango.com/login/index.php" method="post"><input type="hidden" name="do" value="register"><label for="username">Username</label> <input name="username" type="text" maxlength="100" value=""><br><label for="email">Email<span class="small">for password recovery</span></label> <input name="email" type="text" maxlength="100" value=""><br><label for="password">Password</label> <input name="password" type="password" value=""><br><label for="password2">Confirm password<span class="small">retype your password</span></label> <input name="password2" type="password" value=""><br><label for="org">Organisation:<span class="small">your organisation code</span></label> <input name="org" type="text" value=""><br><label for="is_shared">This login is just for me:</label> <input name="is_private" type="checkbox" value="1" checked="checked"><br><button type="submit">Submit</button></form><ul><li><a href="javascript:showLogin();">Login</a></li><li><a href="javascript:showForgotten();">Forgotten your password?</a></li></ul></form>';
}

function fontSize(size)
{
	_fontSize(size);
	set_cookie('stylecookie', size, 10);
}

function _fontSize(size)
{
	document.body.className = 'bodySize'+size;
}

function set_style_from_cookie()
{
 	var size = get_cookie('stylecookie');
	
	if(size)
	{
		_fontSize(size);
	}
	else
	{
		fontSize(0);
	}
}

function set_cookie(cookie_name, cookie_value,lifespan_in_days, valid_domain)
{
	
    var domain_string = valid_domain ? ("; domain=" + valid_domain) : '' ;
    document.cookie = cookie_name+"="+encodeURIComponent(cookie_value)+"; max-age="+60*60*24*lifespan_in_days+"; path=/"+domain_string ;
}

function get_cookie(cookie_name)
{
    var cookie_string = document.cookie;
    if (cookie_string.length != 0)
	{
		//var cookie_value = cookie_string.match('(^|;)[\s]*'+cookie_name+'=([^;]*)' );
		var cookie_value;
		if(cookie_value = cookie_string.match('[\s]*'+cookie_name+'=([^;]*)' ))
		{
			return decodeURIComponent(cookie_value[1]);
		}
    }
    return 0;
}