//=======================================================================================================
//-------------------------------------------------------------------------------------------------------
//	Custom Javascript functions
//-------------------------------------------------------------------------------------------------------
//=======================================================================================================
function loadfunc()
{
	//	Tabs
	$(".tab-container > ul").tabs();
	
	//	Sponsors slideshow
	$('td#sponsors div').cycle({ 
	    fx:      'fade', 
	    speed:    1500, 
	    timeout:  4000 
	});
	
	/* Fix IE */
	if ($.browser.msie) {
		var height      	= $('#container').height();
		$('#middle').height(height - 196);
		
		var height      	= $('#content').height();
		$('#sidebar').height(height - 178);
	};

    $(".tooltip-trigger").hover(
      function () {
		$(this).next('.tooltip').show();
      },
      function () {
		$(this).next('.tooltip').hide();
      });

	//---------------------------------------------------------------------------------------------------------
	//	registration pages
	//---------------------------------------------------------------------------------------------------------
   	//	toggle fields based on registration type selection
	$('#registrationtype').change(function () {

		var type = "";

		$("#registrationtype option:selected").each(function () {
				type =($(this).attr('value'));
			});

		//	Load the date options.
		$("#fieldblock-attendancedates").load('/register/attendance_dates.php?t=' + type);
		
		//	Hide any conditional fields that may have been shown by a previous selection
		$('.hidden').hide(); 

		//	Show conditional fields
		switch(type)
		{
			//	Student
			case '20':
				$("#fieldblock-college").show();
				$("#fieldblock-class").show();
				break;
			
			//	Exhibitor
			case '30':
				$("#fieldblock-representing").show();
				$("#fieldblock-freepass").show();
				$("#fieldblock-exhibitorjobfunction").show();
				break;
		}
	});


	//	Submit buttons
	$('.submit').click(function(event){
		
		value = $(this).attr('value');
		$('#next').attr('value',value);
		
		makeValidationCall('attendee');
	});
	
	//	Options Page
	$('img.toggler').toggle(
			function()
			{
				$(this).attr('src','/images/minus.gif');
				$(this).next('.option-description').show();
			},
			function(){
				$(this).attr('src','/images/plus.gif');
				$(this).next('.option-description').hide();
			});
	
	// Booths page
	$('.booths-order').change(function(event){
		id = $(this).attr('value');

		if(this.checked)
		{
			$('img.icon-'+id).attr('src','/maps/images/icons/iconc.gif');
			$('input.booths-order-'+id).attr('checked',true);
		}
		else
		{
			$('img.icon-'+id).attr('src','/maps/images/icons/icona.gif');
			$('input.booths-order-'+id).attr('checked',false);
		}
	});

	//	Payment Page
	$('#paymenttype').change(function(event){
		$("#paymenttype option:selected").each(function () {
			type =($(this).attr('value'));
		});
		
		$(".hidden").hide();

		//	Show CC fields
		switch(type)
		{
			case 'CC':
				$("#cc-info").show();
				break;

			case 'Check':
				$("#check-info").show();
				break;
		}
	});

	$('.profile-toggle').toggle(
		function()
		{
			$(this).text('Hide Candidate Profiles');
			$(this).next('.profiles').show();
		},
		function()
		{
			$(this).text('Show Candidate Profiles');
			$(this).next('.profiles').hide();
		});
}