// BEGIN TEXT FOR GLOBALIZATION

getFlash_video='To view this content, <a href="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" target="_blank">install the Flash 9 player</a> and then return to this page.';
getFlash_mp3='To use the audio feature, <a href="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" target="_blank">install the Flash 9 player</a> and then return to this page.';
preLoading='Preloading...';
closeLabel='CLOSE';

// END TEXT FOR GLOBALIZATION


// do not change anything below this point

var fVersion=deconcept.SWFObjectUtil.getPlayerVersion();
var playerNumber=0;
Behaviour.register({
	'.mediaplayer_video' : function (e) {
		if ((fVersion['major']<8) || ((window.location.toString().indexOf('?noflash')>=0) ? true : false )) {
			$(e).getElementsByClassName('mediaplayer_summary')[0].insert({ after: '<div class="mediaplayer_getflash">'+getFlash_video+'</div>' });
		} else {
			// parse and apply settings to SWFo
			settings=new Object();
			if ($(e).getElementsByClassName('mediaplayer_settings')[0]) {
				temp=$(e).getElementsByClassName('mediaplayer_settings')[0].innerHTML;
				temp=temp.split(' ');
				temp=temp.join('');
				temp=temp.split(',');
				for (setting=0; setting<temp.length; setting++) {
					temp2=temp[setting].split('=');
					settings[temp2[0].toLowerCase()]=temp2[1];
				}
			}
			so = new SWFObject('/mediaplayer/swf/videoplayer.swf', 'mediaPlayer'+playerNumber, '320', '285', fVersion['major'], '#ffffff');
			so.addVariable('mediaPath',$(e).getElementsByClassName('mediaplayer_url')[0].innerHTML);
			so.addVariable('preLoading',preLoading);
			so.addVariable('mediaAutoPlay',( (settings['autoplay']) ? settings['autoplay'] : false )); // use setting if found otherwise default to false

			pageRoot=window.location.toString().split('http://').join('').slice(window.location.toString().split('http://').join('').indexOf('/'),window.location.toString().split('http://').join('').lastIndexOf('/')+1);
			so.addVariable('pageRoot',pageRoot); //used for relative URLs, '../' is NOT supported

			// if setting is true or not defined AND Flash version is better than 9.0 r115, allow full screen
			// (r9.0 115 is required for fullscreen with transparent wmode, and transparent wmode is required for emc.com because of large overlays)
			// do as both param and setting (for hiding button w/in flash if necessary)
			allowfullscreen=( ((settings['allowfullscreen']=='true') || (settings['allowfullscreen']==undefined)) && ((fVersion['major']>=9)&&(fVersion['minor']>=0)&&(fVersion['rev']>=115)) || ((fVersion['major']>=9)&&(settings['popup']=='true')) ) ? true : false ;
			so.addVariable('allowFullScreen',allowfullscreen);
			so.addParam('allowFullScreen',allowfullscreen);

			so.addParam('menu','false');
			so.addParam('quality','high');
			so.addParam('scale','noscale');
			if (settings['popup']=='true') {
				so.addParam('wmode','window');
			} else {
				so.addParam('wmode','transparent');
			}

			//close button
			if (settings['popup']=='true') {
				f=$(e).getElementsByClassName('mediaplayer_footer')[0].update(closeLabel).removeClassName('mediaplayer_footer').addClassName('mediaplayer_close');
				f.onmouseover=function() {this.style.textDecoration='underline';}
				f.onmouseout=function() {this.style.textDecoration='none';}
				f.onclick=function() {window.close();}
			}

			// make DOM changes
			$(e).getElementsByClassName('mediaplayer_summary')[0].insert({ before: '<div class="mediaplayer_flash"></div>' });
			$(e).getElementsByClassName('mediaplayer_summary')[0].removeClassName('mediaplayer_summary').addClassName('mediaplayer_summary_flash');

			so.write($(e).getElementsByClassName('mediaplayer_flash')[0]);
			playerNumber++;
		}
	},
	'.mediaplayer_video_only' : function (e) {
		if ((fVersion['major']<8) || ((window.location.toString().indexOf('?noflash')>=0) ? true : false )) {
			$(e).getElementsByClassName('mediaplayer_url')[0].insert({ before: '<div class="mediaplayer_getflash">'+getFlash_video+'</div>' });
		} else {
			// parse and apply settings to SWFo
			settings=new Object();
			if ($(e).getElementsByClassName('mediaplayer_settings')[0]) {
				temp=$(e).getElementsByClassName('mediaplayer_settings')[0].innerHTML;
				temp=temp.split(' ');
				temp=temp.join('');
				temp=temp.split(',');
				for (setting=0; setting<temp.length; setting++) {
					temp2=temp[setting].split('=');
					settings[temp2[0].toLowerCase()]=temp2[1];
				}
			}
			so = new SWFObject('/mediaplayer/swf/videoplayer.swf', 'mediaPlayer'+playerNumber, '320', '285', fVersion['major'], '#ffffff');
			so.addVariable('mediaPath',$(e).getElementsByClassName('mediaplayer_url')[0].innerHTML);
			so.addVariable('preLoading',preLoading);
			so.addVariable('mediaAutoPlay',( (settings['autoplay']) ? settings['autoplay'] : false )); // use setting if found otherwise default to false

			pageRoot=window.location.toString().split('http://').join('').slice(window.location.toString().split('http://').join('').indexOf('/'),window.location.toString().split('http://').join('').lastIndexOf('/')+1);
			so.addVariable('pageRoot',pageRoot); //used for relative URLs, '../' is NOT supported

			// if setting is true or not defined AND Flash version is better than 9.0 r115, allow full screen
			// (r9.0 115 is required for fullscreen with transparent wmode, and transparent wmode is required for emc.com because of large overlays)
			// do as both param and setting (for hiding button w/in flash if necessary)
			allowfullscreen=( ((settings['allowfullscreen']=='true') || (settings['allowfullscreen']==undefined)) && ((fVersion['major']>=9)&&(fVersion['minor']>=0)&&(fVersion['rev']>=115)) || ((fVersion['major']>=9)&&(settings['popup']=='true')) ) ? true : false ;
			so.addVariable('allowFullScreen',allowfullscreen);
			so.addParam('allowFullScreen',allowfullscreen);

			so.addParam('menu','false');
			so.addParam('quality','high');
			so.addParam('scale','noscale');
			if (settings['popup']=='true') {
				so.addParam('wmode','window');
			} else {
				so.addParam('wmode','transparent');
			}

			// make DOM changes
			$(e).getElementsByClassName('mediaplayer_url')[0].insert({ before: '<div class="mediaplayer_flash"></div>' });

			so.write($(e).getElementsByClassName('mediaplayer_flash')[0]);
			playerNumber++;
		}
	},
	'.mediaplayer_mp3' : function (e) {
		if ((fVersion['major']<8) || ((window.location.toString().indexOf('?noflash')>=0) ? true : false )) {
			$(e).getElementsByClassName('mediaplayer_audiodownloads')[0].insert({ after: '<div class="mediaplayer_getflash">'+getFlash_mp3+'</div>' });
		} else {
			// parse and apply settings to SWFo
			settings=new Object();
			if ($(e).getElementsByClassName('mediaplayer_settings')[0]) {
				temp=$(e).getElementsByClassName('mediaplayer_settings')[0].innerHTML;
				temp=temp.split(' ');
				temp=temp.join('');
				temp=temp.split(',');
				for (setting=0; setting<temp.length; setting++) {
					temp2=temp[setting].split('=');
					settings[temp2[0].toLowerCase()]=temp2[1];
				}
			}
			so = new SWFObject('/mediaplayer/swf/mp3player.swf', 'mediaPlayer'+playerNumber, '320', '45', fVersion['major'], '#ffffff');
			so.addVariable('mediaPath',$(e).getElementsByClassName('mediaplayer_url')[0].innerHTML);
			so.addVariable('mediaAutoPlay',( (settings['autoplay']) ? settings['autoplay'] : false )); // use setting if found otherwise default to false

			pageRoot=window.location.toString().split('http://').join('').slice(window.location.toString().split('http://').join('').indexOf('/'),window.location.toString().split('http://').join('').lastIndexOf('/')+1);
			so.addVariable('pageRoot',pageRoot); //used for relative URLs, '../' is NOT supported

			so.addParam('menu','false');
			so.addParam('quality','high');
			so.addParam('scale','noscale');
			if (settings['popup']=='true') {
				so.addParam('wmode','window');
			} else {
				so.addParam('wmode','transparent');
			}

			//close button
			if (settings['popup']=='true') {
				f=$(e).getElementsByClassName('mediaplayer_footer')[0].update(closeLabel).removeClassName('mediaplayer_footer').addClassName('mediaplayer_close');
				f.onmouseover=function() {this.style.textDecoration='underline';}
				f.onmouseout=function() {this.style.textDecoration='none';}
				f.onclick=function() {window.close();}
			}

			// make DOM changes
			$(e).getElementsByClassName('mediaplayer_audiodownloads')[0].insert({ before: '<div class="mediaplayer_flash"></div>' });
			$(e).getElementsByClassName('mediaplayer_audiodownloads')[0].removeClassName('mediaplayer_audiodownloads').addClassName('mediaplayer_audiodownloads_flash');

			so.write($(e).getElementsByClassName('mediaplayer_flash')[0]);
			playerNumber++;
		}
	},
	'.mediaplayer_mp3_only' : function (e) {
		if ((fVersion['major']<8) || ((window.location.toString().indexOf('?noflash')>=0) ? true : false )) {
			//$(e).getElementsByClassName('mediaplayer_url')[0].insert({ before: '<div class="mediaplayer_getflash">'+getFlash_mp3+'</div>' });
		} else {
			// parse and apply settings to SWFo
			settings=new Object();
			if ($(e).getElementsByClassName('mediaplayer_settings')[0]) {
				temp=$(e).getElementsByClassName('mediaplayer_settings')[0].innerHTML;
				temp=temp.split(' ');
				temp=temp.join('');
				temp=temp.split(',');
				for (setting=0; setting<temp.length; setting++) {
					temp2=temp[setting].split('=');
					settings[temp2[0].toLowerCase()]=temp2[1];
				}
			}
			so = new SWFObject('/mediaplayer/swf/mp3player.swf', 'mediaPlayer'+playerNumber, '320', '45', fVersion['major'], '#ffffff');
			so.addVariable('mediaPath',$(e).getElementsByClassName('mediaplayer_url')[0].innerHTML);
			so.addVariable('mediaAutoPlay',( (settings['autoplay']) ? settings['autoplay'] : false )); // use setting if found otherwise default to false

			pageRoot=window.location.toString().split('http://').join('').slice(window.location.toString().split('http://').join('').indexOf('/'),window.location.toString().split('http://').join('').lastIndexOf('/')+1);
			so.addVariable('pageRoot',pageRoot); //used for relative URLs, '../' is NOT supported

			so.addParam('menu','false');
			so.addParam('quality','high');
			so.addParam('scale','noscale');
			if (settings['popup']=='true') {
				so.addParam('wmode','window');
			} else {
				so.addParam('wmode','transparent');
			}

			// make DOM changes
			$(e).getElementsByClassName('mediaplayer_audiodownloads')[0].remove();
			$(e).getElementsByClassName('mediaplayer_url')[0].insert({ before: '<div class="mediaplayer_flash"></div>' });

			so.write($(e).getElementsByClassName('mediaplayer_flash')[0]);
			playerNumber++;
		}
	}
});
