/*!
	reflection.js for jQuery v1.03
	(c) 2006-2009 Christophe Beyls <http://www.digitalia.be>
	MIT-style license.
*/

(function($) {

$.fn.extend({
	reflect: function(options) {
		options = $.extend({
			height: 1/3,
			opacity: 0.5
		}, options);

		return this.unreflect().each(function() {
			var img = this;
			if (/^img$/i.test(img.tagName)) {
				function doReflect() {
					var imageWidth = img.width, imageHeight = img.height, reflection, reflectionHeight, wrapper, context, gradient;
					reflectionHeight = Math.floor((options.height > 1) ? Math.min(imageHeight, options.height) : imageHeight * options.height);
					reflectionWidth = Math.floor((options.height > 1) ? Math.min(imageWidth, options.height) : imageWidth * options.height);

					if ($.browser.msie) {
						reflection = $("<img />").attr("src", img.src).css({
							width: imageWidth,
							height: imageHeight,
							marginBottom: reflectionHeight - imageHeight,
							filter: "fliph"
						})[0];
					} else {
						reflection = $("<canvas />")[0];
						if (!reflection.getContext) return;
						context = reflection.getContext("2d");
						try {
							$(reflection).attr({width: reflectionWidth, height: imageHeight});
							context.save();
							context.translate(imageWidth-1,0);
							context.scale(-1, 1);
							context.drawImage(img, 0, 0, imageWidth, imageHeight);
							context.restore();
							context.globalCompositeOperation = "destination-out";

							
						} catch(e) {
							return;
						}
					}
					$(reflection).css({display: "block", border: 0, margin: "0 10px 0 10px", padding: "2px"});

					wrapper = $(/^a$/i.test(img.parentNode.tagName) ? "<span />" : "<div />").insertAfter(img).append([img, reflection])[0];
					wrapper.className = img.className;
					$.data(img, "reflected", wrapper.style.cssText = img.style.cssText);
					$(wrapper).css({width: imageWidth, height: reflectionHeight, overflow: "hidden"});
					img.style.cssText = "display: none; border: 0px";
					img.className = "reflected thumb4";
				}

				if (img.complete) doReflect();
				else $(img).load(doReflect);
			}
		});
	},

	unreflect: function() {
		return this.unbind("load").each(function() {
			var img = this, reflected = $.data(this, "reflected"), wrapper;

			if (reflected !== undefined) {
				wrapper = img.parentNode;
				img.className = 'no_mirror thumb4';
				img.style.cssText = reflected;
				$.removeData(img, "reflected");
				wrapper.parentNode.replaceChild(img, wrapper);
			}
		});
	}
});

})(jQuery);



/**
 * reflection.js v1.7
 *
 * Contributors: Cow http://cow.neondragon.net
 *               Gfx http://www.jroller.com/page/gfx/
 *               Sitharus http://www.sitharus.com
 *               Andreas Linde http://www.andreaslinde.de
 *               Tralala, coder @ http://www.vbulletin.org
 *
 * Freely distributable under MIT-style license.
 */
 
/* From prototype.js */
document.getElementsByClassName = function(className) {
	var children = document.getElementsByTagName('*') || document.all;
	var elements = new Array();
  
	for (var i = 0; i < children.length; i++) {
		var child = children[i];
		var classNames = child.className.split(' ');
		for (var j = 0; j < classNames.length; j++) {
			if (classNames[j] == className) {
				elements.push(child);
				break;
			}
		}
	}
	return elements;
}

