var VKApiId;
var site = window.location.href;
if (site.indexOf("love.sibnet.ru") != -1) VKApiId=2449360;
if (site.indexOf("info.sibnet.ru") != -1) VKApiId=2450013;
if (site.indexOf("video.sibnet.ru") != -1) VKApiId=2450017;
if (site.indexOf("photo.sibnet.ru") != -1) VKApiId=2450019;
if (site.indexOf("joke.sibnet.ru") != -1) VKApiId=2450020;
if (site.indexOf("soft.sibnet.ru") != -1) VKApiId=2450736;
if (site.indexOf("game.sibnet.ru") != -1) VKApiId=2450750;
if (site.indexOf("mors.sibnet.ru") != -1) VKApiId=2450016;
if (site.indexOf("auto.sibnet.ru") != -1) VKApiId=3245814;
if (site.indexOf("avto.sibnet.ru") != -1) VKApiId=3245818;

if (site.indexOf("mors-novosibirsk.sibnet.ru") != -1) VKApiId=3612367;
if (site.indexOf("mors-barnaul.sibnet.ru") != -1) VKApiId=3612379;
if (site.indexOf("mors-kemerovo.sibnet.ru") != -1) VKApiId=3612382;
if (site.indexOf("mors-novokuznetsk.sibnet.ru") != -1) VKApiId=3612386;
if (site.indexOf("mors-irkutsk.sibnet.ru") != -1) VKApiId=3612389;
if (site.indexOf("mors-ulan-ude.sibnet.ru") != -1) VKApiId=3612396;
if (site.indexOf("mors-omsk.sibnet.ru") != -1) VKApiId=3612400;

if (site.indexOf("www.sibnet.ru") != -1) VKApiId=2683950;

var sW_Image_src = (document.getElementById("sW_Image")) ? document.getElementById("sW_Image").src : '';

function load_scripts(url,charset) {
var widget = document.createElement('script');
widget.type = 'text/javascript';
widget.async = true;
widget.src = url;
if (charset) widget.charset = charset;
document.getElementsByTagName('head')[0].appendChild(widget);
}
function load_styles(url) {
var link = document.createElement('link');
link.href = url;
link.type = 'text/css';
link.rel = 'stylesheet';
document.getElementsByTagName('head')[0].appendChild(link);
}

var video = 0;
if (site.indexOf("video.sibnet.ru") != -1 || site.indexOf("video2.sibnet.ru") != -1) video=1;
var mors = 0;
var morsKonkurs = 0;
if (site.indexOf("mors.sibnet.ru") != -1) {
mors=1;
if (site.indexOf("konkurs") != -1) morsKonkurs = 1;
}
var info = 0;

if (site.indexOf("info.sibnet.ru") != -1 && /MSIE (\d+\.\d+);/.test(navigator.userAgent)) info=1;
//if (site.indexOf("info.sibnet.ru") != -1 ) info=1;
//if (info) {var sW_Image_src = (document.getElementById("postImg")) ? document.getElementById("postImg").src : '';}
if (site.indexOf("info.sibnet.ru") != -1) {
sW_Title = postTitle;
sW_Image_src = (document.getElementById("postImg")) ? document.getElementById("postImg").src : '';
}

var d = document.getElementById('rePost');
if (d) {

if (postImg.length != 0) postImg="<div style=\"float:left !important; margin:3px 10px 0 0 !important;\"><a href=\""+window.location.href+"\"><img src=\""+postImg+"\" style=\"border:0px;\"><\/a><\/div>";
if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){postTitle = site;postDescription = site;}

d.innerHTML = "<!-- noindex "+sW_Image_src+"-->";
d.innerHTML += "<!-- facebook --><div style=\"float:left;width:136px;height:26px\"><div id=\"fb-root\"><\/div><fb:like href=\"\" send=\"false\" layout=\"button_count\" width=\"136\" show_faces=\"false\" action=\"recommend\" font=\"\"><\/fb:like><\/div><!-- \/facebook -->";
d.innerHTML += "<!-- odnoklassniki --><div style=\"float: left;height:26px;width:135px\"><a class=\"odkl-share-oc\" href=\""+window.location.href+"\" onclick=\"ODKL.Share(this);return false;\" ><span>0<\/span><\/a><\/div><!-- \/odnoklassniki -->";
d.innerHTML += "<!-- twitter --><div style=\"float:left;height:26px;width:90px\"><a href=\"http://twitter.com/share\" class=\"twitter-share-button\" data-count=\"horizontal\">Tweet</a><\/div><!-- \/twitter -->";
if (!info) d.innerHTML += "<!-- vkontakte --><div style=\"float:left;height:26px;width:100px\"><div id=\"vk_like\"><\/div><\/div><!-- \/vkontakte -->";
//d.innerHTML += "<!-- moymir --><div style=\"float:left;height:26px;width:139px\"><a target=\"_blank\" class=\"mrc__plugin_like_button\" href=\"http://connect.mail.ru/share\" data-mrc-config=\"{'type' : 'button', 'width' : '145'}\">moymir<\н»њ/a><\/div><!-- \/moymir -->";
d.innerHTML += "<!-- moymir --><div style=\"float:left;height:26px;width:139px\"><a target=\"_blank\" class=\"mrc__plugin_uber_like_button\" href=\"http://connect.mail.ru/share\" data-mrc-config=\"{'nc' : '1', 'cm' : '2', 'sz' : '20', 'st' : '2', 'tp' : 'mm'}\">РќСЂР°РІРёС‚СЃСЏ</a><\/div><!-- \/moymir -->";
if (!video) d.innerHTML += "<!-- livejournal --><div style=\"float:left;height:26px;\"><form accept-charset=\"UTF-8\" action=\"http://www.livejournal.com/update.bml\" method=\"post\" target=\"_blank\" style=\"margin:0px\"><input type=\"hidden\" name=\"subject\" value=\""+postTitle+"\"><textarea name=\"event\" style=\"display:none\"><div style=\"padding:10px;background:#ffffff;border:1px solid #DDDDDD;overflow:hidden !important;\">"+postImg+"<div style=\"overflow:hidden !important; zoom:1; font:12px Arial !important; color:#333333 !important;\"><a href=\""+window.location.href+"\" style=\"color:#333333;\">"+postDescription+"<\/a><\/div><div style=\"clear:both !important; font-size:0 !important; line-height:0 !important;\"><\/div><\/div><\/textarea><input type=\"image\" src=\"http://sibnet.ru/promo/livejournal-icon.png\"><\/form><\/div><!-- \/livejournal -->";
//d.innerHTML += "<!-- ya.ru --><div style=\"float:left;height:26px;\"><div class=\"yashare-auto-init\" data-yashareL10n=\"ru\" data-yashareType=\"none\" data-yashareQuickServices=\"yaru\"><\/div><style>.b-share {padding:0px 10px !important;} a.b-share__handle {padding:0px !important}<\/style><\/div><!-- \/ya.ru -->";
d.innerHTML += "<div style=\"clear:both\"><\/div><!--\/noindex-->";

