function PopChat() {
	var prefix = document.location.href.match('/termekek/') ? '/termekek/' : '/';
	ChatWindow = window.open(
		prefix + 'chat/index.php',
		'AEGONdirektChat',
		'status=1,toolbar=0,titlebar=0,location=0,menubar=0,directories=0,resizable=1,scrollbars=1,width=700,height=500,top=100,left=100'
	);
	ChatWindow.focus();
}

function adlogin(mode) {
	var sform = $('bejelentkezoform');
	if (mode!=null) $('mode').setAttribute('value', mode);
	if (sform.getAttribute('action') == '') {
		new Ajax.Updater('bejelentkezodiv', '/sajat/login.php', {method : 'post', parameters: sform.serialize(true)});
	} else {
		sform.submit();
	}
}

function nyomtatasx(id) {
	window.open('/tools/nyomtatas_tudastar.php?id='+id,'Nyomtatás','width=680,height=600,scrollbars=yes');
}

function pdfx(id) {
	window.open('/tools/nyomtatas_tudastar_pdf.php?id='+id,'Nyomtatás','width=680,height=600,scrollbars=yes');
}

function emailx(id) {
	window.open('/tools/email_tudastar.php?id='+id,'Küldés','width=387,height=460,scrollbars=no');
}

function kartyaszam() {
	if (document.viplakas["vipkod"].value == "") {
		document.viplakas["vipkod"].focus();
		alert("Kérem adja meg a kódot!");
		return false;
	} 
return true;
}


function kattancsplay(div, width, height, videourl) {
	if (videourl == null) kattancsstop(div);
	var surl = window.AEGONdirekt_Config!=null ? window.AEGONdirekt_Config.SiteURL : '/';
	var kurl = surl + 'video/player.swf?video_src='+surl+'video/'+videourl+'&link=#&cel=0&lejatszas=1&video_szelesseg='+width+'&video_magassag='+height +'&vege_kep=0&vege=0&kattancs=0';
	$(div).innerHTML=
		'<object id="player" width="'+width+'" height="'+height+'" type="application/x-shockwave-flash" data="'+kurl+'">'+
		'<param name="movie" value="'+kurl+'" />'+
		'<param name="wmode" value="transparent" />'+
		'</object>';
}

function kattancsstop(div) {
	$(div).innerHTML='';
}

function checkLuhn(number, requiredLength) {
	// Strip any non-digits (useful for credit card numbers with spaces and hyphens)
	// var number=number.replace(/\D/g, '');

	// Set the string length and parity
	var number_length=number.length;
	var parity=number_length % 2;

	// Compare the length to the required length (if it is set)
	if (requiredLength!=null && requiredLength!=number_length) return false;

	// Loop through each digit and do the maths
	var total=0;
	for (i=0; i < number_length; i++) {
		var digit=number.charAt(i);
		// Multiply alternate digits by two
		if (i % 2 == parity) {
			digit=digit * 2;
			// If the sum is two digits, add them together (in effect)
			if (digit > 9) digit=digit - 9;
		}
		// Total up the digits
		total = total + parseInt(digit);
	}

  // If the total mod 10 equals 0, the number is valid
  return (total % 10 == 0);
}

function OpenListDown(id, container, contenttype){
	if (typeof(container)=="undefined") var container = 'doclist';
	if (typeof(contenttype)=="undefined") var contenttype = 'ul';
	if ($(id) && $(container)) {
		var ar = $(container).select(contenttype);
		if ($(id).visible()) {
			$(id).hide();
		} else {
			for (i=0; i<ar.length; i++) $(ar[i]).hide();
			$(id).show();
		}
	}
}
