/* DATEI: *.js */


/* Javascript Datei BLUEPAGE CMS 05 -2007 */
/* Copyright by ISS-Oberlausitz */
/* Author: T.Hojenski */

var ie  = document.all;
var dom = document.getElementById;

function img_view(ds,lg,pf,inhId) {
   url = pf + './img_view.php?ds=' + ds + '&lg=' + lg + '&inhId=' + inhId;
   opt = 'location=no,scrollbars=auto,toolbar=no,resizable=yes,left=' + ((screen.availWidth-720)/2) + ',top=' + (((screen.availHeight-650)/2)-20) + ',width=665,height=650';
   galwindow = window.open(url,'_blank',opt);
   galwindow.moveTo(((screen.availWidth-720)/2),((screen.availHeight-650)/2)-20)
}

function hover_li(sel,w,h) {
   if (h == 'H') classZusatz = ' li_sitenav_h'; else classZusatz = '';
   if (w == true) {
      sel.parentNode.parentNode.className = 'li_sitenav2' + classZusatz;
   } else {
      sel.parentNode.parentNode.className = 'li_sitenav' + classZusatz;
   }
}

function NavViewOn(tdf,lg,obj,awhl,txt) {
   if (!tdf.src) {
      if(document.all) tdf = document.all(tdf);
      else if(document.getElementById) tdf = document.getElementById(tdf);
   }
   tdf.src = lg + '/menu/' + awhl + obj;
   window.status = txt;
   setTimeout("window.status=''",25000);
}

function Navchange(nimg,view){
   if (view == 'visible') {
      document.images['p'+nimg].src = document.images['p'+nimg].src.replace(/\/a\./,"\/b.");
   } else {
      document.images['p'+nimg].src = document.images['p'+nimg].src.replace(/\/b\./,"\/a.");
   }
}

function btnchange(obj,whl,zst){
   if(!obj.src) {
      if(document.all) obj = document.all(obj);
      else if(document.getElementById) obj = document.getElementById(obj);
   }
   if(zst == true)  obj.src = 'images/sys/' + whl + '2.gif';
   if(zst == false) obj.src = 'images/sys/' + whl + '.gif';
}

function setline(theRow,linecolor) {
   if (linecolor == '' || typeof(theRow.style) == 'undefined') {
      return false;
   }
   if (typeof(document.getElementsByTagName) != 'undefined') {
      var theCells = theRow.getElementsByTagName('td');
   } else if (typeof(theRow.cells) != 'undefined') {
      var theCells = theRow.cells;
   } else {
      return false;
   }
   var rowCellsCnt  = theCells.length;
//      theCells[0].style.backgroundColor = stopcolor;
   for (var c = 0; c < rowCellsCnt; c++) {
      theCells[c].style.backgroundColor = linecolor;
   }
   return true;
}

function addbookmark() {   // IE
   if (document.all && navigator.userAgent.indexOf('Opera') <= -1) {
      var bookmarkurl   = document.URL
      var bookmarktitle = document.title;
      window.external.AddFavorite(bookmarkurl,bookmarktitle)
   } else {
      alert("Dieser Link funktioniert nur bei Benutzern des Internet-Explorers.\n\nBenutzen Sie bitte die Tastenkombination für\nNetscape/Mozilla:\t\tSTRG+D,\nOpera:\t\t\tSTRG+T.")
   }
}

function open_extern(url,att,w,h) {
   posh = parseFloat(((screen.availHeight-h)/2)-20);
   posw = parseFloat((screen.availWidth-w)/2);
   opt = att + ',left=' + posw + ',top=' + posh + ',width='+w+',height='+h;
   extWindow = window.open(url,'_blank',opt);
   extWindow.focus();
}
function view_rpic(tid,zst) {
   if (zst == true) zst = 'visible';
   else             zst = 'hidden';
   
   if (document.all) {
      document.all('rpic2_'+tid).style.visibility =zst;
      document.all('rtxt_box_'+tid).style.visibility =zst;
   } else if (document.getElementById) {
      document.getElementById('rpic2_'+tid).style.visibility =zst;
      document.getElementById('rtxt_box_'+tid).style.visibility =zst;
   }
   zst = '';
}

