jQuery.noConflict();

jQuery().ready(function($){

    // mod TagCloud. yay.    
    $('div#tagCloud a').each(function() {
        oldAttr = $(this).attr('style');
        //console.log(oldAttr);
        fadeValue = oldAttr.substring( 11,13 );
        //console.log(fadeValue);
        $(this).removeAttr('style').removeAttr('title');
        $(this).fadeTo(0, '0.' + fadeValue )

        //hoverFX
        $(this).hover(function() {
            oldAttr = $(this).attr('style');
            fadeValue = oldAttr.substring( 11,13 );
            //if fadeValue now has one decimal digit, it will contain ";",causing fadeOut to fail,so...
            fadeValue = fadeValue.replace( ';' , '0' );
            //console.log(fadeValue);
            $(this).stop().fadeTo( 200,1 )
         },function(){
            $(this).stop().fadeTo( 400, '0.' + fadeValue );            
        });
    });
    

    //RSS animation
    $('a#rssLink').css( {backgroundPosition: '153px 0px'} )

    $('a#rssLink').hover(function() {
        $('a#rssLink img').stop().animate(
                { //backgroundPosition:'(100px 0px)'
                  right: '56px',
                  top: '-11px',
                  width: '46px',
                  height: '56px'
            } ,300                
                )
        $('a#rssLink span').stop().animate(
            { left: '40px',              
              top: '30px',
              opacity: '0'} ,300
        )
    },function(){
        $('a#rssLink img').stop().animate(
            { //backgroundPosition:'(153px 0px)'
              right: '13px',
              top: '0px',
              width: '36px',
              height: '46px'
        },300
        )
        $('a#rssLink span').stop().animate(
            { left: '0px',
              top: '9px',
              opacity: '1'} ,300
        )
    });

    // cufon init
    Cufon.replace('#mainhead h1 a',{ fontFamily: 'nerdTimes', hover: true });
    Cufon.replace('ul#menu li a', { fontFamily: 'nerdTimes', hover: true });


    //Authors
    $('span.triggerPosts').click(function(){
        if ($(this).parent('p').next('div.auth_latest:visible').size() == 0) {
            $(this).parent('p').next('div.auth_latest').show(300);
            $(this).addClass('underline');
        }
        else {
            $(this).parent('p').next('div.auth_latest').hide(300);
            $(this).removeClass('underline');
        }
    });


    //authImg + Name hoverFX
    $('div.authImg img.avatar,div.authImg img.photo').hover(function(){
        $(this).stop().fadeTo(200 , 1);
        $(this).parent().next().children('p.authName').children('span').addClass('underline');
    },function(){
        $(this).stop().fadeTo(200 , 0.85);
        $(this).parent().next().children('p.authName').children('span').removeClass('underline')
    });
    $('p.authName span').hover(function(){
        $(this).addClass('underline');
        $(this).parent().parent().prev('div').children('img').stop().fadeTo(200, 1);
    },function(){
        $(this).removeClass('underline');
        $(this).parent().parent().prev('div').children('img').stop().fadeTo(200, 0.85);
    });


    // AuthDesc on Img click
    $('div.authImg').click(function(){
        if ($(this).next().children('div.authDetail:visible').size() == 0) {
            $(this).next().children('div.authDetail').show(300);
        }
       else {
            $(this).next().children('div.authDetail').hide(300);
        }
    });

    // AuthDesc on Name click
    $('p.authName span').click(function(){
        if ($(this).parent().next('div.authDetail:visible').size() == 0) {
            $(this).parent().next('div.authDetail').show(300);
        }
        else { 
            $(this).parent().next('div.authDetail').hide(300);
        }
    });


     //input FX
     $('form input[type="text"],form textarea').focus(function(){
         $(this).parent().parent().addClass('activated');
     });
     $('form input,form textarea').blur(function(){
         $(this).parent().parent().removeClass('activated');
     });
     //comments
     $('form#commentform input[type="text"]').focus(function(){
         $(this).next('label').addClass('activated');
     });
     $('form#commentform input').blur(function(){
         $(this).next('label').removeClass('activated');
     });

     // input values Contact
     $('form input#name').focus(function(){
         if ($(this).val() == 'Name'){
            $(this).val('');
         }
     });
     $('form input#email').focus(function(){
         if ($(this).val() == 'Email'){
            $(this).val('');
         }
     });
     $('div.txtarea textarea').focus(function(){
         if ($(this).val() == 'Kommentar'){
            $(this).val('');
         }
     });

     $('form input#name').blur(function(){
         if ($(this).val() == ''){
             $(this).val('Name');
         }
     });
     $('form.wpcf7-form input#email').blur(function(){
         if ($(this).val() == ''){
             $(this).val('Email');
         }
     });
     $('form div.txtarea textarea').blur(function(){
         if ($(this).val() == ''){
             $(this).val('Kommentar');
         }
     });



      // Pagination
      $('ul.page-numbers li a.page-numbers').hover(function(){
         
         $(this).stop().animate(
            { fontSize : '16px',
              opacity : '1' } ,100
            )
    },function(){
         
         $(this).stop().animate(
            { fontSize: '13px',
              opacity : '0.4' },100
        )
      });


     //footer fb+twit
     $('#footer li.fbook, #footer li.twitter').hover(function() {         
        $(this).find('img').stop().fadeTo(300,0);
        },function() {            
        $(this).find('img').stop().fadeTo(300,1);
        });
});


