
function checkstep3() {

	if($('tutuke').value == '') {
		alert('Nincs megadva a szállítási mód!');
		return false;
	}

	return true;
}

function changepic(thisImg, thisImg2) {
	document.getElementById(thisImg).src= thisImg2;
}

function checkQsearch() {

	if($('txtqsearch').value == '') {
		alert('Keresés feltétel nincs megadva!');
		return false;
	}

	return true;
}


function checkUserForm() {

	if($('txtpassw').value == '') {
		alert('Jelszó megadása kötelező!');
		return false;
	}

//	if($('txtpassw').value != $('txtpassw2').value) {
//		alert('Nem egyezzik a jelszó!');
//		return false;
//	}

	if($('txtEmail').value == '') {
		alert('E-mail cím megadása kötelező!');
		return false;
	}

	if(!emailCheck($('txtEmail').value)) {
		alert('Érvénytelen email cím');
		return false;
	}

	if($('txtInvName').value == '') {
		alert('Számlázási név megadása kötelező');
		return false;
	}

	if($('txtInvZip').value == '') {
		alert('Irányítószám megadása kötelező!');
		return false;
	}

	if($('txtInvTown').value == '') {
		alert('Város megadása kötelező!');
		return false;
	}

	if($('txtInvStreet').value == '') {
		alert('Utca megadása kötelező!');
		return false;
	}

	if($('txtInvStreet').value == '') {
		alert('Ország megadása kötelező!');
		return false;
	}

	return true;
}


function checkUserForm2() {

	if($('txtpassw3').value == '') {
		alert('Jelszó megadása kötelező!');
		return false;
	}

	if($('txtpassw3').value != $('txtpassw2').value) {
		alert('Nem egyezzik a jelszó!');
		return false;
	}

	if($('txtusername2').value == '') {
		alert('E-mail cím megadása kötelező!');
		return false;
	}

	if(!emailCheck($('txtEmail').value)) {
		alert('Érvénytelen jeszó');
		return false;
	}

	if($('txtInvName').value == '') {
		alert('Számlázási név megadása kötelező');
		return false;
	}

	if($('txtInvZip').value == '') {
		alert('Irányítószám megadása kötelező!');
		return false;
	}

	if($('txtInvTown').value == '') {
		alert('Város megadása kötelező!');
		return false;
	}

	if($('txtInvStreet').value == '') {
		alert('Utca megadása kötelező!');
		return false;
	}

	if($('txtInvStreet').value == '') {
		alert('Ország megadása kötelező!');
		return false;
	}

	return true;
}

function copyname() {
	$('txtInvName').value = $('txtFirstName').value + ' ' + $('txtLastName').value;
	$('txtDelName').value = $('txtFirstName').value + ' ' + $('txtLastName').value;
}

function copyzip() {
	$('txtDelZip').value = $('txtInvZip').value;
}

function copytown() {
	$('txtDelTown').value = $('txtInvTown').value;
}

function copystreet() {
	$('txtDelStreet').value = $('txtInvStreet').value;
}

function copycountry() {
	$('txtDelCountry').value = $('txtInvCountry').value;
}

function doCheckNumber(field) {
	if(field.value != '')
	{
		if(isNaN(field.value)) {
    	alert('A megadott érték nem szám.');
    	field.focus();
   	 	field.select();
    	return false;
 		}
	}
	return true;
}

function checkLoginForm()  {

	var cname = document.getElementById('txtLoginDisplay');

	if(cname) {
		if(cname.value == '') {
			alert("A név megadása kötelező!");
			return false;
		}
	}
	if(document.getElementById('txtLoginName').value == "") {
		alert("A felhasználónév megadása kötelező!");
		return false;
	}

	if(document.getElementById('txtLoginPassword').value == "") {
		alert("A jelszó nem lehet 0 hosszúságú!");
		return false;
	}

	var field = document.getElementById('txtLoginPassword2');

	if(field) {
		if(field.value != document.getElementById('txtLoginPassword').value) {
			alert("A megadott jelszavak nem egyeznek!");
			return false;
		}
	}

	return true;
}

