//(c)2008 ing.-buero bechler halle//

var is_ie=(navigator.appName.indexOf('Explorer')!=-1);
IELT7=IELT7&&is_ie; IE8=IE8&&!IELT7&&is_ie;

////

//ibh img-animated-gallery-class//
var tGALani=function () {
  //parentID, galdir(vel/inc), timeout, pausetime, firsttime, width, height, path, [[path]img0,...,[]imgN]
  var GALParent=document.getElementById(arguments[0][0]);
  var GALParentID=arguments[0][0];
  var GALdir=-((arguments[0][1])>0?arguments[0][1]:1);
  var GALtime=((arguments[0][2])>0?arguments[0][2]:20);
  var GALpausetime=((arguments[0][3])>0?arguments[0][3]:GALtime);
  var GALfirsttime=((arguments[0][4])>0?arguments[0][4]:GALtime);
  var GALwidth=arguments[0][5];
  var GALheight=arguments[0][6];
  var GALpath=arguments[0][7];
  var GALargcnt=8;
  var GALerrtime=500;
  var GALwatchdogtime=10000;
  var GALerrmax=10;
  var GALerrcount=0;
  var GALidx=0;
  var GALtransp=100.0;
  var GALbusy=false;
  var GALfirst=true;
  var GALimgs=null;
  var HTMR=null;
  var _err=null;
  var _N=0;

  function init (_args) {
    if (_args&&(_args.length>0)&&GALParent) {
      GALimgs=new Array();
      var _maxI=2; var _S=''; var _I=0; var _B=0;
      for (_I=_maxI-1; _I>=0; _I--) _S+= //realimgs
        '<div style="position:absolute; left:0; top:0;'+((GALwidth)>0?' width:'+(GALwidth)+'px;':'')+((GALheight)>0?' height:'+(GALheight)+'px;':'')+' overflow: hidden;">'+
          '<img '+'id="img'+GALParentID+(_I)+'" '+'src="" '+'alt="" '+'/>'+
        '</div>';
      GALParent.innerHTML=_S;
      for (_I=0; _I<_args.length; _I++) //allimgs
        if (_args[_I]) {
          if (_args[_I].substring(0, 6).toLowerCase()=='http:/')
            GALimgs[_B]=_args[_I];
          else
            GALimgs[_B]=GALpath+_args[_I];
          _B++; }
      setTrans(0, GALtransp); setTrans(1, 100.0-GALtransp);
      setImg(0, 0); setImg(1, 1);
      GALidx++; }}

  function valIdx (_N) {
    if (_N<0) return GALimgs.length-1; else if (_N>=GALimgs.length) return 0; else return _N; }

  function setTrans (_I, _T) {
    var _e=document.getElementById('img'+GALParentID+(_I));
    if (_e) try {
      if (is_ie)
        _e.style.filter='alpha(opacity='+(_T)+')'; //ie
      else
        _e.style.opacity=((_T)/100.0); }
      catch(_err) {}}

  function setImg (_N, _I) {
    if (GALParent&&GALimgs) {
      var _img=null;
      if (_img=document.getElementById('img'+GALParentID+(_I))) {
        var _maxI=GALimgs.length;
        _N=valIdx(_N);
        try {
          _img.src=GALimgs[_N];
          return _img.complete; }
        catch(_err) {}}}
    return false; }

  function imgsIO () {
    var _img=null;
    return ((_img=document.getElementById('img'+GALParentID+(0)))&&(_img.complete)&&
            (_img=document.getElementById('img'+GALParentID+(1)))&&(_img.complete)); }
  
  function animate () {
    if (HTMR) { window.clearTimeout(HTMR); HTMR=null; }
    if (!imgsIO||!GALimgs)
      HTMR=window.setTimeout(animate, GALerrtime);
    else
      if (GALbusy&&(GALerrcount<GALerrmax)) {
        GALerrcount++;
        HTMR=window.setTimeout(animate, GALerrtime); }
      else try {
        GALbusy=true;
        GALerrcount=0;
        if (GALfirst) {
          GALtransp+=GALdir;
          GALfirst=false;
          HTMR=window.setTimeout(animate, GALfirsttime+1000); }
        else
          if (((GALdir<0)&&(GALtransp>0))||((GALdir>0)&&(GALtransp<100))) {
            setTrans(0, GALtransp); setTrans(1, 100.0-GALtransp);
            GALtransp+=GALdir;
            HTMR=window.setTimeout(animate, GALtime); }
          else {
            var _gi=GALidx;
            GALdir=-GALdir;
            GALidx++; if (GALidx>=GALimgs.length) GALidx=0;
            setImg(GALidx, (GALdir>0?0:1));
            HTMR=window.setTimeout(animate, (_gi?GALpausetime:GALfirsttime)); }
        GALbusy=false; }
      catch(_err) {
        HTMR=window.setTimeout(animate, GALerrtime);
        GALbusy=false; }}

  //wrapper//
  function start () {
    animate(); }

  //initalization//
  init(arguments[0][GALargcnt]);

  //tGAL_published//
  this.show=function () {
    start(); }
} //tGALani_class

