// Contains a number of default scripts for the website


	/* -------------------------------------------------- *
	 * ToggleVal Plugin for jQuery                        *
	 * Version 1.0                                        *
	 * -------------------------------------------------- *
	 * Author:   Aaron Kuzemchak                          *
	 * URL:      http://kuzemchak.net/                    *
	 * E-mail:   afkuzemchak@gmail.com                    *
	 * Date:     8/18/2007                                *
	 * -------------------------------------------------- */
	
	jQuery.fn.toggleVal = function(focusClass) {
		this.each(function() {
			$(this).focus(function() {
				// clear value if current value is the default
				if($(this).val() == this.defaultValue) { $(this).val(""); }
				
				// if focusClass is set, add the class
				if(focusClass) { $(this).addClass(focusClass); }
			}).blur(function() {
				// restore to the default value if current value is empty
				if($(this).val() == "") { $(this).val(this.defaultValue); }
				
				// if focusClass is set, remove class
				if(focusClass) { $(this).removeClass(focusClass); }
			});
		});
	}
	


	// Initialise toggleval
	$(document).ready(function() {
		$("#searchtext,#newslettertext").toggleVal();
	});

	// Initialise superfish
//	$(document).ready(function() { 
//		$('ul.sf-menu').superfish({ 
//			pathClass:   'current',
//			pathLevels:  0,
//			delay:       200,                            // one second delay on mouseout 
//			animation:   {opacity:'show',height:'show'},  // fade-in and slide-down animation 
//			speed:       'fast',                          // faster animation speed 
//			autoArrows:  true,                           // disable generation of arrow mark-up 
//			dropShadows: true                            // disable drop shadows 
//		}); 
//	});

	$(document).ready(function() {
		$('#slideshow').cycle({
			cleartype: true,
			fx:     'fade',
			timeout: 0,
			pause: true,
			pager:  '#slideshowNav',
			pagerEvent: 'mouseover',
			allowPagerClickBubble: true,
			pagerAnchorBuilder: function(idx, slide) { 
			// return selector string for existing anchor 
			return '#slideshowNav li:eq(' + idx + ') a'; 
			}
		});
	});

$(document).ready(function() {
	$('#content a').filter(function() {
		return this.hostname && this.hostname !== location.hostname;
	}).after(' <img src="/common/images/icons/external.png" alt="external link" title="external link" class="extlink" />');
});

$(document).ready(function() {
	$('#content a').filter(function() {
		$('a[href$=".pdf"]').not('a:has(img)').attr('class','pdflink').attr('title','Click to download file in PDF format');
		$('a[href$=".doc"]').not('a:has(img)').attr('class','doclink').attr('title','Click to download file in MS Word format');
		$('a[href$=".rtf"]').not('a:has(img)').attr('class','doclink');
		$('a[href$=".ppt"]').not('a:has(img)').attr('class','pptlink');
		$('a[href$=".xls"]').not('a:has(img)').attr('class','xlslink');
	});
});

