// JavaScript Document

jQuery(function(){
				
var siteURL = "http://www.gochetwynd.com/";
		   
/* Apply Blank Target to External Links */
var externalLinks = jQuery("a[href^='http']"); /* HREF starts with "http" */
	externalLinks
		/* Except Links to specified domain */	.not("a[href*='gochetwynd.com']")
		/* Except Links to specified domain */	.not("a[href*='100mwh.com']")
		/* Except Links to specified domain */	.not("a[href*='newharvest.ca']")
		/* Except Links to specified domain */	.not("a[href*='macromedia.com']")
		/* Except Links to specified domain */	.not("a[href*='adobe.com']")
		/* Except Links to specified domain */	.not("a[href*='apple.com']")
		/* Except Links to specified domain */	.not("a[href*='linkedin.com']")
		/* Except Links to specified domain */	.not("a[href*='facebook.com']")
		/* Add the _blank target */				.attr('target','_blank')
		/* Insert Image after the link */		.after(" <img src='"+siteURL+"wp-content/themes/chetwynd/images/icon_newWindow.png' width='11' height='8' alt='(link opens in a new window)' title='(link opens in a new window)' class='icon_newWindow no-shadow' /> ");
			
/* Add PDF icons with _blank targets */
var pdfLinks = jQuery("a[href$='.pdf']"); /* HREF ends in ".pdf" */
pdfLinks.attr('target','_blank').after("&nbsp; <img src='"+siteURL+"wp-content/themes/chetwynd/images/icon_pdf.gif' width='16' height='16' alt='(PDF Document)' title='(PDF Document)' class='icon_pdf no-shadow' /> ")
		
/* Add Excel Icon with _blank targets */
var xlsLinks = jQuery("a[href$='.xls']"); /* HREF ends in ".xls" */
var xlsxLinks = jQuery("a[href$='.xlsx']"); /* HREF ends in ".xlsx" */
xlsLinks.attr('target','_blank').after("&nbsp; <img src='"+siteURL+"wp-content/themes/chetwynd/images/icon_excel.jpg' width='16' height='16' alt='(Excel Document)' title='(Excel Document)' class='icon_excel no-shadow' /> ")
xlsxLinks.attr('target','_blank').after("&nbsp; <img src='"+siteURL+"wp-content/themes/chetwynd/images/icon_excel.jpg' width='16' height='16' alt='(Excel Document)' title='(Excel Document)' class='icon_excel no-shadow' /> ")
		
/* Add Word Document Icon with _blank targets */
var docLinks = jQuery("a[href$='.doc']"); /* HREF ends in ".doc" */
var docxLinks = jQuery("a[href$='.docx']"); /* HREF ends in ".docx" */
docLinks.attr('target','_blank').after("&nbsp; <img src='"+siteURL+"wp-content/themes/chetwynd/images/icon_doc.png' width='15' height='15' alt='(Word Document)' title='(Word Document)' class='icon_word no-shadow' /> ")
docxLinks.attr('target','_blank').after("&nbsp; <img src='"+siteURL+"wp-content/themes/chetwynd/images/icon_doc.png' width='15' height='15' alt='(Word Document)' title='(Word Document)' class='icon_word no-shadow' /> ")

// "What To Do In Chetwynd" Page Accordion
	jQuery(".accordion h2").next().slideUp();
	jQuery(".accordion h2").click(function() {
		jQuery(this).next().slideToggle();
		});


// Banner Slideshow
	setInterval(rotate,8000);
	function rotate() {
//		alert("rotate working");
		var curPhoto = jQuery("#photoShow div.current");
		var nxtPhoto = curPhoto.next();
		if (nxtPhoto.length == 0)
			nxtPhoto = jQuery("#photoShow div:first");
		curPhoto.removeClass("current").addClass("previous");
		nxtPhoto.css({opacity:0.0}).addClass("current").animate({opacity:1.0}, 3000, function () {
			curPhoto.removeClass("previous");
		});
	}
}); // End jQuery Document Ready Function


