/* noyb stuff *************************************************************************************/
function dcmadr(nnnn) {
	var a = "";
	for(i=0,m=nnnn.length;i < m;i++){
		if(i%3==0){
			a += String.fromCharCode(nnnn.substr(i, 3)-37);
		}
	}
	return a;
}

function dcmt(nnnn) {
	var a = dcmadr(nnnn);
	location.href=('m'+'ail'+'t'+'o:'+a);
}

function resizeImage(image, width, height, isMax, center) {
	if (image) {
		var origWidth = image.width;
		var origHeight = image.height;
		var scaleFactor = 1;
		if (width && width > 0 && height && height > 0) {
			// Bild-Seitenverhältnis
			var ratioImage = origWidth / origHeight;
			// Box-Seitenverhältnis
			var ratioBox = width / height;			
			if (isMax) {
				if (ratioBox > ratioImage) {
					// Wenn das Box-Seiten-Verhältnis > Bild-Seitenverhältnis muss die Höhe übereinstimmen
					scaleFactor = height / origHeight;
				} else {
					// Wenn das Box-Seiten-Verhältnis < Bild-Seitenverhältnis muss die Breite übereinstimmen
					scaleFactor = width / origWidth;
				}
			} else {
				if (ratioBox < ratioImage) {
					// Wenn das Box-Seiten-Verhältnis < Bild-Seitenverhältnis muss die Höhe übereinstimmen
					scaleFactor = height / origHeight;
				} else {
					// Wenn das Box-Seiten-Verhältnis > Bild-Seitenverhältnis muss die Breite übereinstimmen
					scaleFactor = width / origWidth;
				}
			}
			var newWidth = Math.ceil(origWidth * scaleFactor);
			var newHeight = Math.ceil(origHeight * scaleFactor);
			$(image).css("width", "" + newWidth + "px");
			$(image).css("height", "" + newHeight + "px");
			$(image).css("position", "relative");
			if (isMax && center) {
				if (newWidth < width) {
					$(image).css("left", Math.round((width - newWidth) / 2) + "px");
				}
				if (newHeight < height) {
					$(image).css("top", Math.round((height - newHeight) / 2) + "px");
				}
			}
			if (!isMax && center) {
				if (newWidth > width) {
					$(image).css("left", "-" + Math.round((newWidth - width) / 2) + "px");
				}
				if (newHeight > height) {
					$(image).css("top", "-" + Math.round((newHeight - height) / 2) + "px");
				}
			}
		}
/*		} else if (width && width > 0) {
			ratio = width / origWidth;
		} else if (height && height > 0) {
			ratio = height / origHeight;
		}*/
//		percentage = ratio*100;
	}
}

