function p()
{
    popImage('poll.php?id=1&layout=' + document.getElementById('template').value,"Preview poll");
}

// addstep1.tpl
function viewTemplate()
{
    val = document.getElementById('template').options[document.getElementById('template').selectedIndex].value;
    if (val != '')
    { 
        document.getElementById('preview').innerHTML = '<img src="poll.php?id=1&layout=' + val + '" ALT="Click on this image to popup!">';
    }

}

// polledit.tpl
function validateTemplate()
{
    val = document.getElementById('template').options[document.getElementById('template').selectedIndex].value;
}

// polledit.tpl
function showPoll(type)
{
    // location settings.
    baseUrl     = "http://www.gfxpoll.nl";
    if (document.getElementById('rewrite') && document.getElementById('rewrite').checked != true)
    {
        baseUrlPoll  = baseUrl + "/index.php?page=show&id=" + pollID;
        baseUrlGfx   = baseUrl + "/poll.php?id=" + pollID + "&.png";
        baseUrlVote  = baseUrl + "/poll.php?vote=";
        baseUrlVoteR = "";
    }
    else
    {
        baseUrlPoll  = baseUrl + "/viewpoll/" + pollID + ".html";
        baseUrlGfx   = baseUrl + "/pollgfx/" + pollID + ".png";
        baseUrlVote  = baseUrl + "/pollvote/";
        baseUrlVoteR = ".html";
    }

    enter = "\r\n";

    str = "error";
    
    if (type == "ubb")
    {
        str = "[b]Poll: " + pollTitle + "[/b]" + enter;
        for (x = 1; x <= pollAnswers; x++)
        {
             str += "[*][url=" + baseUrlVote + pollAnswerID[x] + baseUrlVoteR + "]" + pollAnswer[x] + "[/url]" + enter;
        }
        str += enter + enter + "[sup]Tussenstand:[/sup]" + enter + enter + "[img]" + baseUrlGfx + "[/img]";
        str += enter + enter + "[sup]Ook een poll maken? klik dan [url=" + baseUrl + "]hier[/url][/sup]";
    }

    if (type == "ubbsmall")
    {
        str = "[b]Poll: " + pollTitle + "[/b]" + enter;
        for (x = 1; x <= pollAnswers; x++)
        {
             str += "[url=" + baseUrlVote + pollAnswerID[x] + baseUrlVoteR + "]" + pollAnswer[x] + "[/url]" + enter;
        }
        str += enter + enter + "Tussenstand:" + enter + enter + "[img]" + baseUrlGfx + "[/img]";
        str += enter + enter + "[sup]Ook een poll maken? klik dan [url=" + baseUrl + "]hier[/url][/sup]";
    }

    if (type == "html")
    {
        str = "<strong>Poll: " + pollTitle + "</strong><br /><br />" + enter + enter + "<ul>" + enter;
        for (x = 1; x <= pollAnswers; x++)
        {
             str += "    <li><a href=\"" + baseUrlVote + pollAnswerID[x] + baseUrlVoteR + "\" target=\"_newWin\">" + pollAnswer[x] + "</a></li>" + enter;
        }
        str += enter + enter + "</ul>" + enter + enter + "<br /><br /><small>Tussenstand:</small><br /><br />" + enter + "<img src=\"" + baseUrlGfx + "\"><br /><br />";
        str += enter + enter + "<small>Ook een poll maken? klik dan <a href=\"" + baseUrl + "\" TARGET=\"_newwin\">hier</a></small>";
    }

    if (type == "htmlmap")
    {
        str = "<strong>Poll: " + pollTitle + "</strong><br /><br />" + enter + enter;
        str += enter + "<img src=\"" + baseUrlGfx + "\" usemap=\"#poll" + pollID + "\" alt=\"poll image\" border=\"0\">" + enter;
        str += enter + "<MAP name=\"poll" + pollID + "\">" + enter;

        height = 0;

        if (headerpng)
        {
            str += "<area href=\"" + baseUrlPoll + "\" shape=\"rect\" coords=\"0,0," + (headerpng[1]) + "," + headerpng[0] + "\" target=\"_newWin\" TITLE=\"Bekijk de poll\">" + enter;
            height = headerpng[0];
        }

        for (x = 1; x <= pollAnswers; x++)
        {
             
             str += "<area href=\"" + baseUrlVote + pollAnswerID[x] + baseUrlVoteR + "\" shape=\"rect\" coords=\"0,0," + optionpng[1] + "," + (height + (optionpng[0] *x)) + "\" target=\"_newWin\" TITLE=\"Klik hier om te stemmen op: '" + pollAnswer[x] + "'\">" + enter;
        }

        if (footerpng)
        {
            str += "<area href=\"" + baseUrlPoll + "\" shape=\"rect\" coords=\"0,0," + (footerpng[1]) + "," + (height+(optionpng[0] * pollAnswers)) + "\" target=\"_newWin\" TITLE=\"Bekijk de poll\">" + enter;
        }

        str += enter + "</MAP><br /><small>* Klik op het antwoord op het plaatje om te stemmen op jouw keuze!<br /><br />Ook een poll maken? klik dan <a href=\"" + baseUrl + "\" TARGET=\"_newwin\">hier</a></small>";
    }

    str.replace("<", "%3C");
    str.replace(">", "%3E");

    return str;
}

function vPoll(type)
{
     document.getElementById('polltext').value = showPoll(type);
}

// polledit.tpl
function sh(id, off)
{
     if (document.getElementById('new'))
     {
         document.getElementById('new').style.display = 'none';
     }

     document.getElementById(off).style.display = 'none';
     document.getElementById(id).style.display = 'block';
}

// addstep2.tpl
function createForm(answer) 
{
    data = '<table border="0" cellpadding="0" cellspacing="1" width="200">';

    if (25 >= answer && answer > -1) 
    {
        for (i = 1; i <= answer; i++) 
        {
            ch = i-1;
            data = data + '<tr>';
            data = data + '<td width="100%" align="left" nowrap>&nbsp;<input type="input" size="40" id="answer' + i + '" name="answertext[' + ch + ']" value="' + q_Text[ch] + '"></td>';
            data = data + '</tr>';
        } 

        data += '</table>';
        document.getElementById('cust').innerHTML = data; // dit moet werken voor elke browser die DOM kan
    }
}

// addstep2.tpl
function createFormUpd()
{
    for (x = 1; x < 10; x++)
    {
        ch = x-1;
        if (document.getElementById('answer' + ch))
        {
            q_Text[ch-1] = document.getElementById('answer' + ch).value;
        }
    }
}

// unknown
function uitleg()
{
     x = document.getElementById('uitleg');

     if (x.style.display == 'none')
     {
         x.style.display = 'block';
     }
     else
     {
         x.style.display = 'none';
     }
}

// footer adsense
function adBox()
{
    contentSize = 720;

    midden = ((document.documentElement['offsetWidth'] -2)/2 - 80);

    document.getElementById('centerrechts').style.left    = ((document.documentElement['offsetWidth']/2) + (contentSize /2)) + "px";
    document.getElementById('centerrechts').style.display = 'block';
}


function addEvent( obj, type, fn )
{
   if (obj.addEventListener)
      obj.addEventListener( type, fn, false );
   else if (obj.attachEvent)
   {
      obj["e"+type+fn] = fn;
      obj[type+fn] = function() { obj["e"+type+fn]( window.event ); }
      obj.attachEvent( "on"+type, obj[type+fn] );
   }
}
