CRSVP = {
	domId : '',
	types : ["Y", "M", "N", "U"],
	
	init : function(domId)
	{
		this.domId = domId;
	},
	
	editRSVP : function()
	{
		CRSVP.rsvpPop();
	},
	
	postComment : function()
	{
		Grouply.ajaxloadform("myrsvp_form_result", "myrsvp_form", CRSVP.rsvpSubmitFormCallback, false, true);
	},
	
	editComment : function()
	{
		Grouply.hideEl('rsvp_comment');
		Grouply.showEl('rsvp_comment_editor');
		Grouply.get('postrsvpbutton').setHandler(CRSVP.postComment);
		Grouply.get('postrsvpbutton').setText('Post');
	},
	
	rsvpPop : function() {
    Grouply.popin.show("rsvppopin", null, null, function(){Grouply.popin.resizeToContent('rsvppopin')});
  },
  
  rsvpUnpop : function() {
    Grouply.popin.hide("rsvppopin");
  },
  
  submitForm : function() {
    CRSVP.rsvpUnpop();
    Grouply.ajaxloadform("myrsvppopin_form_result", "myrsvppopin_form", CRSVP.rsvpSubmitFormCallback, false, true);
    return false;
  },
  rsvpSubmitFormCallback : function() {  
    CC.ajax.reload(CRSVP.domId, true);
  },
  rsvpMouseOver : function(element) {
    var extel = Ext.get(element);
    var xy = extel.getXY();
    var hidel = Ext.get(element.id + "_full");
    hidel.setVisible(true);
    hidel.dom.style.height = hidel.dom.pixelHeight + "px"; //need to do this or div is infinitely tall and mouseout never happens.
    hidel.setXY(xy);
  },
  rsvpMouseOut: function(element) {
    Ext.get(element).setVisible(false);
  },
  
  showGuestList : function (type) {
		Grouply.popin.show('guestlistpopin', null, null, function() { CRSVP.guestListPopinLoaded(type); } );
	},
	
	showGuestListContent : function (selected) {
		for (type_i in CRSVP.types)
		{
			if (typeof(CRSVP.types[type_i]) == 'string')
			{
				if (CRSVP.types[type_i] == selected ){
					Ext.get('gl_popin_link_'+CRSVP.types[type_i]).addClass('ca-w');
					Grouply.showEl('gl_popin_content_'+CRSVP.types[type_i]);
				} else
				{
					Ext.get('gl_popin_link_'+CRSVP.types[type_i]).removeClass('ca-w');
					Grouply.hideEl('gl_popin_content_'+CRSVP.types[type_i]);
				}
			}
			
			
		}
			
	},
	
	closeGuestList : function () {
		Grouply.popin.hide('guestlistpopin');
	},
	
	guestListPopinLoaded : function (selected) {
		CC.elipse(document.getElementById('guestlistpopin_content'));
		CRSVP.showGuestListContent(selected);		
	}
  
};
