/*
Show products links in a lightbox instead of a popup window
*/

Event.observe(window, 'load', function() {
	$$('*:not([class="AuthorizeNetSeal"]) > a[target="_blank"]:not([class="no-popin"])').each( 
		function(e){ 
						e.observe('click', 
											function(e) {
													re_img = new RegExp("(jpg|png|gif)$", "i");
													if( re_img.exec(e.element().href) ) {
															Modalbox.show('<img src="'+e.element().href+'" />', {title: '', width: 500, height: 600});
															e.stop();
													}
													else {

															re_clean = new RegExp("renderclean\=1$", "i");
															theHref = new String(e.element().href);
															if( theHref == 'undefined' ){
																	theHref = e.element().parentNode.href;
															}
															// See if the href is calling renderclean
															if( ! re_clean.exec(theHref) ) {
																	// check if '?' is already in url, if it is, use '&' instead
																	if (theHref.indexOf('?') == -1){
																			theHref += '?renderclean=1';
																	}
																	else {
																			theHref += '&renderclean=1';
																	}
															}
															Modalbox.show(theHref.valueOf(), {title: e.element().innerHTML, width: 500, height: 600});
															//Modalbox.show(e.element().href, {title: e.element().innerHTML, width: 500, height: 600});
															e.stop(); 
													}
											}
										 );
		} );
} );
