var eLightWindows = Class.create();	
eLightWindows.prototype = {
	initialize: function() {	
		var as = $A(document.getElementsByTagName("a"));
		
		as.each(
			function( elem ) {
				if( Element.hasClassName(elem, 'lWOn') ) {
				
					if( !elem.href.match(/\.(jpg|png|gif)$/) ) {
						elem.href = elem.href + '&popup=true';
					}
					
					if( Element.hasClassName(elem, 'prodDetails') && Prototype.Browser.WebKit ) {
						elem.setAttribute( "params", "lightwindow_height=724" );
					}
					
				} else if( elem.href.match(/\/l\/{1}/) || elem.href.match(/\/LightboxView\/{1}/) ) {
					
					Element.addClassName(elem, 'lWOn');
					var hasQueryString = elem.href.indexOf('?')>-1;
					if (hasQueryString) {
						elem.href += "&popup=true";
					} else {
						elem.href += "?popup=true";
					}
	
				}
				
				if( Element.hasClassName(elem, 'lWOn') ) {
					
					if( window.location.href.match(/https:/) ) {
						if( !elem.href.match(/https:/) ) {
							elem.href = "https" + elem.href.substring(4);
						}
					} else if( window.location.href.match(/http:/) ) {
						if( !elem.href.match(/http:/) ) {
							elem.href = "http" + elem.href.substring(3);
						}
					}
				}
			}
		);
	}
};

var eLightWindow;
Event.observe( 
	window, 
	"load", 
	function(e){ 
		eLightWindow = new eLightWindows(); 
		myLightWindow = new lightwindow();
	} 
);
