tinyMCEPopup.requireLangPack();

var addThisDialog = {
    
	init : function() {
		var f = document.forms[0];
	},

	insert : function() {
		// Insert the contents from the input into the document
		
		var strHtml  = '';
		var divname  = document.forms[0].divname.value;
		var width    = document.forms[0].width.value;
		var height   = document.forms[0].height.value;
		var username = document.forms[0].username.value;
		if (width == "") width = 125;
		if (height == "") height = 16;
		if (divname == "") divname = 'addthis_goweb';
		
		var langcode = tinymce.EditorManager.settings.language;
		html = '<div id="' + divname + '" class="addthis">\n';
		html += '<script type="text/javascript">\n';
		html += 'var addthis_language = "' + langcode + '"; \n';
		if (username){
			html += 'var addthis_pub="' + username + '"; \n';
		}
		html += '</script>\n';
		html += '<!-- AddThis BEGIN -->\n';
		html += '<a onclick="return addthis_sendto()"\n'; 
		html += 'onmouseover="return addthis_open(this, \'\', \'[URL]\', \'[TITLE]\')"\n'; 
		html += 'onmouseout="addthis_close()" \n';
		html += 'href="http://www.addthis.com/bookmark.php?v=20">\n';
		html += '<img style="border:0" src="http://s7.addthis.com/static/btn/lg-share-' + langcode + '.gif" \n';
		html += 'alt="Bookmark and Share" width="' + width + '" height="' + height + '" />\n';
		html += '</a>\n';
		html += '<script src="http://s7.addthis.com/js/200/addthis_widget.js" type="text/javascript"></script>\n';
		html += '<!-- AddThis END -->\n';
		html += '</div>';
		tinyMCEPopup.editor.execCommand('mceInsertContent', false, html);
		tinyMCEPopup.close();
	}
};

tinyMCEPopup.onInit.add(addThisDialog.init, addThisDialog);