function doCheckNumber(field) {
	if(field.value != '')
	{
		if(isNaN(field.value)) {
    	alert('A megadott érték nem szám.');
    	field.focus();
   	 	field.select();
    	return false;
 		}
	}
}

function delConfirm(url, strmsg) {
	//var strmsg = '';

	if(strmsg == '') strmsg = "Biztos törli a kiválasztott tételt?";

	if(confirm(strmsg))
		location.href = url;
}


function emailCheck(emailStr)
{
	var checkTLD=1;
	var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;
	var emailPat=/^(.+)@(.+)$/;
	var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
	var validChars="\[^\\s" + specialChars + "\]";
	var quotedUser="(\"[^\"]*\")";
	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
	var atom=validChars + '+';
	var word="(" + atom + "|" + quotedUser + ")";
	var userPat=new RegExp("^" + word + "(\\." + word + ")*(\\.)*$");
	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
	var matchArray=emailStr.match(emailPat);
	if (matchArray==null)
		return false;

	var user=matchArray[1];
	var domain=matchArray[2];
	for (i=0; i<user.length; i++)
	{
		if (user.charCodeAt(i)>127)
			return false;
	}

	for (i=0; i<domain.length; i++)
	{
		if (domain.charCodeAt(i)>127)
			return false;
	}

	if (user.match(userPat) == null)
		return false;

	var IPArray=domain.match(ipDomainPat);
	if (IPArray!=null)
	{
		for (var i=1;i<=4;i++)
		{
			if (IPArray[i]>255)
				return false;
		}
		return true;
	}

	var atomPat=new RegExp("^" + atom + "$");
	var domArr=domain.split(".");
	var len=domArr.length;

	for (i=0;i<len;i++)
	{
		if (domArr[i].search(atomPat)==-1)
			return false;
	}

	if (checkTLD && domArr[domArr.length-1].length!=2 && domArr[domArr.length-1].search(knownDomsPat)==-1)
		return false;

	if (len<2)
		return false;

	return true;
}

function ShowFlipDiv(tmpdiv) {
	if(IsDivVisible(tmpdiv)) {
		HideDiv(tmpdiv);
	}
	else {
		ShowDiv(tmpdiv);
	}
}

function IsDivVisible(whichLayer) {
	if (document.getElementById)
	{
		// this is the way the standards work
		var style2 = document.getElementById(whichLayer).style;
	}
	else if (document.all)
	{
		// this is the way old msie versions work
		var style2 = document.all[whichLayer].style;
	}
	else if (document.layers)
	{
		// this is the way nn4 works
		var style2 = document.layers[whichLayer].style;
	}

	if(style2.display == "")
	{
		return true;
	}
	else
	{
		return false;
	}
}

function ShowDiv(whichLayer)  {
	if (document.getElementById)
	{
		// this is the way the standards work
		var style2 = document.getElementById(whichLayer).style;
		style2.display = "";
	}
	else if (document.all)
	{
		// this is the way old msie versions work
		var style2 = document.all[whichLayer].style;
		style2.display = "";
	}
	else if (document.layers)
	{
		// this is the way nn4 works
		var style2 = document.layers[whichLayer].style;
		style2.display = "";
	}
}

function HideDiv(whichLayer) {
	if (document.getElementById)
	{
		// this is the way the standards work
		var style2 = document.getElementById(whichLayer).style;
		if(style2.display == "")	style2.display = "none";
	}
	else if (document.all)
	{
		// this is the way old msie versions work
		var style2 = document.all[whichLayer].style;
		if(style2.display == "")	style2.display = "none";
	}
	else if (document.layers)
	{
		// this is the way nn4 works
		var style2 = document.layers[whichLayer].style;
		if(style2.display == "")	style2.display = "none";
	}
}


