var ext2id = [];ext2id['mp3'] = 'mp3';ext2id['jpg'] = 'bg';ext2id['gif'] = 'fg';ext2id['png'] = 'fg';ext2id['swf'] = 'swf';ext2id['pdf'] = 'newwindow';ext2id['mov'] = 'qt';var media_ids = ['mp3','bg','fg','swf','qt'];var media_bgC = {mp3:'none',bg:'#f60',fg:'none',swf:'#000',qt:'#000'};var clean_props = ['innerHTML','src','src','innerHTML','innerHTML'];//var clean_bgColor = [false,true,true,false,false];function in_array (arr, str) {	for (var n in arr) if (arr[n] == str) return true;	return false;}function in_array_keys (arr, key) {	for (var n in arr) if (n == key) return true;	return false;}function clean_all_except (excl_id) {	excl_id = excl_id.split(",");	for (var i=0; i<media_ids.length; i++) {		if (!in_array(excl_id, media_ids[i])) {			// -- kan niet kiezen ... ;)			document.getElementById(media_ids[i])[clean_props[i]] = "";			document.getElementById(media_ids[i]).style['visibility'] = 'hidden';			//document.getElementById(media_ids[i]).style['background-color'] = 'none';		} else {			document.getElementById(media_ids[i]).style['visibility'] = 'visible';			//document.getElementById(media_ids[i]).style['background-color'] = media_bgC[media_ids[i]];		}	}}//show_size = 'fg' of 'bg' function getMedia (src, show_size) {	var ext = src.substr((src.lastIndexOf('.')+1)).toLowerCase();	if (!in_array_keys (ext2id, ext)) {		alert('Invalid extension ...: .'+ext);		return;	}	var id = ext2id[ext];  if(ext == 'jpg')  {    if(show_size == 'fg' || show_size == 'bg' )    {      id = show_size;    }  }	new_media (id, src);}function new_media (id, src) {	id_arr = id.split(",");	src_arr = src.split(",");	if (id_arr.length == src_arr.length) {		for (var n in id_arr) {			//alert (n);			id_swap_src (id_arr[n], src_arr[n]);		}		clean_all_except (id);	} else {		//alert ('new_media ('+id+','+src+')\nfout in media defenitie')	}}function id_swap_src (id, src) {  //alert('id = ' + id + ' src = ' + src);	if (document.getElementById(id)) {		var obj_str = "";		switch (id) {      case 'newwindow':		    window.open(src , 'mediaWindow', 'resizable=yes,scrollbars=yes,status=yes,width=600,height=700,LEFT=0,TOP=0');        break;      			case 'swf':				//alert('loading Flash Movie: '+src);				obj_str += ""					+"\n\t <object id=\"swf_obj\" "					+((navigator.appVersion.indexOf('Win')>0 && navigator.appVersion.indexOf('MSIE')>0) ? "\n\t\t classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\""							+"\n\t\t codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0\">" : "")					+"\n\t\t type=\"application/x-shockwave-flash\" "					+"\n\t\t data=\"c.swf?swf_pad="+src+"\">"					+"\n\t\t <param name=\"bgcolor\" value=\"#000000\">"					+"\n\t\t <param name=\"scaleMode\" value=\"noScale\" \/>"					+"\n\t\t <param name=\"movie\" value=\"c.swf?swf_pad="+src+"\" \/>"					+"\n\t\t <img src=\"no_swf_plug.gif\" width=\"100\" height=\"100\" alt=\"The required plugin for this object was not found on your system\" \/>"					+"\n\t <\/object>";				break;/*			case 'bg':				alert('loading background pic: '+src);				obj_str += ""					+"\n\t <object id=\"swf_obj\" "					+((navigator.appVersion.indexOf('Win')>0 && navigator.appVersion.indexOf('MSIE')>0) ? "\n\t\t classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\""							+"\n\t\t codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0\">" : "")					+"\n\t\t type=\"application/x-shockwave-flash\" "					+"\n\t\t data=\"c.swf?swf_pad="+src+"\">"					+"\n\t\t <param name=\"bgcolor\" value=\"#000000\">"					+"\n\t\t <param name=\"scaleMode\" value=\"noScale\" \/>"					+"\n\t\t <param name=\"movie\" value=\"c.swf?swf_pad="+src+"\" \/>"					+"\n\t\t <img src=\"no_swf_plug.gif\" width=\"100\" height=\"100\" alt=\"The required plugin for this object was not found on your system\" \/>"					+"\n\t <\/object>";				break;*/			case 'qt':				//alert('loading Quicktime movie: '+src);				obj_str += ""					+"\n\t <object id=\"qt_obj\" "/*					+((navigator.appVersion.indexOf('Win')>0 && navigator.appVersion.indexOf('MSIE')>0) ? "\n\t\t classid=\"clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B\""							+"\n\t\t codebase=\"http://www.apple.com/qtactivex/qtplugin.cab\">"							+"\n\t\t src=\""+src+"\" >" : "")					+"\n\t\t type=\"application/x-quicktime\" "					+"\n\t\t data=\""+src+"\" >"					+"\n\t\t <param name=autoplay value=\"true\" \/>"					+"\n\t\t <param name=bgcolor value=\"#000000\">"					+"\n\t\t <param name=controller value=false \/>"					+"\n\t\t <param name=pluginspage value=\"http://quicktime.apple.com/\">"					+"\n\t\t <a href=\"http://quicktime.apple.com/\" target=\"blank\"><img src=\"no_qt_plug.gif\" width=\"100\" height=\"100\" alt=\"The required plugin for this object was not found on your system\" \/></a>"*/										+"\n\t\t width=\"100%\" height=\"100%\" "					+"\n\t\t classid=\"clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B\""					+"\n\t\t codebase=\"http://www.apple.com/qtactivex/qtplugin.cab\">"					+"\n\t\t <param name=\"src\" value=\""+src+"\">"					+"\n\t\t <param name=\"autoplay\" value=\"true\">"					+"\n\t\t <param name=\"controller\" value=\"false\">"					+"\n\t\t <param name=bgcolor value=\"#000000\">"					+"\n\t\t "					+"\n\t\t <embed src=\""+src+"\" autoplay=\"true\" controller=\"false\" width=\"100%\" height=\"100%\" bgcolor=\"#000000\""					+"\n\t\t pluginspage=\"http://www.apple.com/quicktime/download/\">"					+"\n\t\t </embed>"					+"\n\t <\/object>";				break;			case 'mp3':				//alert('loading mp3: '+src);				obj_str += ""					+"\n\t <object id=\"mp3_obj\" "					+"\n\t\t type=\"audio/x-mp3\" "					+"\n\t\t data=\""+src+"\" "					//+"\n\t\t <param name=\"scaleMode\" value=\"noScale\" \/>"					//+"\n\t\t <param name=\"movie\" value=\"c.swf?swf_pad="+src+"\" \/>"					//+"\n\t\t <img src=\"no_mp3_plug.gif\" width=\"100\" height=\"100\" alt=\"The required plugin for this object was not found on your system\" \/>"					+"\n\t <\/object>";				break;			default:				if (id == 'bg' || id == 'fg') {				//alert('loading foreground pic: '+src);					if (src.substring(0,1) == '#') {						document.getElementById(id).style['background-color'] = src;						document.getElementById(id).innerHTML = '';						return;					} else {						if (id == 'fg') { 							obj_str += "<table style=\"height:100%; width:100%\"><tr style=\"height:100%; width:100%\"><td style=\"height:100%; width:100%; text-align:center\">";						}						obj_str += "\n\t <img id=\""+id+"_img\" src=\""+src+"\" \/>";							//+"\n\t <object id=\""+id+"_img\" "							//+"\n\t\t type=\"image/jpeg\" "							//+"\n\t\t data=\""+src+"\" "							//+"\n\t <\/object>";						//document.getElementById(id+'_img').src = src;						//clean_all_except ('bg,fg');						//clean_all_except (id);						if (id == 'fg') { 							obj_str += "</td></tr></table>";						}					}				} else {					alert ('error loading '+src+', server error or your browser does not support getElementById()');				}		}		//alert (obj_str);		if (obj_str) {			document.getElementById(id).innerHTML = obj_str;			//clean_all_except (id);		}		//alertstr='';		//for (var n in document.getElementById(id)) alertstr += n+", ";		//alert (alertstr);	}  else  {    alert( id + ' is an invalid id. define a div with the id in str_media_view.tpl');  }}
