function ContactsButtonClick(lang) {                  				
	if($('#cont_block').html() === null) {
		$('body').append('<div id="cont_block" class="popup_block" style="display: none; z-index: 1000; position: absolute; left:50%; top:40px; width: 620px; margin:0px 0px 0px -310px;"></div>')
	}
	
	if($('#ask_questions-dark').html() === null) {
		$('body').append('<div id="ask_questions-dark" style="display: none; top: 0px; left: 0px; z-index: 999; position: absolute; width: 100%; height: 100%; background: #1D69C9 none repeat scroll 0 0; opacity: 0.5; -moz-opacity: 0.5; filter:alpha(opacity=50);"></div>');
	}
	
	
	
	$scrollTop = $(window).scrollTop();
	$('#cont_block').css('top',$scrollTop + ($(window).height()/2) - 150); 
	
	$('#ask_questions-dark').css('height',$(document).height());
	$(function() {
		$.get(	"/system/php/ask__questions.php",
				{"step": "0", "lang": lang, "rand": Math.random()},
				function(data) { AsksAjaxLoad(data) }
		);
	});
}

function contSelectingSteps(step, prev, lang) {
	$(function() {
		$.get("/system/php/ask__questions.php", {"step": step, "prev" : prev, "lang":lang, "rand": Math.random() }, function(data){ AsksAjaxLoad(data)});
	});
}

function ContactsButtonClickRes(lang) {                  				
	if($('#cont_block').html() === null) {
		$('body').append('<div id="cont_block" class="popup_block" style="display: none; z-index: 1000; position: absolute; left:50%; top:40px; width: 620px; margin:0px 0px 0px -310px;"></div>')
	}
	
	if($('#ask_questions-dark').html() === null) {
		$('body').append('<div id="ask_questions-dark" style="display: none; top: 0px; left: 0px; z-index: 999; position: absolute; width: 100%; height: 100%; background: #1D69C9 none repeat scroll 0 0; opacity: 0.5; -moz-opacity: 0.5; filter:alpha(opacity=50);"></div>');
	}
	
	
	
	$scrollTop = $(window).scrollTop();
	$('#cont_block').css('top',$scrollTop + ($(window).height()/2) - 150); 
	
	$('#ask_questions-dark').css('height',$(document).height());
	$(function() {
		$.get(	"/system/php/ask__questions_res.php",
				{"step": "0", "lang": lang, "rand": Math.random()},
				function(data) { AsksAjaxLoad(data) }
		);
	});
}

function contSelectingStepsRes(step, prev, lang) {
	$(function() {
		$.get("/system/php/ask__questions_res.php", {"step": step, "prev" : prev, "lang":lang, "rand": Math.random() }, function(data){ AsksAjaxLoad(data)});
	});
}

function AsksAjaxLoad(data) {
	$(function() {
		// показываем подложку
		$('#ask_questions-dark').show();
		$("#cont_block").html("");
		$("#cont_block").css({"display":"block"});
		$("#cont_block").html(data);
	});
}

function closeQuestions() {
	$(function() {
		// скрываем подложку
		$('#ask_questions-dark').css({"display":"none"});
		$("#cont_block").css({"display":"none"});
	});
}


$(document).keyup(function(event){
	var keycode = event.keyCode;
	if(keycode == 27 && $('#ask_questions-dark').css('display')!='none') {
		closeQuestions();
	}
});
