var DomainName = document.URL.split("/");

var browserName=navigator.appName; 
if (browserName=="Netscape")
	{ 
	var browser ="NS";
	} else 
if (browserName=="Microsoft Internet Explorer")
	{  
	var browser = "IE";
	} else {
	var browser = "OS";
	}





function randomString() 
	{
	var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
	var string_length = 20;
	var randomstring = '';
	for (var i=0; i<string_length; i++) 
		{
		var rnum = Math.floor(Math.random() * chars.length);
		randomstring += chars.substring(rnum,rnum+1);
		}
	return randomstring;
	}



function cursorpos(event)
	{
	if (browser == "IE")
		{
		var x=event.clientX;
		var y=event.clientY+document.body.scrollTop+10;
        	} else 
	if (browser == "NS")
	        {
		var x=event.clientX+30;
		var y=event.clientY+document.documentElement.scrollTop+10;
        	} else {
		var x=event.screenX-80;	        	
		var y=event.clientY+document.body.scrollTop+10;	
        	};

	document.getElementById('cposx_id').value=x;
	document.getElementById('cposy_id').value=y;

	}

function ocBubble(event, text, open)
	{

       	var objid = document.getElementById('absoltetag_id');
       	if (open == true)
       		{
       		var x = document.getElementById('cposx_id').value;
       		var y = document.getElementById('cposy_id').value;
//		alert (x+" "+y);
		objid.style.display='block';
		objid.style.position='absolute';
		objid.style.left=x+'px';
		objid.style.top=y+'px';
		objid.innerHTML=text;
		} else {
		objid.style.display='none';

        	};
	
	}

var halvanyitasid;
var ertek = 100;
function MyAlert(text, halvanyulas)
	{
	ertek = 100;
	clearInterval(halvanyitasid);	
        var objwidth = 400;
	var CX = document.body.clientWidth;
	var CY = document.body.clientHeight;
	var ST = document.documentElement.scrollTop;

	var obj = document.getElementById('systemalert_id');

	obj.style.opacity = 100/100;  
	obj.style.MozOpacity = 100/100;  
	obj.style.KhtmlOpacity = 1;  
	obj.style.filter = "alpha(opacity=" + 100 + ");";
	
	obj.className="alertconfirmclass";
	obj.style.width=objwidth+'px';
	obj.style.position='absolute';
	obj.style.display='block';
	obj.style.left=(CX/2)-(objwidth/2)+'px';
	obj.style.top=ST+50+'px';

	
	obj.innerHTML=text;


	if(halvanyulas != null)
		{
	 	halvanyitasid = setTimeout('halvanyitasinditas()',2000)
		}
	}


function halvanyitasinditas()
	{
	clearInterval(halvanyitasid);
 	halvanyitasid = setInterval('MyAlertHalvanyitasMIN()',20)
	}
function MyAlertHalvanyitasMIN()
	{
	ertek = ertek-1;
	var obj = document.getElementById('systemalert_id');
	obj.style.opacity = ertek/100;  
	obj.style.MozOpacity = ertek/100;  
	obj.style.KhtmlOpacity = ertek/100;  
	obj.style.filter = "alpha(opacity=" + ertek + ")";


	if(ertek == 0)
		{
		obj.style.display="none";
		clearInterval(halvanyitasid)
		ertek = 100;
		clearInterval(halvanyitasid);
		}


	}

function HiddenMyAlert()
	{
	document.getElementById('systemalert_id').style.display='none';
	document.getElementById('systemalert_id').innerHTML='';
	}

function GETFULLContactTable(idANDtablename)
	{
	var idtbl = idANDtablename.split(":");
	var LoadURL = DomainName[0]+"//"+DomainName[1]+DomainName[2]+"/getcontacttable.php?id="+idtbl[0]+"&table="+idtbl[1];
	window.open (LoadURL,"mywindow","status=1"); 
	}
