function admPopup(id, width, height)
{
	var url = 'popup.php?id='+id;
	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=yes,scrollbars=yes,copyhistory=no,resizable=yes,left='+winl+',top='+wint+',screenX='+winl+',screenY='+wint+'';
	
	win = window.open(url, '', features);
	win.focus();
}

function printContent(id, langid)
{
	var width = 600;
	var height = 700;
	var url = 'print.php?id='+id+'&langid='+langid;
	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=yes,left='+winl+',top='+wint+',screenX='+winl+',screenY='+wint+'';
	
	win = window.open(url, '', features);
	win.focus();
}

function product(id, langid)
{
	var url = 'product.php?id='+id+'&langid='+langid;
	var width = 700;
	var height = 500;
	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=yes,left='+winl+',top='+wint+',screenX='+winl+',screenY='+wint+'';
	
	win = window.open(url, '', features);
	win.focus();
}

function zoom(id, width, height)
{
	var url = 'image.php?id='+id;
	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=no,copyhistory=no,resizable=no,left='+winl+',top='+wint+',screenX='+winl+',screenY='+wint+'';
	
	win = window.open(url, '', features);
	win.focus();
}

function getPage(id)
{
	window.document.location.href = 'index.php?id='+id;
}

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 validateRasykite(msg, msg1)
{
	var f = document.forms['myf'];

	if(isBlank(f.name.value) || isBlank(f.email.value) || isBlank(f.msg.value))
	{
		alert(msg);
	}
	else if(!isemail(f.email.value))
	{
		alert(msg1);
	}
	else
	{
		f.submit();
	}
}

function isemail(strValue)
{
	var objRegExp  = /^[^@]+@[^@.]+\.[^@]*\w\w$/;
	return objRegExp.test(strValue);
}

function validateAnketa(step, msg, backStep, id)
{
	var f = document.forms['myf'];
	var go = false;

	if(step == 1)
	{
		var kokioms_pareigoms = f.kokioms_pareigoms.options[f.kokioms_pareigoms.selectedIndex].value;
		var pageidaujamas_atlyginimas = f.pageidaujamas_atlyginimas.value;
		go = (isBlank(f.name_surname.value) || isBlank(f.phone.value) || isBlank(f.email.value) || kokioms_pareigoms == 0 || isBlank(pageidaujamas_atlyginimas)) ? false : true;
	}
	else
	{
		go = true;
	}

	if(go == false)
	{
		alert(msg);
	}
	else
	{
		if(backStep)
		{
			f.action = 'index.php?id='+id+'&step='+backStep;
		}
		if(step == 3 && !backStep)
		{
			f.send.value = 1;
		}
		f.submit();
	}
}

function validatePoll(msg)
{
	var f = document.forms['myf'];
	var counter = 0;

	for(i = 0; i < f.elements.length; i++)
	{
		var item = f.elements[i];
		if(item.name == 'answerID' && item.checked == true) counter++;
	}
	if(counter == 0)
	{
		alert(msg);
	}
	else
	{
		f.submit();
	}
}

function spalvinimasWin(picid, langid, width, height)
{
	var url = 'popup_spalvinimas.php?picid='+picid+'&langid='+langid;
	var width = width;
	var height = height + 20;
	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=no,copyhistory=no,resizable=no,left='+winl+',top='+wint+',screenX='+winl+',screenY='+wint+'';
	
	win = window.open(url, '', features);
	win.focus();
}