//creates new Swiff object with given link
var createExtPlayer = function(width, height, vlink, desc){
	return new Swiff('/wp-includes/swf/gddflvplay-v35.swf', {
		width: width.toInt(),
		height: height.toInt(),
		params: {
			scale: 'noscale',
			wmode: 'opaque',
			allowFullScreen: 'true',
			allowScriptAccess: 'never',
			quality: 'best',
			bgcolor: '#000000',
			menu: 'false'
		},
		vars: {
			vdo: vlink,
			mylogo: '/wp-includes/logo.png',
			desc: desc,
			autoplay: false,
			sound: 50,
			iehack: $time()
		}
	});
}
// inserts SWF object
var insertSWFPlayer = function(width, height, movie){
	return new Swiff(movie, {
		width: width.toInt(),
		height: height.toInt(),
		params: {
			scale: 'noscale',
			wmode: 'opaque',
			allowFullScreen: 'true',
			allowScriptAccess: 'never',
			allowNetworking: 'internal',
			quality: 'best',
			bgcolor: '#000000',
			menu: 'false'
		},
		vars: {
			iehack: $time()
		}
	});
}
// inserts MP3 flash player object
var insertMP3Player = function(width, height, file, title){
	return new Swiff('/wp-includes/swf/xspfplay.swf', {
		width: width.toInt(),
		height: height.toInt(),
		params:{
			scale: 'noscale',
			wmode: 'opaque',
			allowScriptAccess: 'sameDomain',
			quality: 'best',
			bgcolor: '#000000',
			menu: 'false'
		},
		vars: {
			player_title: '4lol mp3 player - kliknij play | ' + title,
			song_url: file,
			song_title: title,
			iehack: $time()
		}
	});
}
//try to embedd a flash player to each node of 'player' class
window.addEvent('domready', function(){
	$$('.externalPlayer', '.MP3externalPlayer').each(function(player){
		if(pType && pObject){
			var desc = player.getFirst('.desc');
			desc = desc ? desc.get('text') : null;
			var width = player.getStyle('width');
			var height = player.getStyle('height');
			switch(pType){
				case 'Me':
					player.empty().adopt(createExtPlayer(width, height, pObject, desc));
					break;
				case 'SWF':
					player.empty().adopt(insertSWFPlayer(width, height, pObject));
					break;
				case 'MP3':
					player.empty().adopt(insertMP3Player(width, height, pObject, desc));
					break;
			}
		}
	});
});