/*
function FormFeldolgozas(azonosito, formeleresazon)
	{
	var hiba 		= "";
	var belsoadatok 	= document.getElementById('form'+azonosito+'_id');
	var valtozok 		= "?formeleresazon="+formeleresazon;
	var mennyiseg 		= belsoadatok.length
	alert(mennyiseg)
	for(var i=0;i<mennyiseg;i++)
		{
		alert(belsoadatok[i].id)
//		alert(document.getElementById(belsoadatok[i].id).value)
		if(belsoadatok[i].id == azonosito+"_targy")
			{
			valtozok+= "&targy="+document.getElementById(belsoadatok[i].id).value;
			}

		if(belsoadatok[i].id == azonosito+"_visszaigazolouzenet")
			{
			valtozok+= "&visszaigazolouzenet="+document.getElementById(belsoadatok[i].id).value;
			}

		if (i%2==1)
			{
			continue;
			}

		var szakitasok = document.getElementById(belsoadatok[i+1].id).value.split("|");
		if (belsoadatok[i].id != "")
			{

			if (szakitasok[1] == "kotelezokitolteni")
				{
//				alert(document.getElementById(belsoadatok[i].id).value)

				if (document.getElementById(belsoadatok[i].id).value == "")
					{
					hiba+= szakitasok[2]+"<br />\n";
					}

				}

			if (hiba!="")
				{
				MyAlert(hiba+"<br /><input type=\"button\" value=\"OK!\" onclick=\"HiddenMyAlert()\">");
				};
	        	} else {
	        	continue;
	        	}
		valtozok+= "&valtozoneve[]="+szakitasok[0]+"&valtozoertek[]="+document.getElementById(belsoadatok[i].id).value;

		};
	if(hiba=="")
		{
		makeRequest('http://'+window.location.hostname+'/plugins/011_COM_urlapfeldolgozo/outer/http_GET/urlapfeldogozo.php'+valtozok, 'JustInner', 'ajax_inner_id', 'POST');	
		};
	}
*/
/*
function FormFeldolgozas(azonosito, formeleresazon)
	{
	var hiba 		= "";
	var belsoadatok 	= document.getElementById('form'+azonosito+'_id');
	var valtozok 		= "?formeleresazon="+formeleresazon;
	var mennyiseg 		= belsoadatok.length
	alert(mennyiseg)
	for(var i=0;i<mennyiseg;i++)
		{
		if (belsoadatok[i].id == "")
			{
			continue;
			}
		if(belsoadatok[i].id.substring(0, 2) == "_a" && belsoadatok[i+1].id.substring(0, 2) == "_b")
			{
			var szakitasok = document.getElementById(belsoadatok[i+1].id).value.split("|");	
			alert(szakitasok[1])
			if (szakitasok[1] == "kotelezokitolteni")
				{

				if (document.getElementById(belsoadatok[i].id).value == "")
					{
					hiba+= szakitasok[2]+"<br />\n";
					}

				}

			valtozok+= "&valtozoneve[]="+szakitasok[0]+"&valtozoertek[]="+document.getElementById(belsoadatok[i].id).value;
			}

		if(belsoadatok[i].id == "_c_"+azonosito+"_targy")
			{
			valtozok+= "&targy="+document.getElementById(belsoadatok[i].id).value;
			}

		if(belsoadatok[i].id == "_c_"+azonosito+"_visszaigazolouzenet")
			{
			valtozok+= "&visszaigazolouzenet="+document.getElementById(belsoadatok[i].id).value;
			}

			
		}
	if (hiba != "")
		{
		return MyAlert(hiba+"<br /><input type=\"button\" value=\"OK!\" onclick=\"HiddenMyAlert()\">");
		}
	makeRequest('http://'+window.location.hostname+'/plugins/011_COM_urlapfeldolgozo/outer/http_GET/urlapfeldogozo.php'+valtozok, 'JustInner', 'ajax_inner_id', 'POST');	
	}
*/

function str_replace(valtozo) 
	{ 
	var replace = new Array("&", "?"); 
	var mire = new Array("&#38;", "&#63;"); 
	for (var i=0; i<replace.length; i++) 
  		{ 
		valtozo = valtozo.replace(replace[i], mire[i]); 
		} 
//	alert(valtozo)
	return valtozo; 
	} 

function ajaxpostreplace(valtozo)
	{    
	valtozo = valtozo.replace(/\?/g, "*ask*"); 
	valtozo = valtozo.replace(/&/g, "*and*"); 
/*
	
	var replace = new Array("\n", "?", "&"); 
	var mire = new Array("<br>", "*ask*", "*and*"); 
	for (var i=0; i<replace.length; i++) 
  		{ 
		valtozo = valtozo.replace(replace[i], mire[i]); 
		} 
//	alert(valtozo)
*/
	return valtozo;                    
	}

