/**
 * $Id$
 * $RCSfile$
 * $Revision$
 * $Author$
*/

function uzenet(str) {
	alert(str);
}

function ell(miben, szoveg) {
	if (miben.value == '') {
		miben.focus();
		window.scrollBy(0,-10);
		uzenet(szoveg);
		return false;
	}
	return true;
}

function ell2(bool, miben, szoveg, scroll) {
	if (ell2.arguments[3] == undefined)
		scroll = false;
  if (bool == false) {
		if (!scroll) {
			miben.focus();
			window.scrollBy(0,-10);
		}
		else {
			if (typeof(miben) == 'string' && miben.charAt(0) == '#')
				window.location = miben;
			else {
				miben.scrollIntoView();
				window.scrollBy(0,-10);
			}
		}
    uzenet(szoveg);
    return false;
  }
  return true;
}

function ert_ell(_val, _type, _length1, _length2) {
	switch (_type.toLowerCase()) {
		case 'szam':
				x = parseInt(_val, 10);
				if (!isNaN(x)) {
					if (x == _val) return true;
				}
				return false;
			break;
		case 'egyszam':
				zz = _val;
				for (x = 0;x < zz.length;x++) if (!isNaN(parseInt(zz.charAt(x)))) return true;
				return false;
			break;
		case 'egybetu':
				zz = _val;
				for (x = 0;x < zz.length;x++) if (isNaN(parseInt(zz.charAt(x)))) return true;
				return false;
			break;
		case 'minhossz':
				x = "_" + _val;
				if (x.length >= _length1 + 1) return true;
				return false;
			break;
		case 'maxhossz':
				x = "_" + _val;
				if (x.length <= _length1 + 1) return true;
				return false;
			break;
		case 'minmax':
				x = "_" + _val;
				if ((x.length >= _length1 + 1) && (x.length <= _length2 + 1)) return true;
				return false;
			break;
		case 'emailcim':
				var kukac = _val.indexOf('@');
				if (kukac < 1) return false;
				if (_val.length < kukac+3) return false;
				var vege = _val.substr(kukac+1);
				var vanbenne = false;
				if (kukac+1 == _val.length) return false;
				for (i=kukac+1;i<_val.length;i++)
					if (_val.charAt(i) == '.')
						vanbenne = i;
				if (!vanbenne) return false;
				if (_val.length-vanbenne < 3) return false;
				return true;
			break;
	}
}

function init_nwl_signup() {
  _submit = document.getElementById('signup');
  _submit.onclick = function () {

    var df = document.forms['signup_form'];

    if (!ell(df.name,'Kérjük, adja meg a nevét.')) return false;
    if (!ell2(ert_ell(df.email.value,'emailcim'),df.email,'Kérjük, adja meg email címét.')) return false;

    document.forms['signup_form'].submit(); return false;
  }
}

function init_nwl_signoff() {
  _submit = document.getElementById('unsign');
  _submit.onclick = function () {

    var df = document.forms['unsign_form'];
    if (!ell2(ert_ell(df.email.value,'emailcim'),df.email,'A leiratkozáshoz kérjük, adja meg email címét.')) return false;

    document.forms['unsign_form'].submit(); return false;

  }
}

function productSwitch(prod)
{
  _link = document.getElementById('switch'+prod);
  _link.onclick = function() {
    if(activeProductInfo != prod)
    {
    _newHref = document.getElementById('switch'+prod);
    _newHref.className = "red";
    _activeHref = document.getElementById('switch'+activeProductInfo);
    _activeHref.className = "dark";

    _active = document.getElementById(activeProductInfo);
    _div = document.getElementById(prod);
    _active.style.display = "none";
    _div.style.display = "block";
    activeProductInfo = prod;

    window.resizeBy(0, 1);
    window.resizeBy(0, -1);
    }
    return false;

  }
}

function dg(string) {
  return document.getElementById(string);
}

function indexCustomBoxes()
{
  /* IE bug workaround alfacsatornas PNG-k miatt */
  _rightbox = document.getElementById('Right');
  _rdivs = _rightbox.getElementsByTagName('div');

  for( var i=0; i<_rdivs.length; i++ )
  {
    if(_rdivs[i].className == 'indexcustombox')
    {
      obj = _rdivs[i];
      _custombox = obj.getElementsByTagName('div');
      _h2 = obj.getElementsByTagName('h2');
      for( var k=0; k<_custombox.length; k++ )
      {
        if(_custombox[k].className == 'bottom')
          _bottom = _custombox[k];
      }
      for( var k=0; k<_custombox.length; k++ )
      {
        if(_custombox[k].className == 'content')
        {
          _divcontent = _custombox[k];
          _divcontent.firstChild.style.visibility = 'hidden';
          _divclone = _divcontent.cloneNode(true);
          _divorig = _divcontent.cloneNode(true);
          _divclone.className = "IEcontent";
          _divclone.firstChild.style.visibility = 'visible';
          _divorig.className = "DOMcontent";
          obj.insertBefore(_divclone,_bottom);
          obj.insertBefore(_divorig,_bottom);
          obj.removeChild(_divcontent);
        }
      }
    }
  }
}

