var maxWidth = 150;

function initPhotoAlbum() {
	//initswfir();
	//rescaleImages();
}

function initswfir() {
	var thumbs = document.getElementsByClassName("mpa_thumb");
	for(var i = 0; i < thumbs.length; i++) {
		thumbs[i].style.border="0";
	}
	var sir = new swfir();
	sir.specify("src", "/swf/swfir.swf");
	sir.specify("border-width", "5");
	sir.specify("border-color", "fff");
	sir.specify("border-radius", "12");
	sir.specify("rotate", "0");
	sir.swap("#mpa_viewport img");

	/*	------------------------------------------------------------------------------------------
	# Available swfir Parameters:

	border-radius    = Number
	border-width     = Number
	border-color     = CSS Styled Color (i.e. fc600)
	shadow-offset    = Number
	shadow-angle     = Number
	shadow-alpha     = Number between 0 - 100
	shadow-blur-x    = Number
	shadow-blur-y    = Number
	shadow-strength  = Number
	shadow-color     = CSS Styled Color (i.e. fc600)
	shadow-quality   = Number between 0 - 1
	shadow-inner     = Boolean (true or false)
	shadow-knockout  = Boolean (true or false)
	shadow-hide      = Boolean (true or false)
	rotate           = Number between -359 - 359
	overflow         = 'expand-x', 'expand-y' or 'fit'
	link             = String (i.e. http://www.swfir.com)
	src              = String (path to your swf, if not standard)
	wmode            = String ('opaque', 'transparent', etc.)
	elasticity       = String ('true'), Number (pixel-to-em ratio)

	*/
}

function rescaleImages() {
 var thumbs = document.getElementsByClassName("photo_thumb");
	for(var i = 0; i < thumbs.length; i++) {
		var target = thumbs[i].firstChild.lastChild;
		scaleImage(target);
	}
}

function scaleImage(im) {
	if (typeof im.naturalWidth == 'undefined') im.naturalWidth = im.width;
	
	if (im.naturalWidth > maxWidth) {
		im.width = maxWidth;
		im.style.maxWidth = im.naturalWidth + 'px';
		im.className = 'resized';
		im.title = 'Klik voor een vergroting'

		// Onderstaande voor openen in zelfde pagina 
		im.title = 'Klik voor originele grootte';
		im.onclick = unscaleImage;

		// Onderstaande voor openen in een nieuw venster
		//im.aid = aid;
		//im.onclick = popupPicture;
	}
}

function unscaleImage() {
	if (this.width == maxWidth) {
		this.width = this.naturalWidth;
		this.style.borderWidth = '0px';
		this.title = 'Klik om te verkleinen';
	} 
	else {
		this.width = maxWidth;
		this.style.borderWidth = '1px';
		this.title = 'Klik voor originele grootte';
	}
}

function popupPicture() {
	var frmPicture = window.open("assetmanager.asp?aid=" + this.aid, "picture", "resizable=1, scrollbars=1");
}
