﻿/* User Agent (Browserkennung) auf einen bestimmten Browsertyp prüfen */  
function checkBrowserName(name){  
	var agent = navigator.userAgent.toLowerCase();
	if (agent.indexOf(name.toLowerCase())>-1) {
	return true;
    }
    return false;
}

// Banner Slideshow
var show ="";
show = '<ul id="slideshow" style="z-index:0">';
var count = 17;
var img = getRandom(1,count);

	for (var i=0; i<count; i++) {
		img = (img < 10) ? "0" + img : img;
		show += '<li style="display:none;"><img src="/fileadmin/templates/pages/img/banner/' + img + '.jpg" alt="ddv banner" title="DDV Mediengruppe" /><\/li>';
		img++;
		img = (img > count) ? 1 : img;
	}
show += '<\/ul>';
$(document).ready(
	function(){
		$('body').addClass('js');
		$('#first-navi > ul > li:not(:last)').children(':not(ul)').append('<span class="right"></span>');
		$('#first-navi > ul > li:not(:first)').children(':not(ul)').append('<span class="left"></span>');

		$('#inner-wrapper').prepend(show);
		$('ul#slideshow').innerfade({
			speed: 3000,
			timeout: 7000,
			type: 'sequence',
			containerheight: '235px'
		});
		if(checkBrowserName('safari')){
			$('#first-navi ul li:last-child a, #first-navi ul li:last-child em').css({width:"11.4em"});
		}
		if(checkBrowserName('opera')){
		   $('#first-navi').css({top:".08em"});
		}

	}
);


// TYPO 3 std-JS für verschlüsseltes 'mailto' Attribut - SPAMSCHUTZ
// decrypt helper function
		function decryptCharcode(n,start,end,offset)	{
			n = n + offset;
			if (offset > 0 && n > end)	{
				n = start + (n - end - 1);
			} else if (offset < 0 && n < start)	{
				n = end - (start - n - 1);
			}
			return String.fromCharCode(n);
		}
// decrypt string
		function decryptString(enc,offset)	{
			var dec = "";
			var len = enc.length;
			for(var i=0; i < len; i++)	{
				var n = enc.charCodeAt(i);
				if (n >= 0x2B && n <= 0x3A)	{
					dec += decryptCharcode(n,0x2B,0x3A,offset);	// 0-9 . , - + / :
				} else if (n >= 0x40 && n <= 0x5A)	{
					dec += decryptCharcode(n,0x40,0x5A,offset);	// A-Z @
				} else if (n >= 0x61 && n <= 0x7A)	{
					dec += decryptCharcode(n,0x61,0x7A,offset);	// a-z
				} else {
					dec += enc.charAt(i);
				}
			}
			return dec;
		}
// decrypt spam-protected emails from TYPO3 Standard-JS
		function linkTo_UnCryptMailto(s)	{
			location.href = decryptString(s,-1);
		}
// get a pseudo random Number between min and max value
      function getRandom( min, max ) {
              if( min > max ) {
                      return( -1 );
              }
              if( min == max ) {
                      return( min );
              }
              return( min + parseInt( Math.random() * ( max-min+1 ) ) );
      }