//Default 
helpFile="index.html";
helpAttribs = 'resizable=no,left=10,top=10,screenX=12,screenY=12,height=300,width=510,status=no,scrollbars=yes,toolbar=no,menubar=no,location=no';

DOM = (document.getElementById) ? true : false;
NS = navigator.appName == "Netscape";
NS4 = (document.layers) ? true : false;
IE = (document.all) ? true : false;
IE4 = IE && !DOM;
ver4 = (NS4 || IE4);
IE5 = (IE4 && navigator.appVersion.indexOf("5.")!=-1);
isMac = (navigator.appVersion.indexOf("Mac") != -1);
isMenu = (NS4 || (IE4 && !isMac) || (IE5 && isMac));

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();
}
MM_reloadPage(true);

function openWindow (url, winName, features) {
  window.open (url, winName, features);
}

function openHelp (url) {
  window.open(url, "Help", helpAttribs);
}

function displayStatusMsg (msg) {
  status=msg;
  document.returnValue=true;
}

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_callJS(jsStr) { //v2.0
  return eval(jsStr)
}

function setPrinterDefaults () {
  printer.header = "";
  printer.footer = "";
}


function clearListBoxItems (frmName, listName) {
   var list = document.forms[frmName].elements[listName];
   
   if (list != null && list.type == "select" || list.type == "select-one") {
     list.options.length = 0;
   }
   else {
     alert ('list is null!');
   }
}

function addOptionIE(selectVar,itemText,itemValue) {
//  alert ("Enter addOptionIE, test:"+itemText+" value:"+itemValue);
  var newOpt = document.createElement("OPTION");
  newOpt.text=itemText;
  newOpt.value=itemValue;
  newOpt.selected = true;
  alert ("newopt"+newOpt+" selectVar:"+selectVar.name);
  selectVar.add(newOpt);
  alert (selectVar.options[0]);
}
	
function addOptionNS(selectVar,itemText,itemValue) {
//  alert ("Enter addOptionNS, test:"+itemText+" value:"+itemValue);
  var newOpt  = new Option(itemText, itemValue);
  var selLength = selectVar.length;
  selectVar.options[selLength] = newOpt;
}
	      
function addOptionDOM (selectVar,itemText,itemValue) {
//  alert ("Enter addOptionDom, test:"+itemText+" value:"+itemValue);
  var newOpt  = new Option(itemText, itemValue, true);
  var selLength = selectVar.length;
//  alert ("length:"+selLength+" newopt"+newOpt);
  selectVar.options[selLength] = newOpt;
}

function addOption (selectVar,itemText,itemValue) {
//  alert ("Enter addOption");
  if (NS4) {
//    alert ("ns4");
    addOptionNS(selectVar,itemText,itemValue);
  }
  else if (IE) {
//    alert ("ie");
    addOptionIE(selectVar,itemText,itemValue);
  }
  else if (DOM) {
//    alert ("dom");
    addOptionDOM (selectVar, itemText, itemValue);
  }
  else {
    alert ("milyen browserunk van?");
  }
}

function addListBoxItemFromListBox (fromList, toList) {
//  alert("fromlist:"+fromList+" toList:"+toList);
  if (toList != null && toList.type=="select-multiple" || toList.type=="select-one") {
//     alert ("1");
     fromOpt = fromList.options[fromList.selectedIndex];
     if (fromOpt) {
//       alert("2"+fromOpt);
       addOption (toList, fromOpt.text, fromOpt.value);
     }
     else {
       alert ("fromOpt is null");
     }
  }       
}

function addListBoxItem (toList, itemText, itemValue) {
// alert ("tolist:"+toList+", itemText:"+itemText+", itemValue:"+itemValue);
  if (toList != null && toList.type=="select-multiple" || toList.type=="select-one") {
       addOption (toList, itemText, itemValue);
  }
}

function getElement(id) {
   return document.getElementById ? document.getElementById(id) :
   						document.all ? document.all(id) : null;
}

function getRealLeft(id) {         
	var el = getElement(id);
	if (el) {
		xPos = el.offsetLeft;
		tempEl = el.offsetParent;
		while (tempEl != null) {
			xPos += tempEl.offsetLeft;
			tempEl = tempEl.offsetParent;
		}
		return xPos;
	}
}

function getRealTop(id) {
	var el = getElement(id);
	if (el) {
		yPos = el.offsetTop;
		tempEl = el.offsetParent;
		while (tempEl != null) {
			yPos += tempEl.offsetTop;
			tempEl = tempEl.offsetParent;
		}
		return yPos;
	}
}

function replaceAll(strInput, strFind, strRepl) {
	while (strInput.indexOf(strFind) > -1) {
    	strInput = strInput.replace(strFind, strRepl);
	}
	return strInput;
}

function submitLink ( formId, action ) {
   var form=getElement(formId);
   if (form != null) {
     form.action=action;
     form.submit();
   }
}
  
function whatCorrector() {
  var replaces = 0;
  var alltags = document.all ? document.all.tags("SPAN") : document.getElementsByTagName("*");
  for (i=0; i < alltags.length; i++) {
    if (alltags[i].className == 'what') {
      while (alltags[i].innerHTML.indexOf('drotostoth') != -1 && replaces < 10000) {
        var ih = alltags[i].innerHTML;
        ih = replaceAll(ih, 'drotostoth', String.fromCharCode(64));
        ih = ih.replace('level:', 'mailto:');
        alltags[i].innerHTML = ih;
        replaces++;
      }
    }
  }
}

function onLoad (img){
	MM_preloadImages (img);
	whatCorrector ();
}