////create the cpaint object to initiate the request to server
var cplogin = new cpaint();

cplogin.set_transfer_mode('get');
cplogin.set_response_type('text');
cplogin.set_async(true);
cplogin.set_debug(0);

//////////////////employee login function/////////////////////////////////////////////////
function doLogin(backURL){
	
  showWait('showmsg');
 
  var username = $('txtUser').value;
  var password = $('txtPassword').value;
  cplogin.call('employer_login_do.php', 'doLogin', doLogin_results, username, password, backURL);
}

function doLogin_results(result){
	
	var str = result.split("||");

	if (str[1]=="success"){
		
		if (str[2]==""){
			window.location= 'employer_home.php';
		}else{
			window.location= str[2];
		}
	}
	else
	{
		$('tblerror').style.display='block';
		$('showmsg').style.color = "#FF0000";
		$('showmsg').innerHTML = str[0];
		$('txtUser').focus();
	}
}

function f2()
{
var text1;
text1=event.keyCode
var backURL = $('backURL').value;

if(text1==13) 
	{
		return doLogin(backURL);
	}	

}

function HandleKeyPressEvent(e){ // handle i.e. (window.event) and firefox (e) 
var eventInstance = window.event ? event : e;  
// handle i.e. (charCode) and firefox (keyCode) 
var unicode = eventInstance.charCode ? eventInstance.charCode : eventInstance.keyCode;  

if (unicode==13)
	doLogin($('backURL').value);
//var key = String.fromCharCode(unicode); 
}
//////////////////////////////////////////////////////////////////////////////////////////