load_scripts("https://connect.facebook.net/ru_RU/all.js#xfbml=1","UTF-8");
if (!info) load_scripts("https://userapi.com/js/api/openapi.js?34");
load_scripts("https://platform.twitter.com/widgets.js");
load_styles("//stg.odnoklassniki.ru/share/odkl_share.css");
load_scripts("//stg.odnoklassniki.ru/share/odkl_share.js");
load_scripts("//cdn.connect.mail.ru/js/loader.js","UTF-8");
//load_scripts("//yandex.st/share/share.js","UTF-8");

//
//load_scripts("http://www.sibnet.ru/valentinki/game_script.php");

var sWsaveOnload = window.onload;

if(document.getElementsByClassName == undefined) { 
   document.getElementsByClassName = function(cl) { 
      var retnode = []; 
      var myclass = new RegExp('\\b'+cl+'\\b'); 
      var elem = this.getElementsByTagName('*'); 
      for (var i = 0; i < elem.length; i++) { 
         var classes = elem[i].className; 
         if (myclass.test(classes)) { 
            retnode.push(elem[i]); 
         } 
      } 
      return retnode; 
   } 
};

if (mors) {	
	sW_Title = document.title;
	sW_Description = document.title;
	if (morsKonkurs) { sW_Image_src = document.getElementsByClassName('selimg')[0].src; }
	else sW_Image_src = document.getElementById('big_img').src;
}
if (site.indexOf("game.sibnet.ru/wot_pictures") != -1) {
	sW_Image_src = "http://game.sibnet.ru/images/wot_pictures/v3.fw.png";
	sW_Title = document.title;
	//sW_Description = "World of Tanks.";
}

//if (love) {	
//	sW_Title = "love.sibnet.ru";
//	sW_Description = "love.sibnet.ru";
//	sW_Image_src = document.getElementById('konkursCover').src;
//}

if (info) window.onload = function () {ODKL.init();sWsaveOnload();}
else if (mors) {
if (vkPageId) window.onload = function () {VK.init({apiId: VKApiId, onlyWidgets: true});VK.Widgets.Like('vk_like', {width: 160, type: "mini", pageTitle: sW_Title, pageDescription: sW_Description, pageImage: sW_Image_src, verb: 1},vkPageId);ODKL.init();sWsaveOnload();}
else  window.onload = function () {VK.init({apiId: VKApiId, onlyWidgets: true});VK.Widgets.Like('vk_like', {width: 160, type: "mini", pageTitle: sW_Title, pageDescription: sW_Description, pageImage: sW_Image_src, verb: 1});ODKL.init();sWsaveOnload();}
}
else {
	if (sW_Image_src.length != 0) window.onload = function () {VK.init({apiId: VKApiId, onlyWidgets: true});VK.Widgets.Like('vk_like', {width: 160, type: "mini", pageTitle: sW_Title, pageImage: sW_Image_src, verb: 1});ODKL.init();sWsaveOnload();}
	else  window.onload = function () {VK.init({apiId: VKApiId, onlyWidgets: true});VK.Widgets.Like('vk_like', {width: 160, type: "mini", verb: 1});ODKL.init();sWsaveOnload();}
}


//////
/*
socialWidget = (function () {
    var doc = document
    var ready = (function (func){
	try{
	    var oldOnload = window.onload;
	    if(doc.addEventListener) {
		doc.addEventListener("DOMContentLoaded", func, false)
	    }
	    else {
		window.onload = function(){if(oldOnload) oldOnload(); func()}
	    }
	}catch(e){}
    })(function () {
	VK.init({apiId: VKApiId, onlyWidgets: true});VK.Widgets.Like('vk_like', {width: 160, type: "mini", verb: 1});ODKL.init();
    })
})()
*/
//////
}