////

var googleMap=null;

function gMap (_ID) { //google-map//gmapLat,gmapLong,gmapOLat,gmapOLong,gmapovwW,gmapovwH
  if (_ID) try {
    if (GBrowserIsCompatible()) {
      if (googleMap=new GMap2(document.getElementById(_ID))) {
        if ((lang!='undefined')&&(lang=='en')) //todo...s.gmapskey.js
          googleMap.setCenter(new GLatLng(gmapLat, gmapLong), 4);
        else
          googleMap.setCenter(new GLatLng(gmapLat, gmapLong), 16);
        //_map.openInfoWindow(_map.getCenter(), document.createTextNode(''));
        googleMap.addControl(new GSmallZoomControl());
        if (gmapovwW&&gmapovwH)
          googleMap.addControl(new GOverviewMapControl(new GSize(gmapovwW, gmapovwH)));
        googleMap.addOverlay(new GMarker(new GLatLng(gmapLat+gmapOLat, gmapLong+gmapOLong)));
        googleMap.setMapType(G_HYBRID_MAP); }
      else
        if (_e=document.getElementById(_ID))
          _e.style.height=0; }}
    catch(_e) {}} //G_SATELLITE_MAP, G_NORMAL_MAP

function gMapBack () { //google-map//gmapLat,gmapLong
  if (googleMap&&gmapLat&&gmapLong) try {
    if ((lang!='undefined')&&(lang=='en')) //todo...s.gmapskey.js
      googleMap.setCenter(new GLatLng(gmapLat, gmapLong), 4);
    else
      googleMap.setCenter(new GLatLng(gmapLat, gmapLong), 16); }
    catch(_e) {}}

////

var popUpElem=null;

function preldImgs () {
  var _i=0;
  _tmp=new Array();
  for (_i=0; _i<pldImgs.length; _i++) {
    _tmp[_i]=new Image;
    _tmp[_i].src=pldImgs[_i]; }}

function mailpage () {
  window.location='mailto:'+
  '?subject='+escape(mailSubject)+
  '&body='+escape(mailBody); }

function toggleVis (_el, _realTggl) {
  if (_el&&(_el=document.getElementById(_el))) {
    if (_el.style.display=='block') {
      if (_realTggl) {
        _el.style.display='none';
        popUpElem=null; }}
    else {
      var _I=0; //s.css-cv.w:678/657
      if ((_I=get_clientWidth())<911)
        _el.style.right=(_I-683)+'px';
      else
        _el.style.right=(228)+'px';
      _el.style.display='block';
      if (popUpElem)
        popUpElem.style.display='none';
      popUpElem=_el; }}}

function closePopUp () {
  if (popUpElem) {
    popUpElem.style.display='none';
    popUpElem=null; }}

function isIn (_t, popUpElem) {
  if (popUpElem)
    while (_t)
      if (_t==popUpElem)
        return true;
      else
        _t=_t.parentNode;
  return false; }

function toggleCSS (_selector, _prop, _val0, _val1) {
  var _debug=0;
  if (_debug) var _s=''; //testonly//
  if (_selector&&_prop&&(_val0!==_val1)&&document.styleSheets) {
    for (var _iS=0; _iS<document.styleSheets.length; _iS++) {
      var _rules=document.styleSheets[_iS].rules; //ie
      if (!_rules) _rules=document.styleSheets[_iS].cssRules;
      if (_debug) _s+='css#'+_iS+':\n'; //testonly//
      if (_rules)
        for (var _iR=0; _iR<_rules.length; _iR++) {
          if (_rules[_iR]&&_rules[_iR].selectorText&&_rules[_iR].selectorText.toLowerCase()==_selector) {
            if (eval('_rules[_iR].style.'+_prop)!==_val0)
              eval('_rules[_iR].style.'+_prop+'="'+_val0+'"');
            else
              eval('_rules[_iR].style.'+_prop+'="'+_val1+'"');
            if (_debug) alert('_rules[_iR].style.'+_prop+'="'+_val0+'"'+'\n'+eval('_rules[_iR].style.'+_prop));
            break; }
            if (_debug&&_rules[_iR]&&_rules[_iR].selectorText) //testonly//
              _s+=_rules[_iR].selectorText+'\n'; }}
            if (_debug) alert(_s); }} //testonly//

