$(document).ready(function(){
	/* lang change
	 * 23.12.2009
	 */

	var H = 0;
	$(window).load(
		function(){
			H = $("#lang").height();
			$("#lang").css("top",-(H - 27));
		}
	);
	var D;
	var T = 0;

	$("#lang").hover(
		function(){
			T = 0;
			clearInterval(D);
			$("#lang").animate({top:-7},400);
		},
		function(){
			D = setInterval(counter, 50);
		}
	);

	function counter() {
		if(T < 10) {
			T++;
		} else {
			T = 0;
			clearInterval(D);
			$("#lang").animate({top:-(H - 27)},400);
		}
	}

	/* textarea big font remove
	 * 24.12.2009
	 */
	$("textarea.notfocused").focus(
		function(){
			$(this).removeClass("notfocused");
            $("#text").css("background","none")
            $("#text").css("color","#000")
            $(this).text("")
		}
	);

	/* popup contacts
	 * 24.12.2009
	 */
	var xPos = 0;
	var yPos = 0;
	var cLast = 0;
	var cCurrent = 0;

	$("a.showCont").mousemove(function(e){
		xPos = e.pageX;
		yPos = e.pageY;
	});
	$("a.showCont").click(function(){
		$("#manager" + cLast).hide();
		cCurrent = $(this).attr("class").slice(16);
		cLast = cCurrent;
		$("#manager" + cCurrent).show();
		$("#manager" + cCurrent).css("top", yPos - 20).css("left", xPos + 40);
	});
	$("a.showCont").focus(function(){
		$(this).blur(0);
	});
	$("a.close").click(function(){
		$("div.contact").hide();
	});
$(".showContId").bind("click", function(){
    arClass = $(".showContId").attr("class").split(" ")
    $("#"+arClass[1]).show();
    $("#"+arClass[1]).css("top", "40px").css("left", "200px");    
})

	/* cool move
	 * 20.01.2010
	 */
	var changePos = 0;

    $("#csChange a").click(function(event) {
        event.preventDefault();
		$(this).blur();

		if(changePos === 0) {
			$("#csChange a").text("Скрыть форму");
			changePos = 1;
			$("#coolScroll").animate({left:-612},600);
		} else {
			$("#csChange a").text("Задать вопрос");
			$("#coolScroll").animate({left:0},600);
			changePos = 0;
		};
	});

        /* -----------------------------------------------------------
     * tabs widget by IonDen
     * v. 2.1
     * 01.03.2010
     * rev. 22
     * depends on jQuery 1.4
     */

    var tabsNum = $(".tabs a").length;
    var tabHash = document.location.hash;
    if(tabHash === "") {tabHash = "#tab0"};
    var currentTab = parseInt(tabHash.slice(4));
    $(".tabs a[href='" + tabHash + "']").addClass("on");

    $(".tabs a").click(function() {
        $(".tabs a").removeClass("on");
        $(this).addClass("on");
        $(this).blur(0);
        tabHash = $(this).attr("href");
        currentTab = parseInt(tabHash.slice(4));
        setTabs();
    });

    function setTabs() {
        $("div.tab").hide();
        $("#tabCont" + currentTab).show();
    };
    setTabs();

});
