var BaseUrl="/";
String.prototype.Trim = function(){ return this.replace(/(^\s*)|(\s*$)/g, "");}

function CheckLogin(mydir)
{
	var ret=pureland.Ajax.common.CheckLogin(mydir).value;
	return ret;
}

function Login(mydir)
{
	var username=document.getElementById("txtusername").value;
	var userpwd=document.getElementById("txtuserpwd").value;
	if(username=="") { alert("The email can't be empty!"); return; }
	if(userpwd=="") { alert("The password can't be empty!"); return; }
	var ret=pureland.Ajax.common.Login(username,userpwd,mydir).value;
	document.getElementById("LoginBox").innerHTML=ret;
	if(ret.indexOf("txtusername")!=-1) { alert("Error email or password."); return; }
	else
	{
		top.location.href=BaseUrl+"service.Html";
	}
}

function Logout(mydir)
{
	var ret=pureland.Ajax.common.Logout(mydir).value;
	document.getElementById("LoginBox").innerHTML=ret;
	
	var curhref=location.href;
	if(curhref.indexOf("#")!=-1) curhref=curhref.substring(0,curhref.indexOf("#"));
	if(curhref.indexOf("?")!=-1) curhref=curhref.substring(0,curhref.indexOf("?"));
	curhref=curhref.substring(curhref.lastIndexOf("/")+1,curhref.length);
	curhref=curhref.toLowerCase();
	if(curhref=="service.html")
	{
		top.location.href=BaseUrl;
	}
}