$(document).ready(function() {
	ImProcng = {};
	if ($('#fullscreen .fullscreen').length > 0) {
		ImProcng.fs = $('#fullscreen');
		resize();
	}

	if ($('#navigation li').length < 8) {
		$('#navigation ul').removeClass('top-lines').addClass('bottom-lines');
	}
	
	$(this).bind("contextmenu", function(e) {
		e.preventDefault();
	});
	
	resize();

	VideoJS.setupAllWhenReady();
	
	$(window).resize(function() {
		resize();
	});

	function resize() {
		var wh = $(window).height();
		
		if($('#center .image').length == 1){
			var ih = $('#center .image img').height();
			var iw = $('#center .image img').width();
			
			if(wh < 768){
				$('#center .image').css('height', '350px');
				if(ih > 350){
					nw = 350 * iw / ih;
					$('#center .image img').attr({height: '350', width: nw});
					$('#center .image img').css({height: '350', width: nw});
				}
			}else{
				$('#center .image').removeClass('small');
				$('#center .image img').attr({width: iw, height: ih});
				$('#center .image img').css({height: ih, width: iw});
			}
		}
		
		if($('#fullscreen').length == 1){
			var ww = $(window).width();

			if(ImProcng.fs.find(".fullscreen").length > 0){
				ImProcng.fs.find(".fullscreen").css("height", wh-90+"px");
				ImProcng.fs.find(".fullscreen").css("width", ww-90+"px");
				ImProcng.fs.find(".fullscreen").css("left", "30px");
				ImProcng.fs.find(".fullscreen").css("bottom", "30px");

				ImProcng.fs.find(".fullscreen img").css("margin-top","");
				ImProcng.fs.find(".fullscreen img").css("height", "100%");
				ImProcng.fs.find(".fullscreen img").css("width", "auto");
				var imgW = ImProcng.fs.find(".fullscreen img").width();	
				var imgH = ImProcng.fs.find(".fullscreen img").height();
				if(imgW == 0){
					setTimeout(function(){
						resize();
					}, 100);
				}
				if(imgW >= (ww-90)){
					
					ImProcng.fs.find(".fullscreen img").css("width", "100%");
					ImProcng.fs.find(".fullscreen img").css("height", "auto");
					var mT = (ImProcng.fs.find(".fullscreen").height()-ImProcng.fs.find(".fullscreen img").height())/2;
					ImProcng.fs.find(".fullscreen img").css("margin-top", mT+"px");
				}
			}
		}
	}
});

