
function divmoveup(divid)
{
var divem = document.getElementById(divid);
divem.scrollTop += 25;
}

function divmovedown(divid)
{
var divem = document.getElementById(divid);
divem.scrollTop -= 25;
}

function getMousePosY(e) { //you need the 'e', although it does NOT need to be defined
if (document.all) 
	{
	return window.event.clientY;
	}
}


function change_pic(picID,src)
{
var pic = document.getElementById(picID);
pic.src = src;
return true;
}

function VisHid(DivID, mode) // set visible or hidden
{
var Dstyle;
var objs;
if (document.all)
	{ objs = document.all.tags("DIV");}
else if (document.getElementsByTagName)
	{ objs = document.getElementsByTagName("DIV");}
else if (document.layers)
	{ objs = document.layers["DIV"];}
else
	{ alert('Sorry, Your browser does not support this'); }

for (var i=0; i<objs.length; i++)
	{
	if (objs[i].id.substring(0,4) == 'mnu_')
	objs[i].style.display = "none";
	}

if (mode == 'hide')
	{	document.getElementById(DivID).style.display='none';}
if (mode == 'show')
	{	document.getElementById(DivID).style.display='block';}

return true;
}

function csikicsuki(DivID)	// A bezarando div id-je
{	var Dstyle;
	var objs;
	if (document.all)
	{ objs = document.all.tags("DIV");}
	else if (document.getElementsByTagName)
	{ objs = document.getElementsByTagName("DIV");}
	else if (document.layers)
	{ objs = document.layers["DIV"];}
	else
	{ alert('Sorry, Your browser does not support this'); }
	
	for (var i=0; i<objs.length; i++) 
	{
	if (objs[i].id.substring(0,4) == 'mnu_')
	objs[i].style.display = "none";
	}

	if (document.all)
		Dstyle=document.all[DivID].style;
			else
		Dstyle=document.getElementById(DivID).style; 

	if (Dstyle)	if(Dstyle.display == 'block')
		Dstyle.display='none';
			else
		{
		Dstyle.display='block';
		}
}

function hide_div(DivID)	// A bezarando div id-je
{	var Dstyle;
	var objs;
	if (document.all)
	{ objs = document.all.tags("DIV");}
	else if (document.getElementsByTagName)
	{ objs = document.getElementsByTagName("DIV");}
	else if (document.layers)
	{ objs = document.layers["DIV"];}
	else
	{ alert('Sorry, Your browser does not support this'); }
	
	if (document.all)
		Dstyle=document.all[DivID].style.display='none';
			else
		Dstyle=document.getElementById(DivID).style.display='none';
}

/* -------- */
/* menu - start */
navHover = function() {
	if (!document.getElementById("navmenu")) return false;
	var lis = document.getElementById("navmenu").getElementsByTagName("LI");
	for (var i=0; i<lis.length; i++){
		lis[i].onmouseover=function(){this.className+=" iehover";}
		lis[i].onmouseout=function(){this.className=this.className.replace(new RegExp(" iehover\\b"),"");}}}
if (window.attachEvent) window.attachEvent("onload", navHover);
/* menu - end */

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];}
}

var b64str = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"+"abcdefghijklmnopqrstuvwxyz"+"0123456789+/=";
var b64str_m = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"+"abcdefghijklmnopqrstuvwxyz"+"0123456789-_=";
// -lett a + helyett és _ a / helyett

function base64enc(inp,m)
{

 if (inp=="") return("");

 var b64ch=(m==1)?b64str:b64str_m;

 for (i=0;i<inp.length;i++)
 {
   //if (inp.charCodeAt(i)>255) alert("i:"+i+" code:"+inp.charCodeAt(i)+" ch:"+inp.charAt(i));
   if (inp.charCodeAt(i)>255) alert("i:"+i+" code:"+inp.charCodeAt(i)+" code:"+inp.charCodeAt(i+1));
   //alert(inp.charCodeAt(i)+inp.charAt(i));
 }

 if (typeof(btoa)=="function")
  {
    alap=btoa(inp);
    if (m!=1)
    {
     alap=alap.replace(/\x2B/g,"-");
     alap=alap.replace(/\x2F/g,"_");
    }
    return alap;
  }

    var out = ""; //This is the output
    var chr1, chr2, chr3 = ""; //These are the 3 bytes to be encoded
    var enc1, enc2, enc3, enc4 = ""; //These are the 4 encoded bytes
    var i = 0; //Position counter

    do
    { //Set up the loop here
        chr1 = inp.charCodeAt(i++); //Grab the first byte
        chr2 = inp.charCodeAt(i++); //Grab the second byte
        chr3 = inp.charCodeAt(i++); //Grab the third byte

        //Here is the actual base64 encode part.
        //There really is only one way to do it.
        enc1 = chr1 >> 2;
        enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
        enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
        enc4 = chr3 & 63;

        if (isNaN(chr2))
        {
          enc3 = enc4 = 64;
        }
         else if (isNaN(chr3))
         {
            enc4 = 64;
         }

        //Lets spit out the 4 encoded bytes
        out = out + b64ch.charAt(enc1) + b64ch.charAt(enc2) + b64ch.charAt(enc3) + b64ch.charAt(enc4);

        // OK, now clean out the variables used.
        chr1 = chr2 = chr3 = "";
        enc1 = enc2 = enc3 = enc4 = "";

    } while (i < inp.length); //And finish off the loop

    //Now return the encoded values.
    return out;
}

