
//_____________________________________ document base

// Local Base
   var baseDomain = "http://www.gold-gold-gold.de";
   var baseEMD    = "gold-gold-gold.de?subject=Waehrungsgold";
// var currentURL = "http://" + window.location.host + window.location.pathname;
   var currentURL = window.location.href;

//_____________________________________ document support

// open (jQuery) function
   (function($) {

         // Beginn form support
              var form = $('<form><fieldset><input /><textarea /></fieldset></form>');
              $.extend($.support, {
                 checkValidity: !!(form[0].checkValidity),
                 inputMaxlength: !!($('input', form)[0].maxlength !== undefined),
                 placeHolder: !!($('textarea', form)[0].placeholder !== undefined ||
                 $('input', form)[0].placeHolder !== undefined)
              });
              if(!$.support.inputMaxlength) {
                 $(function() {
                    $("input[maxlength]", $('section form')).keyup(function() {
                    var limit = parseInt($(this).attr('maxlength'));
                    var text = $(this).val();
                    var chars = text.length;
                    if(chars > limit) {
                       var new_text = text.substr(0, limit);
                       $(this).val(new_text);
                       }
                    });
                 });
              }
              if(!$.support.placeHolder) {
                 $(function() {
                    $("textarea[placeholder], input[placeholder]:not(input[type=password])",
                    $('form')).each(function() {
                       var placeHolder = this.getAttribute('placeholder').replace(/\n|\r|\f|\t/g, '');
                       this.setAttribute('placeholder', placeHolder);
                       if(!this.value) {
                           this.value = placeHolder;
                           }
                    }).bind('blur', function fillInput() {
                       if(!this.value) {
                           this.value = this.getAttribute('placeholder');
                           }
                    }).bind('focus', function resetInput() {
                       if (this.value == this.getAttribute('placeholder')) {
                           this.value = '';
                           }
                    });
                 });
              }
         // Ende form support

         // Beginn img preloader
              var cache = [];
              $.loadImages = function(images, callback) {
                 if (typeof images == "string") {
                    images = [images];
                 }
              var imagesLength = images.length;
              var loadedCounter = 0;
              for (var i = 0; i < imagesLength; i++) {
                   var cacheImage = document.createElement('img');
                     cacheImage.onload = function() {
                        loadedCounter++;
                    if (loadedCounter == imagesLength) {
                    if ($.isFunction(callback)) {
                        callback();
                        }
                    }
                 }
                 cacheImage.src = images[i];
                 cache.push(cacheImage);
                 }
              }
         // Ende img preloader

         // fadeTo hover
              $.fn.fadeTo_hover = function(hvspeed,hvopacity,uhspeed,uhopacity){
                 return this.each(function(){
                    $(this).css({opacity:uhopacity}).hover(function(){
                    $(this).stop().fadeTo(hvspeed,hvopacity);
                    },function(){
                    $(this).stop().fadeTo(uhspeed,uhopacity);
                    });
                 });
              };

         // hide tooltip [title]
              $.fn.hide_nativTip = function(){
                 return this.each(function(){
                    var $elem = $(this);
                    var savetitle = $elem.attr('title');
                    $elem.hover(function(){
                       $elem.removeAttr('title');
                    }, function(){
                       $elem.attr({title:savetitle});
                    });
                    $elem.click(function(){
                       $elem.attr({title:savetitle});
                    });
                 });
              };

// close (jQuery) function
   })(jQuery);

