
function formStart()
{
	makeFormattingButtons();
}

function makeFormattingButtons()
{
	var img_url = "img/button/";
	var element = document.getElementById("formatting_buttons");
	if (element == null)
		return false;
	var str = "<img src=\""+img_url+"bold1.png\" id=\"bold\" onmouseover=\"setImg('bold','bold2')\" onmouseout=\"setImg('bold','bold1')\" onclick=\"process('bold')\" alt=\"Lihavoi\" title=\"Lihavoi\" style=\"cursor:hand\"> ";
	
	str = str + "<img src=\""+img_url+"italic1.png\" id=\"italic\" onmouseover=\"setImg('italic','italic2')\" onmouseout=\"setImg('italic','italic1')\" onclick=\"process('italic')\" alt=\"Kursivoi\" title=\"Kursivoi\" style=\"cursor:hand\"> ";
		
	str = str + "<img src=\""+img_url+"underline1.png\" id=\"underline\" onmouseover=\"setImg('underline','underline2')\" onmouseout=\"setImg('underline','underline1')\" onclick=\"process('underline')\" alt=\"Alleviivaa\" title=\"Alleviivaa\" style=\"cursor:hand\"> ";
	
	str = str + "<img src=\""+img_url+"overline1.png\" id=\"color\" onmouseover=\"setImg('overline','overline2')\" onmouseout=\"setImg('overline','overline1')\" onclick=\"process('overline')\" alt=\"Yliviivaa\" title=\"Yliviivaa\" style=\"cursor:hand\"> ";
		
	str = str + "<img src=\""+img_url+"image1.png\" id=\"image\" onmouseover=\"setImg('image','image2')\" onmouseout=\"setImg('image','image1')\" onclick=\"process('image')\" alt=\"Liitä kuva\" title=\"Liitä kuva\" style=\"cursor:hand\"> ";
		
	str = str + "<img src=\""+img_url+"link1.png\" id=\"link\" onmouseover=\"setImg('link','link2')\" onmouseout=\"setImg('link','link1')\" onclick=\"process('link')\" alt=\"Liitä linkki\" title=\"Liitä linkki\" style=\"cursor:hand\"> ";
	
	str = str + "<img src=\""+img_url+"quote1.png\" id=\"quote\" onmouseover=\"setImg('quote','quote2')\" onmouseout=\"setImg('quote','quote1')\" onclick=\"process('quote')\" alt=\"Lainaus\" title=\"Lainaus\" style=\"cursor:hand\"> ";
	
	str = str + "<img src=\""+img_url+"youtube1.png\" id=\"youtube\" onmouseover=\"setImg('youtube','youtube2')\" onmouseout=\"setImg('youtube','youtube1')\" onclick=\"process('youtube')\" alt=\"Liitä YouTube-video\" title=\"Liitä YouTube-video\" style=\"cursor:hand\"> ";
		
	str = str + "<br><br>";
	
	str = str + "<img src=\"http://www.kpelit.fi/img/smiley1/smiley.png\" alt=\":)\" title=\"Hymyilee\" onclick=\"process('happy');\" style=\"cursor:hand\" border=\"0\" /> ";str = str + "<img src=\"http://www.kpelit.fi/img/smiley1/lol.png\" alt=\":D\" title=\"Nauraa\" onclick=\"process('laugh');\" style=\"cursor:hand\" border=\"0\" /> ";str = str + "<img src=\"http://www.kpelit.fi/img/smiley1/blink.png\" alt=\";)\" title=\"Iskee silmää\" onclick=\"process('blink');\" style=\"cursor:hand\" border=\"0\" /> ";str = str + "<img src=\"http://www.kpelit.fi/img/smiley1/angry.png\" alt=\"&gt;:(\" title=\"Vihainen\" onclick=\"process('angry');\" style=\"cursor:hand\" border=\"0\" /> ";str = str + "<img src=\"http://www.kpelit.fi/img/smiley1/sad.png\" alt=\":(\" title=\"Surullinen\" onclick=\"process('sad');\" style=\"cursor:hand\" border=\"0\" /> ";str = str + "<img src=\"http://www.kpelit.fi/img/smiley1/confused.png\" alt=\":s\" title=\"Hämmentynyt\" onclick=\"process('confused');\" style=\"cursor:hand\" border=\"0\" /> ";str = str + "<img src=\"http://www.kpelit.fi/img/smiley1/cool.png\" alt=\"8)\" title=\"Iloinen\" onclick=\"process('cool');\" style=\"cursor:hand\" border=\"0\" /> ";str = str + "<img src=\"http://www.kpelit.fi/img/smiley1/cry.png\" alt=\":'(\" title=\"Itkee\" onclick=\"process('cry');\" style=\"cursor:hand\" border=\"0\" /> ";str = str + "<img src=\"http://www.kpelit.fi/img/smiley1/shock.png\" alt=\":o\" title=\"Ihmeissään\" onclick=\"process('shock');\" style=\"cursor:hand\" border=\"0\" /> ";str = str + "<img src=\"http://www.kpelit.fi/img/smiley1/tongue.png\" alt=\":p\" title=\"Näyttää kieltä\" onclick=\"process('tongue');\" style=\"cursor:hand\" border=\"0\" /> ";str = str + "<img src=\"http://www.kpelit.fi/img/smiley1/ups.png\" alt=\":]\" title=\"Nolostunut\" onclick=\"process('oops');\" style=\"cursor:hand\" border=\"0\" /> ";		
	element.innerHTML = str;
}

function setImg(element_id,file)
{
	var img_url = "img/button/";
	file = img_url + file + '.png';
	element = document.getElementById(element_id);
	element.setAttribute("src",file);
}

function process(button)
{
	element = document.getElementById('message');
	
	switch(button) {
		case 'bold':
			wrapSelection(element, '[b]','[/b]');
			break;
			
		case 'italic':
			wrapSelection(element, '[i]','[/i]');
			break;
			
		case 'underline':
			wrapSelection(element, '[u]','[/u]');
			break;
			
		case 'overline':
			wrapSelection(element, '[s]','[/s]');
			break;
			
		case 'image':
			wrapSelection(element, '[img]','[/img]');
			break;
			
		case 'link':
			wrapSelection(element, '[url]','[/url]');
			break;
			
		case 'quote':
			window.open('javascript/form_tool/quote.php','Lainaaminen','location=no,copyhistory=no,width=500,height=650');
			break;
			
		break;
		
		case 'youtube':
			result = window.open('javascript/form_tool/youtube.php','YouTube-videon liittäminen','location=no,copyhistory=no,width=500,height=250')
		break;
		case "happy":
			wrapSelection(element, ":)",'');
			break;
			case "laugh":
			wrapSelection(element, ":D",'');
			break;
			case "blink":
			wrapSelection(element, ";)",'');
			break;
			case "angry":
			wrapSelection(element, "&gt;:(",'');
			break;
			case "sad":
			wrapSelection(element, ":(",'');
			break;
			case "confused":
			wrapSelection(element, ":s",'');
			break;
			case "cool":
			wrapSelection(element, "8)",'');
			break;
			case "cry":
			wrapSelection(element, ":'(",'');
			break;
			case "shock":
			wrapSelection(element, ":o",'');
			break;
			case "tongue":
			wrapSelection(element, ":p",'');
			break;
			case "oops":
			wrapSelection(element, ":]",'');
			break;
						
	}
}


