//Beat Fly core
jQuery(document).ready(function($) {
															   						
	//paging featured post
	$('#featured_pager').pajinate({
		items_per_page : 2,
		item_container_id : '.featured_pager_content',
		nav_panel_id : '.alt_page_navigation'
	});
	
	//lazyload
	$(".entry img").lazyload({
    	placeholder : "grey.gif",
        effect      : "fadeIn"
    });
	
	/* Resize too large images */
	var size = 560;
	var image = jQuery('.entry img');
	
	for (i=0; i<image.length; i++) {
		var bigWidth = image[i].width;
		var bigHeight = image[i].height;
	
		if (bigWidth > size) {	
			var newHeight = bigHeight*size/bigWidth;
			image[i].width = size;
			image[i].height = newHeight;
		}
	}
	
	jQuery(".left:empty + .right:empty").parent().remove();

	//scrolling
	$('#goup span').click(function(){
		$('html, body').animate({
			scrollTop: $("#header").offset().top
			}, 1000);				   
	});
	
	//load portfolio gallery
	$.ajaxSetup ({
		cache: false
	});
		var ajax_load = "<img src='http://www.beatfly.net/wp-content/themes/white_wall/images/loader.gif' alt='loading portfolio...' />"
		//load() functions link
		var loadUrl = "http://www.beatfly.net/wp-content/themes/white_wall/portfolio.php";
			$("#contenitore").html(ajax_load).load(loadUrl);
	
	//scrolling
	$('#goup span').click(function(){
		$('html, body').animate({
			scrollTop: $("#header").offset().top
			}, 1000);				   
	});
	
	//img effect
	$('#sidebar .widget-body ul#author li img, #sidebar .widget-body ul li.advelements img, #footer_flicr_wrap img, #socialnetwork li img, #sidebar .widget-body ul li.galleryitems img').hover(function() {
		$(this).stop().animate({
			opacity : 0.6
		}, 500);
		},
		function(){
		$(this).stop().animate({
			opacity : 1
		}, 500);
	});
	
	//hover border effect
	$('#sidebar .widget-body ul#featured_sidebar li img.attachment-post-thumbnail').mouseover(function() {
		$(this).css({'border':'1px solid #FFF200'});
		}).mouseout(function() {
		$(this).css({'border':'1px solid #ccc'});
	});
			
	//share it
	$("#share").jsocial({highlight: true,
		buttons: "delicious,facebook,stumbleupon,technorati,twitter,digg,google,newsvine,yahoo,", 
		imagedir: "http://www.beatfly.net/wp-content/themes/white_wall/images/", 
		imageextension: "png", 
		blanktarget: true});
	
	//open flickr external link
	$(".footer-mid a[href]").attr('target','_blank');
	
	// Get latest 6 tweets by Graphicgatto twitter account
    $('#tweetsFeed').jTweetsAnywhere({
        username: 'Beatfly',
        count: 5,
        showTweetBox: { label: '<span style="color: #D1C7BA">Spread the word ...</span>' }
    });
	
});//end
