/*
	OFPEC Tags System
	3 January 2008
	
	my first AJAX application - how exciting!
	will dynamically check the database for tag availability on registration
*/

function check_availability() {
	
	var the_tag = document.getElementById('tag').value;
	
	// is the tag box empty?
	if (the_tag.length == 0) { 
		// document.getElementById("available_response").innerHTML="";
		return false;
	}
	
	xmlHttp=GetXmlHttpObject();
	
	if (xmlHttp == null) {
		alert ('Your browser does not support AJAX!');
		return false;
	} 
	
	var url = 'includes/check_available.php';
	url = url + '?tag=' + the_tag;

	xmlHttp.onreadystatechange = stateChanged_check_available;
	xmlHttp.open('GET', url, true);
	xmlHttp.send(null);
} 

function stateChanged_check_available() { 
	if (xmlHttp.readyState == 4) { 
		document.getElementById('available_response').innerHTML = xmlHttp.responseText;
		return false;
	}
}

function clean_tagslate(the_field) {
	var slate = the_field.value;
	if (slate == 'TAG') {
		the_field.value = '';
	}
}
