/*checkscript*/

function checkemptyitems_fromarray(mezotomb,mezotomb_uzi,mezoparam,mezofuggo,hibak) {
	var allowto_submit=1;
	var lastusername="",lastpassword="";
	if (hibak!="" || hibak=="undefined")allowto_submit=0;
	for (i=0;i<mezotomb.length;i++) {
		if (document.getElementById(mezotomb[i]) && (!mezofuggo[i] || mezofuggo[i]=="" || mezofuggo[i]=="undedfined" || (mezofuggo[i] && document.getElementById(mezofuggo[i]) && document.getElementById(mezofuggo[i]).checked==true))) {
			if(mezoparam[i]!="checkbox" && document.getElementById(mezotomb[i]).value=="") {//Üres-e
				hibak+=mezotomb_uzi[i]+"\r\n";
				if (allowto_submit==1)document.getElementById(mezotomb[i]).focus();//nem mindenhol jó a focus, mert rejtett layernél hibát dobhat!
				allowto_submit=0;
			} else if (mezoparam[i]=="email" && !emailType(document.getElementById(mezotomb[i]).value)) {//ha email típus
				hibak+="A megadott email cím nem a megfelelő formátumú!\n";
				if (allowto_submit==1)document.getElementById(mezotomb[i]).focus();
				allowto_submit=0;
			} else if (mezoparam[i]=="domain" && !domainType(document.getElementById(mezotomb[i]).value)) {//ha domain típus/
				hibak+="A megadott domain név nem a megfelelő formátumú!\n";
				if (allowto_submit==1)document.getElementById(mezotomb[i]).focus();
				allowto_submit=0;
			} else if (mezoparam[i]=="ip" && !ipAddressType(document.getElementById(mezotomb[i]).value)) {//ha ip cím típus/
				hibak+="A megadott IP cím nem a megfelelő formátumú!\n";
				if (allowto_submit==1)document.getElementById(mezotomb[i]).focus();
				allowto_submit=0;
			} else if (mezoparam[i]=="domainip" && (!domainType(document.getElementById(mezotomb[i]).value) && !ipAddressType(document.getElementById(mezotomb[i]).value))) {//ha ip vagy domain típus/
				hibak+="A megadott cím nem a megfelelő formátumú!\n";
				if (allowto_submit==1)document.getElementById(mezotomb[i]).focus();
				allowto_submit=0;
			} else if (mezoparam[i]=="number" && (isNaN(document.getElementById(mezotomb[i]).value) || document.getElementById(mezotomb[i]).value==0)) {//ha szám típus 
				hibak+=mezotomb[i]+" - számot kell megadnia!\n";
				if (allowto_submit==1)document.getElementById(mezotomb[i]).focus();
				allowto_submit=0;
			} else if (mezoparam[i]=="username" && document.getElementById(mezotomb[i]).value.indexOf(" ")!=-1 && hibak.indexOf("A felhasználói név nem tartalmazhat szóközt!")==-1) {//ha username tartalmaz szünetet
				hibak+="A felhasználói név nem tartalmazhat szóközt!\n";
				if (allowto_submit==1)document.getElementById(mezotomb[i]).focus();
				allowto_submit=0;
			} else if (mezoparam[i]=="password" && lastusername!="" && lastusername==document.getElementById(mezotomb[i]).value) {//ha jelszó, és már néztük a felh nevet 
				hibak+="A jelszó nem lehet azonos a felhasználói névvel!\n";
				if (allowto_submit==1)document.getElementById(mezotomb[i]).focus();
				allowto_submit=0;
			} else if (mezoparam[i]=="password" && lastpassword!="" && lastpassword!=document.getElementById(mezotomb[i]).value) {//ha két jelszó vanmeg kell egyezniük 
				hibak+="Nem egyezik meg a két jelszó!\n";
				if (allowto_submit==1)document.getElementById(mezotomb[i]).focus();
				allowto_submit=0;
			}
			if (mezoparam[i]=="password"){lastpassword=document.getElementById(mezotomb[i]).value;}
			else if (lastpassword!="")lastpassword="";
			if (mezoparam[i]=="username"){lastusername=document.getElementById(mezotomb[i]).value;}
		}
	}
	if (allowto_submit==0) {
		alert("Az űrlapot hibásan töltötte ki:\n-----------------------------------\n"+hibak);
		return false;
	}
}


