function OpenAskForm() {
     var tmp = document.getElementById("send_form_cont");
		 var tmp2 = document.getElementById("send_form_cont_iframe");
     ScreenSize();     
     tmp.style.top = (myHeight/2+myTop-200) + "px";
		 tmp2.style.top = (myHeight/2+myTop-200) + "px";
     tmp.style.display = "block";
		 tmp2.style.display = "block";
     return false;
}
function ScreenSize(){
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
    myTop = window.pageYOffset;
    myLeft = window.pageXOffset;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
    myTop = document.documentElement.scrollTop;
    myLeft = document.documentElement.scrollLeft;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
    myTop = document.body.scrollTop;
    myLeft = document.body.scrollLeft;
  }
}
function CheckForm(mf) {
  var error=0;  
  if (mf.fio.value=='' && error==0) {
    alert('Заполните, пожалуйста, поле \"ФИО\"');
		mf.fio.focus();
		error=1;
  }
	if (error==0 && !mf.disc_num.value.match(/^\d+$/)) {
    alert('Введите, пожалуйста, количество дисков цифрами');
	  mf.disc_num.select();
		mf.disc_num.focus();
	  error=1;
  }
	if (error==0 && !mf.email.value.match(/^\s*[a-zA-Z0-9._-]+\@[^\s:,]+\.[^\s:,]+$/i)) {
    alert('Заполните, пожалуйста, поле \"e-mail\" корректным e-mail адресом');
		mf.email.select();
		mf.email.focus();
		error=1;
  }
	if (error==0 && (mf.phone.value=='' || mf.phone.value.match(/[^\d \-()\+]+/i))) {
    alert('Введите, пожалуйста, корректный номер телефона');
	  mf.phone.select();
		mf.phone.focus();
	  error=1;
  }
	if (error==0 && mf.city.value=='') {
		alert('Введите, пожалуйста, ваш город');
		mf.city.focus();
		error=1;
  }
	if (error==0 && !mf.zipcode.value.match(/^\d+$/)) {
    alert('Введите, пожалуйста, ваш индекс цифрами');
	  mf.zipcode.select();
		mf.zipcode.focus();
	  error=1;
  }
	if (error==0 && mf.address.value=='') {
		alert('Введите, пожалуйста, ваш адрес');
		mf.address.focus();
		error=1;
  }
	if (error==0 && !mf.code.value.match(/^\d{4}$/)) {
    alert('Введите, пожалуйста, четыре цифры кода');
	  mf.code.select();
		mf.code.focus();
	  error=1;
  }
  if (error==0) {
    //mf.submit();		
		script = document.createElement("script");
		script.src = "/sendmail.phtml?fio="+mf.fio.value+"&disc_num="+mf.disc_num.value+"&delivery_way="+GetRadioGroupValue(mf.delivery_way)+"&email="+mf.email.value+"&phone="+mf.phone.value+"&city="+mf.city.value+"&zipcode="+mf.zipcode.value+"&address="+mf.address.value+"&subway_station="+mf.subway_station.value+"&code="+mf.code.value+"&ref="+escape(location.href);		
		document.body.appendChild(script);
  }
	return false;
}
function CloseForm() {	
	document.getElementById('send_form_cont').style.display = 'none';
	document.getElementById('send_form_cont_iframe').style.display = 'none';
	document.zakaz.reset();
	document.getElementById('captcha').src='/captcha.php?id='+(Math.round(10000*Math.random()));
}
function GetRadioGroupValue(radioGroupObj) { 
	for (var i=0; i < radioGroupObj.length; i++) 
	if (radioGroupObj[i].checked) return radioGroupObj[i].value; 
	return null; 
}

