﻿/*! NV Slideshow v2 <http://nvinteractive.co.nz>
	Copyright (c) NV Interactive
	
	References:
		utilities.2.1.js
		swfobject.js
		jquery-1.2.6.js
		
	Release Notes:
		2.0
		-- rewrote for jQuery
		
*/
nv_slideshow = function(){

	var init = function(){		
		$(".slideshow").each(setupSlideshow);
	}
	
	var setupSlideshow = function(){

		if(this.tagName == "IMG")
			var image = $(this);
		else
			var image = $("img", this);
		
		if(image == undefined)return;
		if(image.attr("longDesc") == "")return;
		
		var w = image.outerWidth();
		var h = image.outerHeight();		

		var bufferColor = $(this).css("color");
		var borderColor = $(this).css("border-top-color");

		bufferColor = new RGBColor(bufferColor).toHex();
		borderColor = new RGBColor(borderColor).toHex();


		if(this.tagName == "IMG"){
			slideshow = this.parentNode;
		}else{
			slideshow = this;
		}

		var slideURL = image.attr("longDesc");
		
		var flashVars = "movieUrl=" + encodeURIComponent(flashBasePath + "slide_show/slide_show.swf")
		flashVars += "&bufferColor=" + encodeURIComponent(bufferColor);
		flashVars += "&slideUrl=" + encodeURIComponent(slideURL);
			
		var pars = {
			flashvars: 		flashVars,
			wmode: 			"transparent"
		};
		
		if( writeFlash(slideshow, "slide_show/slide_show_loader.swf", w, h,  pars)) image.css("visibility", "hidden");

	}
	
	return {
	/* Public API
	*/
	init: init
	}	
	
}();

$(document).ready(nv_slideshow.init);
