d=document;
// obsolated
function hirkeresofel() {
	hirkeresofelpattanoWindow = window.open ("http://hirkereso.hu/segitseg.htm", "hirkeresofelpattanoWindow", "height=400,width=380,scrollbars=yes,resizable=no");
}
function mediafel(file) {
  mediafelpattanoWindow = window.open (file, "mediafelpattanoWindow", "height=400,width=380,scrollbars=yes,resizable=no");
  return false;
}


//obsolated
function tomorfel() {
  tomoritettfelpattanoWindow = window.open ("http://hirkereso.hu/tomoritett.htm", "tomoritettfelpattanoWindow", "height=220,width=380,scrollbars=yes,resizable=no");
}

function felpattano(url,width,height,scroll,name,resize)
{
  t=(screen.availHeight-height)/2;
  l=(screen.availWidth-width)/2;

  if (typeof(resize)=='undefined')
    resize=0;
  var s1="toolbar=0,location=0,directories=0,status=0,\
  menubar=0,scrollbars="+scroll+",resizable="+resize+",width="+width+",height="+height+",left="+l+",top="+t;
  var nyit = window.open(url,name,s1);
  nyit.focus();
  lastopened=nyit;
}



function SetHomePageKapu(url)
{
	if (BrowserDetect.browser == "Chrome"){
		felpattano('http://www.kapu.hu/kezdolap-chrome.htm',680,340,1,'emailcim',0);
	}else if(BrowserDetect.browser == "Firefox"){
		felpattano('http://www.kapu.hu/kezdolap-firefox.htm',600,340,1,'emailcim',0);
	}else if(BrowserDetect.browser == "Opera"){
		felpattano('http://www.kapu.hu/kezdolap-opera.htm',600,340,1,'emailcim',0);
	}else if(BrowserDetect.browser == "Explorer"){
		document.body.style.behavior='url(#default#homepage)';document.body.setHomePage(url);
	}else{
		alert("Nem támogatott böngésző! (" + BrowserDetect.browser + ")Sajnos kézi beállítás szükséges");
	}
}
function SetHomePage(url)
{
	if (BrowserDetect.browser == "Chrome"){
		felpattano('http://www.hirkereso.hu/static/country/hu/kezdolap-chrome.htm',680,340,1,'emailcim',0);
	}else if(BrowserDetect.browser == "Firefox"){
		felpattano('http://www.hirkereso.hu/static/country/hu/kezdolap-firefox.htm',600,340,1,'emailcim',0);
	}else if(BrowserDetect.browser == "Opera"){
		felpattano('http://www.hirkereso.hu/static/country/hu/kezdolap-opera.htm',600,340,1,'emailcim',0);
	}else if(BrowserDetect.browser == "Explorer"){
		document.body.style.behavior='url(#default#homepage)';document.body.setHomePage(url);
	}else{
		alert("Nem támogatott böngésző! (" + BrowserDetect.browser + ") Sajnos kézi beállítás szükséges");
	}
}


	
function tgen(n){
	this.length=n;
	for (var x=1; x<=n; x++){
		this[x] = "1";
	}
        return this;
}
var t = new tgen(50);

function hir_link(url){
	return link(url);
}

function arch_link(url){
	return link(url);
}

function l(url){
	node=url;
	try {
		while (node=node.parentNode){
			if (node.getAttribute('id')){
				//alert(node.getAttribute('id'));
				dobozid=node.getAttribute('id');
				document.getElementById('logImg').src='http://redirect.hirkereso.hu/linkstat.fc?url='+escape(url)+'&link_doboz='+dobozid;
				break;
			}
		}
	} catch(e) {};

	return true;
}

function link(url,dobozid){
	startDate= new Date();	
	//	url=URLEncode(url);
	if (dobozid){
		document.getElementById('logImg').src='http://redirect.hirkereso.hu/linkstat.fc?url='+escape(url)+'&link_doboz='+dobozid;
	}
	if (parseInt(navigator.appVersion) >= 4) 
	{ 
		var width=screen.width/100*95;
		var height=((screen.height/100)*80)-100;
		var top=(screen.height-(height+100))/5;
		var left=(screen.width-width)/2;

		tmpWin2=window.open(url,startDate.getTime(),"toolbar=yes,location=yes,resizable=yes,status=yes,scrollbars=yes,menubar=yes,width=" + width + ",height=" + height + ",left=" + left + ",top=" + top);
	}
	else 
	{
		tmpWin2=window.open(url,startDate.getTime(),"toolbar=yes,location=yes,resizable=yes,status=yes,scrollbars=yes,menubar=yes,width=640,height=400");
	}
}
/*
function sutiellenor(){
        if (document.cookie.length==0){
                window.alert("A böngésző nem fogadja az információt tároló cookie-t ! Amíg nincs engedélyezve nem működik az ablakok nyitása-zárása funkció, s miden ablak kinyitva jelenik meg.");
        }
        return false;
}
*/

