
/**
 * XMS standard functions
 */

var XMS = {
	
	init: function() {
	},
	
	/**
	 * Saves calendar preferences
	 * @todo Should be in XMS.XMSCalendar namespace
	 */
	savePreferences: function (block_id, categories, appointment_types, country) {
		Slik.HTTP.callHandler('setUserPreferences', {'class': 'XMSCalendarBlock', 'id':block_id, 'appointment_types':appointment_types, 'categories':categories, 'country':country}, Slik.HTTP.writeElement, 'savePreferences');
	},
	
	/**
	 * Goes to a website, logging the visit locally
	 * @todo Should be in XMS.XMSCalendar namespace
	 */
	goToWebsite: function(block_class, block_id, record_class, record_id) {
		Slik.HTTP.callHandler('goToWebsite', {'class': block_class, 'id':block_id, 'record_class':record_class, 'record_id':record_id});
	}
	
}



var XMSAntiSpamElement = {
	
	autoFill: function(element_id) {
		
		var parent_el = document.getElementById(element_id);
		
		// Temporary test: assuming bots have no javascript yet, just set the answer to 'js_enabled'
		var inputs = parent_el.getElementsByTagName('input');
		 
	 	parent_el.style.display = "none";
		 
	 	for(x in inputs) {
	 		if(inputs[x].name && inputs[x].name == "captcha_answer") {
	 			inputs[x].value = "js_enabled";
				// Good to know: setting type property throws an error in IE; display: none does the job
				// inputs[x].type = "hidden";
	 			inputs[x].style.display = "none";
	 		}
	 	}
	 	
	 	
	}
}
