function share_getPageTitle()
{
	return $('head title').html();
}
function share_getPageDescription()
{
	if ($('.intro:first').html()) return ($('.intro:first').html());
	return $('meta[name=description]').attr('content');
}
function share_getPageImages()
{
	var arr = new Array();
	$('img').each(function()
	{
			if ($(this).width()<40 || $(this).height()<40)
			{
				return false;
			}
			insert = 
			[
				$(this).width()*$(this).height(),
				$(this).attr('src'),
				$(this).width(),
				$(this).height(),
				$(this).attr('alt').split(',').join('')
			];
			if(!arr[0])
			{
				arr[0] = insert;
			}
			else
			{
				//arr.unshift(insert);
				var add = false;
				for (var i in arr)
				{
					if (insert[0] > arr[i][0])
					{
						arr.splice(i, 0, insert)
						add = true;
						break;
					}
				}
				if (!add)
				{
					arr.push(insert);
				}
			}
	});
	return arr;
}
function share_embed_ajax(current, title)
{
	Shadowbox.init({
		skipSetup: true
	});
	//share_embed_close();
	
	var u=document.location.toString();
	var t=share_getPageTitle();
	var d=share_getPageDescription();
	var i=share_getPageImages();
	$.ajax({
		type: "POST",
		url: scriptPath+"inc/mod/lib-share/front/ajax/embed.php",
		data: "url="+u+"&title="+escape(t)+"&description="+escape(d)+"&images="+i+"&current="+current,
		success: function(datas)
		{
			Shadowbox.open({
        content:   '',
        player:     "html",
        title:      title,
        height:     400,
        width:      600				
  	  });
			if ($('#sb-player').length==0)
			{
				setTimeout( function() { $('#sb-player').html(datas); }, 2200);
			}
			else
			{
				$('#sb-player').html(datas);
			}
		}
	});
	return false;
}
function share_embed_close()
{
	Shadowbox.close(0);
	if ($('.shareEmbedBox').length>0) $('.shareEmbedBox').remove();
	return false;
}

