// JavaScript Document [global.js]

/* --------- start: global variable definitions ------------*/

/* variables needed for the browser recognition */
var is_nav4up = false, is_ie4up = false, is_opera5up = false, is_nav4 = false;

/* variables needed for displaying and positioning of html-elements */
var mctrl=0;
var old, memold, mlayer;

/* image objects */
var images = new Array();
images[0] = new Image(); images[0].src = './images/pfeil_rechts_weiss_auf_grau.gif';
images[1] = new Image(); images[1].src = './images/pfeil_rechts_rot_auf_grau.gif';
images[2] = new Image(); images[2].src = './images/pfeil_rechts_weiss_auf_schwarz.gif';
images[3] = new Image(); images[3].src = './images/pfeil_rechts_rot_auf_schwarz.gif';

var dummy0_src = 'images/dummy_hoch_190x285.gif';
var dummy1_src = 'images/dummy_quer_285x190.gif';
var dummy2_src = 'images/dummy_quad_190x190.gif';

var gallerypic = new Array();
gallerypic[0] = new Image(); gallerypic[0].src = dummy0_src; gallerypic[0].id = 'gallerypic';
gallerypic[1] = new Image(); gallerypic[1].src = dummy1_src; gallerypic[1].id = 'gallerypic';
gallerypic[2] = new Image(); gallerypic[2].src = dummy2_src; gallerypic[2].id = 'gallerypic';

var galleryback = new Array();
galleryback[0] = new Image(); galleryback[0].src = './images/innen_high_vorn_416x384.gif';
galleryback[1] = new Image(); galleryback[1].src = './images/innen_quer_vorn_416x384.gif';
galleryback[2] = new Image(); galleryback[2].src = './images/innen_quad_vorn_416x384.gif';

/* thumbnail gallery relevant variables */
var currentFrame, currentgallery = "";
var pics_per_gallery = 4, last_shown_pic = 4;
/* --------- end: global variable definition ------------*/

/* --------- start: function definitions ------------*/
/**
 * display's a popup windows with the given 'message'
 */
function popup(message) {
  alert(message);
}
/** 
 * this function performs a browsercheck and sets the following variables:
 * is_nav4, is_nav4up, is_ie5up, is_opera5up
 */
function browsercheck() {
  var i = -1;
  var s = "";

  i = parseInt(navigator.userAgent.indexOf("Opera"));
  if ( i > -1) {
    s = navigator.userAgent.substr((i+6),1);
    if ( parseInt(s) >= 5 ) is_opera5up = true;
    else popup("Sorry, your version of Opera isn't supported.");
  } else if ( parseInt(navigator.appName.indexOf("Explorer")) > -1) {
    if ( parseInt(navigator.appVersion.substr(0,1)) >= 4) is_ie4up = true;
    else popup("Sorry, your version of MSIE isn't supported.");
  } else if ( parseInt(navigator.appName.indexOf("Netscape")) > -1 ||
              parseInt(navigator.appName.indexOf("Mozilla")) > -1 ) {
    if ( parseInt(navigator.appVersion.substr(0,1)) == 4) is_nav4 = true;
    else if ( parseInt(navigator.appVersion) > 4 ) is_nav4up = true;
    if ( is_nav4 ) popup("Sorry, your version of Netscape/Mozilla isn't supported.\nPlease use one of the following: IE v4+, NS/Mozilla v5+ or Opera v5+ !");
  } else popup("Sorry, your browser or the version of your browser isn't supported.");
}
function resolutioncheck() {
  if ( !is_ie4up ) {
    if ( parseInt(window.innerWidth) < 833 || parseInt(window.innerHeight) < 535 ) 
      popup("Der sichtbare Bereich ihres Browsers reicht leider nicht aus\num diese Seite korrekt anzuzeigen.\nVersuchen Sie die Auflösung ihres Rechners zu erhöhen.\nEmpfohlen ist eine Auflösung von 1024x768!");
  }
}
function display_statusmessage(msg) {
  window.status=msg;
  document.returnValue = true;
}
/**
 * this functions shows the specified <layer> or <div>-layer
 */
