// Dunstan Orchard
// http://1976design.com/blog/archive/2003/11/10/updates/
//
// Altered from original idea by Simon Willison at:
// http://simon.incutio.com/archive/2002/12/20/blockquoteCitations
// Blockquote styling

function extractBlockquoteInfo()
	{
	quotes = document.getElementsByTagName('blockquote');
	for (i = 0; i < quotes.length; i++)
		{
		cite = quotes[i].getAttribute('cite');
		title = quotes[i].getAttribute('title');
		if ((cite) && (cite != ''))
			{
			if ( (cite.match('http://', 'i')) || (cite.match('ftp://', 'i')) || (cite.match('person://', 'i')) )
				{
				newlink = document.createElement('a');
				newlink.setAttribute('href', cite);
				newlink.setAttribute('title', ('Go to ' + cite));
				title = quotes[i].getAttribute('title');
				if ((title) && (title != ''))
					{
					newlink.appendChild(document.createTextNode(title));
					}
				else
					{
					newlink.appendChild(document.createTextNode('Quote source'));
					}
				newdiv = document.createElement('div');
				newdiv.className = 'source';
				newdiv.appendChild(document.createTextNode('\u2014 '));
				newdiv.appendChild(newlink);
				quotes[i].appendChild(newdiv);
				}
			else
				{
				newdiv = document.createElement('div');
				newdiv.className = 'source';
				newdiv.appendChild(document.createTextNode('\u2014 ' + cite));
				quotes[i].appendChild(newdiv);
				}
			}
		
		else if ((title) && (title != ''))
			{
			newdiv = document.createElement('div');
			newdiv.className = 'source';
			newdiv.appendChild(document.createTextNode('\u2014 ' + title));
			quotes[i].appendChild(newdiv);
			}
		}
	}

window.onload = function(e) {
extractBlockquoteInfo();
}

// JQ script for the testimonials.
$(document).ready(function() {
	
	function onAfter(curr, next, opts, fwd){
		var $ht = $(this).height();
		$ht += 30;
 		$(this).parent().css("height", $ht);
	}

	$('.testimonials').cycle({ 
		prev:   '#prev',
		next:   '#next',
		after: 	onAfter,
		speed:  'fast',
		timeout: 10000
	});
	
	$('a[href*=#]').click(function() {
		if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
			var $target = $(this.hash);
			$target = $target.length && $target || $('[name=' + this.hash.slice(1) +']');
			if ($target.length) {
				var targetOffset = $target.offset().top;
				$('html,body').animate({scrollTop: targetOffset}, 1000);
				return false;
			}
		}
	});
});
