// jquery required
function transformZoomableImages(cid)
{
	var maxw = 1024;
	var maxh = 768;

	try {
		$('#' + cid + ' img.zoomable').each(
			function( intIndex, item ){
				var new_div = $('<div>').addClass("photo").css({width: item.width, float: "left", margin: "5px 5px 5px 5px"});
				if ( item.align ) $(new_div).css({float: item.align});
				var new_a = $('<a>').attr({href: "javascript:pop2('" + item.src + "', " + maxw + ", " + maxh + ", 0);"});
				var new_i1 = $('<img>').attr({src: item.src, width: item.width, height: item.height});
				var new_i2 = $('<img>').attr({src: 'html/img/ico_zoom.gif', alt: ''}).addClass("zoom");

				$(new_a).append(new_i1);
				$(new_a).append(new_i2);
				$(new_div).append(new_a);

				$(item).before(new_div).remove(); 
			}
		);
	} catch ( ex ) { 
		// alert("EX: " + ex);
	}
}

function pop2(imgsrc, maxw, maxh, x)
{
	//var tmpimg = document.createElement('img');
	var tmpimg = new Image();
	tmpimg.onload = function() {
		w = ( this.width > maxw ) ? maxw : this.width;
		h = ( this.height > maxh ) ? maxh : this.height;
		if ( w == 0 || h == 0 ) { w = maxw; h = maxh; }
		pop(imgsrc, w, h, x);
	}
	tmpimg.src = imgsrc;
}
