function newWindow(url, width, height)
{
	var winl = (screen.width - width) / 2;
	var wint = (screen.height - height) / 2;
	var features = 'width='+width+',height='+height+',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,copyhistory=no,resizable=no,left='+winl+',top='+wint+',screenX='+winl+',screenY='+wint+'';
	
	win = window.open(url, '', features);
	win.focus();
}

function isBlank(val){
	if(val==null){return true;}
	for(var i=0;i<val.length;i++) {
		if ((val.charAt(i)!=' ')&&(val.charAt(i)!="\t")&&(val.charAt(i)!="\n")&&(val.charAt(i)!="\r")){return false;}
		}
	return true;
	}

function checkLogin(x, str)
{
	if(isBlank(x.form.username.value) || isBlank(x.form.password.value))
	{
		alert(str);
		return false;
	}
	return true;
}

function checkPool(x, text)
{
	var counter = 0;
	for(i = 0; i < x.form.elements.length; i++)
	{
		var item = x.form.elements[i];
		if(item.name == 'answerID' && item.checked == true) counter++;
	}
	if(counter == 0)
	{
		alert(text);
		return false;
	}
	return true;
}

function checkRegistration(x, str)
{
	var opVal = document.getElementById('asmuo');
	var val = opVal.options[opVal.selectedIndex].value;

	if(val == 0 && (isBlank(x.form.name.value) || isBlank(x.form.surname.value) || isBlank(x.form.telephone.value) || isBlank(x.form.email.value)))
	{
		alert(str);
		return false;
	}
	else if(val == 1 && (isBlank(x.form.name.value) || isBlank(x.form.surname.value) || isBlank(x.form.uabname.value) || isBlank(x.form.uabcode.value) || isBlank(x.form.uabpvmcode.value) || isBlank(x.form.position.value) || isBlank(x.form.adress.value) || isBlank(x.form.city.value) || isBlank(x.form.telephone.value) || isBlank(x.form.email.value)))
	{
		alert(str);
		return false;
	}
	else
	{
		return true;
	}
}

function checkPartnerRegistration(x, str)
{
	if(isBlank(x.form.partner_name.value) || isBlank(x.form.partner_surname.value))
	{
		alert(str);
		return false;
	}
	return true;
}

function checkSentNewPass(x, str)
{
	if(isBlank(x.form.email.value))
	{
		alert(str);
		return false;
	}
	return true;
}

function changeReq(x)
{
	var val = x.options[x.selectedIndex].value;
	var setas = (val == 1) ? '' : 'none';

	for(var i = 1; i < 7; i++)
	{
		var el = document.getElementById('req_'+i);
		if(el)
		{
			el.style.display = setas;
		}
	}
}

function checkMemberRegistration(x, str, str_2)
{
	var opVal = document.getElementById('asmuo');
	var val = opVal.options[opVal.selectedIndex].value;

	if(val == 0 && (isBlank(x.form.username.value) || isBlank(x.form.password.value) || isBlank(x.form.repeat_password.value) || isBlank(x.form.name.value) || isBlank(x.form.surname.value) || isBlank(x.form.telephone.value) || isBlank(x.form.email.value)))
	{
		alert(str);
		return false;
	}
	else if(val == 1 && (isBlank(x.form.username.value) || isBlank(x.form.password.value) || isBlank(x.form.repeat_password.value) || isBlank(x.form.name.value) || isBlank(x.form.surname.value) || isBlank(x.form.uabname.value) || isBlank(x.form.uabcode.value) || isBlank(x.form.uabpvmcode.value) || isBlank(x.form.position.value) || isBlank(x.form.adress.value) || isBlank(x.form.city.value) || isBlank(x.form.telephone.value) || isBlank(x.form.email.value)))
	{
		alert(str);
		return false;
	}
	else
	{
		if(x.form.password.value != x.form.repeat_password.value)
		{
			alert(str_2);
			return false;
		}
		return true;
	}
}

function setShowMonth(id)
{
	var f = document.getElementById('month_form');
	var o = document.getElementById('month');
	var oi = o.options[o.selectedIndex].value;
	
	var url = (oi == '') ? 'index.php?id='+id : 'index.php?id='+id+'&month='+oi;

	document.location.href = url;
}
