window.onload=forms_protect;

function forms_protect() {
	var i;
	for (i=0; i<document.forms.length; i++) {
		if (!document.forms[i].target && !document.forms[i].onsubmit) {
			document.forms[i].onsubmit = forms_protect_handler;
		}
		document.forms[i].blocked = false;
	}
}

function forms_protect_handler(e) {
	if (!e) e = window.event;
	var src = e.target ? e.target : e.srcElement;
	var i;
	for (i=0; i<src.elements.length; i++)
		if (src.elements[i].type=='submit')
			src.elements[i].value = 'Ждите, идет отправка...';
	
	if (src.blocked) {
		alert('Повторная попытка отправки данных блокирована.');
		return false;
	} else {
		src.blocked=true;
		return true;
	}
}

function imgshow(img,title) {
	var popup=window.open('','','top=30,left=30,personalbar=0,maximize=1,resizable=0,toolbar=0,location=0,status=0,menubar=0,scrollbars=0,width=150,height=150');
	popup.document.open();
	popup.document.write("<html><head><title>"+title+"</title></head><body style='margin:0px;padding:0px' onload='loaded=1; window.focus();'><table align=center width=100% height=100%><tr valign=center align=center><td><img id=img align=center src='"+img+"'><br>"+title+"</td></tr></table><script>var loaded = 0; var img=document.getElementById(\"img\"); function check_img_load() { if (img.width && img.height && (img.width>100 || img.height>50)) window.resizeTo(img.width+50,img.height+100); else if (!loaded) setTimeout('check_img_load();',200); }  check_img_load(); window.focus(); </"+"script></body></html>");
	popup.document.close();
}