function changeDate(days,id,set,frml) {
   var wDayArray     = document.forms[frml]['wDayArray['+id+']'].value;
   var wday = '';
   if (set == 0) {
      var getdstring = document.forms[frml]['frml['+id+'][2]'].value;
      var reg     = eval("/^ *("+wDayArray+")\, */");
      var dstring = getdstring.replace(reg,"");
      var tag     = parseInt(1*(dstring.substring(0,dstring.indexOf("."))),10);
      var monat   = parseInt(1*(dstring.substring((dstring.indexOf(".")+1),dstring.lastIndexOf("."))),10)-1;
      var jahr    = parseInt((dstring.substring((dstring.lastIndexOf(".")+1),dstring.length)),10);
   } else {
      var set     = parseInt(set);
      var tag     = parseInt(document.forms[frml]['frml['+id+']['+set+']'].value,10);
      var monat   = parseInt(document.forms[frml]['frml['+id+']['+(set+1)+']'].value,10) - 1;
      var jahr    = parseInt(document.forms[frml]['frml['+id+']['+(set+2)+']'].value,10);
   }

   if (jahr >= 0 && jahr <= 75)      { jahr = 2000 + jahr; }
   else if (jahr > 75 && jahr <= 99) { jahr = 1900 + jahr; }

   var timestamp = new Date(jahr, monat, tag);
   var msec      = timestamp.getTime();

   if (days == '+1')      { msec = msec + (24*60*60*1000); }
   else if (days == '-1') { msec = msec - (24*60*60*1000); }

   timestamp.setTime(msec);

   tag = timestamp.getDate();
   if (tag > 0 && tag < 10) { tag = "0"+tag; }

   monat = timestamp.getMonth() + 1;
   if (monat > 0 && monat < 10) { monat = "0"+monat; }

   jahr = "" + timestamp.getFullYear();
   jahr = jahr.substr(2,2);

   if (wDayArray != '-') {
      var datum = new Date(jahr,(monat-2),tag);
      wday = datum.getDay();
      wday = (wDayArray.substr(3*((1*wday%7)),2));
      wday = wday+", ";
   }
   if (set == 0) {
      document.forms[frml]['frml['+id+'][2]'].value = wday + tag + "." + monat + "." + jahr;
   } else {
      if (set != 5 && wDayArray != '-') document.forms[frml]['frml['+id+'][1]'].value = wday;
      document.forms[frml]['frml['+id+']['+set+']'].value     = tag;
      document.forms[frml]['frml['+id+']['+(set+1)+']'].value = monat;
      document.forms[frml]['frml['+id+']['+(set+2)+']'].value = jahr;
   }
}

function checkIntg (frmlelement) {
   var datelement = '';
   for (var Pos = 0; Pos < frmlelement.value.length; Pos++) {
      if (isNaN(frmlelement.value.charAt(Pos)) == false) {
         datelement += frmlelement.value.charAt(Pos);
      }
   }
   frmlelement.value = datelement;
   frmlelement.focus();
}

var enabletipp = false;


function imap_view(sel,id,zst,txt) {
   if (ie||dom) {
      var tipobj = document.all? document.all["imap_tooltipp_"+sel]  : document.getElementById? document.getElementById("imap_tooltipp_"+sel) : "";
      var layobj = document.all? document.all["imapImg_"+sel+"_"+id] : document.getElementById? document.getElementById("imapImg_"+sel+"_"+id) : "";
   }
   var zst = zst? layobj.style.display = 'inline' : layobj.style.display = 'none';

   tipobj.style.bottom     = 0;
   tipobj.style.left       = 0;
   tipobj.style.visibility = "visible";
   tipobj.innerHTML        = txt
}
function loadincl() {
   document.write('<sc'+'ript src="js/scrl.js" type=text/java'+'script></script>');
}

function setgalerie(id) {
   var config = {
      "id" : id,  
      "speed" : 4,  
		"galobject" : 'jsgal_zoom'+id,  
		"galnavobj" : 'gal_vcont'+id,
		"galtxtobj" : 'jsgal_zoom_titel'+id,  
		"crossobj"  : 'gal_content'+id
   };
   function ini(){
      galerie = new gal(config);
      return false;
   }
   setTimeout(ini,20);
}
function gal(config) {
   var ie  = document.all;  
	var dom = document.getElementById;
	this.config        = config;  
	this._id           = config['id'];  
	this._galobject    = ie ? document.all(config['galobject']) : document.getElementById(config['galobject']);  
	this._galnavobj    = ie ? document.all(config['galnavobj']) : document.getElementById(config['galnavobj']);  
	this._galtxtobj    = ie ? document.all(config['galtxtobj']) : document.getElementById(config['galtxtobj']);  
	this._crossobj     = ie ? document.all(config['crossobj'])  : document.getElementById(config['crossobj']);  
   this._contentwidth = this._crossobj.offsetWidth;
   this._speed        = config['speed'];
   var galerie        = this;

   this.getcontent_width();
}

gal.prototype.change_galpic = function (idNr) {
   this._galobject.innerHTML = window.galeriesrc[this._id+'_'+idNr];
   var galtxtsrc    = ie ? document.all('jsgal_imgtxt_'+this._id+'_'+idNr)     : document.getElementById('jsgal_imgtxt_'+this._id+'_'+idNr);
   this._galtxtobj.innerHTML = galtxtsrc.innerHTML;

}

gal.prototype.moveleft = function (newId) {
   if (newId == true && galerie._id != newId) {
      setgalerie(newId);
      setTimeout("galerie.moveleft(newId)",30);
   } else {
      if (window.moverightvar) clearTimeout(moverightvar);
      if (parseInt(this._crossobj.style.left)<=-1) this._crossobj.style.left = parseInt(this._crossobj.style.left)+this._speed+"px";
      this.moveleftvar = setTimeout("galerie.moveleft()",20);
   }
}

