var share_opts = new Hash();

function kigolSharing(url, link, title) {
	new Ajax.Request(url, {
		parameters: {
			share_link: link,
			share_title: title
		},
		method: "post"
	});
}

function kigolBlogSharing(url, post_id) {
	new Ajax.Request(url, {
		parameters: {
			post_id: post_id
		},
		method: "post"
	});
}

function upShareOpt(url, type, prefix){	
	if(!prefix) prefix ='';
	if(!share_opts.get(prefix+type)) {
		new Ajax.Request(url);
		share_opts.set(prefix+type, true);
		var id = 's_sharing_form_'+prefix+type;		
		var el = $(id);
		if(el){
			var total = parseInt(el.innerHTML);
			total++;
			el.innerHTML = total;
		}
	}
}

function initFloatShareBox() {
	Event.observe(window, 'scroll', function(){
		var element = $('s_sharing_box');
		var min_top = 285;
		var info    = element.cumulativeScrollOffset();
		var top     = info[1];
		
		if(top > min_top && element.hasClassName('share_abs')) {
			element.removeClassName('share_abs');
			element.addClassName('share_fix');
		}else if(top <= min_top && element.hasClassName('share_fix')) {
			element.addClassName('share_abs');
			element.removeClassName('share_fix');
		}

	});
	
	modifyFloatShareBox();

	Event.observe(window, 'resize', function(){
		modifyFloatShareBox();
	});
}

function modifyFloatShareBox() {
	var width = window.innerWidth;

	if(width <= 1125) {		
		//$('s_sharing_box').fade();
		//$('s_sharing_box_small').appear();
		//new Effect.Parallel([new Effect.Fade('s_sharing_box'), new Effect.Appear('s_sharing_box_small')]);
		$('s_sharing_box').hide();
		$('s_sharing_box_small').show();
	} else {		
		//new Effect.Parallel([new Effect.Appear('s_sharing_box'), new Effect.Fade('s_sharing_box_small')]);
		//$('s_sharing_box').appear();
		//$('s_sharing_box_small').fade();
		$('s_sharing_box').show();
		$('s_sharing_box_small').hide();
	}
}