function show_layer(x) {
  if ( eval("parent."+'galleryFrame') || eval("parent."+'contentFrame') ) {
    if ( x == 'm1x' || x == 'm2x' || x == 'm3x' ) currentFrame = eval("parent."+'galleryFrame');
    else if ( x == 'm4x' || x == 'm5x' ) currentFrame = eval("parent."+'contentFrame');
    else if ( x == 'i1x' || x == 'i2x' || x == 'i3x' || x == 'i4x' ) currentFrame = eval("parent."+'contentFrame');
    // for netscape/mozilla 4
    if(is_nav4) {
       if(currentFrame.document.layers[x]) currentFrame.document.layers[x].visibility="show";
    }
    // for internet explorer
    if(is_ie4up)  {
      if(currentFrame.document.all[x]) currentFrame.document.all[x].style.visibility="visible";
    }
    // for other browsers
    if(currentFrame.document.getElementById) {
      if(currentFrame.document.getElementById(x)) {
        currentFrame.document.getElementById(x).style.visibility="visible";
      }
    }
  }
}
/**
 * internal used to close a specific <layer> or <div>-layer
 * is called by 'delayed_out()'
 */
function delayed_close(x) {
  if (mctrl == x) do_out();
}

/**
 * use to fade out and close the current visible <layer> or <div>-layer
 */
function delayed_out() {
  mctrl+=1;
  setTimeout('delayed_close('+mctrl+')',400);
}
/**
 * checks which frame contains the requested submenu and sets the global frame variable currentFrame,
 * which is used by all other functions !
 */
function do_check(x) {
  if(old && old!=x) hide_layer(old);
  show_layer(x);
  old=x;
  mctrl+=1;
}
function do_out() {
  hide_layer("m1x");
  hide_layer("m2x");
  hide_layer("m3x");
  hide_layer("m4x");
  hide_layer("m5x");
  
  memold=old;
  old="";
  mctrl=0; 
}
/**
 * use to fade out and close a specific <layer> or <div>-layer
 */
