var resized = false;

function resizeToImg(img){
	if (!resized) {
		resize(window, img.width + 100, img.height + 120);
		resized = true;
	}
}

function resize(win, width, height){
	win.resizeTo(width, height);
}

function openAutoPopup(prefix, name){
	openBig(prefix, name, "profiLackTisch", 640, 480);
}

function openBig(prefix, name, title, width, height){
	var url = prefix + "?image="+name+"&title="+title;
	var win = window.open(url,"profiLackTisch","directories=no,height=" + height +
			",location=no,menubar=no,resizeable=no,scrollbars=no,status=no,toolbar=no,width=" + width);
//	resize(win, width, height);
	win.focus();
}

function over(img){
	change(img, 'hinten');
}

function out(img){
	change(img, 'vorne');
}

function change(img, newsuffix){
	var l = img.src.lastIndexOf('_');
	var suffix = img.src.substring(l);
	var s = img.src.substring(0, l);
	if (suffix.toLowerCase() == '_small.jpg') {
		l = s.lastIndexOf('_');
		s = s.substring(0, l);
	} else {
		suffix = '.jpg';
	}
	s = s + '_' + newsuffix + suffix;
	img.src = s;
}
