var fotofenster;

function writeMenu(file, width, height) {
}

function writeMenu(file, width, height) {

	//if (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]){
	//	if (navigator.plugins["Shockwave Flash"]) {
			document.write('<object'
				+' classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"  width="'+width+'" height="'+height+'">'
				+'<param name=movie value="'+file+'">'
				+'<param name="loop" value="false">'
				+'<param name=quality value=high>'
				+'<param name=bgcolor value=#ffffff>'
				+'<param name="wmode" value="opaque">'
				+'<embed src="'+file+'" swliveconnect="false" width="'+width+'" height="'+height+'" loop="false" quality="high" bgcolor="#ffffff" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>'
				+'</object>');

	//		document.write('<embed src="'+file+'" swliveconnect="false" width="'+width+'" height="'+height+'" loop="false" quality="high" bgcolor="#ffffff" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" wmode="opaque"></embed><br />');
	//	}
	//}
/*
			document.write('<object'
				+' classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://active.macromedia.com/flash2/cabs/swflash.cab#version=3,0,0,0" width="'+width+'" height="'+height+'"><param'
				+' name="movie" value="'+file+'"><param'
				+' name="loop" value="false"><param'
				+' name="quality" value="high"><param'
				+' name="bgcolor" value="#ffffff"><param'
				+' name="wmode" value="opaque"><embed'
				+' src="'+file+'" swliveconnect="false" width="'+width+'" height="'+height+'" loop="false" quality="high" bgcolor="#ffffff" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" wmode="opaque"></embed></object>');

*/
}


function writeGallery(galerieleiste, file, id, width, height) {
	file = file+"?imageUrl=/img/db/bild"+id+".jpg";
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"');
	document.write(' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"');
	document.write(' id="galerieM'+galerieleiste+'" width="'+width+'" height="'+height+'" align="">');
	document.write('<param name=movie value="'+file+'">');
	document.write('<param name=quality value=best>');
	document.write('<param name=scale value=noscale>');
	document.write('<param name=salign value=T>');
	document.write('<param name=bgcolor value=#ffffff>');
	document.write('<embed src="'+file+'" quality="best" scale="noscale" salign="T" bgcolor="#ffffff" width="'+width+'" height="'+height+'" swLiveConnect="true" name="galerieM'+galerieleiste+'" align=""');
	document.write(' type="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></embed>');
	document.write('</object>');

	document.write('<script language="JavaScript">');
	document.write('function galerieM'+galerieleiste+'_DoFSCommand(command, args) {');
	document.write('	galerieM_DoFSCommand('+galerieleiste+', command, args);');
	document.write('}');
	document.write('</script>');

	// Hook for Internet Explorer
	if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 &&
		  navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) {
		document.write('<SCRIPT LANGUAGE=VBScript\> \n');
		document.write('on error resume next \n');
		document.write('Sub galerieM'+galerieleiste+'_FSCommand(ByVal command, ByVal args)\n');
		document.write('  call galerieM_DoFSCommand('+galerieleiste+', command, args)\n');
		document.write('end sub\n');
		document.write('</SCRIPT\> \n');
	}
}


var picId = 0;

