function vw()
{
    x = document.getElementById('voorwaarden');

    if (x.style.display == 'none')
        x.style.display = 'block';
    else
        x.style.display = 'none';
}

// polledit.tpl
function validateTemplate()
{
    val = document.getElementById('template').options[document.getElementById('template').selectedIndex].value;
}

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>';
            data = data + '     <input type="input" size="40" id="answer' + i + '" name="answertext[' + ch + ']" value="' + q_Text[ch] + '" style="width: 250px;" onkeyup="limit(\'answer' + i + '\', question_min_length, question_max_length, \'answer' + i + 'Length\');" onkeydown="limit(\'answer' + i + '\', question_min_length, question_max_length, \'answer' + i + 'Length\');">&nbsp;<div style="display: inline;" id="answer' + i + 'Length">' + question_max_length + '</div>';
            data = data + '</td>';
            data = data + '</tr>';
        } 

        data += '</table>';
        document.getElementById('cust').innerHTML = data; // dit moet werken voor elke browser die DOM kan

        for (i = 1; i <= answer; i++) 
        {
            limit('answer' + i, question_min_length, question_max_length, 'answer' + i + 'Length');
        } 
    }
}


// addstep2.tpl
function createFormUpd()
{
    for (x = 1; x < 15; 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.tpl
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';
}

// footer.tpl
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]);
   }
}

// step2 & 3.tpl
function limit(veld, minimum, maximum, telveld)
{
    v = document.getElementById(veld);
    i = document.getElementById(telveld);

    var charsLeft = maximum - v.value.length;

    if(charsLeft <= 0) 
    {
  	// always set charsLeft to 0 so no negative #'s display
        charsLeft = 0;
	// trim the extra input off of the input string and push
	// to the input element
        v.value = v.value.substring(0, maximum);
    }
  
    // push the current count to the count element
    if (v.value.length > maximum || v.value.length < minimum)
    {
        i.innerHTML = "<font color=red>" + (charsLeft) + "</font>";
    }
    else      
    {
        i.innerHTML = "<font color=green>" + (charsLeft) + "</font>";
    }
}

function p()
{
    popImage('/poll.php?id=1&layout=' + document.getElementById('template').value, viewpollText);
}

// addstep1.tpl
function viewTemplate()
{
    val = document.getElementById('template').options[document.getElementById('template').selectedIndex].value;
    if (val != '')
    { 
        document.getElementById('preview').innerHTML = '<img src="/preview.php?layout=' + val + params + '" ALT="' + viewImagText + '">';
    }

}


// polledit.tpl
function showPoll(id, type, title, size)
{
    // location settings.
    baseUrl     = "http://www.gfxpoll.com";
    baseUrlPoll  = baseUrl + "/viewpoll/" + pollID + pollIdSeo + ".html";
    baseUrlGfx   = baseUrl + "/pollgfx/" + pollID + ".png";
    baseUrlVote  = baseUrl + "/vote/";
    baseUrlVoteR = ".html";

    enter = "\r\n";

    str = "error";
    
    switch (type)
    {
        case "htmllink":
            str = '<a href=&quot;' + baseUrlPoll + '&quot; target=&quot;_blank&quot;>Poll ' + pollTitle + '</a>';
        break;

        case "link":
            str = baseUrlPoll;
        break;

        case "ubbsmall":
            str = "[b]" + pollText + ": " + pollTitle + "[/b]" + enter;
            for (x = 1; x <= pollAnswers; x++)
            {
                 str += "[url=" + baseUrlVote + pollID + "-" + pollAnswerID[x] + baseUrlVoteR + "]" + pollAnswer[x] + "[/url]" + enter;
            }
            str += enter + "Resultaten:" + enter + "[img]" + baseUrlGfx + "[/img]";
            str += enter + enter + "[sup]" + createPlText + " [url=" + baseUrl + "]" + hereText + "[/url][/sup]";
        break;

        case "html":
            str = "<strong>" + pollText + ": " + pollTitle + "</strong><br /><br />" + enter + enter + "<ul>" + enter;
            for (x = 1; x <= pollAnswers; x++)
            {
                str += "    <li><a href=\"" +  baseUrlVote + pollID + "-" +pollAnswerID[x] + baseUrlVoteR + "\" target=\"_blank\">" + pollAnswer[x] + "</a></li>" + enter;
            }
            str += "</ul>" + enter + "<br /><small>" + pollResuText + ":</small><br />" + enter + "<img src=\"" + baseUrlGfx + "\"><br /><br />";
            str += enter + enter + "<small>" + createPlText + " <a href=\"" + baseUrl + "\" TARGET=\"_blank\">" + hereText + "</a></small>";
        break;

        case "htmlmap":
            str = "<strong>" + pollText + ": " + pollTitle + "</strong><br /><br />" + 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=\"_blank\" TITLE=\"Bekijk de poll\">" + enter;
                height = headerpng[0];
            }

            for (x = 1; x <= pollAnswers; x++)
            {
                 
                str += "<area href=\"" +  baseUrlVote + pollID + "-" + pollAnswerID[x] + baseUrlVoteR + "\" shape=\"rect\" coords=\"0,0," + optionpng[1] + "," + (height + (optionpng[0] *x)) + "\" target=\"_blank\" TITLE=\"" + clickVotText + "'" + pollAnswer[x] + "'\">" + enter;
            }

            if (footerpng)
            {
                str += "<area href=\"" + baseUrlPoll + "\" shape=\"rect\" coords=\"0,0," + (footerpng[1]) + "," + (height+(optionpng[0] * pollAnswers)) + "\" target=\"_blank\" TITLE=\"" + clickVieText + "\">" + enter;
            }

            str += enter + "</MAP><br /><small>" + clickText + "<br /><br />" + createPlText + " <a href=\"" + baseUrl + "\" TARGET=\"_blank\">" + hereText + "</a></small>";
        break;

        default:
            str = "[b]" + pollText + ": " + pollTitle + "[/b]" + enter;
            for (x = 1; x <= pollAnswers; x++)
            {
                 str += "[*][url=" + baseUrlVote + pollID + "-" + pollAnswerID[x] + baseUrlVoteR + "]" + pollAnswer[x] + "[/url]" + enter;
            }
            str += enter + "[sup]" + pollResuText + ":[/sup]" + enter + "[img]" + baseUrlGfx + "[/img]";
            str += enter + enter + "[sup]" + createPlText + " [url=" + baseUrl + "]" + hereText + "[/url][/sup]";
        break;
    }

    str.replace("<", "%3C");
    str.replace(">", "%3E");

    if (size == 1)
    {
        return '<b>' + title + '</b><br /><input type="text" id="' + id + '" style="width: 280px; " onmouseover="javascript:document.getElementById(\'' + id + '\').focus(); document.getElementById(\'' + id + '\').select();" value="' + str + '"><br /><br />';
    }
    else
    {
        return '<b>' + title + '</b><br /><textarea id="' + id + '" style="width: 280px; height: 100px;" onmouseover="javascript:document.getElementById(\'' + id + '\').focus(); document.getElementById(\'' + id + '\').select();">' + str + '</textarea><br /><br />';
    }
}