gal.prototype.moveright = function (newId) {
   if (newId == true && galerie._id != newId) {
      setgalerie(newId);
      setTimeout("galerie.moveright(newId)",30);
   } else {
      if (gal.moveleftvar) clearTimeout(gal.moveleftvar);
      if (parseInt(this._crossobj.style.left)>=(this._contentwidth*(-1)+(this._galnavobj.offsetWidth)+1)) this._crossobj.style.left = parseInt(this._crossobj.style.left) - this._speed  + "px";
      this._crossobj.left -= this._speed;
      this.moverightvar = setTimeout("galerie.moveright()",20);
   }
}

gal.prototype.stopscroll = function (){
   if (galerie.moveleftvar)  clearTimeout(galerie.moveleftvar);
   if (galerie.moverightvar) clearTimeout(galerie.moverightvar);
}
gal.prototype.getcontent_width = function (){
   this._contentwidth = this._crossobj.offsetWidth;
}




function makeRequest(typ,lg,pf,id,InhId) {
   var url = 'incl/request.ajax.php?InhId='+InhId+'&id='+id+'&pfad='+pf+'&typ='+typ+'&zh='+Math.random();
   http_request = false;
   http_request.responseText = '';
   if (window.XMLHttpRequest) { // Mozilla, Safari,...
      http_request = new XMLHttpRequest();
      if (http_request.overrideMimeType) {
         http_request.overrideMimeType('text/xml');
      }
   } else if (window.ActiveXObject) { // IE
      try {
         http_request = new ActiveXObject("Msxml2.XMLHTTP");
      } catch (e) {
         try {
            http_request = new ActiveXObject("Microsoft.XMLHTTP");
         } catch (e) {}
      }
   }
   if (!http_request) {
      alert('Giving up :( Cannot create an XMLHTTP instance');
      return false;
   }
   http_request.onreadystatechange = requestContents;
   http_request.open('GET', url, true);
   http_request.send(null);
}

function requestContents() {
   if (http_request.readyState == 4) {
      if (http_request.status == 200) {
         
         if (http_request.getResponseHeader("Content-Type").substr(0,9) == 'text/html') {
            document.getElementById('popup_content').innerHTML = http_request.responseText;
         } else {
            var xmldoc = http_request.responseXML;
            var r_typ = xmldoc.getElementsByTagName('typ').item(0).firstChild.data;
            if (r_typ == 'gal')         { // Galerie
               var r_html = xmldoc.getElementsByTagName('htmlcode').item(0).firstChild.data;
               document.getElementById('popup_content').innerHTML = r_html;
            } else if (r_typ == 'fgal') { // FTP-Galerie
               var r_html = xmldoc.getElementsByTagName('htmlcode').item(0).firstChild.data;
               document.getElementById('popup_content').innerHTML = r_html;
            } else if (r_typ == 'flv')  { // Flashmovie
               var flv_html = xmldoc.getElementsByTagName('htmlcode').item(0).firstChild.data;
               var flv_file = xmldoc.getElementsByTagName('file').item(0).firstChild.data;
               var flv_img  = xmldoc.getElementsByTagName('img').item(0).firstChild.data;
               var flv_win  = xmldoc.getElementsByTagName('win').item(0).firstChild.data;
               var flv_w    = xmldoc.getElementsByTagName('width').item(0).firstChild.data;
               var flv_h    = xmldoc.getElementsByTagName('height').item(0).firstChild.data;
               var flv_auto = xmldoc.getElementsByTagName('autostart').item(0).firstChild.data;
               var flv_repeat = xmldoc.getElementsByTagName('repeat').item(0).firstChild.data;

               document.getElementById('popup_content').innerHTML = flv_html;
    
	   	      var so = new SWFObject("incl/flvplayer.swf", "flashflv", flv_w, flv_h, "7", "#000000");
		            so.addParam("scale", "noscale"); 
		            so.addParam("salign", "TL");				
		            so.addParam("quality", "high"); 
		            so.addParam("menu", "false");				
          	  	   so.addVariable("file", flv_file);       
		            so.addVariable("image", flv_img);
		            so.addVariable("autostart", flv_auto);
		            so.addVariable("repeat", flv_repeat);
                  so.write(flv_win)
               ;		
            } else if (r_typ == 'vk_frml') {
               var r_html  = xmldoc.getElementsByTagName('htmlcode').item(0).firstChild.data;
              // var r_templ = xmldoc.getElementsByTagName('templ').item(0).firstChild.data;
               var r_zhr   = xmldoc.getElementsByTagName('zhr').item(0).firstChild.data;
                                         
               //document.getElementById('frml_vk_date_'+r_templ+'_'+r_zhr).innerHTML = r_html;
               document.getElementById('frml_vk_date_78_8').innerHTML = r_html;
            }
         }
      } else {
         alert('Bei dem Request ist ein Problem aufgetreten.');
      }
   }
}
