// JavaScript Document
function clearSearchText(thefield){
	if (thefield.value=="Поиск")
		thefield.value = "";
}

function returnSearchText(thefield){
	if(thefield.value==""){
		thefield.value = "Поиск";
	}
}

function clearMailText(thefield){
	if (thefield.value=="Введите E-mail")
		thefield.value = "";
}

function returnMailText(thefield){
	if(thefield.value==""){
		thefield.value = "Введите E-mail";
	}
}

function clearPasswordText(thefield){
	if (thefield.value=="Введите пароль")
		thefield.value = "";
}

function returnPasswordText(thefield){
	if(thefield.value==""){
		thefield.value = "Введите пароль";
	}
}

function clearNameText(thefield){
	if (thefield.value=="Введите ФИО")
		thefield.value = "";
}

function returnNameText(thefield){
	if(thefield.value==""){
		thefield.value = "Введите ФИО";
	}
}

function clearQuestionText(thefield){
	if (thefield.value=="Задайте вопрос")
		thefield.value = "";
}

function returnQuestionText(thefield){
	if(thefield.value==""){
		thefield.value = "Задайте вопрос";
	}
}

function ResizeFooter(){
	var bh = $("body").height();
	var mh = $("#main").height() + parseInt($("#main").css('paddingTop')) + parseInt($("#main").css('paddingBottom'));
	var fh = $("#footer").height() + parseInt($("#footer").css('paddingTop')) + parseInt($("#footer").css('paddingBottom'));
	if (bh > mh + fh) {
		$("#footer").css({"position":"absolute", "left":"0px", "bottom":"0px", "width":"100%"});
	} else {
		$("#footer").css({"position":"relative", "width":"auto"});
	}
}

$(function(){
	$("#slider1").anythingSlider();
	$("#slider2").anythingSlider();
	$("#slider3").anythingSlider();
	$("#slider4").anythingSlider();
	$("#slider5").anythingSlider();

	$('#menu_01 li,#menu_02 li').hover(function(){
		$(this).addClass('hover');
	},function(){
		$(this).removeClass('hover');
	});

	$('#menu_02 li:last-child').css({borderRight:'0'});
});
function actual_initCallback(carousel) {
    carousel.buttonNext.bind('click', function() {
        carousel.startAuto();
    });

    carousel.buttonPrev.bind('click', function() {
        carousel.startAuto();
    });

    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });
	carousel.buttonNext.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });
	carousel.buttonPrev.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });
};
jQuery(document).ready(function() {
	jQuery("#actual_gallery").jcarousel({
		auto: 2,
		wrap: 'circular',
		initCallback: actual_initCallback
	});
	jQuery("#doclad_gallery").jcarousel({
		wrap: 'circular'
	});
	jQuery("#experience_gallery").jcarousel({
		wrap: 'circular'
	});
	jQuery("#video_gallery").jcarousel({
		vertical: true,
		wrap: 'circular'
	});
});

$(window).load(function(){
	ResizeFooter();
	$(".scroll").jScrollPane();
	$(".thumbNav").each(function(){
		var pw = 0;
		$(this).find("li").each(function(){
			var w = $(this).width();
			pw += w;
		});
		$(this).css({"width":pw + "px"});
	});
	$(".jcarousel-skin-doclad ul li a span").hover(function() {
		$(".jcarousel-skin-doclad ul li a span").removeClass("mask");
		$(this).addClass("mask");
	}, function(){
		
	});
	$(".jcarousel-skin-experience ul li a .border").hover(function() {
		$(".jcarousel-skin-experience ul li a .border").removeClass("mask");
		$(".jcarousel-skin-experience ul li .date").removeClass("hover");
		$(this).addClass("mask");
		$(this).prev().prev().addClass("hover");
	}, function(){
		
	});
	
	$("#add").live('click', function(){
		if ($(this).is(".add_on")) {
			$(this).removeClass("add_on");
			$(this).parent().css({"height":"20px"})
		} else {
			$(this).addClass("add_on");
			$(this).parent().css({"height":"184px"})
		}
		return false;
	});
});

$(window).resize(function(){
	ResizeFooter();
});
