/*ADDTHIS BUTTON BEGIN */
var loc;
var title;
var description;
loc = '{';
loc += '{';
loc += 'url' + '}' + '}';

title = '{';
title += '{';
title += 'title' + '}' + '}';

description = '{';
description += '{';
description += 'description' + '}' + '}';

ljDescription = '<table style="margin:0;padding:0">';
ljDescription += '<tr>';
ljDescription += '<td valign="top"><a href="url"><img alt="" src="http://otdelkachestva.ru/userfiles/image/modul2_7.jpg" style="border: none;" /></a></td>';
ljDescription += '<td valign="top" style="padding-left: 15px;width:100%;"><a href="url"><h1 style="margin-top:0;color:#1359BE">title</h1></a>description</td>';
ljDescription += '</tr>';
ljDescription += '</tbody></table>';
//
ljDescriptionIe = ljDescription;
ljDescription = escape(ljDescription);

ljDescription = ljDescription.replace(/url/g, '{{url}}');
ljDescription = ljDescription.replace('description', '{{description}}');
ljDescription = ljDescription.replace('title', '{{title}}');

ljDescriptionIe = ljDescriptionIe.replace(/url/g, '{{url}}');
ljDescriptionIe = ljDescriptionIe.replace('description', '{{description}}');
ljDescriptionIe = ljDescriptionIe.replace('title', '{{title}}');



var addthis_config = {
    ui_header_color: "#28a400",
    ui_header_background: "#000",
    services_compact: 'vkontakte.ru, twitter.com, facebook, connect.mail.ru, www.livejournal.com, www.myspace.com, print, www.odnoklassniki.ru',
    services_expanded: 'vkontakte.ru, twitter.com, facebook, connect.mail.ru, www.livejournal.com, www.myspace.com, print, www.odnoklassniki.ru',
    services_custom: [{
        name: "Вконтакте",
        url: "http://vkontakte.ru/share.php?url=" + loc + "&title=" + title + "&description=" + description,
        icon: "/images/design/vkontakte.gif"
    },
    {
        name: "MySpace",
        url: "http://www.myspace.com/index.cfm?fuseaction=postto&t={{title}}&c={{description}}&u={{url}}",
        icon: "/images/design/myspace.gif"
    },
     {
        name: "LiveJournal",
        url: "http://www.livejournal.com/update.bml?event=" + ljDescription + "&subject={{title}}",
        url_ie: "http://www.livejournal.com/update.bml",
        description: ljDescriptionIe,
        icon: "/images/design/livejournal.png"
    },
    {
        name: "Twitter",
        url: "http://twitter.com/share?url={{url}}&text={{title}}",
        icon: "/images/design/twitter.gif"
    },
    {
        name: "Мир@Mail.ru",
        url: "http://connect.mail.ru/share?share_url={{url}}",
        icon: "/images/design/mailru.gif"
    },
    {
        name: "Одноклассники",
        url: "http://www.odnoklassniki.ru/dk?st.cmd=addShare&st.s=0&st._surl={{url}}",
        icon: "/images/design/classmates.gif"
    }]
}



var addthis_localize = {
   
};

function callback(data) {
    alert(data);
}

function getTitleByType(t){
	switch(t){
		case 1:
			stitle = "Забирай к себе:"
        break;
		case 2:
            stitle = "<div style='overflow:hidden; height: 12px;'> <div style='float:left; width:40%;'>Мне нравится!</div> <div style='float:left; width:50%; text-align:right;'>Отдел Качества</div> </div>"
        
        break;
        case 3:
            stitle = "Делиться с друзьями:"
        break;
        default:
            stitle = "Делиться с друзьями:"           
        break;
    }
	return stitle;	
}

$(document).ready(function(){	
   $('a.addthis_button').mouseover(function(e){		
		type =parseInt($(this).attr('rel'));		
		
		addthis_caption_share = getTitleByType(type);		
	});
	
	
	$('a.addthis_button').html(' ');
});





function utf8_encode ( str_data ) {
    str_data = str_data.replace(/\r\n/g,"\n");
    var utftext = "";

    for (var n = 0; n < str_data.length; n++) {
    var c = str_data.charCodeAt(n);
        if (c < 128) {
            utftext += String.fromCharCode(c);
        } else if((c > 127) && (c < 2048)) {
            utftext += String.fromCharCode((c >> 6) | 192);
            utftext += String.fromCharCode((c & 63) | 128);
        } else {
            utftext += String.fromCharCode((c >> 12) | 224);
            utftext += String.fromCharCode(((c >> 6) & 63) | 128);
            utftext += String.fromCharCode((c & 63) | 128);
        }
    }

    return utftext;
}

/*ADDTHIS BUTTON END */