var Reflection = {
	defaultHeight : 1,
	defaultOpacity: 1,
	
	add: function(image, options) {
		Reflection.remove(image);
		
		doptions = { "height" : Reflection.defaultHeight, "opacity" : Reflection.defaultOpacity }
		if (options) {
			for (var i in doptions) {
				if (!options[i]) {
					options[i] = doptions[i];
				}
			}
		} else {
			options = doptions;
		}
	
		try {
			var d = document.createElement('div');
			var p = image;
			
			var classes = p.className.split(' ');
			var newClasses = '';
			for (j=0;j<classes.length;j++) {
				if (classes[j] != "reflect") {
					if (newClasses) {
						newClasses += ' '
					}
					
					newClasses += classes[j];
				}
			}
				
			var reflectionHeight = Math.floor(p.height*options['height']);
			var divHeight = Math.floor(p.height*(1+options['height']));
			
			//var reflectionHight = p.height;
			var reflectionWidth = p.width;
			
			if (document.all && !window.opera) {
				/* Fix hyperlinks */
				if(p.parentElement.tagName == 'A') {
	                var d = document.createElement('a');
	                d.href = p.parentElement.href;
                }  
                    
				/* Copy original image's classes & styles to div */
				d.className = newClasses;
				p.className = 'reflected';
				
				d.style.cssText = p.style.cssText;
				p.style.cssText = 'vertical-align: bottom';
			
				var reflection = document.createElement('img');
				reflection.src = p.src;
				reflection.style.width = reflectionWidth+'px';
				reflection.style.height = reflectionHeight+'px';
				reflection.style.marginBottom = "-"+(p.height-reflectionHeight)+'px';
				reflection.style.filter = 'fliph';
				reflection.className = 'thumb2';
				//alert(reflectionWidth);
				//alert(Math.round(reflectionWidth*(1/3)));
				//if(reflectionWidth>125)
				//	reflection.style.marginLeft="-123px";
				d.style.width = reflectionWidth+'px';
				d.style.height = divHeight/2+'px';
				
				//alert(d.style.background);			
				p.parentNode.replaceChild(d, p);

				d.appendChild(p);
				d.appendChild(reflection);
				
			} else {
				var canvas = document.createElement('canvas');
				if (canvas.getContext) {
					/* Copy original image's classes & styles to div */
					d.className = newClasses;
					p.className = 'reflected';
					
					d.style.cssText = p.style.cssText;
					p.style.cssText = 'vertical-align: bottom';
			
					var context = canvas.getContext("2d");
					//alert(p.width+' '+reflectionWidth);
					canvas.style.height = reflectionHeight+'px';
					canvas.style.width = reflectionWidth+'px';
					canvas.height = reflectionHeight;
					canvas.width = reflectionWidth;
					canvas.className = 'thumb2';
					d.style.width = reflectionWidth+6+'px';
					d.style.height = divHeight/2+10+'px';
					d.align='center'
					d.style.margin = 'auto';
					if((divHeight/2+10)<100)	{
						d.style.margin='0 10px 0 10px';
						
					}
					p.parentNode.replaceChild(d, p);
					
					d.appendChild(p);
					d.appendChild(canvas);
					
					context.save();
					//alert(image.width);
					//context.translate(1,1);
					context.translate(image.width-1,0);
					context.scale(-1,1);
					//if(image.width>123)	{
					//	var tmp_width=0;	
					//}	else	{
					//	var tmp_width=image.width;		
					//}
					context.drawImage(image, 0, 0, reflectionWidth+20, image.height);
	
					context.restore();	
				}
			}p.parentNode.removeChild(p);
		} catch (e) {
	    }
	},
	
	remove : function(image) {
		if (image.className == "reflected") {
			image.className = image.parentNode.className;
			image.parentNode.parentNode.replaceChild(image, image.parentNode);
		}
	}
}

function addReflections() {
	var rimages = document.getElementsByClassName('reflect');
	for (i=0;i<rimages.length;i++) {
		var rheight = null;
		var ropacity = null;
		
		var classes = rimages[i].className.split(' ');
		for (j=0;j<classes.length;j++) {
			if (classes[j].indexOf("rheight") == 0) {
				var rheight = classes[j].substring(7)/100;
			} else if (classes[j].indexOf("ropacity") == 0) {
				var ropacity = classes[j].substring(8)/100;
			}
		}
		
		Reflection.add(rimages[i], { height: rheight, opacity : ropacity});
	}
}
function removeReflections()	{
	var nrimages = document.getElementsByClassName('highslide');
	var marg_b=((document.all && !window.opera) ? '2px' : '4px'); 
	for (i=0;i<nrimages.length;i++) {
		if(document.all && !window.opera)	{
		var old_width=nrimages[i].style.width;	
		}	else	{
		var old_width=nrimages[i].style.width;
		
		}
		if(nrimages[i].style.height=='95px')	{//elewacje
			var ad_marg='margin-left:10px;margin-right:10px;';
			/*
			if(nrimages[i].href.substr(nrimages[i].href.length-4,nrimages[i].href.length)=='.gif')
				var new_src = nrimages[i].href.substr(0,nrimages[i].href.length-4)+'_tmb2.gif';
			else	
				var new_src = nrimages[i].href.substr(0,nrimages[i].href.length-4)+'_tmb2.jpg';
			*/
			var new_src = parent.top.old_img[i];
		}	else if	(nrimages[i].href.substr(nrimages[i].href.length-4,nrimages[i].href.length)=='.gif')	{	//rzuty w gifie
			var ad_marg='width:'+old_width+';';
			//var new_src = nrimages[i].href;
			var new_src = parent.top.old_img[i];
		}	else	{	//normalne zdjecia
			var ad_marg='width:'+old_width+';';
			//var new_src = nrimages[i].href.substr(0,nrimages[i].href.length-4)+'_tmb1.jpg';	
			var new_src = parent.top.old_img[i];	
		}
		var back_image = "<img style='"+ad_marg+"margin-bottom:"+marg_b+";' class='no_mirror thumb2' src='"+new_src+"' />";	
		//alert(back_image);
		nrimages[i].innerHTML=back_image;
	}
}
var previousOnload = window.onload;
//function flip() { if(previousOnload) previousOnload(); addReflections(); }
//window.onload = function () { if(previousOnload) previousOnload(); addReflections(); }
//&&(parseInt(nrimages[i].style.height)>84)