/* Standard JS for site */

$(document).ready(function() 
    {
    	/* check for iPhone */
    	var agent=navigator.userAgent.toLowerCase();
		var is_iphone = ((agent.indexOf('iphone')!=-1));
		
		
		if (is_iphone) {
		
			/* iPhone telephone number formatting */
			/* adds 'tel:' schema formatted phone number to all microformatted telephone number on the page */
			$('.tel .value:not(.nodial)').each(function(){
				var telNo = $(this).text().replace(/\(.*\)/,'').replace(/\s+/g,'');
				var wrapLink = '<a href="tel:'+telNo+'"></a>';
				$(this).wrap(wrapLink);
			});
		
		}
		
	
		// add '?gallery' to each of the thumbnail links, then add the fancybox functionality to them
		$("#galleryThumbs a, #specThumbs a").attr({href: function() {return this.href + '?gallery'}}).fancybox({
			'overlayShow':	true,
			'overlayOpacity': 0.8,
			'hideOnContentClick': true
		});
			
	
		// transcript
		$('.showTranscript, .hideTranscript').show();
		$('.transcript').hide();
		
		$('.showTranscript').click(function() {
			$('.transcript').slideToggle();
			$('.showTranscript').hide();
		});
		
		$('.hideTranscript').click(function() {
			$('.transcript').slideToggle(function(){
				$('.showTranscript').show();
			});
			
		});

    } 
);
