function ajax_post(){
	var pars   ="action=login&username=" + $F('username') + "&password=" + $F('password');
	var myajax = new Ajax.Request("login.php",{method:'post',parameters: pars,onLoading:show_loading,onComplete:show_result});
    return false;
}

function show_loading(){
     $('loadp').innerHTML = '&nbsp;&nbsp;<img src="images/ajax.gif" >&nbsp;&nbsp;&nbsp;';
}

function show_result(response){
        var r_text = response.responseText;
		if(r_text!='OK'){
			eval(r_text);
		}else{
		    location.href="document.php";
		}
		$('loadp').innerHTML  = '<input style="margin:-5px 0 0 0" type="image" name="Submit" value="Login" src="images/desc/btn01.gif" width="70" height="24" onclick="return ajax_post()"/>';
}

function ajax_logout(){
    var myajax = new Ajax.Request("login.php",{method:'post',parameters: "action=logout",onLoading:show_loading,onComplete:show_result});
	return false;
}

function view(id){
   document.getElementById(id).value = '';
   document.getElementById(id).style.color = '';
   if(id=='password2'){
   document.getElementById('password2').style.display = 'none';
   document.getElementById('password').style.display = 'inline';
   }
   document.getElementById('password').style.color   = '';
}

function ajax_out(){
    var myajax = new Ajax.Request("login.php",{method:'post',parameters: "action=logout2",onLoading:show_loading,onComplete:show_result2});
	return false;
}
function show_result2(response){
     window.location.href="index.php";
}
function del(url){
    if(confirm("Sure you want to delete?")){
	   window.location.href = url;
	}
}
