// JavaScript Document
var xmlHttp
clubIDSelected = 0;
function getClubName(num)
{
	if (num!=''){
		xmlHttp=GetXmlHttpObject()
		if (xmlHttp==null)
		{
			alert ("Browser does not support HTTP Request")
			return
		} 
		document.getElementById("formClubName").innerHTML="Loading...";
		var url="load_clubname.php?stateid="+num+"&"
		url=url+"sid="+Math.random()
		xmlHttp.onreadystatechange=stateChanged 
		xmlHttp.open("GET",url,true)
		xmlHttp.send(null)
	}else{
		document.getElementById("formClubName").innerHTML="Please select state...";
	}
} 

function stateChanged() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{ 
	docXML = xmlHttp.responseXML.documentElement;
	var hNode = getSubNodeByName( docXML, 'clubs' )
	
	if (hNode==null){
		document.getElementById("formClubName").innerHTML="Please select state...";
		return false;
	}
//	var hChildren = hNode.getElementsByTagName( 'club' )
	var hChildren = hNode.getElementsByTagName( 'club' )

	theSelect='<select name="clubID" class="form_profiles1">'
	
	for ( var i = 0; i < hChildren.length; i++ ) 
	{
		hItem = hChildren.item(i)
		if( hItem.nodeType == 1 )
		{
			if( hItem.nodeName == "club" )
			{
				nClubID = getNodeText( getSubNodeByName( hItem, 'clubid' ) )
				nClubName = getNodeText( getSubNodeByName( hItem, 'clubname' ) )
				if (clubIDSelected!=0){
					if (clubIDSelected==nClubID){
						theSelect+='<option value="'+nClubID+'" selected>'+nClubName+'</option>'
					}else{
						theSelect+='<option value="'+nClubID+'">'+nClubName+'</option>'
					}
				}else{
					theSelect+='<option value="'+nClubID+'">'+nClubName+'</option>'
				}
			}
		}
	}
	theSelect+='</select>'
	document.getElementById("formClubName").innerHTML=theSelect;
	
//	document.getElementById("txtHint").appendChild(theTable);
} 
} 

function GetXmlHttpObject()
{ 
var objXMLHttp=null
if (window.XMLHttpRequest)
{
objXMLHttp=new XMLHttpRequest()
}
else if (window.ActiveXObject)
{
objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
}
return objXMLHttp
} 

// SPELL CHECK
var Spell_Win_Name;
var Work_Form_Name;
var Work_Field_Name;

function SpellCheck(form_name,field_name) 
{
 
  var textform = self.document[form_name][field_name].value;
  
  //open popup window and submit to spell_check.php ONLY
  //1. IF popup window is not open or popup window was closed
  //2. OR click comes from another form-field
  
  //otherwise spellcheck click just focus popup window
  
  if ( ! Spell_Win_Name || Spell_Win_Name.closed || (Work_Form_Name != form_name || Work_Field_Name != field_name))
  {
  Spell_Win_Name = win_pop('');
  if (Spell_Win_Name.focus) { Spell_Win_Name.focus(); }
  
  self.document.hidden_form.form_name.value = form_name; 	
  self.document.hidden_form.field_name.value = field_name;  	
  self.document.hidden_form.first_time_text.value = textform;
  self.document.hidden_form.submit();
  
  Work_Form_Name=form_name;
  Work_Field_Name=field_name;
  }
  else
  {
  if (Spell_Win_Name.focus) { Spell_Win_Name.focus(); }
  }

}

function win_pop(URL)
{	
	winname=window.open(URL,'WIN','width=600,height=380,left=210,top=210,resizable=yes,scrollbars=yes,status=yes'); 
return winname;
}

// END SPELL CHECK
