	
	$(document).ready(function() {

			// reworking tabs functionality...
			$(".video_tab_header").click(function() {
				$(".video_tab_header").removeClass("on").addClass("off");
				$(this).removeClass("off").addClass("on");
				var tabID = parseInt($(this).attr("id").replace("videoTabHeader_", ""));

				hide("POST_A_COMMENT");

/*
				if (tabID == 2)
				{
					$(".video_tabs").css({'height': '415px'});
					$("#video_tabs_holder").css({'height': '370px'});
					$(".video_tab_content").css({'height': '370px'});
					if (!$("#videoTabContent_2").is(":visible"))
					{
						$("#video_page_tabs_outer").animate({ 'height': '453px' }, 500);
					}
				}
				else
				{
					// if transcript tabs WAS active...
					if ($("#videoTabContent_1").is(":visible") || $("#videoTabContent_2").is(":visible"))
					{
						// when animate is over, setting all 'height' properties back
						$("#video_page_tabs_outer").animate({ 'height': '268px' }, 500, function() {
							$(".video_tabs").css({'height': '230px'});
							$("#video_tabs_holder").css({'height': '185px'});
							$(".video_tab_content").css({'height': '185px'});
						});
					}
				}
*/
				$(".video_tab_content").hide();
				$("#videoTabContent_" + tabID).show();

			});

		});

		function refreshCaptcha()
		{
			captchaElm = "captcha_image";

			if(document.getElementById(captchaElm))
			{
				randInt = Math.floor(Math.random()*10000);
				document.getElementById(captchaElm).src = "/fitch/resources/captcha/index.php?" + randInt;
			}

			if (captchaTextbox = document.getElementById("captcha"))
			{
				captchaTextbox.value = "";
			}

			return true;
		} // /refreshCaptcha()

		function editComment(id)
		{
			document.getElementById("POST_A_COMMENT_TITLE").innerHTML = "EDIT COMMENT";
			show("POST_A_COMMENT");
			/*$(".video_tabs").css({'height': '415px'});
			$("#video_tabs_holder").css({'height': '370px'});
			$(".video_tab_content").css({'height': '370px'});
			$("#video_page_tabs_outer").animate({ 'height': '453px' }, 500);*/
			document.add_comment.parent_id.value=0;
			document.add_comment.comment_id.value=id;
			document.add_comment.comment.value=document.getElementById('comment_' + id).innerHTML.replace(/<br>/gi, "");
			document.add_comment.button_add_comment.value='SAVE COMMENT';
			return false;
		}

		function cancelComment()
		{
			/*
			$("#video_page_tabs_outer").animate({ 'height': '268px' }, 500, function() {
				$(".video_tabs").css({'height': '230px'});
				$("#video_tabs_holder").css({'height': '185px'});
				$(".video_tab_content").css({'height': '185px'});
			});
			*/
			hide("POST_A_COMMENT");
			document.add_comment.parent_id.value=0;
			document.add_comment.comment_id.value=0;
			document.add_comment.comment.value='';
			document.add_comment.button_add_comment.value='ADD COMMENT';
			return false;
		}

		var time = new Array();
		var timeLimit = 120000; //120000;

		function startTime(id, time_to_edit)
		{
			time[id] = new Array();
			time[id]["t"] = new Date();
			time[id]["l"] = time_to_edit ? time_to_edit*1000 : timeLimit;
			time[id]["o"] = setInterval("updateTime(" + id + ")",500);
		}

		function updateTime(id)
	  {
	  	showTime(id);
	  	if(new Date() - time[id]["t"] >= time[id]["l"])
	  	{
	  		document.getElementById('comment_edit_' + id).innerHTML='';
			  clearInterval(time[id]["o"]);
			}
	  }

	  function showTime(id)
	  {
	  	var t = time[id]["l"] - (new Date() - time[id]["t"]);
	  	if(t >= 0)
	  	{
	  		t = parseInt(t/1000);
	  		var m = parseInt(t/60);
	  		var s = parseInt(t-m*60);
	  		ss = s > 1 ? ' seconds' : ' second';
	  		s = s > 0 ? ' ' + s + ss : '';
	  		mm = m > 1 ? ' minutes' : ' minute';
	  		m = m > 0 ? ' ' + m + mm : '';
	  		document.getElementById('comment_time_' + id).innerHTML = m + s;
			}
	  }

		var username = '{/literal}{$smarty.session.username}{literal}';
		var already_rated = '{/literal}{$parameters.already_rated}{literal}';

		function sortVideos(param)
		{
			document.getElementById('sort_param').value = param;
			document.getElementById('sort_form').submit();
			return false;
		}
