function printLyrics(element)
{
    var lyricsElement = element.parentElement;
    document.body.insertAdjacentHTML("beforeEnd", "<iframe name=\"printHiddenFrame\" width=\"0\" height=\"0\"></iframe>");
    var doc = printHiddenFrame.document;
    doc.open();
    doc.write("<BODY onload=\"parent.onprintHiddenFrame()\" style=\"margin: 20px; background: white; color: black; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px;\">");
    doc.write("<H2>" + lyricsElement.previousSibling.innerHTML + "</H2>");
    doc.write(lyricsElement.innerHTML.replace(/<script(.|\n)*?>((.|\n)*?)<\/script>/gi, ""));
    doc.write("</BODY>");
    doc.close();
    doc.all.printLink.outerHTML = "";
    doc.links[0].outerHTML = doc.links[0].innerHTML;
    var previewWindow = window.open('','Preview0', 'width=800,height=800,resizable=yes,scrollbars=yes');
    previewWindow.document.write(doc.body.outerHTML);
}

function sanat()
{
    
}

function onprintHiddenFrame()
{
    function onfinish()
    {
        printHiddenFrame.outerHTML = "";
        if (window.onprintcomplete)
        {
            window.onprintcomplete();
        }
    }
    printHiddenFrame.print();
}

pageName = null;

function initPage()
{
    if (document.URL.lastIndexOf(".html") != document.URL.length - 5)
    {
        pageName = "index";
    }
    else
    {
        pageName = document.URL.substring(document.URL.lastIndexOf('/') + 1, document.URL.length);
        pageName = pageName.substring(0, pageName.indexOf('.'));
        if (pageName.indexOf('_') != -1)
        {
            pageName = pageName.substring(0, pageName.indexOf('_'));
        }
    }
    /*if (document.all)
    {
        var link = eval("document.all." + pageName);
        if (link)
        {
            link.style.color = "#F9814C";
        }
    }*/
}

function isNonEmpty(textField, field)
{
    a = textField.value;
    if (a == "")
    {
        if (field == 'name')
        {
            alert("Kirjoita nimesi!");
        }
        else if (field == 'text')
        {
            alert("Kirjoita kommentti!");
        }
        textField.focus();
        return false;
    }
    else
    {
        return true;
    }
}

kpikkuna = null;
function kokoonpano(nimi)
{
    if (kpikkuna != null)
    {
        if (!kpikkuna.closed)
        {
            kpikkuna.close();
        }
    }
    if (IE4)
    {
        var pos = "left=" + ((screen.width - 300) / 2) + ",top=" + ((screen.height - 350) / 2);
    }
    else
    {
        var pos = "screenX=" + (screen.width - 300) / 2 + ",screenY=" + (screen.height - 350) / 2;
    }
    kpikkuna=window.open("kok/kok_" + nimi + ".html","kpikkuna","toolbar=no,menubar=no,scrollbars=no,width=300,height=350," + pos);
}

kuvaikkuna = null;
function kuva(nimi)
{
    if (kuvaikkuna != null)
    {
        if (!kuvaikkuna.closed)
        {
            kuvaikkuna.close();
        }
    }
    if (IE4)
    {
        var pos = "left=" + ((screen.width - 580) / 2) + ",top=" + ((screen.height - 550) / 2 - 15);
    }
    else
    {
        var pos = "screenX=" + (screen.width - 580) / 2 + ",screenY=" + (screen.height - 550) / 2;
    }
    kuvaikkuna=window.open("kuvat/" + nimi + ".html","ikkuna","toolbar=no,menubar=no,scrollbars=no,width=580,height=550," + pos);
}

function paivitykset()
{
    if (IE4)
    {
        var pos = "left=" + ((screen.width - 400) / 2) + ",top=" + ((screen.height - 400) / 2 - 15);
    }
    else
    {
        var pos = "screenX=" + (screen.width - 400) / 2 + ",screenY=" + (screen.height - 400) / 2;
    }
    window.open("paivi.html","paivitykset","toolbar=no,menubar=no,scrollbars=yes,width=400,height=400," + pos);
}

function uutiset()
{
    if (IE4)
    {
        var pos = "left=" + ((screen.width - 400) / 2) + ",top=" + ((screen.height - 400) / 2 - 15);
    }
    else
    {
        var pos = "screenX=" + (screen.width - 400) / 2 + ",screenY=" + (screen.height - 400) / 2;
    }
    window.open("uutiset.html","uutiset","toolbar=no,menubar=no,scrollbars=yes,width=400,height=400," + pos);
}

