var popupWin;

function help(url, name) {
  popupWin = window.open(url, name, 'scrollbars=yes,height=450,width=600');
}

function hideMe(id) {
  document.getElementById(id).style.visibility="hidden";
}

function showMe(id) {
  document.getElementById(id).style.visibility="visible";
  //setTimeOut(hideThemAll;, 5000);
}

function getElementPosition(elemId){

    var elem = document.getElementById(elemId);

    var w = elem.offsetWidth;
    var h = elem.offsetHeight;

    var l = 0;
    var t = 0;

    while (elem)
    {
        l += elem.offsetLeft;
        t += elem.offsetTop;
        elem = elem.offsetParent;
    }

    return {"left":l, "top":t, "width": w, "height":h};
}

		function showHelp(id)
		{
			/* define div with black baclground to hide all page */
//			var w = ($.browser.msie && $.browser.version == 6.0) ? ($(document).width()-20) : $(document).width();
//			alert($.browser.version);
//			alert(w);
			var background = $('<div/>');
			$(background).attr('id', 'overlayBackground').animate(
			{
				'opacity' : '.7'
			}, 1000).css(
			{
				'width' : $(document).width(),
				'height' : $(document).height()
			});
			/* append div with dark background to body element*/
			$('body').append(background);
			/* define parent of help text */
			var helpBlock = $('<div/>');
			var close = $('<div/>');
			$(close).attr('id', 'closeButton');
			$(close).text('закрыть');
//			$(helpBlock).corner();
			/* insert html from div with given id */
			$(helpBlock).html($('#'+id).html());
			$(helpBlock).append($(close));
			/* append help block to body element */
			$('body').append($(helpBlock));
			/* define help block position and style */
			h = window.pageYOffset || document.body.scrollTop || document.documentElement.scrollTop;
			$(helpBlock).attr('id', 'helpBlock').css({
				/*'top':($(document).height()/2)-(document.getElementById('helpBlock').offsetHeight/2),*/
/*				'top':document.documentElement.scrollTop + 20,*/
				'top':h+20,
/*				'top':$('body').scrollTop()+20,*/
				'left':($(document).width()/2)-(document.getElementById('helpBlock').offsetWidth/2)
			});
//			$('#helpBlock').corner();
//			$(helpBlock).corner();
			$(close).bind('click', function()
			{
				$(helpBlock).remove();
				$(background).remove();
			});

			/* by clicking a side of help block hide it and background */
			$(background).bind('click', function()
			{
				$(helpBlock).remove();
				$(this).remove();
			});
			return false;
		}

	function form_question_show(){
		var param=document.getElementById('form_question');
		if (param.style.display == 'none'){
			param.style.display='block';
		}
		else{
	        param.style.display='none';
		}
	}
	function checkmailform()
	{
	  if (document.getElementById('email').value == null)
	  {
	    alert("Заполните поле: E-mail отправителя");
	    document.getElementById('email').focus();
	    return false;
	  }
	  if (! (/^\w+[-_\.]*\w+@\w+-?\w+\.[a-z]{2,4}$/.test(document.getElementById('email').value)) )
	  {
	    alert("Введите правильный e-mail адрес");
	    document.getElementById('email').focus();
	    return false;
	  }
	  if (document.getElementById('text_message').value == '')
	  {
	    alert("Заполните поле: Текст сообщения");
	    return false;
	  }
	  return true;
	}
