		function showWindow(id) {
			if (id == 1) {
				$('#window').css('width', '374px');
				$('#window').css('height', '420px');
			} else if (id == 3) {
				$('#window').css('width', '374px');
				$('#window').css('height', '420px');
			} 
			
			$('#window').css('left', Math.round((document.body.clientWidth - parseInt(document.getElementById('window').style.width))/2));
			$('#window').css('top', document.body.scrollTop+Math.round((document.body.clientHeight - parseInt(document.getElementById('window').style.height))/2));

			$('#container1').hide();
			$('#container2').hide();
			$('#container3').hide();

			$('#container'+id).show();
			$('#window').show();
		}
		
		function sendMessage(form) {
			//document.title='extrachance='+form.extrachance.value+' extrachance_region='+form.extrachance_region.value + " business_week=" + form.business_week.value + " competitor="+form.competitor.value;
			//document.title='extrachance='+form.extrachance.checked+' extrachance_region='+form.extrachance_region.checked + " business_week=" + form.business_week.checked + " competitor="+form.competitor.checked;
			
			$('#container2').html('<span style="font-size: 16px;">Подаждите идет отправка сообщения...</span>');
			showWindow(2);
			$.post(
				'/common/send_mail.php',
				{extrachance: form.extrachance.checked, extrachance_region: form.extrachance_region.checked, business_week: form.business_week.checked, competitor: form.competitor.checked, name: form.name.value, firm: form.firm.value, phone: form.phone.value, email: form.email.value, description: form.description.value},
				function(obj) {
					try {
						eval(obj);

						if (response == 'correct') {
							$('#container2').html('<span style="font-size: 16px;">Ваша заявка отправлена</span><br /><br />Благодарим Вас за выбор<br />Издательского дома «Экстра Шанс»');
						} else $('#container2').html('<span style="font-size: 16px;">Во время отправки заявки произошла ошибка</span>');
					} catch (error) {
						$("#container2").html('Content error: "<b>' + error + '</b>"');
					} finally {
					}
				}
			);
		}
		
		function openContent(content, width, height) {
			$('#container2').html(content);
			$('#window').css('width', width);
			$('#window').css('height', height);
			showWindow(2);
		}
		
function getClientWidth()
{
  return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientWidth:document.body.clientWidth;
}

function getClientHeight()
{
  return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientHeight:document.body.clientHeight;
}
function SetFormStyle(trId,st)
{
	objtr=document.getElementById(trId);
	objtr.style.visibility=st;
	//document.title='w'+objtr.style.width+' h='+objtr.style.height;
	if(st=='visible')
	{
		objtr.style.left=Math.round(getClientWidth()/2 - 200);
		objtr.style.top=document.body.scrollTop+Math.round(getClientHeight()/2 - 220);
	}
}
function sendTraining(form) {
	SetFormStyle('training','hidden');
	$('#resultcontent').html('<span style="font-size: 16px;">Подаждите идет отправка сообщения...</span>');
	SetFormStyle('trainresult','visible');
			$.post(
				'/common/training.php',
				{fio: form.fio.value, firm: form.firm.value, scope: form.scope.value, position: form.position.value, contact: form.contact.value, train: form.train.value, otherthem: form.otherthem.value, money: form.money.value},
				function(obj) {
					try {
						eval(obj);

						if (response == 'correct') {
							
							$('#resultcontent').html('<span style="font-size: 16px;">Ваша заявка отправлена</span><br /><br />Благодарим Вас за выбор<br />Издательского дома «Экстра Шанс»');
						} else $('#resultcontent').html('<span style="font-size: 16px;">Во время отправки заявки произошла ошибка</span>');
					} catch (error) {
						$("#resultcontent").html('Content error: "<b>' + error + '</b>"');
					} finally {
					}
				}
			);
		}