	function checkFeedback()
	{
		var result = true;
		document.getElementById('errors').innerHTML = '';
		
		if (!document.getElementById('name').value)
		{
			result = false;
			document.getElementById('errors').innerHTML += 'Поле "Имя" пустое<br>';
		}
		if (!document.getElementById('email').value)
		{
			result = false;
			document.getElementById('errors').innerHTML += 'Поле "Email" пустое<br>';
		}
		
		var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	    var address = document.getElementById('email').value;
	    if(document.getElementById('email').value && reg.test(address) == false)
		{
			result = false;
			document.getElementById('errors').innerHTML += 'Поле "Email" неверное<br>';
		}
		if (!document.getElementById('message').value)
		{
			result = false;
			document.getElementById('errors').innerHTML += 'Поле "Пожелание и вопросы" пустое<br>';
		}
		
		if (result)
			document.getElementById('feedbackForm').submit();
	}

	function checkFeedback2()
	{
		var result = true;
		document.getElementById('errors2').innerHTML = '';
		
		if (!document.getElementById('email2').value)
		{
			document.getElementById('errors2').innerHTML += 'К сожалению, мы не сможем с Вами связаться, если Вы не укажите свой Телефон или E-Mail<br>';
		}
		else {
			document.getElementById('feedbackForm2').submit();
		}
	}

	
	function togglePopup(name)
	{
		if (document.getElementById(name).style.display == 'none')
			showPopup(name);
		else
			hidePopup(name);
	}
	
	var ua = navigator.userAgent.toLowerCase();
	var isOpera = (ua.indexOf('opera')  > -1);
	var isIE = (!isOpera && ua.indexOf('msie') > -1);
	 
	function getDocumentHeight() {
	  return Math.max(document.compatMode != 'CSS1Compat' ? document.body.scrollHeight : document.documentElement.scrollHeight, getViewportHeight());
	}
	 
	function getViewportHeight() {
	  return ((document.compatMode || isIE) && !isOpera) ? (document.compatMode == 'CSS1Compat') ? document.documentElement.clientHeight : document.body.clientHeight : (document.parentWindow || document.defaultView).innerHeight;
	}

	function keyPressHandler(e, name)
	{
		var kC  = (window.event) ? event.keyCode : e.keyCode;
		var Esc = (window.event) ? 27 : e.DOM_VK_ESCAPE
		if(kC==Esc) {
			hidePopup(name);
		}
	}
	
	function showPopup(name)
	{
		document.getElementById('blackness').style.height=getDocumentHeight()+'px';
		document.getElementById('blackness').style.display='block';
		document.getElementById(name).style.display='block';
		document.onkeypress = function (e) { keyPressHandler(e, name) }; 
	}
	
	function hidePopup(name)
	{
		document.getElementById('blackness').style.display='none';
		document.getElementById(name).style.display='none';
		delete document.onkeypress;
	}

	function showPopup2()
	{
		scroll(0,0);
		scroll(0,1);
		showPopup('popup2');
		document.getElementById('quit_counter').innerHTML = '<img height="1" width="1" style="border-style:none;" alt="" src="/setflag" />';
		try{
			_gat._getTracker("UA-16723879-1")._trackPageview('/popup/exit');
			clearTimeout(t2);
		} catch(e){}
	}

	var t1, t2;
	var xPos = 0, yPos = 0;
	function setupQuit()
	{
		return;
		window.onblur = function(){ unsetupQuit(); showPopup2(); return true; }
		document.onmousemove = function(event) {
		    var event = event || window.event;
			xPos = event.clientX;
			yPos = event.clientY;
			if (yPos < 10) {
				unsetupQuit();
				showPopup2();
			}
		};
	}

	function unsetupQuit()
	{
		window.onblur = null;
		window.onfocus = null;
		document.onmousemove = null;

		window.onbeforeunload = null;
		document.body.onclick = null;
	}

	function initQuit()
	{
		return;
		var qtext = '';
		if (/msie/i.test(navigator.userAgent) && !/opera/i.test(navigator.userAgent)) {
			qtext = 'Для того, чтобы прочитать наше специальное предложение, нужно остаться на странице, нажав Отмена / Cancel';
		}
		else if (/firefox/i.test(navigator.userAgent)) {
			qtext = 'Для того, чтобы прочитать наше специальное предложение, нужно остаться на странице, нажав Отмена / Cancel';
		}
		else {
			qtext = 'Для того, чтобы прочитать наше специальное предложение, нужно остаться на странице.';
		}

		window.onbeforeunload  = function(e){ unsetupQuit(); showPopup2();
												e = e || window.event;
												if (e) { e.returnValue = qtext; }
												return qtext;
											}

		t1 = setTimeout("unsetupQuit();", 10000);
		t2 = setTimeout("unsetupQuit(); showPopup2();", 30000);
		window.onfocus = function(){ setupQuit(); return true; }
		document.onmousemove = function(event) {
		    var event = event || window.event;
			xPos = event.clientX;
			yPos = event.clientY;
			if (yPos > 35) {
				setupQuit();
			}
			return true;
		};

		document.body.onclick = function(){ unsetupQuit(); return true; }
	}