function open_doc_scroll(cime,szelesseg,magassag,ablak){
  if (typeof usrwindow != 'undefined'){
  if (!usrwindow.closed){usrwindow.close();}}
    usrwindow=window.open(cime, ablak, 'toolbar=yes,scrollbars=yes,menubar=yes,top=0,left=0,resizable=yes,hotkeys=yes,width='+szelesseg+',height='+magassag);
}



function on_place(id){

}
function off_place(id){

}


function getElementsByClass(cl){
		return document.getElementsByClassName(cl);
}


function getElementsByClass(searchClass,node,tag) {
  // megadott osztályú elemek kigyűjtése egy tömbbe
   http://www.dustindiaz.com/top-ten-javascript/ 
  var classElements = new Array();
  if ( node == null )
    node = document;
  if ( tag == null )
    tag = '*';
  var els = node.getElementsByTagName(tag);
  var elsLen = els.length;
  var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
  for (i = 0, j = 0; i < elsLen; i++) {
    if ( pattern.test(els[i].className) ) {
      classElements[j] = els[i];
      j++;
    }
  }
  return classElements;
}



function showhide(id,forceValue,dont_set_cookie){
  obj=document.getElementById('kinyilo_'+id);
	if (!obj){ return false;}
	
	if (forceValue){
		obj.style.display=forceValue;
		return false;
	}
  if (obj.style.display == 'none'){
	    obj.style.display="block";
			if (!dont_set_cookie){
  	   setAblak(id,1);
			 }

    }else{
    obj.style.display="none";

			if (!dont_set_cookie){
  	   setAblak(id,0);
			 }

    }

  return false;

}



function setAblak(id,value){
  var cookie=Utils.Cookie.get('ablakok');
  var newcookie;
	var ablak_array=new Array();
	var first='';
	if (value){
		first=id+'='+value;
	}
	if (cookie){
	  ablak_array=cookie.split("&");
		if(ablak_array.length>3){
			loop=3;
		}else{
			loop=ablak_array.length;
		}
	}else{
		index=0;
	}
  var found;
	var loop;
  var index=0;
	var new_ablak_array=new Array();
//	alert("oldarr:"+ablak_array);
  while (index < loop){
    ablak=ablak_array[index];
    var tmp=ablak.split('=');
    tmpid= tmp[0];
    tmpvalue=tmp[1];
    var string;

    if (id == tmpid){
      found=1;
			string=''
    }else	{
			new_ablak_array.push(ablak);
    }
		index+=1;

	}
	if (first){
		new_ablak_array.unshift(first)
  }
//	alert('naa:'+new_ablak_array);
	var newcookie=new_ablak_array.splice(0,3).join('&');
//	alert('new cookie:'+newcookie);
  Utils.Cookie.set('ablakok',newcookie);
	return false;
	
}



function getId (obj){
  var id;
  id=obj.getAttribute('id');
	var arr=id.split("_");
  return arr[1];
}

function process_kapu_ablakok(debug) {

 //   Utils.Cookie.set('ablakok','')

  cookie=Utils.Cookie.get('ablakok');
  if (cookie == null){
    var kinyilok= new Array();
    var value='';
    kinyilok= getElementsByClass('kinyilo');
    for (i in kinyilok){
      id=getId(kinyilok[i]);
      var string=id+'=0';
      if (value){
        string = '&'+string;
      }
      if (id){
        value=value+string;
      }
    }
//    alert('creating cookie'+value);

//    Utils.Cookie.set('ablakok',value)
    Utils.Cookie.set('ablakok','')
  }else{
    var ablak_array=cookie.split("&");
    var index=0;
    var found
    while (index < ablak_array.length)
    {
      ablak=ablak_array[index];
      var tmp=ablak.split('=');
      tmpid = tmp[0];
      tmpvalue=tmp[1];
      if (tmpvalue == 1){
//			alert('nyit:'+tmpid);
        showhide(tmpid,'block',1);
      }
      index+=1;


    }

//    alert('orig cookie:'+cookie);

  }
}
function resize_banner(){
}

function resize_banners(kapu){
	var plus_style;
	var plus;
	if (kapu){
		plus_style='_kapu';
		plus=45;
	}else{
		plus_style='';
		plus=0;
	}
  div1=document.getElementById("balbanner" + plus_style);
  div2=document.getElementById("jobbbanner" + plus_style);
	if (!div1 && !div2){
		return;
	}
	
	if (self.innerWidth)
	{
		winW = self.innerWidth;
		winH = self.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientWidth)
	{
		winW = document.documentElement.clientWidth;
		winH = document.documentElement.clientHeight;
	}
	else if (document.body)
	{
		winW = document.body.clientWidth;
		winH = document.body.clientHeight;
	}
	else return;
	if (div1){
  	div1.style.left=winW/2-488;
	  div1.style.top=218 + plus;
		div1.style.display='block';
	}
	if (div2){
	  div2.style.left=winW/2+347;
	  div2.style.top=218 + plus;
		div2.style.display='block';
	}
}

