/*
// ####################################################################################################
// # Datei inc.js V 2.6
// ####################################################################################################
// # Copyright © 2004-2011 ISS-Oberlausitz
// # Author: T.Hojenski
// # Email: info@iss-ol.de
// # URL:   http://www.bluepage-cms.com
// # Diese Datei gehört zu dem kommerziellen bluepage - CMS der ISS-Oberlausitz
// # Bitte beachten Sie die Lizenzbedingungen.
// # Unberechtigte Nutzung, Änderung oder Weitergabe über die Lizenzbedingungen hinaus
// # sind strafbar.
// # Eine unberechtigte Verwendung auch von Teilen des CMS-Systems kann zu Schadensersatz-
// # und/oder Unterlassungsansprüchen führen.
// # Das Entfernen der Copyrighthinweise ist untersagt.
// ####################################################################################################
*/

var ie  = document.all;
var dom = document.getElementById;

/* Browsercheck-Cookie */
function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
	if (document.getElementById('checkbrowser')) document.getElementById('checkbrowser').style.display = 'none'; 
}

Array.prototype.in_array = function(needle) {
   for(var i=0; i < this.length; i++) {
      if(this[ i] == needle) return true;
      else if (this[i].in_array) { // Überprüft ob es ein Array ist, mittels der eigenen Funktion
         if (this[i].in_array(needle)) return true; // Rekursiver Aufruf, return-Wert wird überprüft
      }
   }
   return false;
}

function explode(trenner,string) {
   return Array = string.split(trenner);
}

function str_replace(search, replace, subject) {
   return subject.split(search).join(replace);
}

function getElementByClassName(class_name,id) {
   var obj,ret_obj,teststr;
   obj=document.getElementById(id);
   if(obj.className.indexOf(class_name)!=-1) {
      teststr=","+obj.className.split(" ").join(",")+",";
      if(teststr.indexOf(","+class_name+",")!=-1) ret_obj=obj;
   }
   return ret_obj;
}

function captchaReload(templ) {
   document.getElementById('cp_'+templ).src = wwwUrl + '/incl/captcha.php?t='+templ+'&new='+Math.random();
}

function zoomMedia(typ,lg,pf,id,InhId) {
   if (pf == '../' || !document.getElementById('LightboxWindow')) {
      url = wwwUrl+'media_view.php?typ=' + typ + '&lg=' + lg + '&pf=' + pf + '&id=' + id + '&InhId=' + InhId;
      opt = 'location=no,scrollbars=auto,toolbar=no,resizable=yes,left=' + ((screen.availWidth-880)/2) + ',top=' + (((screen.availHeight-600)/2)-20) + ',width=890,height=600';
      galwindow = window.open(url,'_blank',opt);
      galwindow.moveTo(((screen.availWidth-895)/2),((screen.availHeight-600)/2)-20)
   } else {
      var _param = {   
         'InhId' : InhId,
         'lg'  : lg,
         'typ' : typ,
         'pfad' : pf,
         'id'  : id
      }
      $.ajax({
         type:       "GET",
         url:        wwwUrl+"/incl/request.ajax.php", 
         data: _param,
         success:    function(response){
            var r_html = response.getElementsByTagName('htmlcode').item(0).firstChild.data;
            var r_typ = response.getElementsByTagName('typ').item(0).firstChild.data;
            $('div#LightboxWindow').html(r_html);
            if (r_typ == 'flv' || r_typ == 'vk_flv' || r_typ == 'youtube') {
               var flv_file       = response.getElementsByTagName('file').item(0).firstChild.data;
               var flv_player     = response.getElementsByTagName('player').item(0).firstChild.data;
               var flv_img        = response.getElementsByTagName('img').item(0).firstChild.data;
               var flv_win        = response.getElementsByTagName('win').item(0).firstChild.data;
               var flv_w          = response.getElementsByTagName('width').item(0).firstChild.data;
               var flv_h          = response.getElementsByTagName('height').item(0).firstChild.data;
               var flv_auto       = response.getElementsByTagName('autostart').item(0).firstChild.data;
               var flv_repeat     = response.getElementsByTagName('repeat').item(0).firstChild.data;
               var flv_controlbar = response.getElementsByTagName('controlbar').item(0).firstChild.data;
               var flv_stretching = response.getElementsByTagName('stretching').item(0).firstChild.data;

               var flashvars = {};
                  flashvars.backcolor = "0x000000";
                  flashvars.frontcolor = "0xDEE1DF";
                  flashvars.lightcolor = "0xC7CCC9";
                  flashvars.midroll = "0";
                  flashvars.overstretch = "true";
                  flashvars.smoothing = "true";
                  if (flv_auto) flashvars.autostart = flv_auto;
                  flashvars.volume = "100";
                  if (flv_stretching) flashvars.stretching = flv_stretching;
                  flashvars.width = flv_w;
                  flashvars.height = flv_h;
                  if (flv_controlbar) flashvars.controlbar = flv_controlbar;
                  if (flv_repeat) flashvars.repeat = flv_repeat;
                  if (flv_img) flashvars.image = flv_img;
                  if (r_typ == 'youtube') flashvars.type = "youtube";
                  flashvars.file = flv_file;
                  //flashvars.skin = "incl/Kleur.swf"
               var params = {};
                  params.scale = "noscale";
                  params.salign = "TL";
                  params.quality = "high";
                  params.menu = "false";
                  params.wmode = "transparent";
                  params.allowfullscreen = "true";
                  params.allowscriptaccess = "always";
               var attributes = {};
               swfobject.embedSWF("incl/"+flv_player,flv_win,flv_w,flv_h, "8.0.0","incl/expressInstall.swf", flashvars, params, attributes);
               $('#LightboxContent').css({'height':Number(flv_h)+30});
               $('#LightboxContent').css({'width':Number(flv_w)+30});
            } else {
            }
            var ImgMarginLeft = '-'+(($('#LightboxContent').width()/2)); //-10 
            var ImgMarginTop = '-'+(($('#LightboxContent').height()/2)+50);
            var ImgWidth = ($('#LightboxContent').width()+30);  //+20
            var ImgHeight = ($('#LightboxContent').height()+30); // +40
            //$('div#bluepageDB_LightboxWindow').css({'marginLeft':ImgMarginLeft,'marginTop':ImgMarginTop,'width':ImgWidth,'height':ImgHeight});
            $('div#LightboxWindow').animate({'marginLeft':ImgMarginLeft,'marginTop':ImgMarginTop,'width':ImgWidth,'height':ImgHeight},'fast');
         }
      });
      if ((document.getElementById && !document.all) || (navigator.userAgent.indexOf('Opera') > -1)) {
         $('div#LightboxWindow').css({'position':'absolute','top':document.getElementById('bluepageBody').scrollTop + (window.innerHeight/2),'display':'block'}); 
         $('div#LightboxWindow').css({'position':'absolute','left':document.getElementById('bluepageBody').scrollLeft + (window.innerWidth/2),'display':'block'}); 
         if (document.getElementById('LightboxBackground')) {
            $('#LightboxBackground').animate({ opacity: 'hide' }, 'fast');
            $('#LightboxBackground').animate({ opacity: 'show' }, 'fast');
         }
      } else if (document.all) {
         if ((document.body.scrollTop + ((document.body.clientHeight)/2)-200) >0) {
            $('div#LightboxWindow').css({'top':document.body.scrollTop + ((document.body.clientHeight)/2)});
         } else {
            $('div#LightboxWindow').css({'top':'200px'});
         }
         //   $('#LightboxBackground').animate({ opacity: 'hide' }, 'fast');
         $('#LightboxBackground').animate({ opacity: 'show' }, 'fast');   
         $('div#LightboxWindow').css({'display':'block'});
         //$('#LightboxClose').css({'right':'0','top':'0'});
      }
   }
}