function setPic(galerieleiste,id,text,height) {
	var InternetExplorer = navigator.appName.indexOf("Microsoft") != -1;

	// Handle all the the FSCommand messages in a Flash movie
  	var galerieObj = InternetExplorer ? document.getElementById("galerieM"+galerieleiste) : document["galerieM"+galerieleiste];
  	//alert(galerieObj);

  	galerieObj.SetVariable("imageUrl_t","/img/db/bild"+id+".jpg");
  	galerieObj.SetVariable("restart","1");
  	//galerieObj.GotoFrame(2);
  	//galerieObj.Play();
  	// alert(document.getElementById('vorschau'+id).x);

  	document.getElementById("bu").innerHTML = text;

	// Bild
	delay = 0;
	var speed = InternetExplorer ? 5 : 10;

	var galerieObj = InternetExplorer ? eval("galerieM"+galerieleiste) : document["galerieM"+galerieleiste];

	oldheight = parseInt(galerieObj.height);
	command = height;

	step1 = command-Math.floor((oldheight+command)/2);
	oldheight += step1;
	step2 = command-Math.floor((oldheight+command)/2);
	oldheight += step2;
	step3 = command-Math.floor((oldheight+command)/2);
	oldheight += step3;
	step4 = command-Math.floor((oldheight+command)/2);
	oldheight += step4;
	step5 = command-Math.floor((oldheight+command)/2);
	oldheight += step5;

	setTimeout("delayHeight("+galerieleiste+","+step1+");",1*speed+delay);
	setTimeout("delayHeight("+galerieleiste+","+step2+");",3*speed+delay);
	setTimeout("delayHeight("+galerieleiste+","+step3+");",5*speed+delay);
	setTimeout("delayHeight("+galerieleiste+","+step4+");",7*speed+delay);
	setTimeout("delayHeight("+galerieleiste+","+step5+");",9*speed+delay);
	setTimeout("delayHeight("+galerieleiste+","+(command-oldheight)+");",11*speed+delay);

	// Galerieleiste
	delay = 11*speed+delay;
	speed = InternetExplorer ? 30 : 30;

  	XXX = InternetExplorer ? document.getElementById('vorschau'+id).offsetParent.offsetLeft : document.getElementById('vorschau'+id).x;

	oldValue = document.getElementById('galerieleiste'+galerieleiste).scrollLeft;
	newValue = XXX-210;
	diffValue = Math.round((newValue-oldValue)/12);

	finalValue = oldValue;
	for (i=1; (((oldValue <= newValue) && (finalValue+diffValue <= newValue) || (oldValue >= newValue) && (finalValue+diffValue >= newValue)) && i < 50); i++) {
		finalValue += diffValue;
		setTimeout("document.getElementById('galerieleiste"+galerieleiste+"').scrollLeft += "+diffValue+";",i*speed+delay);
	}
	setTimeout("document.getElementById('galerieleiste"+galerieleiste+"').scrollLeft += "+(newValue-finalValue)+";",(i+1)*speed+delay);


}

var InternetExplorer = navigator.appName.indexOf("Microsoft") != -1;

// Handle all the the FSCommand messages in a Flash movie
function galerieM_DoFSCommand(galerieleiste, command, args) {
	gotoId();
}
function delayHeight(galerieleiste, height) {
	var galerieObj = InternetExplorer ? eval("galerieM"+galerieleiste) : document["galerieM"+galerieleiste];

	galerieObj.height = parseInt(galerieObj.height)+height;
}
function urlEncode(wert) {
	// The Javascript escape and unescape functions do not correspond
	// with what browsers actually do...
	var SAFECHARS = "0123456789" +					// Numeric
					"ABCDEFGHIJKLMNOPQRSTUVWXYZ" +	// Alphabetic
					"abcdefghijklmnopqrstuvwxyz" +
					"-_.!~*'()";					// RFC2396 Mark characters
	var HEX = "0123456789ABCDEF";

	var plaintext = wert;
	var encoded = "";
	for (var i = 0; i < plaintext.length; i++ ) {
		var ch = plaintext.charAt(i);
	    if (ch == " ") {
		    encoded += "+";				// x-www-urlencoded, rather than %20
		} else if (SAFECHARS.indexOf(ch) != -1) {
		    encoded += ch;
		} else {
		    var charCode = ch.charCodeAt(0);
			if (charCode > 255) {
			    alert( "Unicode Character '"
                        + ch
                        + "' cannot be encoded using standard URL encoding.\n" +
				          "(URL encoding only supports 8-bit characters.)\n" +
						  "A space (+) will be substituted." );
				encoded += "+";
			} else {
				encoded += "%";
				encoded += HEX.charAt((charCode >> 4) & 0xF);
				encoded += HEX.charAt(charCode & 0xF);
			}
		}
	} // for

	return encoded;
};