$(function(){

    // later $('#livesearch').attr('autocomplete', 'off');

    $('a.video').ytchromeless();

    $('.ui-state-default').hover(
        function(){$(this).addClass('ui-state-hover');},
        function(){$(this).removeClass('ui-state-hover');}
    );

	$('.clickable:has(a)').click(function(){
		window.location = $(this).find('a').eq(0).attr('href');
	});

	$('.clickable:has(a)').hover(function(){
        
        $(this).addClass('clickable');

    }, function(){

        $(this).removeClass('clickable');

    });
	
//	$.getScript('/javascripts/Hyphenator.js', function(){
//
//		Hyphenator.config({
//			classname : 'text'
//			// donthyphenateclassname : 'header',
//		});
//		Hyphenator.run();
//
//	});
	
	$.getScript('/javascripts/jcookie-min.js', function(){
	
		if ($.jCookie('showmonthlist') == '0'){
		
			$('#monthlist ul.rssMenu').hide();
			$('#monthlist .hidelink').html('Monatsliste einblenden');
			$('#monthlist ul.rssMenu').data('status', 'hidden');
				
		}
		
		$('#monthlist .hidelink').click(function(){
		
			if ($('#monthlist ul.rssMenu').data('status') == 'hidden'){
			
				$.jCookie('showmonthlist', '1');
				$('#monthlist ul.rssMenu').show();
				$('#monthlist .hidelink').html('Monatsliste ausblenden');
				$('#monthlist ul.rssMenu').data('status', 'show');
			
			} else {
			
				$.jCookie('showmonthlist', '0');
				$('#monthlist ul.rssMenu').hide();
				$('#monthlist .hidelink').html('Monatsliste einblenden');
				$('#monthlist ul.rssMenu').data('status', 'hidden');
				
			}
		});
	
	});
    
    // http://www.zurb.com/playground/jquery-text-change-custom-event
    $('#message').bind('hastext', function(){
        $('#commentpreviewbutton').attr('disabled', false);
    });
    $('#message').bind('notext', function(){
        $('#commentpreviewbutton').attr('disabled', true);
    });
    
    /**
     * image hover effects
     */
    //To switch directions up/down and left/right just place a "-" in front of the top/left attribute
    //Vertical Sliding
    $('.boxgrid.slidedown').hover(function(){
        $(".cover", this).stop().animate({top:'-260px'},{queue:false,duration:300});
    }, function() {
        $(".cover", this).stop().animate({top:'0px'},{queue:false,duration:300});
    });
    //Horizontal Sliding
    $('.boxgrid.slideright').hover(function(){
        $(".cover", this).stop().animate({left:'325px'},{queue:false,duration:300});
    }, function() {
        $(".cover", this).stop().animate({left:'0px'},{queue:false,duration:300});
    });
    //Diagnal Sliding
    $('.boxgrid.thecombo').hover(function(){
        $(".cover", this).stop().animate({top:'260px', left:'325px'},{queue:false,duration:300});
    }, function() {
        $(".cover", this).stop().animate({top:'0px', left:'0px'},{queue:false,duration:300});
    });
    //Partial Sliding (Only show some of background)
    $('.boxgrid.peek').hover(function(){
        $(".cover", this).stop().animate({top:'90px'},{queue:false,duration:160});
    }, function() {
        $(".cover", this).stop().animate({top:'0px'},{queue:false,duration:160});
    });
    //Full Caption Sliding (Hidden to Visible)
    $('.media.flickr a img').hover(function(){
        $(".media.flickr p", this).stop().animate({top:'160px'},{queue:false,duration:160});
    }, function() {
        $(".media.flickr p", this).stop().animate({top:'260px'},{queue:false,duration:160});
    });
    //Caption Sliding (Partially Hidden to Visible)
    $('.boxgrid.caption').hover(function(){
        $(".cover", this).stop().animate({top:'160px'},{queue:false,duration:160});
    }, function() {
        $(".cover", this).stop().animate({top:'220px'},{queue:false,duration:160});
    });

    var _gaq = _gaq || [];
    _gaq.push(['_setAccount', 'UA-400066-1']);
    _gaq.push(['_setDomainName', '.samui-samui.de']);
    _gaq.push(['_trackPageview']);

    try {
        var piwikTracker = Piwik.getTracker('http://analytics.blogfarm.de/piwik.php', 1);
        piwikTracker.trackPageView();
        piwikTracker.enableLinkTracking();
    } catch(err){}

    $.getScript(
        'http://api.flickr.com/services/rest/?jsoncallback=flickrstream&method=flickr.people.getPublicPhotos&format=json&api_key=07e434610b63fc8d108bf244bb31c7f9&per_page=2&user_id=85376146@N00'
    );

});

function flickrstream(data) {

    $.each(data.photos.photo, function(i, item){

        var photopage = 'http://www.flickr.com/photos/' + item.owner + '/' + item.id;
        var url = 'http://farm' + item.farm + '.static.flickr.com/' + item.server;
        url += '/' + item.id + '_' + item.secret + '_m.jpg';
        $('#flickrstream').before('<a href="' + photopage + '"><img src="' + url + '" alt="' + item.title + '" /></a>');

    });

}


