function check_handle(result) {
		if(result[0] == 'yes') {
			document.getElementById('not_available').style.display = 'none';
			document.getElementById('available').style.display = 'block';
			window.location = "http://www.trolltraveler.com/my_account.php";
		}
		else {
			document.getElementById('available').style.display = 'none';
			document.getElementById('not_available').style.display = 'block';
		}
	}

	function check_user_exist() {
	    document.getElementById('not_available').style.display = 'none';
		document.getElementById('available').style.display = 'none';
		var username = document.getElementById('username').value;
		var password = document.getElementById('password').value;
		x_check_user_exist(username,password, check_handle);
	}

	function switch_username(username) {
		document.getElementById('username').value = username;
		document.getElementById('password').value = password;
	}
	
	function checkEnter(e){ //e is event object passed from function invocation
var characterCode;

if(e && e.which){ //if which property of event object is supported (NN4)
e = e
characterCode = e.which //character code is contained in NN4's which property
}
else{
e = event
characterCode = e.keyCode //character code is contained in IE's keyCode property
}

if(characterCode == 13){ //if generated character code is equal to ascii 13 (if enter key)
check_user_exist();  //submit the form
return false ;
}
else{
return true 
}

}

function popup(mylink, windowname)
{
if (! window.focus)return true;
var href;
if (typeof(mylink) == 'string')
   href=mylink;
else
   href=mylink.href;
window.open(href, windowname, 'width=270,height=400,scrollbars=no');
return false;
}

