$(document).ready(function(){

	 $("#sendcomment").click(function () {
        $("#sendcomment").ajaxStart(function(){
               $("#loading").html( "<img src='"+imgLoader.src+"' />");
         });
         $.ajax({
                 type: "GET",
                 data: "messtext="+encodeURI($("#commentcontent").val())+"&key="+encodeURI($("#securecode").val())+"&username="+encodeURI($("#username").val())+"&news_id="+$("#news_id").val(),
                 url: "/webapp/main/lib/sendcomments.php",
                 success: function(html){
                         var message = html.split("|");
                         if(message[1] == "inserted")
                         {
                                  $("#commentcontent").val("");
                                  $("#success").html(message[0]);
                                  $("#errors").html("");
                                  HideCommentForm();
                         }
                         else
                         {                         		$("#errors").html(message[0]);                         }
                         $("#securecode").val("");
                         $("#loading").html("");
                         updateCaptcha();
                 }

         });
    });

    $("#search_form").submit(function(){    	if($("#search").val().length < 3){    		alert(search_message);
    		return false;
    	}
    	else {    		  $("#search_form").attr("action", "/search/"+encodeURI($("#search").val()));
    	}    });

	$("#techdata tr").mouseover(function() {		if(this.rowIndex > 1){			$("td",this).addClass("over");
		}
	}).mouseout(function() {		$("td",this).removeClass("over");
	});



  });

function SwitchLanguage(lng,cnt)
{
    	$("#langs"+cnt).submit();}

function updateCaptcha()
{
        $("#commentform>img").attr("src","/captcha.html?"+Math.random());
}

function ShowCommentForm()
{
        $(document.getElementById("commentform")).fadeIn("slow");
        $("#title_link").attr("href", "javascript:HideCommentForm()");
        $("#title_link").attr("title", "Скрыть");
         $("#success").html("");
}
function HideCommentForm()
{
        $(document.getElementById("commentform")).fadeOut("slow");
        $("#title_link").attr("href", "javascript:ShowCommentForm()");
        $("#title_link").attr("title", "Показать");
}

function ShowInfoBlock(showdiv)
{	 if ($("#"+showdiv).is(":hidden")) {
        $("#"+showdiv).fadeIn("slow");
        $("#p"+showdiv).html("-&nbsp;");
      } else {
      	$("#"+showdiv).fadeOut("slow");
      	$("#p"+showdiv).html("+");
      }}