onerror=error

if(!parent.main)
{
   if (location.pathname.indexOf('search') != -1)
   {
   		top.location.href='http://www.klaus-michael-zimmermann.de/index.html';
   }
   else
   {
   		location.href="../index.html?" + location.pathname;
   }
}

function error()
{
   return true;
}

var picture;
var actual_img=1;
var first_img=1;
var last_img=1;

function pre_img(name,type,first,last)
{
   picture=new Array (last+1);
   picture[0]=new Image();
   picture[0].src="images/leer.gif"

   for (i=first; i<=last; i++)
   {
       picture[i]=new Image();
       picture[i].src=name+i+"."+type;
   }
   actual_imag=first;
   first_img=first;
   last_img=last;
}

function load_next_img(pos,next)
{
   if (next > last_img)
   {
       actual_img=first_img;
   }
   else
   {
       if (next < first_img)
       {
             actual_img=last_img;
       }
       else
       {
             actual_img=next;
       }
   }

   return (load_img(pos,actual_img));
}

function load_random_img(max,pos)
{
   actual_img=Math.floor((Math.random() * max) + 1);
   return (load_img(pos,actual_img));
}

function load_img(pos,nr)
{
   document.images[pos].src=picture[nr].src;
   return false;
}

function show_stranger(name)
{
    if (parent.ask != true && parent.main.location.href.indexOf('fremd') == -1)
    {
       parent.ask=true;

       load_gen_header();
       parent.main.window.location="fremd.html?"+name;

       return true;
    }

    return false;
}

function is_stranger()
{
    if (top.frames.length != 4 && document.referrer.indexOf('mjm') == -1 && window.location.href.indexOf('kmz') == -1)
    {
       return true;
    }

    return false;
}

function load_contents(name)
{
    if (is_stranger())
    {
       if (show_stranger(name))
       {
          return false;
       }
    }

    if (parent.frames.length == 4)
    {
       if (name == null || name == "undefined")
       {
          return true;
       }

       var l_file=parent.main.location.href.split("/");
       var n_file=name+".html";

       switch (name)
       {
          case "home":
          case "kontakt":

          if (l_file[l_file.length-1] != n_file)
          {
             load_navi(name);
             load_gen_header();

             parent.main.window.location=n_file;
          }
          break;

          case "namen":
          case "orte":
          case "baum":

          if (l_file[l_file.length-1] != n_file)
          {
             load_navi(name);
             load_header(name);

             parent.main.window.location=n_file;
          }
          break;

          case "karten":

          if (l_file[l_file.length-1] != n_file)
          {
             load_navi(name);
             load_gen_header('&Uuml;bersichtskarte');

             parent.main.window.location=n_file;
          }
          break;

          case "links":

          if (l_file[l_file.length-1] != n_file)
          {
             load_navi(name);
             load_gen_header('Links');

             parent.main.window.location=n_file;
          }
          break;

          case "aktuell":

          if (l_file[l_file.length-1] != n_file)
          {
             load_navi(name);
             load_gen_header('Aktuell&nbsp;&amp;&nbsp;Demn&auml;chst');

             parent.main.window.location=n_file;
          }
          break;

          default:
                  parent.main.window.location=name;
          break;
       }

       return false;
    }

    return true;
}

function load_navi(name)
{
    if (parent.frames.length == 4)
    {
       var n_file="navi.html";
       var l_file=parent.navi.location.href.split("/");

       if (name != null && name != "undefined")
       {
          n_file="navi_"+name+".html";
       }

       if (l_file[l_file.length-1] != n_file)
       {
          parent.navi.window.location=n_file;
          parent.navi.window.location.replace(n_file);
       }
    }
    return true;
}

function load_gen_header(name)
{
    if (parent.frames.length == 4)
    {
       var l_file=parent.header.location.href.split("/");
       var n_file="gen_header.html";

       if (name != null && name != "undefined" && name != "")
       {
       		if (name == "Suchergebnis")
            {
            	n_file="suchen_header.html";
            }
            else {
            	n_file="gen_header.html?"+name;
            }
       }

       if (l_file[l_file.length-1] != n_file)
       {
          parent.header.window.location=n_file;
          parent.header.window.location.replace(n_file);
       }
    }
    return true;
}

function load_header(name)
{
    if (parent.frames.length == 4)
    {
       var n_file=name.concat("_header.html");
       var l_file=parent.header.location.href.split("/");

       if (l_file[l_file.length-1] != n_file)
       {
          parent.header.window.location=n_file;
          parent.header.window.location.replace(n_file);
       }
    }
    return true;
}
function open_link(path)
{
    if (path != null && path != "")
    {
       var link="http://"+path;

       open (link, 'extern', 'location=yes,menubar=yes,resizable=yes,scrollbars=yes,status=yes,toolbar=yes');
       return false;
    }
    return true;
}

function show_picture(path)
{
    if (path != null && path != "")
    {
       newWindow= window.open (path, 'showPicture', 'location=no,menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no,width=418,height=430');
       newWindow.focus();

       return false;
    }
    return true;
}

function gohome()
{
    if (top.frames.length == 4)
    {
       if (top.main.location.href == self.location.href)
       {
          self.location.href='home.html';
       }
       else
       {
          top.location.href='http://www.klaus-michael-zimmermann.de/index.html';
       }
    }
    else
    {
        if (document.referrer.indexOf('genealogienetz') != -1)
        {
            top.location.href='../index.html';
        }
        else
        {
            top.location.href='http://www.klaus-michael-zimmermann.de/index.html';
        }
    }

    return false;
}