function widget(id,color,encoding, x, y)
{	
	var r,g,b,z,foot,foot_color,x2;
	// temp
	r = color.substring(1,3);
	g = color.substring(3,5);
	b = color.substring(5,7);
	r = parseInt("0x" + r);
	g = parseInt("0x" + g);
	b = parseInt("0x" + b);
	z = 0.299 * r + 0.587 * g + 0.114 * b;

	if ((r>160)&&(g<150)&&(b<150)){
		foot = "logo_blue_white.png";
		foot_color =  "#000000";
	}
	else
	if (z>160){
		foot =  "logo_blue_red.png";
		foot_color =  "#000000";
	}
	else{
		foot = "logo_white_red.png";
		foot_color =  "#ffffff";
	}

	head_height = 53;
	min_height = 161;
	max_height = 500;
	if (y < min_height)
		y = min_height;
	if (y > max_height)
		y = max_height;
	min_width = 240;
	max_width = 800;
	if (x < min_width)
		x = min_width;
	if (x > max_width)
		x = max_width;
	x2 = x;
	if (document.all)
		x = x-2;
		
	if (encoding != 'UTF-8')
		text = 'Wpisz tekst do t�umaczenia'; 
	else
		text = 'Wpisz tekst do tłumaczenia';
		
	document.getElementById('widzet_view').innerHTML = '<div id="widzet" style="border: 1px solid #b2b2b2; width: '+ x2 +'px; height: '+ y +'px; background-color: white;">\n<a href="http://www.translatica.pl"><img src="http://heweliusz.translatica.pl:5009/widzet-counter/widzet-id/'+id+'.png/" alt="translatica.pl"  style="border:none; float: left; margin: 10px auto 0 12px;"/></a><div style="clear: both;"></div>\n<div style="text-align: left; background-color: #'+ color +'; position: relative; height: '+ (y - head_height) +'px;">\n<div style="width: 5px; height: 5px; background: url('+"'"+'http://www.translatica.pl/images/layout/widzet_border_2.png/'+"'"+') no-repeat; float: left; overflow: hidden;"></div><div style="height: 5px; width: '+ (x - 10) +'px; background-color: white; float: left; overflow: hidden;"></div><div style="width: 5px; height: 5px; background: url('+"'"+'http://www.translatica.pl/images/layout/widzet_border.png'+"'"+') no-repeat; float: left; overflow: hidden;"></div><div style="clear: both;"></div>\n<form id="trans_form" target="_blank" method="post" action="http://heweliusz.translatica.pl:5009/" style="margin: 0 8px 8px;">\n<input type="hidden" name="widget-id" value="'+id+'" />\n<input type="hidden" id="encoding" value="'+ encoding +'" size="10" name="encoding"/>\n<textarea name="text" cols="'+ ((x - 16) / 6) +'" rows="'+ ((y - 147) / 14) +'" onclick="if (removed[this.id]==null){this.value=\'\';removed[this.id]=true;}" id="translate_text" style="overflow: hidden; border:1px solid #B2B2B2; color:#292722; font: 11px Arial, sans-serif; margin-bottom: 8px; width: '+ (x-20) +'px; height: '+ (y - 143) +'px; margin-top: 10px; padding: 2px;">'+ text +'</textarea><br />\n<input type="submit" class="trans" id="_trans" value="&nbsp;" style="float: right; background:transparent url(http://www.translatica.pl/images/layout/przycisk_tlumacz_widget.png) no-repeat scroll 0pt 0pt; border:medium none !important; cursor:pointer; height:22px; margin:0px; padding:0px; width:77px; margin-left: 25px;" />\n<select name="dir" class="fl" id="Dir" style="float: right; font: 11px Arial, sans-serif; width: 120px; margin-bottom: 5px;">\n<option value="plen" selected="selected">polski =&gt; angielski</option>\n<option value="enpl">angielski =&gt; polski</option>\n<option value="plru">polski =&gt; rosyjski</option>\n<option value="rupl">rosyjski =&gt; polski</option>\n<option value="plde">polski =&gt; niemiecki</option>\n<option value="depl">niemiecki =&gt; polski</option>\n</select>\n<div style="clear: both"></div>\n</form>\n<div style="width: 100%; height: 32px; border: none; position: absolute; bottom: 0px!important;">\n<div style="float: right; margin: 9px 8px 4px; width: 106px; border: none;">\n<span id="foot_text" style="color: '+ foot_color +'; font: 11px Arial, sans-serif; margin: 0; padding: 2px 0; float: left;">(c) 2009 by </span><span style="margin-left: 3px; float: left; filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='+"'"+'http://www.translatica.pl/images/layout/'+ foot +"'"+');"><img src="http://www.translatica.pl/images/layout/'+ foot +'" alt="pwn.pl" style="float: left; margin: 0; border: none; padding: 0; filter:progid:DXImageTransform.Microsoft.Alpha(opacity=0);"/></span>\n</div>\n</div>\n<div style="clear: both;"></div>\n</div>\n</div>';
}