function setTransparency (_el, _percent) {
  if (_el&&(_el=document.getElementById(_el))) try {
    if (is_ie)
      _el.style.filter='alpha(opacity='+(_percent)+')'; //ie
    else
      _el.style.opacity=_percent/100.0; }
    catch(_err) {}}

////

function trim (_s) {
  if (_s)
    return _s.replace(/(^\s*)|(\s*$)/, ''); }

function isOnline () {
  return framework.system.network.online; }

function get_clientWidth () {
  if (is_ie&&IELT7)
    return document.body.scrollWidth+2;
  else
    return document.documentElement.clientWidth; }

function get_clientBot () {
  return (is_ie
    ?(IELT7
      ?document.body.scrollHeight
      :document.documentElement.clientHeight+document.documentElement.scrollTop)
    :document.documentElement.clientHeight+window.pageYOffset); }

////

var fMailto='&#109;&#97;&#105;&#108;&#116;&#111;&#58;';
var fAt='&#64;';

function EMlink (_EM, _Host) { //coded mail-link
  if (_EM&&_Host) {
    var _S=''; var _H=''; var _I=0;
    var _N=_Host.indexOf('?');
    for (_I=0;_I<_EM.length;_I++)
      _S+='&#'+_EM.charCodeAt(_I)+';';
    _S+=fAt;
    for (_I=0;_I<_Host.length;_I++) {
      _S+='&#'+_Host.charCodeAt(_I)+';';
      if ((_N<0)||(_I<_N))
        _H+='&#'+_Host.charCodeAt(_I)+';'; }
    document.write('<a href="'+fMailto+_S+'">'+_EM+fAt+_H+'</a>'); }}

function extern (_uri) { //target_blank/xhtml
  if (_uri)
    window.open(_uri,'_blank').focus(); }

////

function docOnMouseDown (_e) {
  _e=_e||window.event;
  if (_e) {
    var _t=null;
    if (!(_t=_e.target)) _t=_e.srcElement;
    //mpos//
    if (_e.pageX||_e.pageY) {
      _mx=_e.pageX;
      _my=_e.pageY; }
    else {
      var _de=document.documentElement;
      var _b=document.body;
      _mx=_e.clientX+(_de.scrollLeft||_b.scrollLeft)-(_de.clientLeft||0);
      _my=_e.clientY+(_de.scrollTop||_b.scrollTop)-(_de.clientTop||0); }
    if ((_mx>=0)&&(_mx<get_clientWidth())&&(_my>=0)&&(_my<get_clientBot())&&
        _t&&popUpElem&&!isIn(_t, popUpElem)&&(_t.tagName.toLowerCase()!=='a')) {
      //try { _e.preventDefault(true); } catch(_err) { try { _e=null; } catch(_err) {}}
      closePopUp(); }}}
          
////

function debug (_s) {
  var _e=null;
  if (_e=document.getElementById('debug'))
    _e.innerHTML=_s; }
  
////

function leave () {
  if (idgmap&&googleMap&&document.getElementById(idgmap)) { try {
    GUnload(); }
    catch(_e) {}}}

function init () {
  var _e=null;
  if (top!=self)
    top.location=self.location;
  else {
    //tranparentElems//
    for (var _i=0; _i<tranparentElems.length; _i++)
      setTransparency(tranparentElems[_i], 65);
    //visibleElems//
    for (_i=0; _i<visibleElems.length; _i++)
      if (_e=document.getElementById(visibleElems[_i]))
        _e.style.display='block';
    //animatedElems//
    for (_i=0; _i<animatedElems.length; _i++)
      (new tGALani(animatedElems[_i])).show();
    //preload imgs//
    preldImgs();
    //google map//
    if (document.getElementById(idgmap)) { try {
      gMap(idgmap); }
      catch(_e) {}}
    //ev//
    document.onmousedown=docOnMouseDown;
    //cal//
    if (document.getElementById(idcal))
      calCurr(idcal, 0, 1); }}
    
////

if (top!=self)
  top.location=self.location;
