////
// Document Ready
//
$(document).ready(function() {
	
	
	
	////
	// form hint for EOI
	//
	$('#eoi input.text').focus(function() {
		//console.log('tik');
		if($(this).attr('value')=='enter e-mail')
		{
			$(this).attr('value', '');
			$(this).removeClass('init');
		}
	});
	
	$('#eoi input.text').blur(function() {
		//console.log('tok');
		if($(this).attr('value')=='')
		{
			$(this).attr('value', 'enter e-mail');
			$(this).addClass('init');
		}
	});
	
	
	
	
	////
	// add '_blank' to external links
	//
	
		$('a[href^="http"]:not([href*="'+location.hostname+'"])').each(function() {
			var orgTitle = $(this).attr("title");
			
			$(this).attr({'target': "_blank", 'title': orgTitle+" [new window]"});
			if(!$('#scientificprogram').length)
			{
				$(this).append('<span class="out">^</span>');
			}

		});	
	
	////
	// add 'target="_blank"' to links to PDFs
	//
	$('a[href$=".pdf"]').each(function() {
		var orgTitle = $(this).attr("title");
		
		$(this).attr({'target': "_blank", 'title': orgTitle+" [.PDF]"});
		$(this).addClass('pdf');
	});
	
	
	
	////
	// show hide readmore bits ei. speaker bios
	//
	$('.readmore').hide();
	
	$('.speakerbox .morebtn').click(function() {
		$(this).parents().children('.readmore').slideToggle('fast');
		$(this).slideToggle('fast');
		});
		
		
	$('.speakerbox .hidebtn').click(function() {
		$(this).parents().children('.readmore').slideToggle('fast');
		$(this).parents('.speakerbox').children().children('.morebtn').slideToggle('fast');
		});
	
	
	////
	// show hide readmore bits .desc
	//
	$('.boxpop .desc').hide();
	
	$('.boxpop .descbtn').click(function(event) {
		event.preventDefault();
		var desc = $(this).parents().children('.desc')
		
		desc.wrap('<div id=blanket>')
		
		
		desc.addClass('show');
		
		desc.slideToggle('fast');
		});
	
	$('.boxpop .desc').click(function() {
		$(this).slideToggle('fast', function() {
		    $(this).removeClass('show');
		    $('#blanket').children('.desc').unwrap();
		  });
	});
	
	
	
	
	///
	// preconference info
	//
	$('.workshop .further').hide();
	
	$('.workshop .reveal a').click(function(event) {
		event.preventDefault();
		$(this).parents().children('.further').slideToggle('fast');
		if($(this).html()=='Learn more about this Workshop')
		{
			$(this).html('Hide this info');
			$(this).parents('.reveal').addClass('act');
		}
		else if($(this).html()=='Hide this info')
		{
			$(this).html('Learn more about this Workshop');
			$(this).parents('.reveal').removeClass('act');
		}
	});
	
	///
	// preconference speaker info
	//
	$('.workshop .extend').hide();
	
	$('.workshop .extendbtn').click(function(event) {
		event.preventDefault();
		$(this).parents().children('.extend').slideToggle('fast');
		
	});
	$('.workshop .extend .close').click(function(event) {
		event.preventDefault();
		$(this).parents('.extend').slideToggle('fast');
		
	});
	
	
	
	
	///
	// FAQ back to top
	//
	$('#frequentlyaskedquestions #content h2').prepend('<a class="btt" href="faq.php#header" title="back to top"><img src="pixels/back-to-top.png" alt="back to top" width="19" height="19" /></a>')
	/// animate to top
	$('a.btt, a.topbtn').click(function(event){
		event.preventDefault();
	     $('html, body').animate({scrollTop: '0px'}, 300);
	});
	
	
	
	///
	// table zoom
	//
//	$('.programtable').hide();
//	$('.programtable .closebtn').click(function(event) {
//		event.preventDefault();
//		$(this).parents('.programtable').fadeToggle('slow');
//	});
//	$('.viewtable').click(function(event) {
//		event.preventDefault();
//		$('.programtable').fadeToggle('slow');
//	});






	////
	// session stream title from class
	//
	if($('#scientificprogram').length)
	{
	
		////
		// withdrawn
		//
		$('.withdrawn').prepend('<div class="msg">- WITHDRAWN -</div>')
	
	
		var stream = new Array();
		
		stream['neurology'] = 'Neurology';
		stream['contemporary_practice_issues'] = 'Contemporary Practice Issues';
		stream['occupational_therapy_education'] = 'Occupational Therapy Education';
		stream['occupational_therapy_research'] = 'Occupational Therapy Research';
		stream['children_youth_families'] = 'Children, Youth &amp; Families';
		stream['mental_health'] = 'Mental Health';
		stream['palliative_care'] = 'Palliative Care';
		stream['community_mobility_driving'] = 'Community Mobility &amp; Driving';
		stream['indigenous_health'] = 'Indigenous Health';
		stream['occupational_science'] = 'Occupational Science';
		stream['rural_remote_health'] = 'Rural &amp; Remote Health';
		stream['assistive_technology'] = 'Assistive Technology';
		stream['ageing_healthcare_reform'] = 'Ageing / Healthcare Reform';
		stream['chronic_pain'] = 'Chronic Pain';
		stream['ergonomics_workplace_health'] = 'Ergonomics / Workplace Health';
		stream['rehabilitation'] = 'Rehabilitation';
		stream['community_development'] = 'Community Development';
		stream['stream_home'] = 'Home';
		stream['occupational_transitions'] = 'Occupational Transitions';
		stream['chronic_conditions'] = 'Chronic Conditions';
		stream['educating_evidencebased_practitioners'] = 'Educating Evidence-based Practitioners';
		
		for(xclass in stream)
		{
			//alert(xclass+': '+stream[xclass]);
			$('.'+xclass).attr('title', 'Session Stream: '+stream[xclass]);
		}
	}
	
	
	////
	// cycle fade
	//
	    	var a2fade = $('.cyclefade');
	setInterval(function(){
		if(a2fade.css('opacity') <= 0.5)
		{
			a2fade.fadeTo(1000, 0.9);
		}
		else
		{
			a2fade.fadeTo(1000, 0.5);
		}
	}, 1010 );
	
	
});
