function url(){
	link_name = prompt('Wpisz nazwe dla odnośnika',"");
	link_url = prompt('Podaj adres odnośnika',"http://");
	if ((link_url != null) && (link_url != ""))
	{
		if ((link_name != null) && (link_name != "")) addText('message', "[URL="+link_url+"]"+link_name+"[/URL]","");
		else addText('message', "[URL]"+link_url+"[/URL]","");
	}
}

function resizeImages(){
	var content=document.getElementById('content');
	var images=content.getElementsByTagName('img');
	var maxImageWidth=700; //1024: 960 - 2x180 (sides) - 150 (author)
	var node=document.createElement('p');
	node.setAttribute('style','font-size:smaller;');
	node.innerHTML='Obrazek został zmniejszony. Kliknij w obrazek aby zobaczyć go w pełnych rozmiarach.';
	for(var i=0;i<images.length;i++){
		if(images[i].width>maxImageWidth){
			var a=document.createElement('a');
			a.href="javascript:showAttachImg('"+images[i].src+"',"+(images[i].width+20)+","+(images[i].height+20)+")";
			images[i].parentNode.insertBefore(node.cloneNode(1),images[i]);
			images[i].parentNode.insertBefore(a,images[i]);
			a.appendChild(images[i]);
			images[i].width=maxImageWidth;
		}
	}
}

function showAttachImg(source,width,height){
  var el=$('#attachment_dialog'),img;
  if(!el.length){
    el = $('<div/>')
      .appendTo(document.body)
      .attr('id','attachment_dialog')
      .dialog({
        resizable:false,
        autoOpen:false,
        position:'top',
        modal:true});
    el.dialog('option','title','Zdjęcie z załącznika');
  }
  el.dialog('close');
  el.html('<img src="'+source+'">');
  img = $('img',el);
  img.click(function(){
        el.dialog('close');
  });
  el.dialog('option','width',width+10);
  el.dialog('option','height',height+20);
  el.dialog('open');
}
