window.onload = function() {
  clearDefault();
};

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}


function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.id; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' mezőbe add meg az email címed.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' számnak kell lennie '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' mezőt ki kell töltened.\n'; }
  } if (errors) alert('Hiányosan töltötted ki a regisztrációs lapot:\n'+errors);
  document.MM_returnValue = (errors == '');
}

function MakeArrayENG(n) {
	this.length = n
	return this
}
monthNamesENG = new MakeArrayENG(12)
monthNamesENG[1] = "January"
monthNamesENG[2] = "February"
monthNamesENG[3] = "March"
monthNamesENG[4] = "April"
monthNamesENG[5] = "May"
monthNamesENG[6] = "June"
monthNamesENG[7] = "July"
monthNamesENG[8] = "August"
monthNamesENG[9] = "September"
monthNamesENG[10] = "October"
monthNamesENG[11] = "November"
monthNamesENG[12] = "December"
dayNamesENG = new MakeArrayENG(7)
dayNamesENG[1] = "Sunday"
dayNamesENG[2] = "Monday"
dayNamesENG[3] = "Tuesday"
dayNamesENG[4] = "Wednesday"
dayNamesENG[5] = "Thursday"
dayNamesENG[6] = "Friday"
dayNamesENG[7] = "Saturday"

function customDateStringENG() {
	currentDate = new Date()
	var theDay = dayNamesENG[currentDate.getDay() + 1]
	var theMonth = monthNamesENG[currentDate.getMonth() + 1]
	msie4 = ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4 ));
	if (msie4) {
	    var theYear = currentDate.getYear()
	}
	else {
	     var theYear = currentDate.getYear() +1900
	}
	return theDay + ", " + theMonth + " " + currentDate.getDate() + ", " + theYear
}

function MakeArrayHUN(n) {
	this.lHUNth = n
	return this
}
monthNamesHUN = new MakeArrayHUN(12)
monthNamesHUN[1] = "január"
monthNamesHUN[2] = "február"
monthNamesHUN[3] = "március"
monthNamesHUN[4] = "április"
monthNamesHUN[5] = "május"
monthNamesHUN[6] = "június"
monthNamesHUN[7] = "július"
monthNamesHUN[8] = "augusztus"
monthNamesHUN[9] = "szeptember"
monthNamesHUN[10] = "október"
monthNamesHUN[11] = "november"
monthNamesHUN[12] = "december"
dayNamesHUN = new MakeArrayHUN(7)
dayNamesHUN[1] = "Vasárnap"
dayNamesHUN[2] = "Hétfő"
dayNamesHUN[3] = "Kedd"
dayNamesHUN[4] = "Szerda"
dayNamesHUN[5] = "Csütörtök"
dayNamesHUN[6] = "Péntek"
dayNamesHUN[7] = "Szombat"

function customDateStringHUN() {
	currentDate = new Date()
	var theDay = dayNamesHUN[currentDate.getDay() + 1]
	var theMonth = monthNamesHUN[currentDate.getMonth() + 1]
	msie4 = ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4 ));
	if (msie4) {
	    var theYear = currentDate.getYear()
	}
	else {
	     var theYear = currentDate.getYear() +1900
	}
	//return theDay + ", " + theMonth + " " + currentDate.getDate() + ", " + theYear
	return theDay + ", " + theYear + ". " + theMonth + " " + currentDate.getDate() + "."

}


function checkForm()
{
	var cname, cemail, csubject, cmessage, cnumber;
    with(window.document.msgform)
    {
        cname    = sname;
        cemail   = email;
        csubject = subject;
        cmessage = message;
		cnumber = txtNumber;
    }
    
    if(trim(cname.value) == '')
    {
        alert('Kérem adja meg a nevét!');
        cname.focus();
        return false;
    }
    else if(trim(cemail.value) == '')
    {
        alert('Kérem adja meg az email címét!');
        cemail.focus();
        return false;
    }
    else if(!isEmail(trim(cemail.value)))
    {
        alert('A megadott email cím hibás!');
        cemail.focus();
        return false;
    }
    else if(trim(csubject.value) == '')
    {
        alert('Az üzenetnek nincs tárgya!');
        csubject.focus();
        return false;
    }
    else if(trim(cmessage.value) == '')
    {
        alert('Az üzenet mező üres!');
        cmessage.focus();
        return false;
    }
    else if(trim(cnumber.value) == '')
    {
        alert('Kérem adja meg az ellenőrző kódot!');
        cnumber.focus();
        return false;
    }

    else
    {
        cname.value    = trim(cname.value);
        cemail.value   = trim(cemail.value);
        csubject.value = trim(csubject.value);
        cmessage.value = trim(cmessage.value);
        cnumber.value = trim(cnumber.value);
        return true;
    }
}

