LoginUI		= function( displayObj ) {
	
	this.cLayer			= displayObj;
	
	var ref				= this;

	this.initTemplate			= function() {
		
		var url		= "";
		if( hasSession() ) {
			url		= "/_ui/MainPage/LoginUI/template_logout.html";
		}
		else {
			url		= "/_ui/MainPage/LoginUI/template_login.html";
		}
		
		new ASYNCXMLHTTP( this._____initTemplateHandler, url );
	}
	
	
	this._____initTemplateHandler	= function(xmlHttp) {
	    ref.proc( xmlHttp );
	}
	
	this.proc			= function(xmlHttp) {
		
		var output		= xmlHttp.responseText;
		this.cLayer.innerHTML		= output;
		
		if( hasSession() ) {
			this.procLogoutForm();
		}
		else {
			this.procLoginForm();
		}
	}
	// ---------------------------------------------------------------------------------------------
	// ---------------------------------------------------------------------------------------------
	this.procLogoutForm		= function() {
		document.getElementById('btnLogout').onclick		= function() {
			procLogout();
		}
		document.getElementById('btnLogout').onmouseover		= function() {
			this.style.cursor		= "hand";
		}
	}
	// ---------------------------------------------------------------------------------------------
	// ---------------------------------------------------------------------------------------------
	
	this.procLoginForm		= function() {
		document.getElementById('uBtn').onclick		= function() {
			ref.submitLoginForm();
		}
	}
	this.submitLoginForm	= function() {


		var url = "/_share_/__SESSION/login.php";
		var queryString = "" +
				"&uid="		+ document.getElementById('uid').value +
				"&upw="		+ document.getElementById('upw').value +
				"";
		

		this.postHttp	= getXMLHTTP();
		this.postHttp.open("POST", url, true);
		this.postHttp.onreadystatechange = this.loginHandler;
		this.postHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");    
		this.postHttp.send(queryString);
	}
	this.loginHandler	= function() {
	    if(ref.postHttp.readyState == 4) {
	        if(ref.postHttp.status == 200) {
	        	
	        	if( ref.postHttp.responseText == "o" ) {
	        		ref.refreshSession();
	        	}
	        	else {
	        		alert( "Error !!");
	        		document.getElementById('uid').focus();
	        	}
	        }
	    }
	}
	
	
	this.refreshSession			= function() {
		refreshSession();
	}
	// ---------------------------------------------------------------------------------------------
	// ---------------------------------------------------------------------------------------------
	
	this.initTemplate();
}


var loginUIJS	= new LoginUI( document.getElementById('loginUI') );
