var ImageDir = "images/";
var ImagePercentage = 100;
var isIE = false;
var OverClass = "Over"
var OverDir = ImageDir + "over/";
var hs = 0;
var ws = 0;

function FilenameOf(url) {
	s = "" + url;
	x = s.lastIndexOf("/");
	if (x > -1) {
		x++;
	}
	if (x != s.length) {
		return s.substr(x);
	}	
	else {
		return url;
	}
}

function GetUA(){
	 if (window.navigator.userAgent.indexOf("MSIE ") > 0){
	 	isIE = true;
	 }
}

function ImageOver(imgName, imgFile) {
	document.images[imgName].src = OverDir + imgFile;
}

function ImageOverLoad() {
	if (document.images) {
		for (i = 0; i < document.images.length; ++i) {
			with (document.images[i]) {
				if (className == OverClass) {
					img = new Image();
					img.src = OverDir + FilenameOf(src);
				}
			}
		}
	}
}

function ImageOut(imgName, imgFile) {
	document.images[imgName].src = ImageDir + imgFile;
}

function PathOf(url) {
	s = "" + url;
	x = s.lastIndexOf("/");
	if (x > -1) {
		x++;
		if (x == s.length) {
			return url;
		}
		else {
			return s.slice(0, x);
		}
	}
	else {
		return "";	
	}
}

function NavIE(){
	GetUA();
	return isIE;
	 }

function NewImageWindowInit(Percentage) {
	ImageOverLoad();
	GetUA();
	with (screen) {
		hs = availHeight;
		ws = availWidth;
		}
	ImagePercentage = 100 / (Percentage - 1);
	 }

function NewImageWindow(ImageName, WindowTitle, ImageWidth, ImageHeight, Lang) {
	if (!document.images[ImageName]) {
		ImageSource = "images/screenshot/original/" + ImageName;
		w  = ImageWidth;
		h  = ImageHeight;
		}
	else {
		with (document.images[ImageName]) {
			ImageSource = src;
			w = Math.round(width * ImagePercentage);
			h = Math.round(height * ImagePercentage);
			}
		ImageSource = PathOf(ImageSource) + "original/" + FilenameOf(ImageSource);
		}
	if (isIE) {
		w = w + 36;
		h = h + 108;
		}
	else {
		w = w + 20;
		h = h + 60;
		}
	sb = "no";
	if (w > ws) {
		w = ws;
		sb = "yes";
		}
	if (h > hs) {
		h = hs;
		if (sb != "yes") {
			sb = "yes";
			}
		}
	if (Lang != true) {
		ButtonCaption = "Close";
		}
	else {
		ButtonCaption = "Schließen";
		}		
	l = Math.round((ws - w) / 2);
	t = Math.round((hs - h) / 2);
	if (isIE) {
		NewWindow =  window.open("screenshot.html", "screenshot", "location=no,menubar=no,width=" + w.toString() + ",height=" + h.toString() + ",top=" + t.toString() + ",left=" + l.toString() + ",resizable=yes,scrollbars=" + sb + ",status=no,toolbar=no", true);
		}
	else {
		NewWindow =  window.open("screenshot.html", "screenshot", "dependent=yes,location=no,menubar=no,innerHeight=" + h.toString() + ",innerWidth=" + w.toString() + ",left=" + l.toString() + ",top=" + t.toString() + ",resizable=yes,screenX=" + l + ",screenY=" + t + ",scrollbars=" + sb + ",status=no,toolbar=no");
		}
	with (NewWindow) {
		with (document) {
			close();
			open();
			writeln("<img name='screenshot' src=" + ImageSource + " alt='[" + ImageName + "]' border='0'><br>");
			writeln("<hr noshade size='2'>");
			writeln("<div align='center'><input id='closeMe' type='button' name='closeMe' value='    " + ButtonCaption + "    ' onClick='window.close()'><\/div>");
			close();
			getElementsByTagName("body")[0].bgColor = "white";
			title = WindowTitle;
			}
		if (isIE) {
			moveTo(l, t);
			resizeTo(w, h);
			}
		else {
			w = w - innerWidth;
			h = h - innerHeight;
			if ((Math.abs(h) > 0) || (Math.abs(w) > 0)) {
				w = w + 8;
				h = h + 8;
				resizeBy(w, h);
				}
			w = -Math.round(w / 2);
			h = -Math.round(h / 2);
			if ((Math.abs(h) > 5) || (Math.abs(w) > 5)) {
				moveTo(l, t);
				}
			}
		focus();
		}
	}

function ShowMovie(file) {
	if (isIE) {
		showModalDialog(file,null,"dialogWidth:560px;dialogHeight:308px");
		}
	else {
		window.open(file,null,"dependent=yes,location=no,menubar=no,innerHeight=260,innerWidth=560,left="+((screen.width/2)-(560/2))+",top="+((screen.height/2)-(260/2))+",resizable=yes,scrollbars=no,status=no,toolbar=no");
	}
}
function Wait() {
	return true;
	}
