var ns4,ie4,ns6;
ns4 = (document.layers)? true:false;
ie4 = (document.all)? true:false;
if (ie4) ns6=false ; 
else ns6 = (document.getElementById)? true:false;
//alert ("ns4="+ns4+"  ie4="+ie4+"  ns6="+ns6)

var Animation = false ;

var BASEx=0 ;
var BASEy=0 ;
var Initialized = false ;


function initialize()
{
  initBasePos() ;
  setupLayers() ;
  Initialized = true ;
}

function setInitialized( AInitialized )
{
  Initialized = AInitialized ;
}

function PAli_startAnimation()
{
  Animation = true ;
}

function kvoid() 
{
}

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 PAli_findObj(n, d) { //v6.0
  var p,i,x;
  if (ns6) { 
    if((n.indexOf("?"))>0&&parent.frames.length) {
      t=n.split("?"); x=eval("parent.frames['"+t[1]+"'].document.getElementById('"+t[0]+"')");} 
    else {
      x=document.getElementById(n);if (x==null) x=document.getElementsByName(n)[0];}
  }
  else {
    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=PAli_findObj(n,d.layers[i].document);
  }
return x;
}



function PAli_showHideLayers() { //v3.0A Modified by Sparber/Foti for NN6 Compatibility
  var i,p,v,obj,args=PAli_showHideLayers.arguments;

//  if(document.getElementById){
//    for (i=0; i<(args.length-2); i+=3){
//      obj=PAli_findObj(args[i]);
//      v=args[i+2];
//      v=(v=='show')?'visible':(v='hide')?'hidden':v;
//      if (obj) { obj.style.visibility=v; }
//    }
//  } else {


      if ( ! Initialized ) initialize() ;

      for (i=0; i<(args.length-2); i+=3) 
        if ((obj=PAli_findObj(args[i]))!=null) { 
            v=args[i+2];
            if (obj.style) { 
                obj=obj.style;
                v=(v=='show')?'visible':(v='hide')?'hidden':v; 
             }
             obj.visibility=v; 
         }
//  }
}


function PAli_swapImage() 
{ 
  //alert ("ok")
  var i,j=0,x,a=PAli_swapImage.arguments; 

  asrc=new Array;
  for(i=0; i< (a.length-2); i+=3 )
  {   
    if ((x=PAli_findObj(a[i]))!=null)
    {
      asrc[j++]=x;
      if(!x.oSrc) x.oSrc=x.src; 
      x.src=a[i+2];
    }
  }
}



function PAli_swapImgRestore() 
{ //v3.0
  var i,x ; 
  for(i=0;asrc && i<asrc.length && (x=asrc[i]) && x.oSrc; i++ ) x.src=x.oSrc ;
}




//------------------------------specials------------------------------------------


function preloadImages_HU() {
MM_preloadImages(
		'images/HU/menu_intro_A.png',
		'images/HU/menu_intro_B.png'
		)
}

function preloadImages_EN() {
MM_preloadImages(
		'images/n_MagyarZaszlo_A.gif',
		'images/en_menuTevekenysegek_A.gif'
		)
}

function preloadImages_GE() {
MM_preloadImages(
		'images/n_MagyarZaszlo_A.gif',
		'images/n_MagyarZaszlo_B.gif',
		'images/ge_menuTevekenysegek_A.gif'
		)
}




function initBasePos()
{
  //alert ("haho");

   var IsIndex = false ; 
   var obj=PAli_findObj('LogoImg');
   if ( obj == null )
   {
      obj=PAli_findObj('IndexMenuTop');
      IsIndex=true ;
   }
   //if ( obj == null ){} alert("does not exists") ;return ;}
   
   if (ns4) { BASEx=obj.x ; BASEy=obj.y; }
   if (ie4 || ns6)
   { 
      //alert("Itt vagyunk"); 
      BASEx = obj.offsetLeft; 
      BASEy = obj.offsetTop ; 
      
 
      
      tempEl = obj.offsetParent;
      while (tempEl != null) 
      {
         BASEx += tempEl.offsetLeft;
         BASEy += tempEl.offsetTop;   
         tempEl=tempEl.offsetParent;
      }
      //alert ("x="+xPos+"  y="+yPos);
   }
   
   if ( IsIndex )
   {
     BASEx -= 5 ; //5;  
     BASEy -= 206 ; //148 ; 
   }
   
 //alert ("ahoj BASEx="+ BASEx );
}

