
function PP_init_js()
{
 
	if (ns4)
	skn=document.dek
	else if (ns6)
	skn=document.getElementById("dek").style
	else if (ie4)
	skn=document.all.dek.style
	if(ns4)document.captureEvents(Event.MOUSEMOVE);
	else{
	skn.visibility="visible"
	skn.display="none"
	}

}


// szöveg

function refocus_msg(obj)
{
 obj.focus();
}

function savecaret_msg(obj)
{
  if (!document.all) return;

  if (obj.isTextEdit) 
    obj.caretPos = document.selection.createRange();
}

function instext_msg(obj, txt)
{
  if (isie)
  {
   if (!obj.isTextEdit) return;

    if ( obj.caretPos )
       obj.caretPos.text = replaceSubstring_msg(txt,'%selected%',obj.caretPos.text);
    else
       obj.value = obj.value + replaceSubstring_msg(txt,'%selected%','');
  }
  else
  {
    otext = obj.value; ss = obj.selectionStart;	se = obj.selectionEnd;
	txt = replaceSubstring_msg(txt,'%selected%',otext.substring(ss,se));
    obj.value = otext.substring(0,ss) + txt + otext.substring(se, otext.length);
    obj.selectionStart = ss + txt.length;
    obj.selectionEnd = obj.selectionStart;
  }
}

function insertcode_msg(obj,code)
{
 if (isopera)
   with (obj) 
     value += replaceSubstring_msg(code,'%selected%','');
 else
   instext_msg(obj,code);
 return true;
}

function replaceSubstring_msg(text,expression,value){
  var exp = new RegExp(expression,'g');
  return text.replace(exp,value);
}

 var isie = (document.all);
 var isopera = (navigator.userAgent.indexOf('Opera')!=-1);

 
// onclick="insertcode_msg(':)'); refocus_msg(); return false;"
 
  
 
 // ablakok


function myquery_msg(promptcaption, defvalue)
{
  return window.prompt(promptcaption,defvalue);
}

function insertcodequery_msg(obj,code, promptcaption, defvalue)
{
 
  x = window.prompt(promptcaption,defvalue);
  if(!x) return false;
  if (x!="undefined") {
    code = replaceSubstring_msg(code,'%input%',x);
    return insertcode_msg(obj,code);
  }
}

function insertcodequery2_msg(obj,code, promptcaption, defvalue, esel)
{
  sel="";
  if (isie){ if (!obj.isTextEdit) return; if ( obj.caretPos ) sel= obj.caretPos.text; }else  sel= obj.value.substring(obj.selectionStart,obj.selectionEnd);
  if(sel=='') sel= esel;
  defvalue = replaceSubstring_msg(defvalue,'%selected%',sel);
  return insertcodequery_msg(obj,code, promptcaption, defvalue);
}
 

 
 
 
 //help
 

function ablak(url,nev,w,h,scroll){LeftPosition=(screen.width)?(screen.width-w)/2:0;TopPosition=(screen.height)?(screen.height-h)/2:0;settings='height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable';new_window=window.open(url,nev,settings)}

Xoffset=0;Yoffset= 25;var old,skn,iex=(document.all),yyy=-1000;var ns4=document.layers;var ns6=document.getElementById&&!document.all;var ie4=document.all;
show_dek=1;



function OnPopup(msg){

clearTimeout(timer1);

if(kill_dek) return;

var content='&nbsp;'+ msg + '&nbsp;';
show_dek=1;

if(ns4){skn.document.write(content);skn.document.close();skn.visibility="visible"}
if(ns6){document.getElementById("dek").innerHTML=content;skn.display=''}
if(ie4){document.all("dek").innerHTML=content;skn.display=''}

skn.left=mx+Xoffset+"px";
skn.top=my+Yoffset+"px";

}

function popup(msg){
 kill_dek=0;
 timer1 = setTimeout("OnPopup('"+msg+"')",500);
};

document.onmousemove=get_mouse;

function get_mouse(e){
 
 if(!skn) return;
 
 scrollx=(document.documentElement.scrollLeft?document.documentElement.scrollLeftt:document.body.scrollLeft);
 scrolly=(document.documentElement.scrollTop?document.documentElement.scrollTop:document.body.scrollTop);
 mx=(ns4||ns6)?e.pageX:event.x+scrollx;
 my=(ns4||ns6)?e.pageY:event.y+scrolly;
 if(show_dek)
 {
  skn.left=mx+Xoffset+"px";
  skn.top=my+Yoffset+"px";
 }
 else skn.top="-1000px";
 
}


function kill(){
show_dek=0;
kill_dek=1;
clearTimeout(timer1);

}


function popup_marks(points, votes){			

  if(votes>0) popup("Értékelés: "+ Math.round(points / votes *10)/10 + "<br /> " + points + " pont &nbsp; " + votes + " szavazat");
  else popup("Nem érkezett szavazat");

}

function hot(obj){
 var r;

if(!document.styleSheets[0].rules) return;

for(j=0;j<document.styleSheets.length;j++)
	for(i=0;i<document.styleSheets[j].rules.length && i<5;i++)
	{
	 r=document.styleSheets[j].rules[i];
	 
	 if(r.selectorText==".forum_topics TR."+obj.className+":hover"){ obj.style.backgroundColor= r.style.backgroundColor; return; };
	 
	}

}

function cool(obj){

 if(!obj.getBoundingClientRect) return;

 var r= obj.getBoundingClientRect();
  
 if(event.y<r.top+2 || event.y>r.bottom-2 || event.x<r.left+2 || event.x>r.right-2 ) obj.style.backgroundColor="";
 
 
}

function checkall()
{
	c=document.Levelek.elements.length;
	for (i=0;i<c;i++)
	if (document.Levelek.elements[i].type=="checkbox")
	{
	  document.Levelek.elements[i].checked=true;
	}
}