//_____________________________________ document init

    $(document).ready(function() {

         // iframe - frameborder @ie7 - scrolling @Chrome
              $('iframe').attr({frameborder:'0', scrolling:'no'});

         // attr anhängen
              $("#mail, a[itemprop='email']").attr('rel','mail');
              $("#print").attr('href','javascript:self.print()');

         // Seite empfehlen  tellafriend.php
              $("a#friend").click(function() {
                 var features = "height=560,"
                              + "width=500,"
                              + "resizable=1,"
                              + "scrollbars=1,"
                              + "toolbar=0,"
                              + "status=0,"
                              + "menubar=0,"
                              + "location=0,"
                              + "top=5,"
                              + "left=5";
                 newwindow=window.open(this.href, 'Popup', features);
                 return false;
                 });

         // Seite bookmarken - add favorite
              $("#favorit").click(function() {
                 // e.preventDefault(); e.stopPropagation();
                 var bookmarkUrl = this.href="http://www.gold-gold-gold.de";
                 var bookmarkTitle = this.title="gold-gold-gold.de - Schützen Sie Ihr Vermögen";
                 if (window.sidebar) { // firefox
                 window.sidebar.addPanel(bookmarkTitle, bookmarkUrl,"");  return false;
                 } else if(window.external || document.all) { // IE
                 window.external.AddFavorite(bookmarkUrl, bookmarkTitle); return false;
                 } else if(window.opera) {
                 $(this).attr("href",bookmarkUrl).attr("title",bookmarkTitle);
                 } else {
                 alert("Your browser does not support this bookmark action");
                 return false;
                 }
              });

         // eMail decrypt
              $("a[rel='mail']").click(function(emd) {
                 var str = this.rel;
                 var emailHandle = str.replace();
                 window.location = "mailto:" + emailHandle + "@" + baseEMD;
                 emd.preventDefault();
                 });

         // SmoothScroll | Version 10-04-30
              $("a[href='#top'], a[href^='#target']", $('section')).bind("click", function(eScr) {
                 eScr.preventDefault();
                 var duration=1000;
                 var easing='swing';  // easing values: swing | linear
                 var newHash=this.hash;
                 var target=$(this.hash).offset().top;
                 var oldLocation=window.location.href.replace(window.location.hash, '');
                 var newLocation=this;
              if(oldLocation+newHash==newLocation) {
              $('html:not(:animated), html.webkit body:not(:animated)').animate({
                 scrollTop: target }, duration, easing, function() {
                 window.location.href=newLocation;
                 });
                 return false;
                 }
              });

         // blockquote cite + title   http://heliologue.com/projects/blockquote-metadata-extractor/
              $("blockquote", $('#main, #main-column, #bodyFooter')).each(function() {
                 var title = $(this).attr("title");
                 var cite  = $(this).attr("cite");
                 if (cite == null && title != null) {  // cite|no   title|yes
                    $(this).append("<em class='source'>"+title+"</em>");
                 } else
                 if (cite != null && title == null) {  // cite|yes  title|no
                    $(this).append("<em class='source'><a rel='external' href='"+cite+"'>"+cite+"</a></em>");
                 } else
                 if (cite != null && title != null) {  // cite|yes  title|yes
                    $(this).append("<em class='source'><a rel='external' href='"+cite+"' title='"+title+"'>"+title+"</a></em>");
                 } else { }
              });

         // SocialBookmarks
              $("#delicious").attr('href','http://delicious.com/post?url=http://www.gold-gold-gold.de/');
              $("#digg").attr('href','http://digg.com/submit?phase=2&amp;url=http://www.gold-gold-gold.de/');
              $("#facebook").attr('href','http://www.facebook.com/sharer.php?u=http://www.gold-gold-gold.de/');
              $("#studivz").attr('href','http://www.studivz.net/Link/ExternLink/Url/?u=http://www.gold-gold-gold.de/');
              $("#stumbleupon").attr('href','http://www.stumbleupon.com/submit?url=http://www.gold-gold-gold.de/');
              $("#technorati").attr('href','http://technorati.com/faves?add=http://www.gold-gold-gold.de/');
              $("#twitter").attr('href','http://twitter.com/home?status=Currently+reading+http://www.gold-gold-gold.de/');
              $("#reddit").attr('href','http://reddit.com/submit?url=http://www.gold-gold-gold.de/');

              var ask_confirm = 'Google +1 Button ist nun aktiviert.\nFür Ihr Voting bitte ein zweites Mal anklicken.\nHierbei werden Daten an Google übermittelt,\nsiehe Google Datenschutzbestimmungen.';
              var ele_confirm = '<iframe src="https://plusone.google.com/u/0/_/+1/fastbutton?url='+currentURL+'&amp;size=standard&amp;count=true&amp;lang=de" scrolling="no" frameborder="0"></iframe>';

              $('#aPlusone').click(function(frame){ if(confirm(ask_confirm)){ $(this).replaceWith(ele_confirm) }
                 frame.preventDefault();
              }).attr('title','Disable: click to activate Google +1 Button');

         // Preload IMG
              $.loadImages([
              '/img/default/logo/gold-textur.jpg',                 // background-Img
              '/img/gold/home/slider/gold-ist-unvergaenglich.jpg'  // Slider Home
              ])  // Komma setzen - letztes Bild nicht !!


         // target blank
              $("a[rel~='external']").click(function() {
                 this.target = "_blank";
                 });

         // return false
              $("a.void").click(function() {
                 return false;
                 });

         // hide native tooltips - [title]
              $("figure a[title]:not(.showTip),"
              + "blockquote[title],"
              + "blockquote a[title]").hide_nativTip();

         // animate fadeToHover
              $(".fadeToHover").fadeTo_hover(500,1,500,0.4);

         // animate Navitop
              $("#Navitop ul li a:not(.active) span").css('padding','14px 17px 4px')
              .hover(function() {
                 $(this).stop().animate({paddingTop:'8px',paddingBottom:'10px'},300);
                 },  function() {
                 $(this).animate({paddingTop:'14px',paddingBottom:'4px'},600);
              });

         // animate aside nav
             $("aside nav ul li a:not(.active)").css('padding','5px 15px')
              .hover(function() {
                 $(this).stop().animate({paddingLeft:'40px'},400);
                 },  function() {
                 $(this).animate({paddingLeft:'15px'},500);
              });

         // animate aside Video - slideDown() + slideUp() + animate()
              $('#fig_aside_Video figcaption').hide();
              $('#fig_aside_Video').hover(function() {
                 $(this).children('figcaption').stop().slideDown(1000).animate({height:'65px'});
                 }, function() {
                 $(this).children('figcaption').stop().slideUp(500);
              });

         // Copyright
              $("#Copyright").prepend("Copyright &copy; 2010-" +
                 (new Date).getFullYear() + " by ");

         // append footer
              $("#foot_left .inset").append(
                '<a target="_blank" rel="nofollow" href="http://www.w3.org/html/logo/" title="HTML5 Powered with CSS3 and Semantics">'
              + '<img src="http://www.gold-gold-gold.de/img/icons/badges/valid/html5/html5-css3-semantics.png" alt="HTML5 Logo" width="140" height="39">'
              + '</a>'
              );


    });  // close document.ready function