function zoomMediaClose() {
   if ((document.getElementById && !document.all) || (navigator.userAgent.indexOf('Opera') > -1)) {
      document.getElementById('LightboxWindow').style.display       = 'none';
      document.getElementById('LightboxWindow').innerHTML           = '';
   } else if (document.all) {
      document.all('LightboxWindow').style.display                  = 'none';
      document.all('LightboxWindow').innerHTML                      = '';
   }
   $('#LightboxBackground').animate({ opacity: 'hide' }, 'fast');
}


$("#LightboxContentNav").live('click', function(event) {
  if (event.target.nodeName != 'A') zoomMediaClose();
});

$('#LightboxWindow').live('mouseover', function(e) {
   $('#LightboxContentNav').animate({ opacity: 'show' }, 'fast');
});
$('#LightboxBackground').live('mouseover', function(e) {
   $('#LightboxContentNav').animate({ opacity: 'hide' }, 'fast');
});

function img_view(ds,lg,pf,inhId) {
   url = wwwUrl + '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 frml_checked(box) {
   if (box[0].checked == true) {
      for(i=1;i<box.length; i++) box[i].checked = true;
   }
}

function frml_checked(box) {
   if (box[0].checked == true) {
      for(i=1;i<box.length; i++) box[i].checked = true;
   }
}

$(document).ready(function(){ 
   $(".hover").mouseover(function (event) {
      var src = $(this).find('IMG').attr('src'); $(this).find('IMG').attr('src',src.replace('.png','.hover.png'));
   });
   $(".hover").mouseout(function (event) {
      var src = $(this).find('IMG').attr('src'); $(this).find('IMG').attr('src',src.replace('.hover.png','.png'));
   });
   $(".link_in").mouseover(function (event) {         
      var src = $(this).find('IMG').attr('src'); $(this).find('IMG').attr('src',src.replace('.png','.hover.png'));
   });
   $(".link_in").mouseout(function (event) {
      var src = $(this).find('IMG').attr('src'); $(this).find('IMG').attr('src',src.replace('.hover.png','.png'));
   });
   $(".link_sitenav_l").mouseover(function (event) { var src = $(this).find('IMG').attr('src'); var srcArray = src.split('.'); $(this).find('IMG').attr('src',srcArray[0]+'.hover.png'); });
   $(".link_sitenav_l").mouseout(function (event)  { var src = $(this).find('IMG').attr('src'); var srcArray = src.split('.'); $(this).find('IMG').attr('src',srcArray[0]+'.png'); });
   $(".link_sitenav_r").mouseover(function (event) { var src = $(this).find('IMG').attr('src'); var srcArray = src.split('.'); $(this).find('IMG').attr('src',srcArray[0]+'.hover.png'); });
   $(".link_sitenav_r").mouseout(function (event)  { var src = $(this).find('IMG').attr('src'); var srcArray = src.split('.'); $(this).find('IMG').attr('src',srcArray[0]+'.png'); });

   $("#bluepage_ul_1").find('LI').live('click', function(e) {
     if (e.target.nodeName == 'LI') { location.href = wwwUrl+$(this).find('A').attr('href'); }
   });
   $("#bluepage_ul_1").find('TD').live('click', function(e) {
     if (e.target.nodeName == 'TD') { location.href = wwwUrl+$(this).find('A').attr('href'); }
   });
   $(".navUL_2").find('LI').live('click', function(e) {
     if (e.target.nodeName == 'LI') { location.href = wwwUrl+$(this).find('A').attr('href'); }
   });
}); 

