/*
	Init.js
	Copyright 2010 Avalanche Creative
	
	@job:	White Cleland / C&I Projects
	@loc:	scripts/
	@desc:	Initialiser script called in document header.
*/


//	Adds a target="_blank" attribute to all anchor tags
//	found with an attribute with rel="external" at runtime.
//
//	*	Thanks to Marius Stanciu for the helpful technique.
//		URL:	http://marius.code-purity.com/archives/2009/4/13/opening_pages_in_a_new/
function addExternalLinks(){
	var links;
	
	//	Prototype Framework
	if(typeof(Prototype) != "undefined"){
		links	= $$('a[rel="external"]');
		links.each(function(link){
			if(link.readAttribute("href") != "" && link.readAttribute("href") != "#")
				link.writeAttribute("target", "_blank");
		});
	}
	
	//	jQuery Framework
	else if(typeof(jQuery) != "undefined"){
		jQuery("a[rel='external']").attr("target", "_blank");
	}
}


function addRotators(){
	
	//	Cycle
	if(typeof(jQuery.fn.cycle) != "undefined"){
		$(".cycle").cycle({
			fx: "fade"
		});
	}
}

//	Triggered when DOM's finished loading
jQuery(document).ready(function(){
	addExternalLinks();
	addRotators();
});