function NetflipWidget() {
	this.attachWidgetEvent = function(){
		var obj = document.getElementById("netflip_add");
		if(obj == null || obj == undefined) return;
		
		var pos_x = (screen.width - 500) / 2;
		var pos_y = 100;
		var that = this;
		obj.onclick = function(){
			var w = window.open(that.getActionUrl(), "_blank", "menubar=no,location=no,resizable=no,scrollbars=no,status=no,width=500,height=500,left=" + pos_x + ",right=" + pos_y );
			w.focus();
		}
	};
	
	this.createWidget = function(){
		document.write('<img id="netflip_add" class="netflip_add" src="http://www.netflip.ru/images/widget/icon.png" alt="добавить на netflip" title="добавить на netflip" style="border:0px;cursor:pointer;"/>');
	};
	
	this.getMetaContent = function(Name){
		var content = "";
		var metas = document.getElementsByTagName('meta');
		for (var x = 0,y = metas.length; x < y; x++){
			if (metas[x].name.toLowerCase() == Name) {
				content = metas[x].content;
				break;
			}
		}
		return content;
	};

	this.url = window.location.href;
	this.title = document.title;
	this.description = this.getMetaContent("description");
	
	this.getActionUrl = function() {
        return "http://netflip.ru/item/widget/?url=" + encodeURIComponent(this.url) + "&title=" +  encodeURIComponent(this.title) + "&description=" +  encodeURIComponent(this.description);
    };
}