function indexServiceBox()
{
    /* IE bug workaround alfacsatornas PNG-k miatt */
     obj = document.getElementById('Services');
     //obj.style.visibility = 'hidden';

     _custombox = obj.getElementsByTagName('div');

    /* a lista elemek alatti vonalak legyenek egyvonalban */
     for( var k=0; k<_custombox.length; k++ )
     {
       if(_custombox[k].className == 'content')
       {
         _lis = _custombox[k].getElementsByTagName('li');
         for( var i=0; i<_lis.length; i++ )
         {
           /* kettesével vizsgálunk */
           if(i % 2 == 0)
           {
             if(_lis[i+1]){
               if( _lis[i].offsetHeight >= _lis[i+1].offsetHeight )
                 {
                   /* le kell vonni a paddingot... */
                   _newheight = eval(_lis[i].offsetHeight - 23);
                   _lis[i+1].style.height = _newheight+'px';
                 } else {
                   /* le kell vonni a paddingot... */
                   _newheight = eval(_lis[i+1].offsetHeight - 23);
                   _lis[i].style.height = _newheight+'px';
                 }
             }
           }
         }
       }
     }


     _h2 = obj.getElementsByTagName('h2');
     for( var k=0; k<_custombox.length; k++ )
     {
       if(_custombox[k].className == 'bottom')
         _bottom = _custombox[k];
     }
     for( var k=0; k<_custombox.length; k++ )
     {
       if(_custombox[k].className == 'content')
       {
         _divcontent = _custombox[k];
         _divcontent.firstChild.style.visibility = 'hidden';
         _divclone = _divcontent.cloneNode(true);
         _divorig = _divcontent.cloneNode(true);
         _divclone.className = "IEcontent";
         _divclone.firstChild.style.visibility = 'visible';
         _divorig.className = "DOMcontent";
         obj.insertBefore(_divclone,_bottom);
         obj.insertBefore(_divorig,_bottom);
         obj.removeChild(_divcontent);
       }
    }

   // obj.style.display = 'block';

}

function apmArchive()
{
  /* archivum box csikicsuki */
  if(document.getElementById('apmArchive'))
  {
    _archive = document.getElementById('apmArchive');
    _hrefs = _archive.getElementsByTagName('a');
    for( var i = 0; i < _hrefs.length; i++ )
    {
      if(_hrefs[i].className.indexOf('red') > -1)
      {
        _hrefs[i].id = 'apmA'+i;
        if(_hrefs[i].parentNode.className == 'opened' )
        {
          apmOpened = _hrefs[i].id;
        }
        _hrefs[i].onclick = function() {
          if(apmOpened)
          {
            document.getElementById(apmOpened).parentNode.className = '';
            document.getElementById(apmOpened).parentNode.className = 'closed';
          }
          this.parentNode.className = '';
          this.parentNode.className = 'opened';
          apmOpened = this.id;
          return false;
        }
      }
    }
  }
}

function hideSubmitValue()
{
  /* eltunteti a submit value erteket ahol a submit elem class-a 'noval' */
  _inputs = document.getElementsByTagName('input');
  for( var i = 0; i < _inputs.length; i++ )
  {
    if( (_inputs[i].getAttribute('type') == 'submit') && ( _inputs[i].className.indexOf('noval') > -1 )  )
      {
         _inputs[i].setAttribute("value", "");
      }
  }
}

function targetHrefNew()
{
  /* uj ablakba nyitja meg azon linkeket melyek class-a 'new' */
  _hrefs = document.getElementsByTagName('a');
  for( var i = 0; i < _hrefs.length; i++ )
  {
    if( ( _hrefs[i].className.indexOf('new') > -1 )  )
      {
         _hrefs[i].onclick = function()
         {
           window.open(this.getAttribute('href'), "_blank", "");
           return false;
         }
      }
  }
}

function printPage()
{
  if(document.getElementById('Print'))
    {
      _print = document.getElementById('Print');
      _print.onclick = function ()
      {
        void(window.print()); return false;
      }

    }
}


var apmOpened;
apmOpened = false;
