$(document).ready(function(){
    $("#but2").click(function () {
        var user_name = $("#user_name").val();
        var email = $("#email").val();
        var secret_code = $("#secret_code").val();
        var user_lang = $("#lang").val();
        var question_form = $("#question_form").val();
        var sess_code = $("#sess_code").val();
        if(user_name == "")
        {
        	if(user_lang == 'ru')
        	{
           		$("#error_place").html("Вы не ввели своё имя!");
           	}
           	else
           	{           		$("#error_place").html("Enter your name!");
           	}
        }
        else if(email == "")
        {
        	if(user_lang == 'ru')
        	{
           		$("#error_place").html("Вы не ввели свой E-Mail!");
           	}
           	else
           	{           		$("#error_place").html("Enter your E-Mail!");
           	}
        }
        else if(secret_code == "")
        {
        	if(user_lang == 'ru')
        	{
           		$("#error_place").html("Вы не ввели секретный код!");
         	}
         	else
         	{         		$("#error_place").html("Enter secret code!");
         	}
        }
        else if(secret_code != sess_code)
        {
        	if(user_lang == 'ru')
        	{
           		$("#error_place").html("Вы ввели не верный секретный код!");
           	}
           	else
           	{           		$("#error_place").html("You entered wrong secret code!");
           	}
        }
        else
        {
           $("#error_place").html("<img src=\"images/loadingAnimation.gif\">");
           $("#user_name").val("");
           $("#email").val("");
           $("#secret_code").val("");

	          JsHttpRequest.query(
			     "skin/php/writeQuestion.php",
			     {
			     "question_form": question_form,
			     "user_name": user_name,
			     "email": email
			   	  },
				   function (result,errors)
				   {
					   if (result)
					   {
					   		var ok = result.ok;
					   		if(ok == 'ok')
					   		{
					   			if(user_lang == 'ru')
        						{
					   				$("#question_form").val("Спасибо за Ваш вопрос.");
					   			}
					   			else
					   			{					   				$("#question_form").val("Thank you for your question.");
					   			}
					   			setTimeout("$(\"#close\").trigger(\"click\")", 2000);
					   		}
					   		else
					   		{
	                            $("#error_place").html("<img src=\"images/loadingAnimation.gif\">");
					   		}
					   }
					   else
					   {

					   }
			   	   },
					true
				)
        }
    });

    var mineCooc = $.cookie("hoverShowMenu");
    if(mineCooc == 1)
    {
    	var menu_dev = $("#top_menu_dev").html();

    	$("#temp_top_menu").val("2");
     	$("#top_menu_place").hide();
      	$("#top_menu_place").html(menu_dev);
	    $("#top_menu_place").show();
	    $("#top_menu_place").css("text-align","right");
    }
    else
    {

    }

    $("#head_arch").hover(function(){
    	var menu_arch = $("#top_menu").html();
    	if($("#temp_top_menu").val() == 1)
    	{
    	}
    	else
    	{
    	    $("#temp_top_menu").val("1");            //$("#top_menu_place").hide("slide", {}, 500);
            $("#top_menu_place").hide();
            $("#top_menu_place").html(menu_arch);
	        $("#top_menu_place").show("slide", {direction:"horizontal"}, 500);
	        $("#top_menu_place").css("text-align","left");

	        $.cookie("hoverShowMenu", null);
    	}
    	$(this).css("cursor","pointer");
	},
	function()
	{

	}
	);

	$("#head_devel").hover(function(){
		var menu_dev = $("#top_menu_dev").html();
    	if($("#temp_top_menu").val() == 2)
    	{

    	}
    	else
    	{
    	    $("#temp_top_menu").val("2");
            //$("#top_menu_place").hide("slide", {}, 500);
            $("#top_menu_place").hide();
            $("#top_menu_place").html(menu_dev);
	        $("#top_menu_place").show("slide", {}, 500);
	        $("#top_menu_place").css("text-align","right");

	        $.cookie("hoverShowMenu", "1");
    	}
    	$(this).css("cursor","pointer");
	},
	function()
	{

	}
	);

	$("#ok_but").hover(function(){
    	$(this).css("cursor","pointer");
	},
	function()
	{

	}
	);

	$("#ok_but").click(function(){
       var question_form = $("#question_form").val();
       var user_lang = $("#lang").val();
       if(user_lang == 'ru')
       {
	       if(question_form == "" || question_form == "впишите ваш вопрос" || question_form == "Спасибо за Ваш вопрос.")
	       {
	       }
	       else
	       {
	         $("#links").trigger("click");
	         $("#error_place").html("");
	       }
	}
	else
	{           if(question_form == "" || question_form == "Type your question" || question_form == "Thank you for your question.")
	       {

	       }
	       else
	       {
	       		 $("#links").trigger("click");
	         	 $("#error_place").html("");
	       }
	}
	});
});

function setActivity(id)
{
	var span_activity = "act_"+id;

	JsHttpRequest.query(
     "skin/php/setActivity.php",
     {
     "id": id
   },
	   function (result,errors)
	   {
		   if (result)
		   {
		   		var activity_new = result.activity_new;
	            if(activity_new == 1)
	            {
	            	document.getElementById(span_activity).innerHTML="<img src=\"images/active.png\" border=0 alt=\"Отключить\" title=\"Отключить\">";
	            }
	            else
	            {
                   document.getElementById(span_activity).innerHTML="<img src=\"images/unactive.png\" border=0 alt=\"Включить\" title=\"Включить\">";
	            }
		   }
		   else
		   {

		   }
   	   },
		true
	)
}
