/* jquery/jquery.alphanumeric.pack.js */
eval(function(p,a,c,k,e,d){e=function(c){return(c<a?"":e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('(2($){$.c.f=2(p){p=$.d({g:"!@#$%^&*()+=[]\\\\\\\';,/{}|\\":<>?~`.- ",4:"",9:""},p);7 3.b(2(){5(p.G)p.4+="Q";5(p.w)p.4+="n";s=p.9.z(\'\');x(i=0;i<s.y;i++)5(p.g.h(s[i])!=-1)s[i]="\\\\"+s[i];p.9=s.O(\'|\');6 l=N M(p.9,\'E\');6 a=p.g+p.4;a=a.H(l,\'\');$(3).J(2(e){5(!e.r)k=o.q(e.K);L k=o.q(e.r);5(a.h(k)!=-1)e.j();5(e.u&&k==\'v\')e.j()});$(3).B(\'D\',2(){7 F})})};$.c.I=2(p){6 8="n";8+=8.P();p=$.d({4:8},p);7 3.b(2(){$(3).f(p)})};$.c.t=2(p){6 m="A";p=$.d({4:m},p);7 3.b(2(){$(3).f(p)})}})(C);',53,53,'||function|this|nchars|if|var|return|az|allow|ch|each|fn|extend||alphanumeric|ichars|indexOf||preventDefault||reg|nm|abcdefghijklmnopqrstuvwxyz|String||fromCharCode|charCode||alpha|ctrlKey||allcaps|for|length|split|1234567890|bind|jQuery|contextmenu|gi|false|nocaps|replace|numeric|keypress|which|else|RegExp|new|join|toUpperCase|ABCDEFGHIJKLMNOPQRSTUVWXYZ'.split('|'),0,{}));

$(document).ready(function(){
    var dc = $('#domain_checker'), di = $('#domain_input').val('');
    dc
        .data('tld', $('input[type=checkbox]', dc))
        .data('$results', $('.results', dc))
        ;
    dc.submit(function(e){
        e.preventDefault();
        var $this = $(this), d = {}, message = [];

        d['domain'] = di.val();
        if (!d['domain']) {
            message.push('Nem választott domain nevet!');
        } else {
            d['tlds'] = [];
            $this
                .data('tld')
                .filter(':checked')
                .each(function(){
                    d['tlds'].push('.'+$(this).attr('value'));
                });
            if (d['tlds'].length<=0) {
                message.push('Nem választott domain végződést!');
            } else {
                $this.data('$results').html('<div class="loading" />');
                $.post('/domain/ajax2', d, function(data){
                    var html, x, y, base;
                    if (data != false) {
                        html = '<table><thead><tr><th>Kifejezés</th>';
                        for (x in d['tlds']) {
                            html += '<th>' + d['tlds'][x] + '</th>';
                        }
                        html += '</tr></thead><tbody>';
                        for (x in data[0]) {
                            base = data[0][x];
                            html += '<tr><th>' + x + '</th>';
                            for (y in base) {
                                //http://www.domain.hu/domain/domainsearch/whois.html?domain=mehet.hu&ekes=mehet.hu
                                if (base[y][0]) {
                                    html += '<td class="good">szabad</td>';
                                } else {
                                    html += '<td class="bad">foglalt</td>';
                                }
                            }
                            html += '</tr>';
                        }
                        html += '</tbody></html>';
                        $this.data('$results').html(html);
                    }
                }, 'json');
            }

        }
        if (message.length>0) {
            alert(message.join('\n'));
        }
    });
    di.alphanumeric({allow:"-"}).change(function(){
        var i, $this = $(this), val = $this.val(), s = "!@#$%^&*()+=[]\\\';,/{}|\":<>?~`. ".split('');
        for (i=0; i < s.length; i++) {
            if (val.indexOf(s[i]) != -1) {
                $this.val('');
                break;
            }
        }
    });
});