function emailType(email) {
	if (email.indexOf(" ")==-1 && email.match(/[a-z0-9]+[a-z0-9\-]*@[a-z0-9]+[a-z0-9\-]+\.[a-z0-9\-]+[a-z0-9\-]+/)) {
		return true;
	} else if (ekezetesEmailType(email)){
//		alert("Vigyázat! Ékezetes Email!");
		return true;
	} else return false;
}

function ekezetesEmailType(email) {
	if (email.indexOf(" ")==-1 && email.match(/[a-záéőúöüóűí0-9]+[a-záéőúöüóűí0-9\-]*@[a-záéőúöüóűí0-9]+[a-záéőúöüóűí0-9\-]+\.[a-záéőúöüóűí0-9\-]+[a-záéőúöüóűí0-9\-]+/)) {
		return true;
	} return false;
}

function domainType(url) {
	if (url.indexOf(" ")==-1 && url.match(/[a-z0-9]+[a-z0-9\-]+\.[a-z0-9\-]+[a-z0-9\-]+/)) {
		return true;
	} else if (ekezetesDomainType(url)){
//		alert("Vigyázat! Ékezetes Domain!\nA rendszer automatikusan konvertálja a megadott domain nevet,\nazonban kérjük ellenőrizze a konvertálás helyességét!");
		return true;
	} else return false;
}

function ekezetesDomainType(url) {
	if (url.indexOf(" ")==-1 && url.match(/[a-záéőúöüóűí0-9]+[a-záéőúöüóűí0-9\-]+\.[a-záéőúöüóűí0-9\-]+[a-záéőúöüóűí0-9\-]+/)) {
		return true;
	} return false;
}

function ipAddressType(url) {
	if (url.match(/\d+\.\d+\.\d+\.\d+/)) {
		return true;
	} return false;
}



/*notown*/
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

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_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src;x.src=a[i+2];}
}

function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'':(v='hide')?'none':v; }
    obj.display=v; }
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}

/*own layer*/

function layer_fel(name){
		document.getElementById(name).style.visibility='visible';
		document.getElementById(name).style.display='';
		MM_showHideLayers(name,'','show');
}

function layer_le(name){
		document.getElementById(name).style.visibility='hidden';
		document.getElementById(name).style.display='none';
		MM_showHideLayers(name,'','hide');
}

/*own irszam*/

var varos_irszam_tomb=new Array();
var elozoirszam=0;

function set_varos_fromirszam(irszam,varos_input_id) {//ügyfeleknél árányítószámhoz városkeresés
	if (irszam && varos_irszam_tomb[irszam] && document.getElementById(varos_input_id))document.getElementById(varos_input_id).value=varos_irszam_tomb[irszam];
	else if(irszam && elozoirszam!=irszam) {
		alert("Nincs ilyen irányítószám!");
	//	document.getElementById(varos_input_id).focus();
	}
	elozoirszam=irszam;
}

function set_irszam_fromvaros(varos,irszam_input_id) {//ügyfeleknél városhoz irányítószám
	if (varos && document.getElementById(irszam_input_id)) {
		for (i=1010;i<=9999;i++) {
			var string1=new String(varos);
			var string2=new String(varos_irszam_tomb[i]);
			if (string1.toUpperCase()==string2.toUpperCase()){
				document.getElementById(irszam_input_id).value=i;
				return true;
			}
		}
	} else if(varos) {
//		document.getElementById(irszam_input_id).focus();
		alert("Nincs ilyen irányítószám!");}
	return true;

}



/*egyeb*/

function kepkeretnyito(kep,type) {
	if (type=="undefined") type="";
	window.open('kepmutato.php?kep='+kep+'&type='+type,'_blank','width=450,height=340,menubar=no,scrollbars=auto,resizable=no');
	return false;
}

