String.prototype.trim = function() {return (this.replace(/^[\s\xA0]+/, "").replace(/[\s\xA0]+$/, ""));}

String.prototype.setInitials = function() {
strOut="";
for (i=0;i<this.length;i++) {
	intCurrChr=this.charCodeAt(i);
	intPrevChr= i>0 ? this.charCodeAt(i-1) : 32;
	bIsFirst=intPrevChr==32 || intPrevChr==45 || intPrevChr==46;
	if (bIsFirst) {
		if (intCurrChr>=97 && intCurrChr<=122) {
			intCurrChr=intCurrChr-32;
		}
		else {
			switch (intCurrChr) {
	                case 225:
	                    intCurrChr=193;
	                    break;
	                case 233:
	                    intCurrChr=201;
	                    break;
	                case 237:
	                    intCurrChr=205;
	                    break;
	                case 243:
	                    intCurrChr=211;
	                    break;
	                case 246:
	                    intCurrChr=214;
	                    break;
	                case 337:
	                    intCurrChr=336;
	                    break;
	                case 250:
	                    intCurrChr=218;
	                    break;
	                case 252:
	                    intCurrChr=220;
	                    break;
	                case 369:
	                    intCurrChr=368;
	                    break;
			}
		}
	}
	else {
		if (intCurrChr>=65 && intCurrChr<=90) {
			intCurrChr=intCurrChr+32;
		}
		else {
			switch (intCurrChr) {
	                case 193:
	                    intCurrChr=225;
	                    break;
	                case 201:
	                    intCurrChr=233;
	                    break;
	                case 205:
	                    intCurrChr=237;
	                    break;
	                case 211:
	                    intCurrChr=243;
	                    break;
	                case 214:
	                    intCurrChr=246;
	                    break;
	                case 336:
	                    intCurrChr=337;
	                    break;
	                case 218:
	                    intCurrChr=250;
	                    break;
	                case 220:
	                    intCurrChr=252;
	                    break;
	                case 368:
	                    intCurrChr=369;
	                    break;
			}
		}
	}
	strOut+=String.fromCharCode(intCurrChr)
}
return strOut;
}

String.prototype.convDate = function() {
strOut=""
with(document.form1) {
	strOut=this.trim();
	strOut=strOut.replace(/:/g,'.');
	strOut=strOut.replace(/;/g,'.');
	strOut=strOut.replace(/,/g,'.');
	strOut=strOut.replace(/-/g,'.');
	strOut=strOut.replace(/ /g,'.');
	strOut=strOut.replace(/\//g,'.');
	if (strOut.length>5 &&  strOut.substring(2,3)=='.' && strOut.substring(4,5)=='.' ) {strOut=strOut.substring(0,3)+'0'+strOut.substring(3,11)}
	if (strOut.length==7 &&  strOut.substring(2,3)=='.' && strOut.substring(5,6)=='.') {strOut=strOut.substring(0,6)+'0'+strOut.substring(6,11)}
	if (strOut.length==6 && !isNaN(strOut)) {
		strOut='19'+strOut.substring(0,2)+"."+strOut.substring(2,4)+"."+strOut.substring(4,6)+".";
	}
	else {
		if (strOut.length==8 && !isNaN(strOut.substring(0,2)) && !isNaN(strOut.substring(3,5)) && !isNaN(strOut.substring(6,8)) && strOut.substring(2,3)=='.' && strOut.substring(5,6)=='.') {

			strOut='19'+strOut.substring(0,2)+"."+strOut.substring(3,5)+"."+strOut.substring(6,8)+".";
		}
		else {
			if (strOut.length==8 && !isNaN(strOut) ) {

				strOut=strOut.substring(0,4)+"."+strOut.substring(4,6)+"."+strOut.substring(6,8)+".";
			}
		}
	}
}
return strOut;
}

String.prototype.convDate2000 = function() {
	strOut=this.trim();
	if (strOut.length==6) {strOut="20"+strOut};
	strOut=strOut.convDate();
	return strOut;
}

function switchMenu() { el=event.srcElement;  if (el.className=="menuItem") {    el.className="highlightItem";  } else if (el.className=="highlightItem") {    el.className="menuItem";  }}
function displayMenu() {contextMenu.style.leftPos+=10;  contextMenu.style.posLeft=event.clientX;  contextMenu.style.posTop=event.clientY;  contextMenu.style.display="";  contextMenu.setCapture();}
function clickMenu() {  contextMenu.releaseCapture();  contextMenu.style.display="none";  el=event.srcElement; menuExecute(el.id)}

function displayMenu2() {contextMenu2.style.leftPos+=10;  contextMenu2.style.posLeft=event.clientX;  contextMenu2.style.posTop=event.clientY;  contextMenu2.style.display="";  contextMenu2.setCapture();}
function clickMenu2() {  contextMenu2.releaseCapture();  contextMenu2.style.display="none";  el=event.srcElement; menuExecute(el.id)}

function chkCsekk(objCsekk,objCsekkValue) {
strToChk=objCsekkValue.trim();
if (strToChk!="") {
	bError=true;
	if (strToChk.length==13) {
		if (!isNaN(strToChk)) {
			intS=0;
			for (i=1;i<8;i++) intS+=parseInt(strToChk.substr(i-1,1))* (i % 2 == 0 ? 1 : 3);
			bError= (intS % 10) != parseInt(strToChk.substr(7,1));
		}
		bError=bError || objCsekkValue.substring(0,8)=="00000000";
	}
	if (bError) {
		objCsekk.style.backgroundColor="#ff8080";
		if (confirm("Érvénytelen csekkszám!\n\nKijavítod?")) {objCsekk.focus()}
	}
	else {
		objCsekk.style.backgroundColor="#ffffff";
	}
}}