function FeljegyzesekNyitas(ertek)
	{

	if(document.getElementById('adminfejlegyzesek_id').style.display=='none')
		{
		makeRequest('http://'+window.location.hostname+'/system/http_GET/admin_feljegyzesek.php', 'JustInner', 'adminfejlegyzesek_id', 'GET');	
		document.getElementById('adminfejlegyzesek_id').style.display='block';
		} else {
		document.getElementById('adminfejlegyzesek_id').style.display='none';
		}
	}



function DateFormat(val, id, e)
	{

	var unicode=e.keyCode? e.keyCode : e.charCode

	if (unicode != 8)
		{
	
		NewValue = "";

		if (val.charAt(0) == "1" || val.charAt(0) == "2" || val.charAt(0) == undefined)
			{

			} else {
			document.getElementById(id).value="";
//			alert ("A dßtumot /ÚÚÚÚ-hh-nn/ formßban add meg!");
			};


		val = val.replace(/[^0-9]/g, '');

		lgtnum = val.length;

		for (i=0; i<lgtnum; i++)
			{

			NewValue+=val.charAt(i);						

			if (i == 3)
				{
				NewValue+= "-";						
				} else 

			if (i == 5)
				{
				NewValue+= "-";						
				};

			};

		honapertek = ""+parseInt(val.charAt(4)+"") + ""+parseInt(val.charAt(5)+"")
		if (honapertek > 12)
			{
//			alert ("A h¡nap nem lehet nagyobb 12-nÚl!");
	                NewValue = NewValue.substr(0, 5);
			};


		napertek = ""+parseInt(val.charAt(6)+"") + ""+parseInt(val.charAt(7)+"")
		if (napertek > 31)
			{
//			alert ("A nap nem lehet nagyobb 31-nÚl!");
	                NewValue = NewValue.substr(0, 8);
			};
		
		
		document.getElementById(id).value=NewValue;
		};
	
	};	

function CsakSzam(val, id)
	{
	var JNval = val.replace(/[^0-9, ',']/g, '');
	document.getElementById(id).value=JNval;
	};


function OsszegFormazas(val, id)
	{ 
	s = val.replace(/ /g, '');
	n = s.length;

	NNew = s.substr(0, n%3);
	for(i=n%3; i<n; i+=3) 
		{
		NNew = NNew+" "+s.substr(i,3);
        	};

	if (NNew.charAt(0) == " ")
		{
		NNew = NNew.substr(1);
		}
	document.getElementById(id).value=NNew;
	if (document.getElementById(id).value.charAt(0) == 0)
		{
		document.getElementById(id).value="";
		};

 
	}

function OsszegFormazasCsuszka(val)
	{ 
	s = val.replace(/ /g, '');
	n = s.length;

	NNew = s.substr(0, n%3);
	for(i=n%3; i<n; i+=3) 
		{
		NNew = NNew+" "+s.substr(i,3);
        	};

	if (NNew.charAt(0) == " ")
		{
		NNew = NNew.substr(1);
		}
	/*document.getElementById(id).value=NNew;
	if (document.getElementById(id).value.charAt(0) == 0)
		{
		document.getElementById(id).value="";
		}; */

        return NNew;
	}


function globalis_nyomtatas(keret_id, alert_ablak, alapertelmezett_muvelet)
	{                           

//	globalis_nyomtatas("float=left*lefttable_id|float=right*content_id|clear=both; background-color:#aa0000;*footer_id")
        var elemes=keret_id.split("|");
	var elemekfuzes = "";
        for (i=0;i<elemes.length;i++)
        	{
		var elemdarabolas = elemes[i].split("*");
		elemekfuzes+= "<div style=\""+elemdarabolas[0]+"\">";
		elemekfuzes+= document.getElementById(elemdarabolas[1]).innerHTML;
		elemekfuzes+= "</div>";
	        }                       
	//alert(elemekfuzes)	           	
//	var elem=document.getElementById(keret_id).innerHTML;	
//	document.getElementById('seged_iframe').innerHTML=elem;
        var formaction = DomainName[0]+"//"+DomainName[1]+DomainName[2]+"/print.php";
	var vform = "";
	var target = "seged_iframe";

	if(browserName == "Opera")
		{
		target = "_blank";
		}

	vform+= "<form name=\"objprint\" method=\"POST\" action=\""+formaction+"\" target=\""+target+"\">";
	vform+= "<textarea name=\"printarea\" id=\"segedform_id\" style=\"width: 0px; height: 0px; visibility: hidden;\"></textarea>";
	vform+= "</form>";
	
	document.getElementById('ajax_inner_id').innerHTML=vform;
	document.getElementById('segedform_id').value=elemekfuzes;
	document.objprint.submit();
	//document.getElementById('ajax_inner_id').innerHTML='';

	}

