function loadVideo(path, file){
	var flashvars = {
			"uid":"expotv",
			"file":path+file,
			"st":path+"uppod_style.txt",
			"autoplay": true
		};
		var params = {
			wmode:"transparent",
			allowFullScreen:"true",
			allowScriptAccess:"always",
			id:"expotv"
		};
		new swfobject.embedSWF(path+"uppod.swf", "expotv", "474", "265", "9.0.115.0", false, flashvars, params, '', function(){$('#expotv').css('visibility', 'hidden');});
}

$(function() {
	
	//scrollpane parts
	var scrollPane = $( ".scroll-pane" ),
				scrollContent = $( ".scroll-content" );
	
	//build slider
	var scrollbar = $( ".scroll-bar" ).slider({
		orientation: 'vertical',
		value: 100,
		slide: function(event, ui){slide(ui.value)}
	});
	
	function slide(val){
		if ( scrollContent.height() > scrollPane.height() ) {
				scrollContent.css("margin-top", Math.round((scrollPane.height() - scrollContent.height())*(100-val)/100) + "px");
			} else {
				scrollContent.css("margin-top", 0);
			}
	}
	
	$('.scroll-pane').mousewheel(function(event, delta) {
		var that = $('.scroll-bar');
		var current = $(that).slider('value') + delta*2;
		if(current < $(that).slider("option", 'min')) current = $(that).slider("option", 'min');
		if(current > $(that).slider("option", 'max')) current = $(that).slider("option", 'max');
		$(that).slider('value', current);
		slide(current);
		return false;
	});
	
	$('.tv_content').mouseenter(function(){
		if($('.scroll-content').children().length<2) return false;
		$('.scroll-pane').fadeIn(200);
		if($('.scroll-content').children().length<4) $('.scroll-bar-wrap').hide();
		else $('.scroll-bar-wrap').show();
	}); 
	$('.tv_content').mouseleave(function(){
		$('.scroll-pane').fadeOut(200);
	});
	
	$('.show_img').click(function(){
		$('#changed_content').html('<img src="'+$(this).attr('href')+'" width="474" height="265">');
		$('#expotv').css('visibility', 'hidden');
		uppodSend('expotv','stop');
		$('#changed_content').show();
		return false;
	});
	$('.play_mini, .play_big').click(function(){
		$('#changed_content').hide();
		$('#expotv').css('visibility', 'visible');
		uppodSend('expotv','file:'+$(this).attr('rel')+'');
		$('.noplay').mouseleave();
		return false;
	});
	
	//loadVideo('http://sepang.lgg.ru/assets/video/', 'etv_16x9.flv');
	
	/*
	--------- MAIN NAVIGATION ---------- 
	*/
	$('#topblock div a').hover(
		function () {
			if(!$(this).parent().hasClass('hover')){
				src = 'assets/images/'+$(this).parent().attr('class')+'_hover.png';
				$('img', this).attr('src',src);
			}
		}, 
		function () {
			if(!$(this).parent().hasClass('hover')){
				src = 'assets/images/'+$(this).parent().attr('class')+'.png';
				$('img', this).attr('src',src);
			}
		}
	);
});
