// Form_class validate functions
var ErrFound = false;

function $(n){return document.getElementById(n)}

function ErrorMsg (elem, text) {
	if(ErrFound) return;
	window.alert('Incorrect value of field: ' + text);
	if(elem.type !='select-one') elem.select();
	elem.focus();
	ErrFound = true;
}

function validPattern(item, pattern) {
	var valid = new RegExp(pattern, 'g');
	if(!valid.exec(item))
		return false;
	return true;
}

function showHideForm(eid)
{
	if($(eid).style.display=='inline')
		$(eid).style.display='none'; 
	else
		$(eid).style.display='inline';
}

function rand(n) {
	return (Math.floor(Math.random() * n + 1));
}

function imageCodeReoload() {
	$('imageCode').src='images/captcha.php?captcha=' + rand(9999);
}

function OpenPopup(name,width,height,top,left)
{
	popup=window.open('',name,'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width='+width+',height='+height+',top='+top+',left='+left);
	popup.focus();
}


