setTimeout('loadHashTab()', 100);

function loadHashTab()
{
	switch(window.location.hash)
	{
		case "#location":
			switch_tabs(2);
			break;
		case "#games":
			switch_tabs(3);
			break;
		case "#faq":
			switch_tabs(4);
			break;
		case "#rsvp_list":
			switch_tabs(5);
			RSVP_list(lk_event_id);
			break;
		case "#registration":
			switch_tabs(6);
			break;
		default:
			switch_tabs(1);
			break;
	}	
}

function popupRSVP(eventid)

{

	$('rsvp_box').style.left = (document.body.clientWidth / 2 - 150) + "px";

	$('rsvp_box').style.display = "";

	$('document_modal').style.display = "";

	$('rsvp_eventid').value = eventid;

}



function hideRSVP()

{

	$('rsvp_box').style.display = "none";

	$('document_modal').style.display = "none";

}



function RSVP_list(id)

{

	var realBaseUrlWww = location.protocol + '//www.' + location.host + location.pathname + '?';

	

	/* Normal Base URL which PHP uses */

	var	baseUrl = ipb.vars['base_url'] + '&app=events&module=ajax&section=coreAjax&secure_key=' + ipb.vars['secure_hash'] + '&';

	

	var rsvp_status = "no";

	

	new Ajax.Request( baseUrl + 'type=rsvp_list',

		{

			method: 'post',

			encoding: ipb.vars['charset'],

			parameters: {

				eventid:	id

			},

			onSuccess: function(s)

			{

				$('rsvp_inner').innerHTML = s.responseText;

			}

		}

	);

}



function RSVP()

{

	var realBaseUrlWww = location.protocol + '//www.' + location.host + location.pathname + '?';

	

	/* Normal Base URL which PHP uses */

	var	baseUrl = ipb.vars['base_url'] + '&app=events&module=ajax&section=coreAjax&secure_key=' + ipb.vars['secure_hash'] + '&';

	

	var rsvp_status = "no";

	

	if($('rsvp_status_yes').checked == 1) 

		rsvp_status = "yes";

	else if($('rsvp_status_maybe').checked == 1) 

		rsvp_status = "maybe";
		
	

	new Ajax.Request( baseUrl + 'type=rsvp',

		{

			method: 'post',

			encoding: ipb.vars['charset'],

			parameters: {

				eventid:	$('rsvp_eventid').value,

				status:		rsvp_status,

				comment:	$('rsvp_comment').value

			},

			onSuccess: function(s)

			{

				//alert( s.responseText );

				switch_tabs(5);

				RSVP_list($('rsvp_eventid').value);

				$('unrsvp').style.display = "";

			}

		}

	);

}



function removeRSVP(userid)

{

	

	var realBaseUrlWww = location.protocol + '//www.' + location.host + location.pathname + '?';

	

	/* Normal Base URL which PHP uses */

	var	baseUrl = ipb.vars['base_url'] + '&app=events&module=ajax&section=coreAjax&secure_key=' + ipb.vars['secure_hash'] + '&';

	

	if( confirm( "Are you sure you want to Un-RSVP?" ) )

	{

		new Ajax.Request( baseUrl + 'type=unrsvp',

			{

				method: 'post',

				encoding: ipb.vars['charset'],

				parameters: {

					eventid:	$('rsvp_eventid').value,

					userid:		userid

				},

				onSuccess: function(s)

				{

					//alert( s.responseText );

					switch_tabs(5);

					RSVP_list($('rsvp_eventid').value);

					$('unrsvp').style.display = "none";

					hideRSVP();

				}

			}

		);

	}

}



function switch_tabs(tabID) 

{

	//THESE ARE ALL THE TABS, Gamma o.0

	$('info_box').style.display = "none";

	$('location_box').style.display = "none";

	$('games_box').style.display = "none";

	$('faq_box').style.display = "none";

	$('rsvp_list_box').style.display = "none";
	
	if(lk_paid_event == 1)
	{
		$('registration_box').style.display = "none";
	}

	$('info_tab').setAttribute("class", "");

	$('location_tab').setAttribute("class", "");

	$('games_tab').setAttribute("class", "");

	$('faq_tab').setAttribute("class", "");

	$('rsvp_list_tab').setAttribute("class", "");
	
	if(lk_paid_event == 1)
	{
		$('registration_tab').setAttribute("class", "");
	}

	switch(tabID) 

	{

		case 1:

			$('info_box').style.display = "";

			$('info_tab').setAttribute("class", "active");

			break;

		case 2:

			$('location_box').style.display = "";

			$('location_tab').setAttribute("class", "active");

			break;

		case 3:

			$('games_box').style.display = "";

			$('games_tab').setAttribute("class", "active");

			break;

		case 4:

			$('faq_box').style.display = "";

			$('faq_tab').setAttribute("class", "active");

			break;

		case 5:

			$('rsvp_list_box').style.display = "";

			$('rsvp_list_tab').setAttribute("class", "active");

			break;
			
		case 6:

			$('registration_box').style.display = "";

			$('registration_tab').setAttribute("class", "active");

			break;

	}

}
