/* This is just a sample how to create an ajax
the accomplices are view/reviews/conventions.thtml and function conventions in the reviewscontroller
*/
/*function registerAjaxInfo() {
   ajaxEngine.registerRequest( 'getPersonInfo', 'getPersonInfo.do' );
   ajaxEngine.registerAjaxElement( 'personInfo' );
}

function getPersonInfo(selectBox) {
   var nameToLookup = selectBox.value.split(",");
   var firstName = nameToLookup[1].substring(1);
   var lastName  = nameToLookup[0];

   ajaxEngine.sendRequest( 'getPersonInfo',
                           "firstName=" + firstName,
                           "lastName=" + lastName );
}

function getSynopsis(selectBox) {
	//alert(selectBox);
	var ajax = new Ajax.Updater(
			         'reviewInfo', 
			         'convention/'+selectBox, // URL
			         {
			         	asynchronous:true, 
			         	evalScripts:true,
			            method:'get',
			            onComplete: showResponse
			         });
	return false;
}

function showResponse(req) {
	//response  = req.responseXML.documentElement;
	//data = response.getElementByTagName('test')[0].firstChild.data;			
				//url         = response.getElementsByTagName('url')[0].firstChild.data;
	//alert(response)			;
	$('reviewInfo').value = req.responseText;
}
*/

function getStateList(countryId) {
	//alert(countryId);
	var ajax = new Ajax.Updater(
			         'state', 
			         '/conventions/states/'+countryId, // URL
			         {
			         	asynchronous:true, 
			         	evalScripts:true,
			            method:'get',
			            onComplete: emptyCity
			         });
	//return false;
}

function getCityList(stateId) {
	var ajax = new Ajax.Updater(
			         'city', 
			         '/conventions/cities/'+stateId, // URL
			         {
			         	asynchronous:true, 
			         	evalScripts:true,
			            method:'get'
			           // onComplete: updateVenue
			         });
	
}

function getVenueList(cityId) {
	//alert(cityId);
	var ajax = new Ajax.Updater(
			         'venue', 
			         '/conventions/venues/'+cityId, // URL
			         {
			         	asynchronous:true, 
			         	evalScripts:true,
			            method:'get'
			            //onComplete: updateState
			         });
	
}

function emptyCity() {
	document.forms['convention'].city.options.length=0;	
}	

function updateVenue(venue) {
	//alert(venue);
	$('venueInText').value=venue;
}

function updateState(req) {
	//alert(req.responseText);
	document.forms['convention'].city.options.length=0;
	//alert(req.responseText);
	//response  = req.responseXML.documentElement;
	//alert(response.childNodes.length);
	//alert(response.childNodes[1].hasChildNodes());
	//alert(response.childNodes[1].length);
	//alert(response.childNodes[9].childNodes[3].firstChild.data);
	//alert(response.childNodes[1].getAttribute('sex'));
	//alert(response.childNodes[9].childNodes[5].firstChild.data);
	//childe = response.getElementsByTagName('response')[0].firstChild.data;
	//alert(childe);
	/*$('state')
	for (i=0; i<cities[selectedcitygroup].length; i++)
		citieslist.options[citieslist.options.length]=new Option(cities[selectedcitygroup][i].split("|")[0], cities[selectedcitygroup][i].split("|")[1])
	}*/
}	

