// client side validation to help users 
// with javascript enabled,	fields are also 
// validated on the server side
function validate(obj)
{
	// category_id
	if(obj.category_id.value == "")
	{
		alert("Error: Please select a category.");
		return false;
	}
	
	// listing_title
	if(obj.listing_title.value == "")
	{
		alert("Error: Please enter a title.");
		return false;
	}

	// listing_description
	if(obj.listing_description.value == "")
	{
		alert("Error: Please enter a description.");
		return false;
	}
	
	// listing_contact
	if(obj.listing_contact.value == "")
	{
		alert("Error: Please enter a way to contact you.");
		return false;
	}
	
	// listing_url
	if(obj.listing_url.value == "")
	{
		alert("Error: Please enter a URL.");
		return false;
	}
	
	// image_verification
	if(obj.image_verification.value == "")
	{
		alert("Error: Please enter the image verification number.");
		return false;
	}
}

// update category description iframe when select 
// option is selected
function updateDescription(obj)
{
	// set up xmlhttprequest object
	if (navigator.appName == "Microsoft Internet Explorer")
	{
		c_xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	}
	else
	{
		c_xmlhttp = new XMLHttpRequest();
	}

	// called when state changes
	c_xmlhttp.onreadystatechange = function statechanged() 
	{
		if(c_xmlhttp.readyState == 4)
		{
			document.getElementById("category_description").innerHTML = c_xmlhttp.responseText;
		}
	}
	
	// send request
	c_xmlhttp.open("GET", "listing_submit_description.php?category_id=" + obj.value);
	c_xmlhttp.send(null);
}
