i = 0;
function wattermark() {
	$('*[class^="watterm"]').each(function() {											 
		$(this).clone(true).insertBefore(this).attr('class', $(this).attr('class') + '_w');
	});
}
jQuery(document).ready(function() {wattermark();});

function open_close(id) {
	$('#' + id).toggle();
}

function input_text_blink(id, text) {
	$('#'+id).val(text);
	$('#'+id).focus(function(){
		if($(this).val() == text) $(this).val('');
	});
	$('#'+id).blur(function(){
		if($(this).val() == '') $(this).val(text);
	});
}

function select_input(el) {
	$(el).attr('class', $(el).attr('class')+'_focus');
}

function unselect_input(el) {
	$(el).attr('class', $(el).attr('class').replace(/_focus/, ''));
}

function message(text) {
	// создаем элемент с сообщением
	$('#maket_main').prepend('<div id="message"></div>');
	elem = $("#message");
	elem.css('display', 'none');
	// -------------
	elem.html(text).fadeIn(300);
	var offset_elem = elem.offset(); // координаты сообщения
	var window_top = $(window).scrollTop(); // координаты вертикального скролла браузера
	if(offset_elem.top - 100 < 0) top_elem = 0; else top_elem = offset_elem.top;
	$.scrollTo(top_elem, 800); // скролл к сообщению
	// анимация сообщения
	elem.html(text)
		.animate({opacity:0.3}, 250)
		.animate({opacity:1}, 250)
		.animate({opacity:0.3}, 250)
		.animate({opacity:1}, 250)
		.animate({opacity:0.3}, 250)
		.animate({opacity:1}, 250)
		.animate({opacity:0}, 350, function(){
			$(this).remove();
			$.scrollTo(window_top, 800);
		});
}

$("a[href*=#]:not([href=#])").bind('click', function (event) {
    var thisHash = this.hash;
    var targetOffset = $(thisHash).offset().top;
    $("html,body").stop().animate({
        scrollTop: targetOffset
    }, 1100 );
    location.hash = thisHash;
    event.preventDefault();
});
