function clrOther(elmid) {
    var el = document.getElementById(elmid);
    el.value = "";
}

function cmpFormShow(id, elm) {
    if (id > 0) {
	$('conference_registration_name').innerHTML = 'To: ' + elm.innerHTML;

	var cF = $('attendee_contact_form');
	var f = $('contactFrm');
	f.conference_registration_id.value = id;
	cF.setProperty('cfid', id);
	cF.setStyle('left', findPosX(elm));
	cF.setStyle('top', findPosY(elm));
	cF.setStyle('display', "block");
    }
}

function cmpFormHide(id) {
    if (id > 0) {
	var cF = $('attendee_contact_form');
	var f = $('contactFrm');
	f.reset();
	cF.setProperty('cfid', null);
	cF.setStyle('display', "none");
    }
}

function cmpFormSubmit(f) {
    if (f.contact_subject.value == "") {
	alert("Please enter a subject!");
	f.contact_subject.focus();
	return false;
    }

    if (f.contact_message.value == "") {
	alert("Please enter a message!");
	f.contact_message.focus();
	return false;
    }

    new Request.JSON( {
	url :'/rpc.php',
	method :'post',
	onComplete : function(r) {
	    if (r != true) {
		alert('There was an error trying to send! Please try again.');
	    } else {
		alert('Sent successfully!');
		cmpFormHide(f.conference_registration_id.value);
	    }
	}
    }).post( {
	'method' :"sendAttendeeContactEmail",
	'cr2' :f.conference_registration_id.value,
	'subject' :f.contact_subject.value,
	'body' :f.contact_message.value
    });
}

window.addEvent('domready', function() {
    try {
	var availableTours = $('AvailableTourContainer').getElements('div.AvailableTour');
	var usedTours = $('UsedTourContainer').getElements('div.AvailableTour');
    } catch (e) {
    }

    var allTours = new Array();
    if ($defined(availableTours)) {
	allTours.combine(availableTours);
    }
    if ($defined(usedTours)) {
	allTours.combine(usedTours);
    }

    $each(allTours, function(tour, idx) {
	var toggler = tour.getElements('h4')[0];
	var togglee = tour.getElements('div')[0];

	var nFx = new Fx.Slide(togglee, {
	    mode :'vertical',
	    duration :500,
	    transition :Fx.Transitions.Pow.easeOut
	});

	nFx.hide();

	toggler.addEvent('click', function() {
	    nFx.toggle();
	});
    });
});