/*function ParseScript(control){
        if(!control){
            return;
            }
       for(var n=0;n<control.children.length;n++){
             if(control.children[n].tagName == 'SCRIPT'){
                   window.ScriptLoader.loadScript(control.children[n].innerHTML);
              }else{
                   ParseScript(control.children[n]);
             }
        }
} 

window.ScriptLoader = new function(){
    varqueuedScripts = new Array();
    varcurrentScript = null;
    function onScriptLoaded(){
    //Load next
    doScriptLoad();
    }

    function onScriptError(){
        //Add Support for error handlers
        //Load next
        doScriptLoad();
    } 
    function onScriptReadyStateChange(){
        if(event.srcElement.readyState == "complete" ||event.srcElement.readyState == "loaded")
            onScriptLoaded();
        }
    this.loadScript = function(scriptPath){
        queuedScripts.push(scriptPath);
        if(currentScript == null)
            doScriptLoad();
        } //Does the actual script loading
        
    function doScriptLoad(){
    if(currentScript){
        currentScript.onload = onScriptLoaded; //For Mozilla/Opera
        currentScript.onerror = onScriptError; //For Mozilla/Opera
        currentScript.onreadystatechange = onScriptReadyStateChange; //For IE

    }
    if(queuedScripts.length == 0)
        return;
    currentScript = document.createElement("SCRIPT");
    currentScript.onload = onScriptLoaded; //For Mozilla/Opera
    currentScript.onerror = onScriptError; //For Mozilla/Opera
    currentScript.onreadystatechange = onScriptReadyStateChange; //For IE

    currentScript.type = "text/javascript";
    currentScript.text = queuedScripts.pop();
    document.getElementsByTagName('head')[0].appendChild(currentScript);
    }
}
*/

//WYSIWYG.attach(textBoxId);

linkButtonClick = function(textFormId){
    var tForm = document.getElementById(textFormId);
	var selection = new Selection(tForm);

	tForm.focus();
	var selText = selection.getText();
	var linkRef = prompt("Linkin (" + selText + ") kohdeosoite:", "http://");
	if (linkRef !== null){
		selText = "<a href=\"" + linkRef + "\">" + selText + "</a>";
	}
	selection.setText(selText);
	tForm.focus();
};

linkButtonClickSv = function(textFormId){
    var tForm = document.getElementById(textFormId);
	var selection = new Selection(tForm);

	tForm.focus();
	var selText = selection.getText();
	var linkRef = prompt("M"+ "\u00e5" + "l adress f" + "\u00f6" + "r l" + "\u00e4" + "nken (" + selText + "):", "http://");
	if (linkRef !== null){
		selText = "<a href=\"" + linkRef + "\">" + selText + "</a>";
	}
	selection.setText(selText);
	tForm.focus();
};

boldButtonClick = function(textFormId){
	 var tForm = document.getElementById(textFormId);
	var selection = new Selection(tForm);

	tForm.focus();
	var selText = selection.getText();
	selText = "<strong>" + selText + "</strong>";
	selection.setText(selText);
	tForm.focus();
	 };

loadWysiwyg = function(textFormId, width, height){
    //var mysettings = new WYSIWYG.Settings();
    //width !== null ?? mysettings.Width = width;
    //height !== null ?? mysettings.Height = height;
    WYSIWYG.attach(textFormId); //mysettings

};