function addbookmark(url, msg)
{
if(navigator.appName == 'Microsoft Internet Explorer')
{
if (document.all)
window.external.AddFavorite(url, msg)

}
else if(navigator.appName == 'Netscape')
{
if ((typeof window.sidebar == 'object') && (typeof window.sidebar.addPanel == 'function'))
window.sidebar.addPanel (msg, url,'');
}
}

function goto_cursor(targetNAME)
{
	document.getElementsByName(targetNAME)[0].focus();   
}

function date_separator(element)
{
var num = element.value;
num = num.replace(/-/g,"");
if (num.length >= 6)
 {
 var year = num.substr(0,4);
 var month = num.substr(4,2);
 var day = num.substr(6,2);
 num = year + "-" + month + "-" + day;
 document.getElementById(element.id).value = num;
 return;
 }
if (num.length >= 4)
 {
 var year = num.substr(0,4);
 var month = num.substr(4,2);
 num = year + "-" + month;
 document.getElementById(element.id).value = num;
 return;
 }
}


function createGradient() {
if(!document.getElementById)return;

objArray = getGradientObjects();
if(!objArray.length) return;

for(i=0;i<objArray.length;i++) {
params = objArray[i].className.split(" ");
if(document.all && !window.opera) {
objArray[i].style.width = objArray[i].offsetWidth + "px";
params[3] == "horizontal"?gType = 1:gType = 0;
objArray[i].style.filter = "progid:DXImageTransform.Microsoft.Gradient(GradientType="+gType+",StartColorStr=\"#" + params[1] + "\",EndColorStr=\"#" + params[2] + "\")";
} else {
colorArray = createColorPath(params[1],params[2]);
x=0;y=0;
if(params[3] == "horizontal") {
w=Math.round(objArray[i].offsetWidth/colorArray.length);
if(!w)w=1;
h = objArray[i].offsetHeight;
} else {
h = Math.round(objArray[i].offsetHeight/colorArray.length);
if(!h) h =1;
w = objArray[i].offsetWidth;
}
makeGrandParent(objArray[i]);
tmpDOM = document.createDocumentFragment();
for(p=0;p<colorArray.length;p++) {
g = document.createElement("div");
g.setAttribute("style","position:absolute;z-index:0;top:" + y + "px;left:" + x + "px;height:" + h + "px;width:" + w + "px;background-color:rgb(" + colorArray[p][0] + "," + colorArray[p][1] + "," + colorArray[p][2] + ");");
params[3] == "horizontal"?x+=w:y+=h;
tmpDOM.appendChild(g);
if(y>=objArray[i].offsetHeight || x >= objArray[i].offsetWidth) break;
}
//Csalás eleje!!!
if ((x<objArray[i].offsetWidth) && (params[3] == "horizontal")){
g = document.createElement("div");
g.setAttribute("style","position:absolute;z-index:0;top:" + y + "px;left:" + x + "px;height:" + h + "px;width:" + (objArray[i].offsetWidth-x) + "px;background-color:rgb(" + colorArray[p-1][0] + "," + colorArray[p-1][1] + "," + colorArray[p-1][2] + ");");
tmpDOM.appendChild(g);
}
//Csalás vége!!!
objArray[i].appendChild(tmpDOM);
tmpDOM = null;
}
}
}

function getGradientObjects() {
	a = document.getElementsByTagName("*");
	objs = new Array();
	for(i=0;i<a.length;i++) {
		c = a[i].className;
		if(c != "") if(c.indexOf("gradient") == 0) objs[objs.length] = a[i];
	} 
	return objs;
}
	
function createColorPath(color1,color2) {
	colorPath = new Array();
	colorPercent = 1.0;
	do {
		colorPath[colorPath.length]=setColorHue(longHexToDec(color1),colorPercent,longHexToDec(color2));
		colorPercent-=.01;
	} while(colorPercent>0);
	return colorPath;
}
		
function setColorHue(originColor,opacityPercent,maskRGB) {
	returnColor=new Array();
	for(w=0;w<originColor.length;w++) returnColor[w] = Math.round(originColor[w]*opacityPercent) + Math.round(maskRGB[w]*(1.0-opacityPercent));
	return returnColor;
}

function longHexToDec(longHex) {
	return new Array(toDec(longHex.substring(0,2)),toDec(longHex.substring(2,4)),toDec(longHex.substring(4,6)));	
}

function toDec(hex) {	
	return parseInt(hex,16);
}
	
function makeGrandParent(obj) {
	disp = document.defaultView.getComputedStyle(obj,'').display;
	disp == "block"?nSpan = document.createElement("div"):	nSpan = document.createElement("span");
	mHTML = obj.innerHTML;
	obj.innerHTML = "";
	nSpan.innerHTML = mHTML;
	nSpan.setAttribute("style","position:relative;z-index:10;");
	obj.appendChild(nSpan);
}
