function preview()
{
    var ob = document.getElementById('enquete_preview');

    ob.style.width = document.objForm.width.value + 'px';
    ob.style.padding = document.objForm.padding.value + 'px';
    ob.style.background = document.objForm.background_color.value;
    ob.style.borderColor = document.objForm.border_color.value;
    ob.style.color =  document.objForm.font_color.value;
    ob.style.fontFamily = document.objForm.font_family.options[document.objForm.font_family.selectedIndex].value;
    ob.style.fontSize = document.objForm.font_size.options[document.objForm.font_size.selectedIndex].value;
    ob.style.textAlign = document.objForm.text_align.options[document.objForm.text_align.selectedIndex].value;
    ob.style.lineHeight = document.objForm.font_size.options[document.objForm.font_size.selectedIndex].value;
    ob.style.borderStyle = "solid";
    ob.style.borderWidth = 1+"px";

    var aa = document.getElementById('a');
    aa.style.color = document.objForm.link_color.value;

    var url_im = document.objForm.background_image.value;
    ob.style.backgroundImage = "url("+url_im+")";
    ob.style.backgroundPosition = document.objForm.background_position.options[document.objForm.background_position.selectedIndex].value;
    ob.style.backgroundRepeat = document.objForm.background_repeat.options[document.objForm.background_repeat.selectedIndex].value;
}

window.onload = preview;

function useOption(where,elem1,elem2,flg)
{
    elem1 = document.getElementById(elem1);
    if(elem2 != ''){elem2 = document.getElementById(elem2);}
    if (where.value == 'true') {
        elem1.disabled = false;
        if(elem2 != ''){elem2.disabled = false;}
    } else {
        elem1.disabled = true;
        if(elem2 != ''){elem2.disabled = true;}
    }
    document.getElementById('enquete_preview').style.backgroundImage = (flg) ? 'url(' + document.objForm.background_image.value + ')' : 'url()';

}

function changeDisp(where,that)
{
    var thatElem = document.getElementById(that);
    if (where.value == 'true') {
        thatElem.disabled = false;
        if (thatElem.value == '') {
            thatElem.value = 'http://';
        }
        thatElem.focus();
    } else if (where.value == 'false') {
        thatElem.disabled = true;
    }
}

var changeColorObj,colorTableObj;
function changeColorWindow(obj)
{
    changeColorObj = obj;
    try{
        colorTableObj.focus();
    }
    catch(e) {
        colorTableObj = window.open('/enqueteform/color-table.html','colorTable','width=340,height=300');
    }
}

function colorTableObjDel() {
    colorTableObj = '';
}

window.onunload = function() {
    colorTableObj.close();
}

function setColor(color) {
    changeColorObj.value = color;
    preview();
}

