 (function($)
    {

    	var fComplience = false;
    	//var fComplience = ($.browser.mozilla);
    	if ($.browser.msie &&  $.browser.version < 6 || navigator.userAgent.toLowerCase().indexOf('ipod') > -1)
    	{
    	  fComplience = true;
    	}

    	$.setComplienceMode = function(fBool)
    	{
    	  fComplience = fBool;
    	}

      $(function()
      {
        // "Du sollst keinen anderen Frame ueber mir haben!"
        // Da es immer noch nette Menschen gibt, die andere Seiten in Ihren Frames verlinken,
        // schützen wir uns ein wenig selbst ...
        if (document.location.href.indexOf('no-js') < 1 && parent.frames.length!=0) window.top.location.href=window.location.href;

        $('div.showFlash').each(function(){
	        var $this = $(this);
	        $this.flash($this.metadata(), { version: '6.0.65' });
				});


				if (!fComplience)
				{
				  $('a.advenz-gift').attr('href', '/advenz/gift_new.php?jsMode=on').click(function(){
            $.openGiftBox();
            return false;
          });
				}

				$.getComplianceMode = function()
				{
					return fComplience;
				}


				$.openGiftBox = function(url)
				{
				  // Hier ist JS beim Client SICHER ausgeschaltet
          if (fComplience)
          {
            document.location.href = 'http://www.advenz.de/advenzkalender-verschenken.htm';
          }
          else // hier ist JS eingeschaltet
          {
            if (url == null)
            {
              url = '/advenz/gift_new.php?jsMode=on';
             	location.hash='verschenken';
            }


            try {
            	$('#cluetip').hide();
              $.GB_show(url, {
                close_img: "fileadmin/js/greybox/close.gif",
              	height: 5800,
                width: 700,
                animation: true,
                overlay_clickable: false,
                fOverflowHidden: true,
                iCaptionHeight:61,
                fAjax : true,
                fIframe : false,
                fImage : false,
                //callOnCloseStart: function(){if (document.location.hash='#verschenken') {document.location.href = document.location.href.substr(0, document.location.href.indexOf("#")); }}
                //ppp, 2009-11-27: Reload entfernt, da er nervt und ich nicht mehr
                //genau weiß wieso ich ihn brauchte. Falls es zu Fehlern kommen sollte
                //muss ggf. doch ein echter Reload durchgeführt werden
                callOnCloseStart: function(){if (location.hash=='#verschenken') {location.hash=''; }}
              });
            }
            // und falls jemad tatsächlich hier landet, dann ist JS zwar eingeschaltet, allerdings funktieniert die Greybox aus irgendeinem Grund nicht
            // dann (und nur dann!) wird umgeleitet auf die kompatiblitäts-Modus Verschenken Seite (ohne JS)
            catch(e)
            {
              document.location.replace('http://www.advenz.de/alt-verschenken.htm');
            }

          }

				}

				$.openCalBox = function()
				{
          document.location.hash='advenzkalender';
          var sCalAll = $('#btnAnsehen').attr('href');
          $.GB_show(sCalAll, {
            close_img: "/fileadmin/templates/gfx/close20px.gif",
            sBoxPreFix: 'advenzCal_',
            animation: true,
            overlay_clickable: true,
            fOverflowHidden: true,
            iCaptionHeight:20,
            fIframe : true,
            fAutoSize: true,
            dAspectRatio: 1.46,
            fFireAnimationAtOnce : false,
            //callOnCloseStart: function(){if (document.location.hash='#advenzkalender') {document.location.href = document.location.href.substr(0, document.location.href.indexOf("#")); }}
            callOnCloseStart: function(){location.hash=''; }
          });
				}

				// Für MSIE auch die input-Elemente "aktiv" schalten
        if ($.browser.msie) $('form.frmElement input[type="text"], form.frmElement textarea').blur(function() {$(this).removeClass('onActiveFcous')}).focus(function() { $(this).addClass('onActiveFcous'); });

				if (document.location.hash == '#verschenken')
				{
				  $.openGiftBox(null);
				}


				if (document.location.hash == '#advenzkalender')
				  $.openCalBox();

				$('a.guestBookLink').click(function(){
					$.GB_show('http://www.advenz.de/gaestebuch/eintragen.htm?getOnlyContent=1', {
            close_img: "fileadmin/js/greybox/close.gif",
          	height: 680,
            width: 700,
            animation: true,
            overlay_clickable: false,
            fOverflowHidden: true,
            iCaptionHeight:61,
            fAjax : true,
            fIframe : false,
            fImage : false
          });
          return false;
				});



      });




    })(jQuery)