function ujablaknyito(mit) {
	var width=800,height=600;
	window.open(mit,'_blank','width='+width+',height='+height+',menubar=no,scrollbars=auto,scrolling=auto,resizable=yes');
	return false;
}

function oldal_cimke_elotag(str) {
	if (document.getElementById('oldal_cimke_elotag')) {
		document.getElementById('oldal_cimke_elotag').innerText=str;
	}
}

function checkurl(id) {
	if (document.getElementById(id) && document.getElementById(id).host && document.getElementById(id).href) {
		var href=document.getElementById(id).href;
		var host=document.getElementById(id).host;
		if (host=="collactive.iosephinum.hu:80")document.getElementById(id).href=href.replace(/collactive.iosephinum.hu\//,"");
	}
}

function oldalKereso(mitkeresid,formname) {
if (!formname || formname=="undefined") {
	if (document.getElementById('holkeres')) {
		if (document.getElementById(mitkeresid)) {
			var mitkeres=document.getElementById(mitkeresid).value;
		}
		var holkeres=document.getElementById('holkeres').value;
		if (holkeres) {
			location.href="?page="+holkeres+"&holkeres="+holkeres+"op=search&mitkeres="+mitkeres;
			return false;
			//ha nem jó a location.href
			document.getElementById('jobbkereso').action="?page="+holkeres+"&holkeres="+holkeres+"op=search&mitkeres="+mitkeres;
		}
	} 
} else {
	if (document.getElementById(mitkeresid)) {
		var mitkeres=document.getElementById(mitkeresid).value;
	}
	document.getElementById(formname).action+="&mitkeres="+mitkeres;
}
}


function setInputValue(id,value) {
	if (document.getElementById(id)) {
		document.getElementById(id).value=value;
	}
}


function showhideIndexReference(id) {
	if (document.getElementById('indextable_'+id)) {
		if (document.getElementById('indextable_'+id).style.display=='none') {//aktiválom
			document.getElementById('indextable_'+id).style.display='Block';
//			document.getElementById('img_changer_'+id).src='images/design/ikonok/nyomtatas.gif';
			MM_swapImage('img_changer_'+id,'images/design/ikonok/nyomtatas.gif');
			document.getElementById('ids_hidden_'+id).disabled=false;
		} else {//leveszem
			document.getElementById('indextable_'+id).style.display='None';
//			document.getElementById('img_changer_'+id).src='images/design/ikonok/nagymeret.gif';
			MM_swapImage('img_changer_'+id,'images/design/ikonok/nagymeret.gif');
			document.getElementById('ids_hidden_'+id).disabled=true;
		}
	}	
}

function number_format(number, decimals, point, separator)
		{
			if(!isNaN(number))
			{
				point = point ? point : '.';
				number = number.split('.');
				if(separator)
				{
					var tmp_number = new Array();
					for(var i = number[0].length, j = 0; i > 0; i -= 3)
					{
						var pos = i > 0 ? i - 3 : i;
						tmp_number[j++] = number[0].substring(i, pos);
					}
					number[0] = tmp_number.reverse().join(separator);
				}
				
				if(decimals && number[1]) 
					number[1] = number[1].substr(0,decimals);
//					number[1] = Math.round(parseFloat(number[1].substr(0, decimals) + '.' + number[1].substr(decimals, number[1].length), 10));
				return(number.join(point));
			}
			else return("0");
		}


	
function resizeTopTable(toptableid) {
	var maxwidthvalue=1278,minwidthvalue=780;
	var maxdomainnamewidthvalue=320,mindomainnamewidthvalue=170,mindomainnamewidthlimit=970;
	var width=0,width2=0,searchinputclass="searchtext";
	var htmlWidth=document.body.clientWidth?document.body.clientWidth:screen.width;
	if (htmlWidth) {
		if (htmlWidth>=maxwidthvalue ) {
			width=maxwidthvalue;
			width2=maxdomainnamewidthvalue;
			searchinputclass="searchtext";
		} else if (htmlWidth<=minwidthvalue) {
			width=minwidthvalue;
			width2=mindomainnamewidthvalue;
			searchinputclass="searchtext-narrow";
		} else {
			width='100%';
			if (htmlWidth<mindomainnamewidthlimit) {
				width2=mindomainnamewidthvalue;
				searchinputclass="searchtext-narrow";
			} else {
				width2=maxdomainnamewidthvalue;
				searchinputclass="searchtext";
			}
		}
	}
	if(toptableid && document.getElementById(toptableid) && width/* && document.getElementById(toptableid).width=='100%'*/) {
		document.getElementById(toptableid).width=width;
		document.getElementById(toptableid).style.width=width;
		if (document.getElementById('domainname')){
			document.getElementById('domainname').className=searchinputclass;
			document.getElementById('domainname').style.width=width2;
			document.getElementById('domainname').width=width2;
		}
	} else return width;
}


function domain_kereso(){
	if (document.getElementById('domainname') && document.getElementById('domainname').value) {
		if (document.getElementById('domainname').value!=String(document.getElementById('domainname').value).match(/[a-z0-9éáűőúöüóí\-\.]+/)) {
//			alert("Hibás domain név formátum! Csak '-' jelet, betűket és betűket használjon!");
			document.getElementById('domainform').action='?page=domaincheck&op=hibasformatum';
//			return false;
		}
		if (String(document.getElementById('domainform').action).match(/page=/)) {
			return true;
		} else {
			if (document.getElementById('ext').value==".hu") {
				window.open("http://www.domain.hu/domain/domainsearch/?domain="+document.getElementById('domainname').value+"&tld=hu&lang=magyar");
				return false;
			} else {
				window.open("http://www.whois.sc/name-spinner/?q="+document.getElementById('domainname').value);
				return false;
			}
		}
	} 
	alert("Töltse ki a domain nevet!");
    return false;
}

	function getAnchorPosition(anchorname) {
	// This function will return an Object with x and y properties
	var useWindow=false;
	var coordinates=new Object();
	var x=0,y=0;
	// Browser capability sniffing
	var use_gebi=false, use_css=false, use_layers=false;
	if (document.getElementById) { use_gebi=true; }
	else if (document.all) { use_css=true; }
	else if (document.layers) { use_layers=true; }
	// Logic to find position
 	if (use_gebi && document.all) {
		x=AnchorPosition_getPageOffsetLeft(document.all[anchorname]);
		y=AnchorPosition_getPageOffsetTop(document.all[anchorname]);
		}
	else if (use_gebi) {
		var o=document.getElementById(anchorname);
		x=AnchorPosition_getPageOffsetLeft(o);
		y=AnchorPosition_getPageOffsetTop(o);
		}
 	else if (use_css) {
		x=AnchorPosition_getPageOffsetLeft(document.all[anchorname]);
		y=AnchorPosition_getPageOffsetTop(document.all[anchorname]);
		}
	else if (use_layers) {
		var found=0;
		for (var i=0; i<document.anchors.length; i++) {
			if (document.anchors[i].name==anchorname) { found=1; break; }
			}
		if (found==0) {
			coordinates.x=0; coordinates.y=0; return coordinates;
			}
		x=document.anchors[i].x;
		y=document.anchors[i].y;
		}
	else {
		coordinates.x=0; coordinates.y=0; return coordinates;
		}
	coordinates.x=x;
	coordinates.y=y;
	coordinates.w=document.getElementById(anchorname).width;
	coordinates.h=document.getElementById(anchorname).height;
	return coordinates;
	}

function AnchorPosition_getPageOffsetLeft (el) {
	var ol=el.offsetLeft;
	while ((el=el.offsetParent) != null) { ol += el.offsetLeft; }
	return ol;
	}
function AnchorPosition_getWindowOffsetLeft (el) {
	return AnchorPosition_getPageOffsetLeft(el)-document.body.scrollLeft;
	}	
function AnchorPosition_getPageOffsetTop (el) {
	var ot=el.offsetTop;
	while((el=el.offsetParent) != null) { ot += el.offsetTop; }
	return ot;
	}
function AnchorPosition_getWindowOffsetTop (el) {
	return AnchorPosition_getPageOffsetTop(el)-document.body.scrollTop;
	}

