(function($){$(document).ready(function(){

	

	// match

	var m = null;

	var f = function(parent){

		$("[href="+parent+"]").addClass('curr').css('text-decoration', 'none');

		var new_parent = $("[href="+parent+"]").attr('parent');

		

		if(new_parent) arguments.callee(new_parent);

	};

	

	// langs && currlink

	/*m = window.location.href.match(/(ru|lv|en)\.[a-z]*$/);

	if(m == null) m = new Array('', 'lv');

	$("[href="+m[1]+"]").addClass('curr');

	

	m = window.location.href.match(/\/([a-z]*\.[a-z]*)$/);

	if(m == null) m = new Array('', 'homelv.html');



	$("[href="+m[1]+"]")

	.addClass('curr')

	.css('text-decoration', 'none');

	

	f($("[href$="+m[1]+"]").attr('parent'));

	

	// change all lang links

	m[1] = m[1].replace(/[a-z]{2}\.[a-z]*$/, '');

	$(".lang a").each(function(){

		$(this).attr('href', window.location.href.replace(/[^\/]*$/, m[1]+$(this).attr('href')+'.html'));

	});*/

	

	// show feedabck

	$("[feedback=1]").click(function(){

		$(".feedback_layer").css({

			height: $(".page").height(),

			width: $("body").width()

		}).show();

		

		$(".feedback").css({

			top: $("body").height() * 0.5 - $(".feedback").height() * 0.5 + $(window).scrollTop() * 0.5,

			left: $(".body").width() * 0.5 - $(".feedback").width() * 0.5

		}).fadeIn();		

		

		$("[defvalue]").each(function(){

			$(this).val($(this).attr('defvalue'));

		});

		

		$("[name=file]").val('');

		return false;

	});

	

	// hide feedback

	$("[feedback=2]").click(function(){

		$(".feedback_layer").hide();

		$(".feedback").fadeOut(null, showFBbutton);

		

		return false;

	});	

	

	$("#formfilebuton").css({

		'display': 'inline',

		'top': $(".fillbreak").height() + 99,

		'left': $(".fillbreak").width() - 70

	});

	

	$(window).resize(function(){

		$("#formfilebuton").css({

		'display': 'inline',

		'top': $(".fillbreak").height() + 99,

		'left': $(".fillbreak").width() - 70

		});						  

	});

	

	// show forfile

	$("#formfilebuton").click(function(){

		$(".formfile_layer").css({

			height: $(".page").height(),

			width: $("body").width()

		}).show();

		

		$(".formfile").css({

			top: $("body").height() * 0.5 - $(".formfile").height() * 0.5 + $(window).scrollTop() * 0.5,

			left: $(".body").width() * 0.5 - $(".formfile").width() * 0.5

		}).fadeIn();		

	

		return false;

	});

	

	// hide feedback

	$("[formfile=2]").click(function(){

		$(".formfile_layer").hide();

		$(".formfile").fadeOut(null, showFBbutton);

		

		return false;

	});	

	

	// feedback form

	$("[defvalue]")

	.focus(function(){

		if($(this).val() == $(this).attr('defvalue')){

			$(this).val('');

		}

	})

	.blur(function(){

		if($(this).val() == $(this).attr('defvalue') || $.trim($(this).val()).length == 0){

			$(this).val($(this).attr('defvalue'));

		}

	});



	function showFBbutton(){

		$("[fbmessage=-1]").hide();

		$("[feedback=send]").css('display', 'inline');

		$("[feedback=send]").val($("[feedback=send]").attr('readyvalue')).attr('disabled', false);

	};

	

	function hideFBbutton(){

		$("[feedback=send]").hide();

		$("[fbmessage=-1]").css('display', 'inline');

		

		if(arguments.length < 1) setTimeout(showFBbutton, 1000);

	};

	

	//send feedback

	$("#feedbackform").submit(function(){

		var errno = 0;

		$("[defvalue]").each(function(){

			if($(this).val() == $(this).attr('defvalue') || $.trim($(this).val()).length == 0){

				errno = 1;

			}



			$(this).val($.trim($(this).val()));

		});



		if(errno){

			$("[fbmessage=-1]").html(($("[fbmessage="+errno+"]").html()));

			hideFBbutton();

			return false;

		}



		if(!/^[a-z0-9\._-]+@([a-z0-9_-]+\.)+[a-z]{2,6}$/i.test($("[name=email]").val())){

			errno = 2;

			$("[fbmessage=-1]").html(($("[fbmessage="+errno+"]").html()));

			hideFBbutton();			

			return false;

		}



		$("[feedback=send]").val($("[feedback=send]").attr('sendvalue')).attr('disabled', true);

		

		$("#feedbackframe").load(function(){

			$("[fbmessage=-1]").html(($("[fbmessage="+errno+"]").html()));

			hideFBbutton(false);

			setTimeout(function(){$("[feedback=2]").trigger('click');}, 1000);			

		});



		return true;

	});

	

	// content

	var zoom = false;

	$(".content_zoom").click(function(){

		var text = $("[zoom=1]").attr('zoomtext');

		if(!zoom){

			$(".content").css('font-size', '16px');

		} else {

			$(".content").css('font-size', '13px');

		}



		$("[zoom=1]").attr('zoomtext', $("[zoom=1]").html()).html(text);

		$("[zoom=2]").each(function(){

			var classname = $(this).attr('class');

			$(this).attr({

				'class': $(this).attr('revclass'),

				'revclass': classname

			});

		});

		zoom = !zoom;

	})

	

	

});})(jQuery);


