function ajaxgencounter(code) {
    if (getCookie('source') != null) var source = getCookie('source');
    $.facebox(function() {
        $.get('/reg.php', {
            digi: Math.random(),
            source: source
        },
        function(data) {
            delCookie("source");
            //adwords conv
			adwordsConv();
            code = code.replace(/userid/g, data.id);
            $.facebox('<textarea cols="60" rows="10" onclick="this.focus();this.select()" readonly style="width:588px;">' + code + '</textarea>');
        },
        "json")
    })
}

function getCookie(name) {
    var arr = document.cookie.match(new RegExp("(^| )" + name + "=([^;]*)(;|$)"));
    if (arr != null) return unescape(arr[2]);
    return null;

}
function delCookie(name) {
    var exp = new Date();
    exp.setTime(exp.getTime() - 1);
    var cval = getCookie(name);
    if (cval != null) document.cookie = name + "=" + cval + ";expires=" + exp.toGMTString();
}
function adwordsConv() {
    var ga = document.createElement('IMG');
    ga.src = 'http://www.googleadservices.com/pagead/conversion/1071708137/?label=mCIMCIjXwQIQ6e-D_wM&amp;guid=ON&amp;script=0';
    document.getElementsByTagName("body")[0].appendChild(ga);

}

