function loadStates(countryName){
	if(document.all(countryName).value!=null && document.all(countryName).value.length!=0){
		getStateList(document.all(countryName).value);
	}
}

function getStateList(country)
{
	RemoteFacade.listState(country, populateStateList);
    DWRUtil.removeAllOptions("state");
    oo=document.createElement('OPTION'); 
    oo.text="loading......";
    oo.value="";
    document.getElementById("state").options.add(oo);
}

function populateStateList(list)
{
	DWRUtil.removeAllOptions("state");
	DWRUtil.addOptions("state", list,'alias','name');
	var ss = document.all['selectedState'].value;
	if(ss) DWRUtil.setValue("state",ss);
} 

function checkUsernameUnique(username)
{
    RemoteFacade.existUsername(username, checkUsernameResult);
} 

function checkUsernameResult(data)
{
	if(data){
		$("ERROR_LOGIN").innerText = 'LoginName same!';
	}else{
		$("ERROR_LOGIN").innerText = '';
    }
} 

function checkEmailUnique(email)
{
    RemoteFacade.existEmail(email, checkEmailResult);
} 

function checkEmailResult(data)
{
	if(data){
		$("ERROR_EMAIL").innerText = 'This e-mail address belongs to another registered user. Please enter a different e-mail address.';
	}else{
		$("ERROR_EMAIL").innerText = '';
    }
}


