function cwin(f,w,h,s){
var t=(screen.height)?(screen.height-h-50)/2:100;
var l=(screen.width)?(screen.width-w)/2:100;
(t<0||t>=screen.height)?t=0:t=t;
(l<0||l>=screen.width)?l=0:t=t;
window.open(f,'_blank','width='+w+',height='+h+',status=0,menubar=0,location=0,resizable=0,directories=0,top='+t+',left='+l+',toolbar=0,scrollbars='+s)}
function isEmpty(str){str=this!=window?this:str;return (str.replace(/^\s+/g, '').replace(/\s+$/g, '')=='')?true:false}
function isEmail(str){return /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/.test(str)}

function validate(formObj){ alert(1);
    errorMessage = 'Необходимо заполнить все поля.';
    wrongEmailMessage = 'Введите правильный E-mail.';

    requestUri = String(document.location);
    if (requestUri.indexOf('/eng/') > 0){
        errorMessage = 'Please fill all the required fields out.';
        wrongEmailMessage = 'Wrong E-mail address';
    }

	for (i=0;i<formObj.length;i++){
		if (formObj[i].className.indexOf("mandatory")!='-1' && isEmpty(formObj[i].value)){
			alert (errorMessage);
			formObj[i].focus();
			return false;
		}
		if (formObj[i].className.indexOf("email")!='-1' && !isEmpty(formObj[i].value) && !isEmail(formObj[i].value)){
			alert (wrongEmailMessage);
			formObj[i].focus();
			return false;
		}
	}
	if (formObj.referrer) formObj.referrer.value=document.referrer;
	return true;
}
