$(document).ready(function(){
	
	$('.hero-track-get, .track-get, .promo-track-get , .promo-overlay, .track-image').click(function(event){
		var id = $(this).attr('id');
		event.preventDefault();
		Shadowbox.open({
	        content:    'get-track.php?id='+id,
	        player:     'iframe',
	        height:     575,
	        width:      566
	    });
	});	
	
	if($.browser.msie){
	
		/* Use jwplayer */
		
		var domain = jQuery.url.attr("host");
			
		$('#video2').flash({   
				swf: 'swf/player-licensed.swf',
				height: 194,   
				width: 308,
				params: {
					wmode: 'transparent',
					flashvars: {
						file : 'http://'+domain+'/video/video2.flv',
						autostart: true,
						bufferlength: 3,
						controlbar: 'none',
						image: 'http://'+domain+'images/bg-video-100723-02-rest.png',
						skin: 'http://'+domain+'/swf/example_skin.zip'				
					}
				}
		});
		
		$('.one-of-three-flash-videos').click(function(event){
			event.preventDefault();
			var clipid = getID($(this).attr('id'));
			$('.track-sample object, .promo-track-sample object, .one-of-three-flash-videos:not(#video'+clipid+') object').remove();
			$('.track-sample, .promo-track-sample, .one-of-three-flash-videos:not(#video'+clipid+')').addClass('deactivated');
			if($(this).hasClass('deactivated')){
				$(this).flash({   
					swf: 'swf/player-licensed.swf',   
					height: 194,   
					width: 308,
					params: {
						wmode: 'transparent',
						base: 'swf/',
						flashvars: {
							file : 'http://'+domain+'/video/video'+clipid+'.flv',
							autostart: true,
							controlbar: 'none',
							image: 'http://'+domain+'/images/bg-video-100723-0'+clipid+'-rest.png',
							skin: 'http://'+domain+'/swf/example_skin.zip'		
						}
					}
				});
			}
			$(this).removeClass('deactivated');
		});
		
	} else {
	
		$('#video2').flash({   
				swf: 'swf/sockzplayer.swf',   
				height: 194,   
				width: 308,
				params: {
					wmode: 'transparent',
					base: 'swf/',
					flashvars: {
						videoPath : '../video/video2.flv',
						imagePath : '../images/bg-video-100723-02-rest.png'								
					}
				}
		});
		
		$('.one-of-three-flash-videos').click(function(event){
			event.preventDefault();
			var clipid = getID($(this).attr('id'));
			$('.track-sample object, .promo-track-sample object, .one-of-three-flash-videos:not(#video'+clipid+') object').remove();
			$('.track-sample, .promo-track-sample, .one-of-three-flash-videos:not(#video'+clipid+')').addClass('deactivated');
			if($(this).hasClass('deactivated')){
				$(this).flash({   
					swf: 'swf/sockzplayer.swf',   			
					params: {
						wmode: 'transparent',
						base: 'swf/',
						flashvars: {
							videoPath : '../video/video'+clipid+'.flv',
							imagePath : '../images/bg-video-100723-0'+clipid+'-rest.png'
						}
					},
					height: 194,   
					width: 308
				});
			}
			$(this).removeClass('deactivated');
		}); 
	
	}
	
	/* Test with Vimeo
	$('.one-of-three-flash-videos').click(function(event){
		var clipid = getID($(this).attr('id'));
		$('.track-sample object, .promo-track-sample object, .one-of-three-flash-videos:not(#video'+clipid+') object').remove();
		$('.track-sample, .promo-track-sample, .one-of-three-flash-videos').not('#video'+clipid).addClass('deactivated');
		event.preventDefault();
		if($(this).hasClass('deactivated')){
			$(this).flash({   
			swf: 'http://vimeo.com/moogaloop.swf?clip_id=12697802&amp;server=vimeo.com&amp;show_title=1&amp;autoplay=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1'
			});
		} else {
		}
		$(this).removeClass('deactivated');
	});*/
		
	
});

function getID(strID){
 return strID.replace(/[^0-9]/gi, '');
}




