function encode(v) {
    return typeof encodeURIComponent == "function" ?
        encodeURIComponent(v) : escape(v);
}

function appendArg(k, v) {
    req_url = req_url.concat("&" + k + "=" + v);
}

function appendEncodedArg(k, v) {
    appendArg(k, encode(v));
}

function sendAdRequest() {
    appendEncodedArg("req", document.location);
    appendArg("codeid", youdao_codeid);
    if (typeof(youdao_bgc) != "undefined") {
        appendEncodedArg("bgc", youdao_bgc);
    }
    if (typeof(youdao_tc) != "undefined") {
        appendEncodedArg("tc", youdao_tc);
    }
    if (typeof(youdao_dc) != "undefined") {
        appendEncodedArg("dc", youdao_dc);
    }
    if (typeof(youdao_uc) != "undefined") {
        appendEncodedArg("uc", youdao_uc);
    }

    var text = '<div style=display:none>-</div><iframe align="center,center"';
    if (typeof(youdao_width) != "undefined") {
    	appendEncodedArg("width", youdao_width);
        text += ' width=' + youdao_width;
    }
    if (typeof(youdao_height) != "undefined") {
    	appendEncodedArg("height", youdao_height);
        text += ' height=' + youdao_height;
    }
    req_url = req_url.substring(0, 2000);
    req_url = req_url.replace(/%\w?$/, "");
    text += ' src="http://impservice.union.youdao.com/imp/request.s?' + req_url.slice(1)
        + '" marginwidth=0 marginheight=0 scrolling=no frameborder=0 '
        + 'allowtransparency></iframe>';
    document.write(text);
    req_url = null;
}

var req_url = "";
sendAdRequest();