function installSocialPlugins() {
	var vk_init = false;
	
	$('.vk-group-box').each(installVKGroupBox);
	$('.vk-like-button').each(function() {
		var $this = $(this),
			apiId = $this.attr('data-aid');
		
		if(!vk_init) {
			VK.init({apiId: apiId, onlyWidgets: true});
			vk_init = true;
		}
		
		installVKLikeButton.apply(this);
		
	});

}

function installVKGroupBox() {
	var $this = $(this),
		group = $this.attr('data-gid') || false,
		width = 202,
		height = 218;
	
	if(!group) return;
	
	$this.attr('id', 'vk-group-box_'+group);
	
	VK.Widgets.Group('vk-group-box_'+group, {mode: 0, width: width, height: height}, group);
}

function installVKLikeButton() {
	var $this = $(this),
		title = $this.attr('data-title') || false,
		descr = $this.attr('data-descr') || false,
		text = $this.attr('data-text') || false,
		image = $this.attr('data-image') || false;
	
	VK.Widgets.Like(this.id, {type: 'mini', text: text, pageTitle: title, pageDescription: descr, pageImage: image});
}

function installGooglePlusButton() {
	
}

$(function() {
	installSocialPlugins();
});
