/*! Phoenix Organics Polaroid v1 <http://nvinteractive.co.nz>
	Copyright (c) NV Interactive
	
	References:
		jquery-1.2.6.js +
		
	Release Notes:

		
*/

polaroid = function() {

	

    var init = function() {
		$("img.polaroid")
			.css("visibility", "hidden")
			.each(function(){

				  $(this).load(replaceImage);
				  if(this.readyState == "complete" || this.complete)$(this).load();
					});
    }
	
	var replaceImage = function(){
		//writeFlash(el, flashFile, w, h, pars, initObj)
		var src = encodeURIComponent( $(this).attr("src") );
		var alt = encodeURIComponent( $(this).attr("alt") );
		
		var w = $(this).width() + 60;
		var h = $(this).height() + 60;
		
		var flashvars = "src=" + src + "&alt=" + alt;
		
		
		var pars = { 	flashvars: flashvars,
						wmode: "transparent"
		};
		
		var d = document.createElement("div");
		d.className = this.className;
		this.className = "";
		
		$(this).before(d);
		
		if( writeFlash(d, "/flash/polaroid/polaroid.swf", w, h, pars) ){
			$(this).remove();
		}
	}

    return {
        /* Public API
        */
        init: init
    }

} ();


$(polaroid.init);