function setupLayers() 
{
 //alert ("ahoj BASEx="+ BASEx );
 
   //Setting layer positions
   OBJMenuIntroLayer = PAli_findObj('MenuIntroLayer');
   OBJMenuUserLayer = PAli_findObj('MenuUserLayer');

   if (ie4 || ns6)
   {
      OBJMenuIntroLayer=OBJMenuIntroLayer.style;
      if ( OBJMenuUserLayer != null ) OBJMenuUserLayer=OBJMenuUserLayer.style;
   }
 

   OBJMenuIntroLayer.left = BASEx-22; //BASEx+20;
   OBJMenuIntroLayer.top = BASEy+193 ; 
 
   if ( OBJMenuUserLayer != null )
   { 
      OBJMenuUserLayer.left = BASEx-22; 
      OBJMenuUserLayer.top = BASEy+295 ;
   } 
}




function PAli_ViewImageInWindow(ImgName,w,h) 
{
  ImgWindow=window.open('',
    "mosMarTudomMinekVanItt",
    "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,"+
    "width="+w+",height="+h+"");
  imgWindow.focus();
  image="<BODY BACKGROUND= " + ImgName + " >";
  ImgWindow.document.write(image);
  ImgWindow.document.close();

}



function PAli_detailsWindow(fileName,w,h) 
{
imgWindow=window.open(fileName,
		"imgWindow",
		"toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1,"+
		"width="+w+",height="+h+"");
imgWindow.focus();
//imgsWindow.close() ;
}


var BlinkSpeed = 300 ;

function blink(layerName)
{
   if (NS4 || IE4) 
   { 
      if(i%2==0)
      {
        eval(layerRef+'["'+layerName+'"]'+
        styleSwitch+'.visibility="visible"');
      }
      else
      {
        eval(layerRef+'["'+layerName+'"]'+
        styleSwitch+'.visibility="hidden"');
      }
    } 

    if(i<1)
    {
      i++;
    } 
    else
    {
      i--
    }
    setTimeout("Blink('"+layerName+"')",BlinkSpeed);
}


var scrollerheight=18;
var scrollerwidth=450;
var scrollertop ;
var ScrollerLeft ;
var cliptop=0;
var clipbottom=scrollerheight;
var clipleft=0;
var clipright=scrollerwidth ;
var i_height=0;
var step=1;
var pause=25;
var totalheight;
var TotalWidth ;
var OBJscrollertext;

function addRealXYprop(imgElem) 
{
  var obj=PAli_findObj(imgElem);
  if (ie4 || ns6)
  { 
    xPos = obj.offsetLeft; 
    yPos = obj.offsetTop ; 
    tempEl = obj.offsetParent;
    while (tempEl != null) 
    {
        xPos += tempEl.offsetLeft;
        yPos += tempEl.offsetTop;
        tempEl=tempEl.offsetParent;}
        obj.x=xPos ; 
        obj.y=yPos;
        //alert ("x="+xPos+"  y="+yPos);
    }

}

function initiatescroller()
{
  //alert("1");

  cliptop=0;
  clipbottom=scrollerheight;
  clipleft= -1*scrollerwidth;
  clipright=0 ;

  i_height=0;

  addRealXYprop('HeaderImg');
  OBJscrollPosImg=  PAli_findObj('HeaderImg');
  OBJscrollertext=  PAli_findObj('scrollertext');

  if (ie4 || ns6)
  {
    totalheight=OBJscrollertext.offsetHeight;
    TotalWidth=OBJscrollertext.offsetWidth;
    OBJscrollertext=OBJscrollertext.style;
    OBJscrollertext.clip="rect("+cliptop+" "+clipright+" "+clipbottom+" "+clipleft+")";
  }

  if ( ns4 )
  {
    totalheight=OBJscrollertext.clip.bottom;
    TotalWidth=OBJscrollertext.clip.right;
    OBJscrollertext.clip.top=cliptop ;
    OBJscrollertext.clip.bottom=clipbottom ;
    OBJscrollertext.clip.left=clipleft;
    OBJscrollertext.clip.right=clipright;
  }

  OBJscrollertext.left=OBJscrollPosImg.x ;
  OBJscrollertext.top =OBJscrollPosImg.y+75  ;

  //alert ("OBJscrollertext.left: "+OBJscrollertext.left);

  OBJscrollertext.visibility='visible';

  scrollertop=OBJscrollertext.top;
  ScrollerLeft=OBJscrollertext.left;

}

