/*main block - sends request, assigns response*/function inraid_responseToDivs(theText) {	//alert('inraid_responseToDivs');	inraid_response_good = false; 	var m = theText.match('<!-- BEGIN "([^"]+)" (\\S+) -->([\\s\\S]*)<!-- END "\\1" \\2 -->([\\s\\S]*)');	if (m) {		if (m[2] == 'z0') { // code insertion			new Insertion.Top(m[1]+'-container', m[3]);			return true;		}		inraid_response_good = true;		// alert(m[3]);		target = m[1] + '-' + m[2];		$(target).update(m[3]);				inraid_responseToDivs(m[4]);	}	inraid_response_good = (inraid_response_good || theText.blank());	if (!inraid_response_good) alert("Inraid exception:\n" + theText);}function inraid_update(raid_name, raid_recurrence, param_hash) {	var send_params = $H({raid_name: raid_name, raid_recurrence: raid_recurrence});	if (param_hash)		send_params.merge(param_hash);		div_container = $(raid_name + '-container');	div_loading = div_container.getElementsByClassName('inraid-loading')[0];		div_loading.show();			new Ajax.Request('inraid/inraid.php', {		method: 'POST', 		parameters: send_params,		onSuccess: function(transport) {			inraid_responseToDivs(transport.responseText);			div_loading.hide();		},		onFailure: function() {			Element(raid_name + '-z1').update('went wrong');			div_loading.hide();		}			} );		 }function inraid_init(raid_title) {	var divitemlist = $$('div[id="' + raid_title + '-container"]');	if (divitemlist.size() == 1) {		inraid_update(raid_title, '');	} else {		// if this raid's already on this page, don't activate this one, remove duplicate id		divitemlist[1].id = '';		divitemlist[1].getElementsByClassName('inraid-loading')[0].hide();	}}/*checks date input, makes submit button in/visible depending on all data being filled in,returns data if inputs are good*/function inraid_get_datetime(theContainerName) {	var theContainer = $(theContainerName);	var checkSelects = theContainer.getElementsBySelector('select');	var returnHash = $H();	var goodToGo = true;	var theSubmitBlock = theContainer.getElementsBySelector('span#inraid_date_submit')[0];	var theDaysBlock = theContainer.getElementsBySelector('span#inraid_date_days')[0];		// check all dropdowns have values	checkSelects.each(function(item) {		if ($F(item) != "") {			returnHash[item.name] = $F(item);		} else {			goodToGo = false;		}		if (item.name == 'inraid_date_freq') {			if ($F(item) == 'days') {				daysVal = inraid_get_day_value(theContainerName);				returnHash.merge( {inraid_date_days: daysVal} );				// alert (daysVal);				theDaysBlock.show();				// if this is selected, at least one day must be				if (!daysVal) {					goodToGo = false;				}			} else {				//alert('hide');				theDaysBlock.hide();			}		}	} );//alert(returnHash.inspect());	if (goodToGo) {		theSubmitBlock.show();		return returnHash;	}	else {		theSubmitBlock.hide();		return false;	}}var inraid_date_day_selects = 0;function inraid_get_day_value(theContainerName) {	var daySpan = $(theContainerName).getElementsBySelector('span#inraid_date_days')[0];	var dayCheckboxes = daySpan.getElementsBySelector('input[type="checkbox"]');	var returnVal = 0;		dayCheckboxes.each(function(box) {		checkVal = Math.floor($F(box)); // insists on staying a string otherwise, for some reason		if (checkVal) { returnVal += checkVal };	});		return returnVal;}function inraid_toon_add(raid_name, raid_recurrence, theDiv) {	toon_name = $F(theDiv.getElementsBySelector('[name="inraid_toon_name"]')[0]);	toon_class = $F(theDiv.getElementsBySelector('[name="inraid_toon_class"]')[0]);	toon_race = $F(theDiv.getElementsBySelector('[name="inraid_toon_race"]')[0]);		if (toon_name.blank() || toon_class.blank() || toon_race.blank()) {		alert("Enter all three.");		return false;	} else if (!toon_name.match(/^[A-Za-z]+$/)) {		alert("Name can only be letters.");		return false;	} else {		inraid_update(raid_name, raid_recurrence, $H( {					toon_name: toon_name,					toon_class: toon_class,					toon_race: toon_race,					action: 'add_toon'					} ) );	}}					function inraid_input_filter(e) {	var characterCode;	if (!e) var e = window.event;		// get character code of key pressed	if (e.keyCode) characterCode = e.keyCode;	else if (e.which) characterCode = e.which;		if(characterCode == 13) { //if generated character code is equal to ascii 13 (if enter key)		return false;	} else {		return true;	}}function inraid_toon_signup(raid_name, raid_recurrence, user_name, toon_name, toon_role) {	inraid_update(raid_name, raid_recurrence, $H( {		action:		"toon_signup",		user_name:	user_name,		toon_name:	toon_name,		toon_role: 	toon_role } ) );}	function inraid_toon_signup_cancel(raid_name, raid_recurrence, user_name, just_do_it) {	if (just_do_it || confirm("Are you sure you want to cancel this signup?")) {		inraid_update(raid_name, raid_recurrence, $H( {			action:		"toon_signup_cancel",			user_name:	user_name } ) );	}}function inraid_toon_signup_accept(raid_name, raid_recurrence, user_name) {	inraid_update(raid_name, raid_recurrence, $H( {		action:		"toon_signup_accept",		user_name:	user_name } ) );}		