	var cur_seo_url = '';
	var no_auto = false;
	$( function () {
		flowplayer("player_c", {src: "swf/flowplayer-3.1.5.swf", wmode: 'opaque'}, { 
		key: '#$ebd2ebc4f840399ac6b',
        clip: {
			baseUrl: 'http://blip.tv/file/get/',
			onBeforeBegin: function(clip) {
				if (playcount == 1 && clip.index == 1)
				{
					return false;
				}
				if (clip.index == cur_clip && looped && !finished)
				{
					finished = true;
					return false;
				}
			},
			onStart: function(clip) { 
				var series = $('li.playing .modalW h4').html();
				var urlseries = $('li.playing span.series').html();
				var urlepisode = $('li.playing span.episode').html();
				var title = $('li.playing .modalW span').html();
				var desc = $('li.playing .itemDescr span').html();
				object.properties.title = series + ' - ' + title;
				object.properties.url = 'http://'+document.location.host+'/website/videos/'+urlseries+'/'+urlepisode+'/';
				
				$('.MainVideo h1').html(series);
				$('.MainVideo h2').html(title);
				$('.MainVideoDescr span').html(desc);
				Cufon.replace('.MainVideoDescr h2');				
				playing_clip = clip;
				cur_seo_url = '/videos/'+urlseries+'/'+urlepisode+'/';
				if (no_auto)
				{
					auto_ste = false;
					no_auto = false;
				}
				auto_ste = true;
				if (auto_ste)
				{
					$('.hor_slide_item a').each(function(index) {
						if (this.href == $('li.playing a.playlink')[0].href)
						{
							h_cur = index + 1;
							$(".hor_slide_content").fadeIn(100).animate({marginLeft: (256 * index * -1)},500);
							$('.girls:eq('+ index + ') img:first').click();
						}
					});
				}
				if (pageTracker !== undefined)
				{
					pageTracker._trackPageview(cur_seo_url+'play'); 
				}
				update_stats('playstart', clip.url);
				auto_ste = false;
			},
			onLastSecond: function(clip) {
				if (pageTracker !== undefined)
				{
					pageTracker._trackPageview(cur_seo_url+'playcomplete'); 
				}
				update_stats('playcomplete', clip.url);
			},
			onBeforeFinish: function(clip) {
				if (clip.index == (mplaylist.length - 1) && (cur_clip > 0 && !looped && !finished))
				{
					looped = true;
					no_auto = true;
					$('#playlist_container li:first').click();
				}
			}
			
		}, 
         
        // our playlist 
        playlist: mplaylist, 
         
        // show playlist buttons in controlbar 
        plugins: { 
            controls: { 
                playlist: true,
				backgroundColor: '#000000',
				backgroundGradient: 'none',
				progressColor: '#686868',
				sliderColor: '#cfcfcf',
				bufferColor: '#cfcfcf',
				volumeSliderColor: '#cfcfcf',
				volumeColor: '#cfcfcf',
				buttonColor: '#ffffff',
				buttonOverColor: '#cfcfcf',
				timeColor: '#FFFFFF',
				timeBgColor: '#686868',
				timeBorder: 'none',
				fullscreenColor: '#fffff',
				background: '#000000 url(/website/videos/images/player-background_tranps.gif) no-repeat 0 0',
				autoHide: {
					enabled: true,
					hideDelay: 4000
				},
				url: '/website/videos/swf/flowplayer.controls-skinless-3.1.5.swf', 
				skin: 'customskin', 
				all: true, stop: false
            },
			customskin: { url: "/website/videos/swf/buttons_tube.swf", type: "classLibrary" } 
        } 
		
		
		}).playlist('#playlist_container', {loop:true});
		
		$('#playlist_container li').each(function () {
			if (current_clip == cur_clip)
			{
				auto_ste = true;
				$(this).click();
			}
			current_clip++;
			if (current_clip > playcount)
			{
				$(this).remove();
			}
		});
		
		$('#playlist_container').append(document.getElementById('series_container').innerHTML);
		$('#series_container').remove();
		
		$( function () {
			$('.playlist_item_more span').click(function () {
				$(this.parentNode.parentNode.children[this.parentNode.parentNode.children.length - 1]).CenterIt({ ignorechildren: true });
				return false;
			})
		});
		
		$('.lnkClose').click(function() {
			$(this).parent().fadeOut();
			return false;
		});
		$('.lnkWatch').click(function() {
			$(this).parent().parent().hide();
			if (this.href == '#')
			{
				$(this).parent().parent().click();
				return false;		
			}
		});
		
		$('.lnkEmbed').click(function() {
			var clip = playing_clip;
			var embed = '&lt;object width="636" height="369" data="http://test.whowhatwear.com/website/videos/swf/flowplayer-3.1.5.swf" type="application/x-shockwave-flash"&gt;&lt;param name="movie" value="http://test.whowhatwear.com/website/videos/swf/flowplayer-3.1.5.swf" /&gt;&lt;param name="allowfullscreen" value="true" /&gt;&lt;param name="allowscriptaccess" value="always" /&gt;&lt;param name="flashvars" value=\'config={"clip":{"url":"'+clip.url+'"},"title":"Video","baseUrl":"http://blip.tv/file/get/"}]}\' /&gt;&lt;/object&gt;';
			embed = '<textarea style="width:270px;height:150px;">&lt;object width="636" height="369" data="http://test.whowhatwear.com/website/videos/swf/flowplayer-3.1.5.swf" type="application/x-shockwave-flash"&gt;&lt;param name="movie" value="http://test.whowhatwear.com/website/videos/swf/flowplayer-3.1.5.swf" /&gt;&lt;param name="allowfullscreen" value="true" /&gt;&lt;param name="allowscriptaccess" value="always" /&gt;&lt;param name="flashvars" value=\'config={"clip":{"url":"'+clip.completeUrl+'"},"title":"Video","baseUrl":"http://blip.tv/file/get/"}]}\' /&gt;&lt;/object&gt;</textarea>';
			$('.MainVideo .itemDescr').html(embed);
			$('.MainVideo .modalW').show();

			return false;
		});
		
		$('.girls img').click(function() {
			var model_id = this.id.replace('model_','');
			$('#model_large').attr('src', 'images/icons/models/large/'+model_id+'.jpg?qwe='+Math.floor(Math.random()*1112983293));
			var xurl = 'xhr/models.php?model_id='+encodeURIComponent(model_id);
			jQuery.post( xurl, '', function(data) {
				$('.slide_content').html(data.items);
				$('.slide_content').css('height', $('.slide_content a').size() * 118);
			}, 'json' );
		});
		$('a.series').click(function(){
			document.location.href = this.href;
			return false;
		});
	});
	
	function update_stats(status, url)
	{
		var xurl = 'xhr/status.php?status='+encodeURIComponent(status)+'&url='+encodeURIComponent(url);
		jQuery.post( xurl, '', function(data) {
		}, 'json' );
	}