var flashvars = {
	frontcolor: 'cccccc',
	backcolor: '323232',
	lightcolor: 'ffffff',
	enablejs: true,
	autostart: true,
	file: 'http://' + videoserver + '/' + videofile
};

var params = {};
params.menu = 'false';
params.wmode = 'opaque';
params.allowfullscreen = 'true';
params.allowscriptaccess = 'always';
params.allownetworking = 'all';

var attributes = {};
attributes.id = 'flashVideo_overlay';
attributes.name = 'flashVideo_overlay';

var overlayPlayer = null;
swfobject.embedSWF("/static/mediaplayer/mediaplayer.swf", "video_player", "480", "404", "9.0.115.0", false, flashvars, params, attributes);

function setPlayerViewOut() {
	$('#video_overlay').fadeOut(500);
	$('#video_bg').css({'background-color' : 'transparent', 'left' : '-10000px'});
	if ( overlayPlayer) overlayPlayer.sendEvent("PLAY", false);
}

///////////////////////////////////////////////////////////////////////////////////////////////////

$(document).ready( function() {

	var docHeight = $(document).height();
	overlayPlayer = document.getElementById('flashVideo_overlay');

	$('#video_bg').css({ 'height': docHeight});
	$('#video_button').css({'display' : 'block'});
	$('#video_playsymbol').css({'display' : 'block'});

	$('#video_button').click( function(e) {
		if( $('#video_overlay').is(':hidden')){
			$('#video_bg').css({'background-color' : '#000', 'left' : '0'});
			$('#video_overlay').fadeIn(500);
			$.post('cat_videoblog_ajax~ncxes.html', { action: 'logging', parm1: 'PLAYPROD', parm2: videoID } );
		}
		
		e.preventDefault();
		e.stopPropagation();
	});
	
	$('#video_overlay_close').click( function () {
		setPlayerViewOut();
		return false;
	});
	
	$('#back_to_products').click( function () {
		setPlayerViewOut();
		return false;
	});
	
	$('#go_to_videoblog').click( function () {
			window.location.href = videoblogLink;
	});

	$('.video_window').draggable({ handle: 'h2', containment: 'document' });
	
	$('#video_sidebar_teaser').click( function (e) {
				if( $('#video_overlay').is(':hidden')){
					$('#video_bg').css({'background-color' : '#000', 'left' : '0'});
					$('#video_overlay').fadeIn(500);
					$.post('cat_videoblog_ajax~ncxes.html', { action: 'logging', parm1: 'PLAYPROD', parm2: videoID } );
				}
				
				e.preventDefault();
				e.stopPropagation();
	});
	
	$('#video_bg').click( function () {
		setPlayerViewOut();
		return false;
	});


});

