var callbackhash_rshr_ajax_jobsearch = {

	process: function (result) {

		// parse xml into dom object
		this.returnObject = eval('(' + result + ')');

		// iterate over all id -> html combinations
		for(var i=0;i<this.returnObject.length;i++) {
			var obj       = document.getElementById(this.returnObject[i]['id']);
			obj.innerHTML = this.returnObject[i]['html'];
		}
	}
}

var html_jobsearch  = new rshr_ajax_jobsearch(callbackhash_rshr_ajax_jobsearch);

// variables for processing steps in jobsearch form
var jobsearch_steps = new Array('suitability', 'areaofoperation', 'region', 'country', 'location');
var jobsearch_ids   = new Array('ausbildung', 'arbeitsgebiet', 'region', 'land', 'standort', 'jobs_found');

function rshr_jobsearch_ajax(type, language) {

	// return false if ajax is not found
	if (!rshr_check_ajax_available()) return false;

	var post_object          = new Object();
	post_object['source']    = type;
	post_object['_language'] = language;

	// fill region/language
	var step_found = false;
	//for(var s=0;s<jobsearch_steps.length;s++) {
	for(var s=0;s<5;s++) {
		if (step_found == false) {
			post_object[jobsearch_steps[s]] = document.getElementById('jobsuche_'+jobsearch_ids[s]).value;
			if (type == jobsearch_steps[s]) {
				//step_found = true;
			}
		}
	}

	html_jobsearch.process(post_object);

} // end rshr_jobsearch_ajax

function rshr_jobsearch_ajax_locationselect(location, country, region, areaofoperation, suitability, language) {

	// return false if ajax is not found
	if (!rshr_check_ajax_available()) return false;

	var post_object            = new Object();
	post_object['source']      = 'location';
	post_object['suitability'] = suitability;
	post_object['areaofoperation'] = areaofoperation;
	post_object['region']      = region;
	post_object['country']     = country;
	post_object['location']    = location;
	post_object['_language']   = language;

	html_jobsearch.process(post_object);

} // end rshr_jobsearch_ajax_countryselect