function divnyitrejt(mit, mitmer)
	{
	var mitobj = document.getElementById(mit).style.display;
	if(mitobj =="block")
		{
		mitobj = "none";
		} else {
		mitobj = "block";
		}
	document.getElementById(mit).style.display=mitobj;

	if (mitmer != false)
		{
		document.getElementById(mit).style.width=document.getElementById(mitmer).offsetWidth+'px';
		}
	}             

function addSeparatorsNF(nStr, inD, outD, sep)
{
	nStr += '';
	var dpos = nStr.indexOf(inD);
	var nStrEnd = '';
	if (dpos != -1) {
		nStrEnd = outD + nStr.substring(dpos + 1, nStr.length);
		nStr = nStr.substring(0, dpos);
	}
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(nStr)) {
		nStr = nStr.replace(rgx, '$1' + sep + '$2');
	}
	return nStr + nStrEnd;
}

function szovegvagasvegerol(szoveg, mennyit)
	{
	var szoveghossz = szoveg.length;
	return szoveg.substring(0, szoveghossz-mennyit);
	}

function hatteralap_elhomalyositas()
	{
	var obj = document.getElementById('ajax_inner_id');
	var obj2 = document.getElementById('out1');     
	var obj3 = document.getElementById('content');     
	obj.style.position='absolute';
	obj.style.left='0px';
	obj.style.top='0px';
	obj.style.opacity = 80/100;  
	obj.style.MozOpacity = 80/100;  
	obj.style.KhtmlOpacity = 0.8;  
	obj.style.filter = "alpha(opacity=" + (80) + ");";
	obj.style.zIndex='500';
	obj.style.backgroundColor='#303030';
	obj.style.display='block';
	obj.style.width=document.body.offsetWidth+'px';
	obj.style.height=document.body.offsetHeight+'px';
//	obj2.style.position='absolute';
	obj2.style.zIndex='900'; 	
}

function checkEmail(email) 
	{
	if(email.indexOf("@") == -1 || email.indexOf(".") == -1) 
		{ 
		return false;
		} else {
	        var first = email.split("@");
        	var user = first[0];
	        var second = first[1].split(".");
        	var domain = second[0];
	        var ending = second[1];
        	if(user.length < 2 || domain.length < 2 || ending.length < 2) 
        		{
		        return false;
		        } else {
		        return true;
		        }
	    	}
	}



var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{
			string: navigator.userAgent,
			subString: "Chrome",
			identity: "Chrome"
		},
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari",
			versionSearch: "Version"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			   string: navigator.userAgent,
			   subString: "iPhone",
			   identity: "iPhone/iPod"
	    },
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};
BrowserDetect.init();


function sutibeiras(valtozonev,sutiertek)
	{
	var expDate = new Date();
	expDate.setTime(expDate.getTime() + (365*24*60*60*1000));
        var expire = expDate;
        
	document.cookie = valtozonev + "=" + escape(sutiertek)+ ((expire == null) ? "" : ("; expires=" + expire.toGMTString()));
	
	}

function sutiertekkeres(keresettvaltozonev,visszateres)
	{
	
	var i;
	var ertekkereses = "";
	var eredmeny = "";
	
	var sutiszetszedes = document.cookie.split(";");
	
	for (i=0;i<sutiszetszedes.length;i++)
  		{
  		ertekkereses = sutiszetszedes[i].substr(0,sutiszetszedes[i].indexOf("="));
 		eredmeny = sutiszetszedes[i].substr(sutiszetszedes[i].indexOf("=")+1);
		ertekkereses = ertekkereses.replace(/^\s+|\s+$/g,"");
  		if(ertekkereses == keresettvaltozonev)
    			{
    			
    			if(document.getElementById(visszateres))
    				{
    				return document.getElementById(visszateres).value = unescape(eredmeny);
    				} else {
    				return unescape(eredmeny);
    				}
    			
    			}
		}

	
	
	}