/*
Strip whitespace from the beginning and end of a string
Input : a string
*/
function trim(str)
{
    return str.replace(/^\s+|\s+$/g,'');
}

/*
Check if a string is in valid email format. 
Returns true if valid, false otherwise.
*/
function isEmail(str)
{
    var regex = /^[-_.a-z0-9]+@(([-_a-z0-9]+\.)+(ad|ae|aero|af|ag|ai|al|am|an|ao|aq|ar|arpa|as|at|au|aw|az|ba|bb|bd|be|bf|bg|bh|bi|biz|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|com|coop|cr|cs|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|ec|edu|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gh|gi|gl|gm|gn|gov|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|in|info|int|io|iq|ir|is|it|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|mg|mh|mil|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|museum|mv|mw|mx|my|mz|na|name|nc|ne|net|nf|ng|ni|nl|no|np|nr|nt|nu|nz|om|org|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|pro|ps|pt|pw|py|qa|re|ro|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sv|sy|sz|tc|td|tf|tg|th|tj|tk|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw)|(([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5])\.){3}([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5]))$/i;
    return regex.test(str);
}


function clearDefault(){ 
var dbg=''; // Background color, Default
var fbg='#D3E1E7'; // Background color, onFocus 
	var tI = document.getElementsByTagName('input'); var tT = document.getElementsByTagName('textarea');
	for (var i = 0; i < tI.length; i++) { 
		if (tI[i] && tI[i].getAttribute('type') != '' && tI[i].getAttribute('type').toLowerCase() == 'text' || tI[i].getAttribute('type').toLowerCase() == 'password') 
		{tI[i].style.backgroundColor = dbg; thisValue = tI[i].getAttribute("title");
			if (thisValue){	tI[i].value = thisValue;} 
			tI[i].onfocus = function(){this.style.backgroundColor = fbg; if (this.value != this.getAttribute("title") && this.value != '') {return;} 
			else {this.value = '';}};
			tI[i].onblur = function(){this.style.backgroundColor = dbg; if (this.value == ''){this.value = this.getAttribute("title");}};}} 
	for (var i = 0; i < tT.length; i++){if (tT[i]){tT[i].style.backgroundColor = dbg; thisValue = tT[i].getAttribute("title");if (thisValue){tT[i].value = thisValue;} 
			tT[i].onfocus = function(){this.style.backgroundColor = fbg; if (this.value != this.getAttribute("title") && this.value != ''){return;}
			else {this.value = '';}};
			tT[i].onblur = function(){this.style.backgroundColor = dbg;if (this.value == ''){this.value =  this.getAttribute("title");}};}} 
}

