
packarr = Array();
packarr["tmpl_top"] = '<table style="width:{width}px" class="win win_text"><tr><td class="wc wtl"/><td class="wh wt"/><td class="wc wtr"/></tr><tr><td class="ww wl"/><td class="whead c" height="25" width="{width-20}">{head_content}</td><td class="ww wr"/></tr><tr><td class="wcm wml"/><td class="whm wm"/><td class="wcm wmr"/></tr>';
packarr["head_content_big"] = '<table><tr><td class="wheadl"/><td class="wheadt" width="{width-140}">{cont}</td><td class="wheadr"/></tr></table>';
packarr["head_content_small"] = '<span class="wheadt">{cont}</span>';
packarr["tmpl_up"] = '<table style="width:{width}px" class="win win_text"><tr><td class="wc wtl"/><td style="width:{width-20}px" class="wh wt"/><td class="wc wtr"/></tr>';
packarr["tmpl_header"] = '<tr><td class="ww wl"/><td class="tbl_bg2" width="{width-20}"><div class="win_padded_text wh2t">{cont}</div></td><td class="ww wr"/></tr>';
packarr["tmpl_content"] = '<tr><td class="ww wl"/><td class="win_bg" width="{width-20}">{cont}</td><td class="ww wr"/></tr>';
packarr["tmpl_middle"] = '<tr><td class="wcm wml"/><td style="width:{width-20}px" class="whm wm"/><td class="wcm wmr"/></tr>';
packarr["tmpl_bottom"] = '<tr><td class="wc wbl"/><td style="width:{width-20}px" class="wh wb"/><td class="wc wbr"/></tr></table>';

function unpack(nm, divnm, width, content){
    var tmpl = packarr[nm];
    if(content)
        tmpl = tmpl.split("{cont}").join(content);
    if(width) {
        tmpl = tmpl.split("{width}").join(width);
        tmpl = tmpl.split("{width-20}").join(width-20);
        tmpl = tmpl.split("{width-140}").join(width-140);
    }
    if(tmpl.split("{head_content}").length>1){
        if(width>=590)
            tmpl = tmpl.split("{head_content}").join(unpack("head_content_big", width, content));
        else tmpl = tmpl.split("{head_content}").join(unpack("head_content_small", width, content));
    }
    alert(tmpl);
    document.getElementById(divnm).innerHTML = tmpl;
}