function checkExistence(URL,target,context)
	{
		//var URL="/Markslist/join/checkAvailability.do?username=sun@sun.com";
			document.getElementById("avail_check_indicator").style.display="";
			document.getElementById("bademail").style.display="none";
			document.getElementById("password").style.display="none";
			document.getElementById("enterpassword").style.display="none";
			document.getElementById("firstname").style.display="none";
			document.getElementById("createpassword").style.display="none";
			document.getElementById("needreminder").style.display="none";
			document.getElementById("legal").style.display="none";
			document.getElementById("not_a_member").style.display="none";
			document.getElementById("already_member").style.display="none";
			document.getElementById("ziprow").style.display="none";
		
		var xmlHttp;
		if(window.XMLHttpRequest)
			{ // For Mozilla, Safari, ...
				var xmlHttp = new XMLHttpRequest();
			}
		else if(window.ActiveXObject)
			{ // For Internet Explorer
				var xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
			}
	URL=URL+"&context="+context;
	xmlHttp.open('POST', URL, true);

	xmlHttp.onreadystatechange = function()
		{
						
			if (xmlHttp.readyState == 4){
			updatepage(xmlHttp.responseText);
			}
			else
			{
				//alert(xmlHttp.statusText);
			}
		}
	var data="test=abc";
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");                  
	xmlHttp.send(data);
	

	}



function updatepage(str)
	{
		var pos=str.indexOf("&");
		var word=str.split("&")
		if(word[1]!=null)
		{
			document.getElementById("ziprow").style.display="";
		}
		if(word[0]=="found")
			{
			document.getElementById("avail_check_indicator").style.display="none";
			document.getElementById("password").style.display="";
			document.getElementById("enterpassword").style.display="";
			document.getElementById("needreminder").style.display="";
			if(document.getElementById("action"))
			{
				document.getElementById("action").disabled = false;
			}
			if (document.getElementById("action1"))
			{
				document.getElementById("action1").disabled = false;
			}
			document.getElementById("already_member").style.display="";
	}else if(word[0]=="notfound")
		{
			document.getElementById("avail_check_indicator").style.display="none";
			document.getElementById("firstname").style.display="";
			document.getElementById("password").style.display="";
			document.getElementById("createpassword").style.display="";
			document.getElementById("legal").style.display="";
			if(document.getElementById("action"))
			{
				document.getElementById("action").disabled = false;
			}
			if (document.getElementById("action1"))
			{
				document.getElementById("action1").disabled = false;
			}
			document.getElementById("not_a_member").style.display="";
			document.getElementById("ziprow").style.display="";
	}else if(word[0]=="bademail")
		{
			document.getElementById("avail_check_indicator").style.display="none";
			document.getElementById("bademail").style.display="";
	}

}

function confirmDelete() {
  if (confirm("Are you sure you want to delete?")) {
	  return true; 
  } else {
	  return false; 
  }
}

function confirmAction() {
	if (confirm("Are you sure you want to perform this action?")) {
		return true; 
	} else {
		return false; 
	}
}

function trim( str)
{
    str = str.replace(/\s+$/,"");
    str = str.replace(/^\s+/,"");
    return str;
}

function selectProvince(obj)
{
    if (obj)
    {

        var chosenoption=obj.options[obj.selectedIndex] ;
        if (chosenoption.value=='US')
        {
            document.getElementById("usstates").style.display="";

            document.creditCardForm.province.value="";
            //document.creditCardForm.province.disabled=true;
            document.getElementById("provinceid").style.display="none";
            document.creditCardForm.state.focus();

        }
        else
        {
            document.getElementById("provinceid").style.display="";
            document.creditCardForm.province.disabled=false;
            document.creditCardForm.province.value="";

            document.creditCardForm.province.focus();
            document.creditCardForm.state.options[0].selected=true;
            document.getElementById("usstates").style.display="none";

        }

    }

}
