$(function() {
$('.helpme').click(function() {
	if (!$(this).hasClass('disabled')) {
		$(this).addClass('disabled'); 
		$(this).next().fadeIn(200);	
	}
	return false;
});

$('#change-promo').click(function() {
	if ($("#image-wrap .image.active").next().length>0) var next = $("#image-wrap .image.active").next();
	else var next = $("#image-wrap .image:first");
	var first = $("#image-wrap .image.active");
	$(first).fadeOut(300);
	$(next).fadeIn(300);
	$(first).toggleClass("active");
	$(next).toggleClass("active");	
	
	if ($(".promo-text.active").next().length>0) var next = $(".promo-text.active").next();
	else var next = $(".promo-text:first");
	var first = $(".promo-text.active");
	$(first).fadeOut(300, function() { $(next).fadeIn(300); });
	$(first).toggleClass("active");
	$(next).toggleClass("active");	
	
	$("#h2-title").text($(next).find(".title").text());
	
	
	
	return false;
});

});


//Prilipanie obratnoi svyazi
$(document).ready(function(){
var obj = $(".right2 .write_us");
var height = $("#yakor").offset().top+$("#yakor").height();
var mayak = $("#mayak").offset().top;
var itog = mayak - height;
 
if(itog > "0"){
$(obj).animate({top: itog},200);
}

$(window).scroll(function () {
    mayak = $("#mayak").offset().top;
	itog = mayak - height;
	if(itog > "0"){
		$(obj).stop();
		$(obj).animate({top: itog},200);
	}
	else{
		$(obj).stop();
		$(obj).animate({top:"0"},200);
	}
}); 
});


$(document).ready(function(){

function str_replace(search, replace, subject) {
    return subject.split(search).join(replace);
} 

function ownformat(str) {
	if (str==0) return "";
	var newstr="";
	str = parseInt(str)+"";
	for (i=0;i<str.length;i=i+3) {
		j=str.length-i;
		if (j<3) newstr = str.substring(0,j) + " " + newstr;
		else newstr = str.substring(j-3,j) + " " + newstr;
	}
	return newstr;
}


function sec2() {
	var price = str_replace(' ', '', $("#supPrice").text());
	var price = parseInt(price) + 1;
	price = ownformat(price);
	$("#supPrice").text(price);	
}	
setInterval(sec2, 1000);
}); 

