/*************** mediapopup.js ****************/

function CenteredImgPopup(imgURL, winName, w, h) {
	mediaPopup(imgURL, winName, w, h);
}

function CenteredSWFPopup(imgURL, winName, w, h) {
	mediaPopup(imgURL, winName, w, h);
}

function mediaPopup(imgURL, winName, w, h, preview) {
	var winl = (screen.width - parseInt(w)) / 2;
	var wint = (screen.height - parseInt(h)) / 2;
	winprops = 'width='+w+',height='+h+',top='+wint+',left='+winl+',scrollbars=no';
	// alert(winprops);
	win = window.open('', getRandomName(), winprops);
	win.document.open();
	win.document.writeln('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">');
	win.document.writeln('<html><head><title>'+winName+'</title></head>');
	win.document.writeln('<body bgcolor="#A7C8FD" marginHeight="20" marginWidth="20" leftMargin="20" topMargin="20"style="margin:0px"><table cellpadding=0 cellspacing=0 border=0 width="100%" height="100%">');
	win.document.write('<tr><td align="center" valign="middle">');
	var mediaExtension = /(\.\w+)$/;
	mediaExtension.exec(imgURL);
	switch(RegExp.$1) {
	case ".jpeg":
	case ".jpg":
	case ".png":
	case ".gif":
		win.document.write('<a href="javascript:close();"><img src="'+imgURL+'" border=0 ALT="Ein Klick auf das Bild schließt das Fenster"></a>');
		break;
	case ".swf":
		win.document.write('<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0"');
		win.document.write('WIDTH='+w+' HEIGHT='+h+'><PARAM NAME=movie VALUE="'+imgURL+'"><PARAM NAME=quality VALUE=high><PARAM NAME=bgcolor VALUE=#FFFFFF>');
		win.document.writeln('<EMBED src="'+imgURL+'" quality=high bgcolor=#FFFFFF  WIDTH='+w+' HEIGHT='+h+' TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></EMBED></OBJECT>');
		break;
	case ".mpg":
	case ".mpeg":
		win.document.write('<object width="'+w+'" height="'+h+'" classid="clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab">');
		win.document.write('<param name="src" value="'+imgURL+'">');
		win.document.write('<embed src="'+imgURL+'" type="video/mpeg" width="'+w+'" height="'+h+'"></embed></object>');
		break;
	case ".mov":
		win.document.write('<object width="'+w+'" height="'+h+'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://www.apple.com/qtactivex/qtplugin.cab">');
		win.document.write('<param name="src" value="'+imgURL+'">');
		win.document.write('<embed src="'+imgURL+'" type="video/quicktime" width="'+w+'" height="'+h+'"></embed></object>');
		break;
	case ".wmv":
		win.document.write('<object width="'+w+'" height="'+h+'" classid="clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab">');
		win.document.write('<param name="src" value="'+imgURL+'">');
		win.document.write('<embed src="'+imgURL+'" type="video/x-ms-wmv" width="'+w+'" height="'+h+'"></embed></object>');
		break;
	case ".avi":
		win.document.write('<object width="'+w+'" height="'+h+'" classid="clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab">');
		win.document.write('<param name="src" value="'+imgURL+'">');
		win.document.write('<embed src="'+imgURL+'" type="video/x-msvideo" width="'+w+'" height="'+h+'"></embed></object>');
	case ".rm":
	case ".ram":
		win.document.write('<object width="'+w+'" height="'+h+'" classid="clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA">');
		win.document.write('<param name="src" value="'+imgURL+'">');
		win.document.write('<embed src="'+imgURL+'" type="audio/x-pn-realaudio-plugin" width="'+w+'" height="'+h+'"></embed></object>');
		break;
	default:
		// unknown media type
		win.document.write('<object width="'+w+'" height="'+h+'">');
		win.document.write('<param name="src" value="'+imgURL+'">');
		win.document.write('<embed src="'+imgURL+'" width="'+w+'" height="'+h+'"></embed></object>');
		break;
	}	
	win.document.writeln('</td></tr>');
	win.document.writeln('</table></body></html>');
	win.document.close();
	if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); };
	// return win;
}

function mediaPopup2(imgURL, winName, w, h, preview) {
	var winl = (screen.width - parseInt(w)) / 2;
	var wint = (screen.height - parseInt(h)) / 2;
	winprops = 'width='+w+',height='+h+',top='+wint+',left='+winl+',scrollbars=no';
	// alert(winprops);
	win = window.open('/waltergasse/popup.php?u='+imgURL+'&c='+winName+'&w='+w+'&h='+h+'&p='+preview, getRandomName(), winprops);
	if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); };
	// return win;
}