function scroll()
{
  if ( i_height< 3*scrollerwidth ) 
  {
    i_height+=step ;
    clipright+=step ;
    clipleft+=step ;
    if (ie4 || ns6 )
    { 
      OBJscrollertext.width= i_height;
      OBJscrollertext.clip="rect("+cliptop+" "+clipright+" "+clipbottom+" "+clipleft+")" ; 
    }
    if (ns4)        { OBJscrollertext.clip.top=cliptop ;  OBJscrollertext.clip.bottom=clipbottom ;  }

    OBJscrollertext.left= parseInt(ScrollerLeft) + scrollerwidth -i_height;
    clearTimeout(timer);
    var timer=setTimeout("scroll()",pause) ;
  } 
  else
  { 
    i_height=0 ;
    clipleft= -1*scrollerwidth ; 
    clipright=0 ;
    //OBJscrollertext.left= 900;//parseInt(ScrollerLeft) + parseInt(900);
    clearTimeout(timer);
    var timer=setTimeout("scroll()",pause); 
  }

}




/*
Orig vertical scroll

var scrollerheight=120;
var scrollerwidth=200;
var scrollertop ;
var cliptop=0;
var clipbottom=scrollerheight;
var clipleft=0;
var clipright=scrollerwidth ;
var i_height=0;
var step=1;
var pause=25;
var totalheight;
var OBJscrollertext;

function addRealXYprop(imgElem) 
{
  var obj=PAli_findObj(imgElem);
  if (ie4 || ns6)
  { 
    xPos = obj.offsetLeft; 
    yPos = obj.offsetTop ; 
    tempEl = obj.offsetParent;
    while (tempEl != null) 
    {
        xPos += tempEl.offsetLeft;
        yPos += tempEl.offsetTop;
        tempEl=tempEl.offsetParent;}
        obj.x=xPos ; 
        obj.y=yPos;
        //alert ("x="+xPos+"  y="+yPos);
    }

}

function initiatescroller()
{
  //alert("1");

  cliptop=0;
  clipbottom=scrollerheight;
  clipleft=0;
  clipright=scrollerwidth ;

  i_height=0;

  addRealXYprop('HeaderImg');
  OBJscrollPosImg=  PAli_findObj('HeaderImg');
  OBJscrollertext=  PAli_findObj('scrollertext');

  if (ie4 || ns6)
  {
    totalheight=OBJscrollertext.offsetHeight;
    OBJscrollertext=OBJscrollertext.style;
    OBJscrollertext.clip="rect("+cliptop+" "+clipright+" "+clipbottom+" "+clipleft+")";
  }

  if ( ns4 )
  {
    totalheight=OBJscrollertext.clip.bottom;
    OBJscrollertext.clip.top=cliptop ;
    OBJscrollertext.clip.bottom=clipbottom ;
    OBJscrollertext.clip.bottom=400 ;
    OBJscrollertext.clip.left=clipleft;
    OBJscrollertext.clip.right=clipright;
  }

  OBJscrollertext.left=OBJscrollPosImg.x ;
  OBJscrollertext.top =OBJscrollPosImg.y-70  ;

  //alert ("OBJscrollertext.left: "+OBJscrollertext.left);

  OBJscrollertext.visibility='visible';

  scrollertop=OBJscrollertext.top;

}

function scroll()
{
  if ( i_height<totalheight ) 
  {
    i_height+=step ;
    cliptop+=step ;
    clipbottom+=step ;
    if (ie4 || ns6 ){ OBJscrollertext.clip="rect("+cliptop+" "+clipright+" "+clipbottom+" "+clipleft+")" ; }
    if (ns4)        { OBJscrollertext.clip.top=cliptop ;  OBJscrollertext.clip.bottom=clipbottom ;  }

    OBJscrollertext.top= parseInt(scrollertop)-i_height;
    clearTimeout(timer);
    var timer=setTimeout("scroll()",pause) ;
  } 
  else
  { 
    i_height=0 ;
    cliptop=0 ; 
    clipbottom=scrollerheight ;
    OBJscrollertext.top=scrollertop ;
    clearTimeout(timer);
    var timer=setTimeout("scroll()",pause); 
  }

}
*/