function hide_layer(x) {
  if ( eval("parent."+'galleryFrame') || eval("parent."+'contentFrame') ) {
    if ( x == 'm1x' || x == 'm2x' || x == 'm3x' ) currentFrame = eval("parent."+'galleryFrame');
    else if ( x == 'm4x' || x == 'm5x' ) currentFrame = eval("parent."+'contentFrame');
    else if ( x == 'i1x' || x == 'i2x' || x == 'i3x' || x == 'i4x' ) currentFrame = eval("parent."+'contentFrame');
    
      // for netscape/mozilla 4 
      if(is_nav4) {
        if (currentFrame.document.layers[x])
          currentFrame.document.layers[x].visibility="hide";
      }
      // for internet explorer
      if(is_ie4up)  {
        if (currentFrame.document.all[x])
        currentFrame.document.all[x].style.visibility="hidden";
      }
      // for other browsers
      if(currentFrame.document.getElementById) {
        if (currentFrame.document.getElementById(x))
          currentFrame.document.getElementById(x).style.visibility="hidden";
      }
  }
  if ( x != 'i1x' || x != 'i2x' || x != 'i3x' || x != 'i4x' ) delayed_out();
}
function show_gallery(x,dir) {
  if ( (x!="nothing") && eval("parent."+'contentFrame') ) {
    var contentFrame = eval("parent."+'contentFrame');
    last_shown_pic = pics_per_gallery; 
    currentgallery = x;
    var uri = dir+'_php/show_gallery.php?gallery='+x+'&last_shown_pic='+last_shown_pic;
    contentFrame.location.href = uri;
  }
}
function display_image_info(x) {
  if ( x != "" ) {
    show_layer(x);
    
    if ( x == 'i1x' ) {
      hide_layer('i2x');
      hide_layer('i3x');
      hide_layer('i4x');
    } else if ( x == 'i2x' ) {
      hide_layer('i1x');
      hide_layer('i3x');
      hide_layer('i4x');
    } else if ( x == 'i3x' ) {
      hide_layer('i1x');
      hide_layer('i2x');
      hide_layer('i4x');
    } else if ( x == 'i4x' ) {
      hide_layer('i1x');
      hide_layer('i2x');
      hide_layer('i3x');
    }
  }
}
function forward() {
  if ( eval("parent."+'contentFrame') ) {
      var contentFrame = eval("parent."+'contentFrame');
      last_shown_pic += pics_per_gallery;
      var uri = 'show_gallery.php?gallery='+currentgallery+'&last_shown_pic='+last_shown_pic;
      
      contentFrame.location.href = uri;
    }
}
function backward() {
  if ( eval("parent."+'contentFrame') ) {
      var contentFrame = eval("parent."+'contentFrame');
      if ( last_shown_pic >= 2*pics_per_gallery ) {
        last_shown_pic -= pics_per_gallery;
      
        var uri = 'show_gallery.php?gallery='+currentgallery+'&last_shown_pic='+last_shown_pic;
        
        contentFrame.location.href = uri;
      } else {
        last_shown_pic = pics_per_gallery;
      }
    }
}
function change_galleryframe(x,dir,img_uri,idx) {
  if ( eval("parent."+'galleryFrame')) {
    var tmpFrame = eval("parent."+'galleryFrame');
    if ( img_uri != null && img_uri != '' ) {
      if ( img_uri != gallerypic[0].src ) gallerypic[0].src = img_uri;
      if ( img_uri != gallerypic[1].src ) gallerypic[1].src = img_uri;
      if ( img_uri != gallerypic[2].src ) gallerypic[2].src = img_uri;
    } else {
      if ( gallerypic[0].src != dummy0_src ) gallerypic[0].src = dummy0_src;
      if ( gallerypic[1].src != dummy1_src ) gallerypic[1].src = dummy1_src;
      if ( gallerypic[2].src != dummy2_src ) gallerypic[2].src = dummy2_src;
    }
    var uri = dir;
    if ( x == 'f1x' ) uri += 'table_gallery_hochformat.html';
    else if ( x == 'f2x' ) uri += 'table_gallery_querformat.html';
    else if ( x == 'f3x' ) uri += 'table_gallery_quadratformat.html';
    
    if (uri != dir ) tmpFrame.location.href = uri;
    
    if (idx != '') display_image_info(idx);
  }
}
function change_bothframes(uri1,uri2,dir,img_uri) {
  if ( eval("parent."+'galleryFrame') && eval("parent."+'contentFrame') ) {
    var galleryFrame = eval("parent."+'galleryFrame');
    var contentFrame = eval("parent."+'contentFrame');
    
    if ( img_uri != null && img_uri != '' ) {
      if ( img_uri != gallerypic[0].src ) gallerypic[0].src = img_uri;
      if ( img_uri != gallerypic[1].src ) gallerypic[1].src = img_uri;
      if ( img_uri != gallerypic[2].src ) gallerypic[2].src = img_uri;
    } else {
      if( gallerypic[0].src != dummy0_src ) gallerypic[0].src = dummy0_src;
      if ( gallerypic[1].src != dummy1_src ) gallerypic[1].src = dummy1_src;
      if ( gallerypic[2].src != dummy2_src ) gallerypic[2].src = dummy2_src;
    }
    
    if ( uri1 != '' ) galleryFrame.location.href = dir+uri1;
    if ( uri2 != '' ) contentFrame.location.href = dir+uri2;
  }
}
/* --------- end: function definitions ------------*/

/* --------- start: code ------------*/
browsercheck();
/* --------- end: code ------------*/
// EOF JavaScript Document [global.js]