function JustSoPicWindow(imageName,imageWidth,imageHeight,alt,bgcolor,hugger,hugMargin) {
// by E Michael Brandt of ValleyWebDesigns.com - Please leave these comments intact.
// version 3.0.4
	if (bgcolor=="") {
	bgcolor="#FFFFFF";
	}
	var adj=10
	var w = screen.width;
	var h = screen.height;
	var byFactor=1;

	if(w<740){
	  var lift=0.90;
	}
	if(w>=740 & w<835){
	  var lift=0.91;
	}
	if(w>=835){
	  var lift=0.93;
	}
	if (imageWidth>w){
	  byFactor = w / imageWidth;
	  imageWidth = w;
	  imageHeight = imageHeight * byFactor;
	}
	if (imageHeight>h-adj){
	  byFactor = h / imageHeight;
	  imageWidth = (imageWidth * byFactor);
	  imageHeight = h;
	}

	var scrWidth = w-adj;
	var scrHeight = (h*lift)-adj;

	if (imageHeight>scrHeight){
  	  imageHeight=imageHeight*lift;
	  imageWidth=imageWidth*lift;
	}

	var posLeft=0;
	var posTop=0;

	if (hugger == "hug image"){
	  if (hugMargin == ""){
	    hugMargin = 0;
	  }
	  var scrHeightTemp = imageHeight - 0 + 2*hugMargin;
	  if (scrHeightTemp < scrHeight) {
		scrHeight = scrHeightTemp;
	  }
	  var scrWidthTemp = imageWidth - 0 + 2*hugMargin;
	  if (scrWidthTemp < scrWidth) {
		scrWidth = scrWidthTemp;
	  }

	  if (scrHeight<100){scrHeight=100;}
	  if (scrWidth<100){scrWidth=100;}

	  posTop =  ((h-(scrHeight/lift)-adj)/2);
	  posLeft = ((w-(scrWidth)-adj)/2);
 	}

	if (imageHeight > (h*lift)-adj || imageWidth > w-adj){
		imageHeight=imageHeight-adj;
		imageWidth=imageWidth-adj;
	}
	posTop = parseInt(posTop);
	posLeft = parseInt(posLeft);
	scrWidth = parseInt(scrWidth);
	scrHeight = parseInt(scrHeight);

	var agt=navigator.userAgent.toLowerCase();
	if (agt.indexOf("opera") != -1){
	  var args= new Array();
	  args[0]='parent';
	  args[1]=imageName;
	  var i ; document.MM_returnValue = false;
	  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
	} else {
	newWindow = window.open("vwd_justso.htm","newWindow","width="+scrWidth+",height="+scrHeight+",left="+posLeft+",top="+posTop);
	newWindow.document.open();
	newWindow.document.write('<html><title>'+alt+'</title><body leftmargin="0" topmargin="0" marginheight="0" marginwidth="0" bgcolor='+bgcolor+' onBlur="self.close()" onClick="self.close()">');
	newWindow.document.write('<table width='+imageWidth+' border="0" cellspacing="0" cellpadding="0" align="center" height='+scrHeight+' ><tr><td>');
	newWindow.document.write('<img src="'+imageName+'" width='+imageWidth+' height='+imageHeight+' alt="Bezáráshoz kattintson a képre!" >');
	newWindow.document.write('</td></tr></table></body></html>');
	newWindow.document.close();
	newWindow.focus();
	}
}

function checkPw(form) {
jelszo = form.jelszo.value;
jelszo2 = form.jelszo2.value;

if (jelszo != jelszo2) {
alert ("\nA megadott két jelszó nem azonos. Add meg újra a jelszót!")
return false;
}
else return true;
}

function checkT(form) {
jelszo = form.jelszo.value;
jelszo2 = form.jelszo2.value;

if (jelszo != jelszo2) {
alert ("\nA megadott két jelszó nem azonos. Add meg újra a jelszót!")
return false;
}
else return true;
}


function FillBilling(f) {
  if(f.megegyezo_cim.checked == true) {
     f.szallitasi_nev.value   	 	=  f.szamlazasi_nev.value;
   	 f.szallitasi_varos.value  		=  f.szamlazasi_varos.value ;
     f.szallitasi_utca.value   		=  f.szamlazasi_utca.value;
     f.szallitasi_iranyitoszam.value =  f.szamlazasi_iranyitoszam.value  ;
  }
}


	function UpdateQty(item)
	{
		itemId = item.name;
		termekAra = item.id2;
		newQty = item.options[item.selectedIndex].text;
		
		document.location.href = 'kosar.php?action=update_item&id='+itemId+'&qty='+newQty;
	}
	
	function UpdateQty2(item)
	{
		itemId = item.name;
		newQty = item.options[item.selectedIndex].text;
		
		document.location.href = 'penztar.php?action=update_item&id='+itemId+'&qty='+newQty;
	}
	
	
	function UpdateQtyMuszer(item)
	{
		itemId = item.name;
		newQty = item.options[item.selectedIndex].text;
		
		document.location.href = 'kosar.php?action=update_item_muszer&id='+itemId+'&qty='+newQty;
	}

	function UpdateQtyMuszer2(item)
	{
		itemId = item.name;
		newQty = item.options[item.selectedIndex].text;
		
		document.location.href = 'penztar.php?action=update_item_muszer&id='+itemId+'&qty='+newQty;
	}
