function ZoomThumbnail( arg_class, arg_attr, arg_varname, arg_is_class_substring )
{
	this.className = arg_class;
	this.attrName = arg_attr;
	this.varName = arg_varname;
	this.isClassSubstring = arg_is_class_substring;
}

ZoomThumbnail.prototype.init = function()
{
	var els = document.getElementsByTagName( '*' );

	/* search for objects with given class */

	/* search in substrings */
	if( this.isClassSubstring ) {
		for( var i = 0; i < els.length; i++ ) {
			var el = els[ i ];
			var className = new String;
			className = (( el.getAttribute( 'class' ) )? el.getAttribute( 'class' ) : el.getAttribute( 'className' ) ) + '';

			if( className.match( this.className ) ){
				/* adding listener on click */
				ZoomThumbnail.attach( el, 'click', ZoomThumbnail.popup );
			}
		}

		/* or, exactly match */
	} else {
		for( var i = 0; i < els.length; i++ ) {
			var el = els[ i ];
			var className = new String;
			className = (( el.getAttribute( 'class' ) )? el.getAttribute( 'class' ) : el.getAttribute( 'className' ) ) + '';

			if( className == this.className ){
				/* adding listener on click */
				ZoomThumbnail.attach( el, 'click', ZoomThumbnail.popup );
			}
		}
	}

	/* and, appending style */
	ZoomThumbnail.appendStyle();
}

	ZoomThumbnail.prototype.attach = function( o, e, a )
	{
		if( o.addEventListener ) { o.addEventListener(e, a, false ); }
		else if( o.attachEvent ) { o.attachEvent( 'on' + e, a ); }
		else return null;
	}


		ZoomThumbnail.prototype.popup = function( e )
		{
			/* searching for target */
			if( e.target ) {
				var targ = e.target;
			} else {
				var targ = e.srcElement;
			}


			/* FIXME class names (we need something like "this" )*/
			var attr = targ.getAttribute( ZoomThumbnail.attrName );
			var s;
			var title = (( s = targ.getAttribute( 'title' ) )? s : targ.getAttribute( 'alt' ) );
			var image_location = ZoomThumbnail.getUrlParameter( ZoomThumbnail.varName, attr );

			var newWindow = window.open('', 'mywindow', 'width=100,height=100,location=no,menubar=no,scrollbar=no,status=no' );
			var functionResize = 'function resize() { var offsetWidth = (( typeof( window.outerWidth ) != "undefined" )? window.outerWidth - window.innerWidth : 0 ); var offsetHeight = (( typeof( window.outerHeight ) != "undefined" )? window.outerHeight - window.innerHeight : 30 ); if (document.images[ 0 ]) { window.resizeTo( document.images[0].width + offsetWidth, document.images[0].height + offsetHeight );}self.focus();}';
			var newContent='<html><head>'
			+ '<style type="text/css">html, body { margin:0px; padding: 0px; }</style>'
			+ '<script type="text/javascript" language="javascript">' + functionResize + '</script>'
			+ '<title>' + title + '</title>'
			+ '</head><body onload="resize();"><img src="' + image_location + '" onclick="self.close();" style="cursor:pointer" />' 
			+ '</body></html>';

			newWindow.document.write( newContent );
			newWindow.document.close();
		}

			ZoomThumbnail.prototype.appendStyle = function()
			{

				/* todo: style by media */
				/* moz */
				var selector = '.' + this.className;
				var rule = 'cursor:pointer;cursor:hand;';

				var selectedSheets = new Array();
				for( var i = 0; i < document.styleSheets.length; i++ ) {
					if( document.styleSheets[ i ].media != 'print' ) {
						selectedSheets[ selectedSheets.length ] = i;
					}
				}

				for( var i = 0; i < selectedSheets.length; i++ ) {
					if( typeof( document.styleSheets[ selectedSheets[ i ] ].cssRules ) !== 'undefined' ) {
						document.styleSheets[ selectedSheets[ i ] ].insertRule( selector + '{' + rule + '}', document.styleSheets[ selectedSheets[ i ] ].cssRules.length );
					} else if( typeof( document.styleSheets[ selectedSheets[ i ] ].rules ) !== 'undefined' ) {
						document.styleSheets[ selectedSheets[ i ] ].addRule( selector, rule, document.styleSheets[ selectedSheets[ i ] ].rules.length );
					}
				}

			}

				ZoomThumbnail.prototype.getUrlParameter = function( arg_name, arg_url )
				{
					var array = arg_url.split( '\?' );

					if( typeof( array[ 1 ] ) != 'undefined' ) {
						var query_string = array[ 1 ];
					} else return false;

					array = query_string.split( '\&' );

					for( var i = 0; i < array.length; i++ ) {
						var pair = array[ i ].split( '=' );
						if( typeof( pair[ 0 ] ) != 'undefined' && typeof( pair[ 1 ] ) != 'undefined' && pair[ 0 ] == arg_name ) {
							return pair[ 1 ];
						}
					}

				}

