var searchFlag = false;
var skipCheckboxes = false;

function sprintf() {
    var message = sprintf.arguments[0];
    for (var i = 1; i < sprintf.arguments.length; i++) {
        var pos = message.indexOf('%s');
        if (pos < 0)
            break;
        message = message.substring(0, pos) + sprintf.arguments[i] + message.substring(pos + 2);
    }
    return message;
}

function autotooltips()
{
    $('.at,.at-wide').each(function() {
        var o = $(this);
        var encode = !o.hasClass('html');
        title = o.attr('title') ? o.attr('title') : o.attr('tooltip');
        o.attr('tooltip', !encode ? title : htmlspecialchars(title)).attr('title', '');
    })
    $('.at').unbind('mouseover.at').unbind('mouseout.at').bind('mouseover.at', function(e) {
        var o = $(this);
        var t = o.attr('tooltip') || '';
        var sep = o.attr('sep') ? o.attr('sep') : '/';
        var pos = t.indexOf(sep);
        var tokens;
        if (pos != -1)
            tokens = [$.trim(t.substring(0, pos)), $.trim(t.substring(pos + sep.length))];
        else
            tokens = [$.trim(t), ''];
        if (tokens[0] == '' && tokens[1] == '')
            return;
        var offset = o.offset();
        $('#tt').css('display','block').css('left', offset.left + o.width() / 2).css('top', offset.top);
        $('#tt_title').html(tokens[0]);
        $('#tt_body').html(tokens[1] ? tokens[1] : '');
    }).bind('mouseout.at', function() {
        $('#tt').css('display','none');
    });

    $('.at-wide').unbind('mouseover.at-wide').unbind('mouseout.at-wide').bind('mouseover.at-wide', function(e) {
        var o = $(this);
        var t = o.attr('tooltip') || '';
        var sep = o.attr('sep') ? o.attr('sep') : '/';
        var pos = t.indexOf(sep);
        var tokens;
        if (pos)
            tokens = [t.substring(0, pos), t.substring(pos + sep.length)];
        else
            tokens = [t, ''];
        var offset = o.offset();
        $('#tt').css('display','block').css('left', offset.left + o.width() / 2).css('top', offset.top);
        $('#tt_title').html(tokens[0]);
        $('#tt_body').html(tokens[1] ? tokens[1] : '');

        o.attr('tt_width', $('#tooltip-width').css('width'));
        // $('#tooltip-width').css('width','200px');
        $('#tooltip-width').css('height','1px');
        $('.tooltip_content').css('width','230px');
    }).bind('mouseout.at-wide', function() {
        $('#tt').css('display','none');

        $('#tooltip-width').css('width',$(this).attr('tt_width'));
        /* var ttc = parseInt($(this).attr('tt_width')) + 30;
        $('.tooltip_content').css('width',ttc+'px'); */
        $(this).removeAttr('tt_width');
    });
}

function dqr_log(str){
    if (window.console && window.console.log)
        window.console.log(str);
}

function set_locale(locale)
{
    set_cookie('language', locale, 365);
    document.location.reload(false);
}

function param(qs, name)
{
    if (!qs)
        return null;
    var params = qs.split(/[&?]/);
    for (var p in params)
    {
        var tokens = params[p].split('=');
        if (tokens.length == 2 && tokens[0] == name)
            return tokens[1];
    }
    return null;
}

function str_replace(search, replace, subject)
{
    if (typeof(subject) != 'string') {
        return subject;
    }
    return subject.split(search).join(replace);
}

function strpad(s, c, len, before)
{
    s = '' + s;
    if (s.length >= len)
        return s;
    var l = len - s.length;
    for (var i = 0; i < l; i++)
        s = before ? c + s : s + c;
    return s;
}

function convert_utc_date(o)
{
    $(o).html(utc_date(jQuery.trim($(o).html()), $(o).attr('format')));
}

function utc_date(time_t, f) {
    add_zero = function (val){
        return strpad(val, '0', 2, true);
    }
    var d = new Date();
    d.setTime(time_t * 1000 - d.getTimezoneOffset() * 60);
    if (f) {
        var year     = '' + d.getFullYear();
        var month    = d.getMonth();
        var day      = d.getDate();
        var hours    = d.getHours();
        var minutes  = d.getMinutes();
        var seconds  = d.getSeconds();
        var hours_12 = (hours > 12) ? hours - 12 : hours;

        f = f.replace(/%j/, day ).replace(/%d/, add_zero(day) )
            .replace(/%n/, month + 1).replace(/%m/, add_zero(month + 1) )
            .replace(/%y/, year.substr(2,2) ).replace(/%Y/, year)
            .replace(/%G/, hours).replace(/%H/, add_zero(hours) )
            .replace(/%g/, hours_12 ).replace(/%h/, add_zero(hours_12) )
            .replace(/%A/, (hours > 11) ? 'PM' : 'AM' )
            .replace(/%i/, add_zero(minutes) ).replace(/%s/, add_zero(seconds) )
            .replace(/%S/, seconds).replace(/%I/, minutes);
        if(typeof(SHORT_MONTHS) != 'undefined')
            f = f.replace(/%M/, SHORT_MONTHS[month]);
        if(typeof(FULL_MONTHS) != 'undefined')
            f = f.replace(/%F/, FULL_MONTHS[month]);
        if(typeof(SHORT_DAYS) != 'undefined')
            f = f.replace(/%D/, SHORT_DAYS[d.getDay()] );
        if(typeof(FULL_DAYS) != 'undefined')
            f = f.replace(/%l/, FULL_DAYS[d.getDay()] );
        return f;
    }
}

function rect(width, height, max_width, max_height, mm)
{
    if (width <= max_width && height <= max_height)
        return [width, height];

    height *= 1.0;
    width  *= 1.0;
    var k = Math.min(max_width/width, max_height/height);
    var w = Math.min(Math.max(mm ? (width * k).toFixed(1) : Math.floor(width * k), 1), max_width);
    var h = Math.min(Math.max(mm ? (height * k).toFixed(1) : Math.floor(height * k), 1), max_height);
    return [w, h];
}

function set_cookie(name, value, days)
{
    $.cookie(name, value, { expires: days, path: '/', domain: '.darqroom.com'});
    $.cookie(name, value, { expires: days, path: '/', domain: '.darqroom.fr'});
    $.cookie(name, value, { expires: days, path: '/'});
}

function escape(str) {
    return str.replace('"', '&quot;');
}

function htmlspecialchars (string, quote_style) {
    if (!string)
        return '';
    // http://kevin.vanzonneveld.net
    // +   original by: Mirek Slugen
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   bugfixed by: Nathan
    // +   bugfixed by: Arno
    // +    revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // -    depends on: get_html_translation_table
    // *     example 1: htmlspecialchars("<a href='test'>Test</a>", 'ENT_QUOTES');
    // *     returns 1: '&lt;a href=&#039;test&#039;&gt;Test&lt;/a&gt;'

    var histogram = {}, symbol = '', tmp_str = '', i = 0;
    tmp_str = string.toString();

    if (false === (histogram = get_html_translation_table('HTML_SPECIALCHARS', quote_style))) {
        return false;
    }

    for (symbol in histogram) {
        entity = histogram[symbol];
        tmp_str = tmp_str.split(symbol).join(entity);
    }

    return tmp_str;
}

function htmlspecialchars_decode(string, quote_style) {
    // http://kevin.vanzonneveld.net
    // +   original by: Mirek Slugen
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   bugfixed by: Mateusz "loonquawl" Zalega
    // +      input by: ReverseSyntax
    // +      input by: Slawomir Kaniecki
    // +      input by: Scott Cariss
    // +      input by: Francois
    // +   bugfixed by: Onno Marsman
    // +    revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // -    depends on: get_html_translation_table
    // *     example 1: htmlspecialchars_decode("<p>this -&gt; &quot;</p>", 'ENT_NOQUOTES');
    // *     returns 1: '<p>this -> &quot;</p>'

    var histogram = {}, symbol = '', tmp_str = '', i = 0;
    tmp_str = string.toString();

    if (false === (histogram = get_html_translation_table('HTML_SPECIALCHARS', quote_style))) {
        return false;
    }

    for (symbol in histogram) {
        entity = histogram[symbol];
        tmp_str = tmp_str.split(entity).join(symbol);
    }

    return tmp_str;
}

function get_html_translation_table(table, quote_style) {
    // http://kevin.vanzonneveld.net
    // +   original by: Philip Peterson
    // +    revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // %          note: It has been decided that we're not going to add global
    // %          note: dependencies to php.js. Meaning the constants are not
    // %          note: real constants, but strings instead. integers are also supported if someone
    // %          note: chooses to create the constants themselves.
    // %          note: Table from http://www.the-art-of-web.com/html/character-codes/
    // *     example 1: get_html_translation_table('HTML_SPECIALCHARS');
    // *     returns 1: {'"': '&quot;', '&': '&amp;', '<': '&lt;', '>': '&gt;'}

    var entities = {}, histogram = {}, decimal = 0, symbol = '';
    var constMappingTable = {}, constMappingQuoteStyle = {};
    var useTable = {}, useQuoteStyle = {};

    useTable      = (table ? table.toUpperCase() : 'HTML_SPECIALCHARS');
    useQuoteStyle = (quote_style ? quote_style.toUpperCase() : 'ENT_COMPAT');

    // Translate arguments
    constMappingTable[0]      = 'HTML_SPECIALCHARS';
    constMappingTable[1]      = 'HTML_ENTITIES';
    constMappingQuoteStyle[0] = 'ENT_NOQUOTES';
    constMappingQuoteStyle[2] = 'ENT_COMPAT';
    constMappingQuoteStyle[3] = 'ENT_QUOTES';

    // Map numbers to strings for compatibilty with PHP constants
    if (!isNaN(useTable)) {
        useTable = constMappingTable[useTable];
    }
    if (!isNaN(useQuoteStyle)) {
        useQuoteStyle = constMappingQuoteStyle[useQuoteStyle];
    }

    if (useTable == 'HTML_SPECIALCHARS') {
        // ascii decimals for better compatibility
        entities['38'] = '&amp;';
        entities['60'] = '&lt;';
        entities['62'] = '&gt;';
    } else if (useTable == 'HTML_ENTITIES') {
        // ascii decimals for better compatibility
      entities['38'] = '&amp;';
      entities['60'] = '&lt;';
      entities['62'] = '&gt;';
      entities['160'] = '&nbsp;';
      entities['161'] = '&iexcl;';
      entities['162'] = '&cent;';
      entities['163'] = '&pound;';
      entities['164'] = '&curren;';
      entities['165'] = '&yen;';
      entities['166'] = '&brvbar;';
      entities['167'] = '&sect;';
      entities['168'] = '&uml;';
      entities['169'] = '&copy;';
      entities['170'] = '&ordf;';
      entities['171'] = '&laquo;';
      entities['172'] = '&not;';
      entities['173'] = '&shy;';
      entities['174'] = '&reg;';
      entities['175'] = '&macr;';
      entities['176'] = '&deg;';
      entities['177'] = '&plusmn;';
      entities['178'] = '&sup2;';
      entities['179'] = '&sup3;';
      entities['180'] = '&acute;';
      entities['181'] = '&micro;';
      entities['182'] = '&para;';
      entities['183'] = '&middot;';
      entities['184'] = '&cedil;';
      entities['185'] = '&sup1;';
      entities['186'] = '&ordm;';
      entities['187'] = '&raquo;';
      entities['188'] = '&frac14;';
      entities['189'] = '&frac12;';
      entities['190'] = '&frac34;';
      entities['191'] = '&iquest;';
      entities['192'] = '&Agrave;';
      entities['193'] = '&Aacute;';
      entities['194'] = '&Acirc;';
      entities['195'] = '&Atilde;';
      entities['196'] = '&Auml;';
      entities['197'] = '&Aring;';
      entities['198'] = '&AElig;';
      entities['199'] = '&Ccedil;';
      entities['200'] = '&Egrave;';
      entities['201'] = '&Eacute;';
      entities['202'] = '&Ecirc;';
      entities['203'] = '&Euml;';
      entities['204'] = '&Igrave;';
      entities['205'] = '&Iacute;';
      entities['206'] = '&Icirc;';
      entities['207'] = '&Iuml;';
      entities['208'] = '&ETH;';
      entities['209'] = '&Ntilde;';
      entities['210'] = '&Ograve;';
      entities['211'] = '&Oacute;';
      entities['212'] = '&Ocirc;';
      entities['213'] = '&Otilde;';
      entities['214'] = '&Ouml;';
      entities['215'] = '&times;';
      entities['216'] = '&Oslash;';
      entities['217'] = '&Ugrave;';
      entities['218'] = '&Uacute;';
      entities['219'] = '&Ucirc;';
      entities['220'] = '&Uuml;';
      entities['221'] = '&Yacute;';
      entities['222'] = '&THORN;';
      entities['223'] = '&szlig;';
      entities['224'] = '&agrave;';
      entities['225'] = '&aacute;';
      entities['226'] = '&acirc;';
      entities['227'] = '&atilde;';
      entities['228'] = '&auml;';
      entities['229'] = '&aring;';
      entities['230'] = '&aelig;';
      entities['231'] = '&ccedil;';
      entities['232'] = '&egrave;';
      entities['233'] = '&eacute;';
      entities['234'] = '&ecirc;';
      entities['235'] = '&euml;';
      entities['236'] = '&igrave;';
      entities['237'] = '&iacute;';
      entities['238'] = '&icirc;';
      entities['239'] = '&iuml;';
      entities['240'] = '&eth;';
      entities['241'] = '&ntilde;';
      entities['242'] = '&ograve;';
      entities['243'] = '&oacute;';
      entities['244'] = '&ocirc;';
      entities['245'] = '&otilde;';
      entities['246'] = '&ouml;';
      entities['247'] = '&divide;';
      entities['248'] = '&oslash;';
      entities['249'] = '&ugrave;';
      entities['250'] = '&uacute;';
      entities['251'] = '&ucirc;';
      entities['252'] = '&uuml;';
      entities['253'] = '&yacute;';
      entities['254'] = '&thorn;';
      entities['255'] = '&yuml;';
    } else {
        throw Error(RES.common.table+' '+useTable+' '+RES.common.not_supported);
        return false;
    }

    if (useQuoteStyle != 'ENT_NOQUOTES') {
        entities['34'] = '&quot;';
    }

    if (useQuoteStyle == 'ENT_QUOTES') {
        entities['39'] = '&#039;';
    }

    // ascii decimals to real symbols
    for (decimal in entities) {
        symbol = String.fromCharCode(decimal)
        histogram[symbol] = entities[decimal];
    }

    return histogram;
}

function nl2br(str) {
    breakTag = '<br />';
    return (str + '').replace(/([^>]?)\n/g, '$1'+ breakTag +'\n');
}

function br2nl(str, strip_nl) {
    if (!strip_nl) {
        str = (str + '').replace(/([^>]?)\n/g, '$1');
    }
    return (str + '').replace(/<br\s*\/?>/mig,"\n");
}

function domain(user, uri)
{
    if (!uri) 
        uri = '';
    return sprintf($('#domain').val(), user, uri);
}

function host_name()
{
    return $('#host-name').val();
}

function toMoney(o)
{
    return (parseFloat(o) + 0.5e-4).toFixed(2);
}

function stopPropagation(e)
{
    e.stopPropagation();
    e.preventDefault();
    return false;
}

function parseJSON(src)
{
    if (typeof(JSON) == 'object' && JSON.parse)
        return JSON.parse(src);
    return eval("(" + src + ")");
}

lightboxCounter = {
    increase: function(){
        $('#lightbox_size').html($('#lightbox_size').html()*1 + 1 + '');
        if($('#lightbox_size').html()*1 > 0) {
            $('#lightbox_size').parent().parent().addClass('lightbox_full');
        }
        else {
            $('#lightbox_size').parent().parent().removeClass('lightbox_full');
        }
    },

    decrease: function(){
        $('#lightbox_size').html($('#lightbox_size').html()*1 - 1 + '');
        if($('#lightbox_size').html()*1 > 0) {
            $('#lightbox_size').parent().parent().addClass('lightbox_full');
        }
        else {
            $('#lightbox_size').parent().parent().removeClass('lightbox_full');
        }
    }
}

function preventDefault(e)
{
    e.preventDefault();
    e.stopPropagation();
}

$(document).ready(function() {

    if (!skipCheckboxes) $(':checkbox, :radio').checkBox();

    function setUserMenuWidthCheck() {
        if ($('#umenu').css('position') == 'absolute') { // check css for ready
            setUserMenuWidth();
            return;
        }
        setTimeout(setUserMenuWidthCheck, 500);
    }

    function setUserMenuWidth() {
        var ut = $('#umenu-top');
        var u = $('#umenu');
        u.show();
        var _ut_width = ut.outerWidth();
        var _u_width = u.outerWidth();
        if (_ut_width < _u_width) {
            _ut_width = _u_width;
            ut.width(_ut_width - parseInt(ut.css('padding-left')) - parseInt(ut.css('padding-right')));
        }
        u.width(_ut_width - parseInt(u.css('padding-left')) - parseInt(u.css('padding-right')));
        u.hide();
        ut.data('init', true);
    }

    setUserMenuWidthCheck();

    var user_menu_timeout;
    $('.user-menu-box').bind('mouseenter', function(event) {
        var ut = $('#umenu-top');
        if (ut.data('init') != true) {
            return;
        }
        if (!ut.hasClass('act')) {
            $('#umenu').show();
            ut.addClass('act');
        }
        $(document).unbind('click.user_menu');
        clearTimeout(user_menu_timeout);
    });
    $('.user-menu-box').bind('mouseleave', function(event) {
        $(document).one('click.user_menu', function() {
            $('#umenu').hide();
            $('#umenu-top').removeClass('act');
            clearTimeout(user_menu_timeout);
        });
        user_menu_timeout = setTimeout(function() {
            $(document).triggerHandler('click.user_menu');
        }, 2000);
    });


    $('#worldMap').bind('click', function(event)
    {
        event.preventDefault();
        event.stopPropagation();
        $('#langBox').toggleClass('open');
        $('body').bind('click.lc', function(event)
        {
            if (event.target.id != 'langBox')
            {
                $('#langBox').toggleClass('open');
                $('body').unbind('click.lc');
            }
        });
    });

    $('.utc').each(function() {
        convert_utc_date(this);
    });

    $('#searchfield').bind('focus', function() {
        if (!searchFlag) {
            $(this).val('');
            searchFlag = true;
        }
    }).bind('blur', function() {
        if (searchFlag && jQuery.trim($(this).val()).length == 0) {
            $(this).val(RES.searchbox[$('#search_type_list :radio:checked').val() || 'images']);
            searchFlag = false;
        }
        $('#search_type_button span').html($('#search_type_list :radio:checked').parent().parent().find('span').html());
    });

    $('.search-btn-ok').bind('click', function() {
        $('#searchform').submit();
    });

    $('.asf').bind('keypress', function(e) {
        if (e.which == 13) {
            $('#searchform').submit();
            e.preventDefault();
            e.stopPropagation();
        }
    });

    var holder = $('#search-options-holder');
    if (holder.css('display') == 'block') {
        $('#quckSearch').addClass('open');
    }

    $('#search_type_button').bind('click',function(event) {
        $('#search_type_list').css('display', 'block');
        /*
        event.preventDefault();
        event.stopPropagation();

        $(this).toggleClass('act');
        if ($(this).hasClass('act'))
            $('#search_type_list').css('display', 'block');
        else
            $('#search_type_list').css('display', 'none');

        $('body').bind('click.searchlistopen', function(event)
        {
            var cur = $(event.target);
            var cur_tag = $(cur).get(0).tagName;

            while (cur_tag.toUpperCase() !='BODY')
            {
                if (cur.attr('id') == 'search_type_list')
                    return;
                cur = cur.parent();
                var cur_tag = $(cur).get(0).tagName;
            }
            $('#search_type_list').css('display', 'none');
            $('#search_type_button').removeClass('act');
            $('#search_type_list').unbind('click.searchlistopen');
        });
        */
    });

    $('#searchform').attr('action', 'http://' + host_name() + '/search/' + ($('#search_type_list :radio:checked').val() || 'images'));

    $('#search_type_list li').click(function(){
       // var t = $(this).find('span').html();
       //$('#search_type_button span').html(t);
        var mode = $(this).find('input').val();
        $(this).find('input').setCheckBoxVal(true);
        $('#search_type_list').hide();

        $('#searchfield').trigger('focus').trigger('blur');
        $('#searchform').attr('action', '/search/' + mode);
        if ($('#search-options-holder').css('display') == 'block') {
            $('.advanced-search-options').hide();
            $('#advanced-search-' + mode).show();
        }
    });

    $('.btn_search').click(function() {
        $('#searchform').submit();
    });

    $('#quickSearchTip').bind('click', function(e) {
        var mode = $('#search_type_list :radio:checked').val() ||  'images';

        var holder = $('#search-options-holder');
        if (holder.css('display') == 'block') {
            // turn off
            holder.hide();
            $('#quckSearch').removeClass('open');
        }
        else {
            holder.show();
            $('#quckSearch').addClass('open');
            $('.advanced-search-options').hide();
            var options = $('#advanced-search-' + mode);
            if (options.length) {
                options.show();
            } else {
                holder.load('/search/options', null, function() {
                    $('#advanced-search-artwork :checkbox').checkBox();

                    $('.asf').bind('keypress', function(e) {
                        if (e.which == 13) {
                            $('#searchform').submit();
                            e.preventDefault();
                            e.stopPropagation();
                        }
                    });
                    $('.btn_search').unbind('click').bind('click', function() {
                        $('#searchform').submit();
                    });
                    $('#advanced-search-' + mode).show();
                });
            }
        }

        e.preventDefault();
        e.stopPropagation();
    });

    $('#searchform').bind('submit', function() {
        $('#searchfield').trigger('focus');

        var holder = $('#search-options-holder');

        var empty = true;

        if (jQuery.trim($('#searchfield').val()).length > 0)
            empty = false;
        else {
            if (holder.css('display') == 'block') {
                var root = $('#advanced-search-' + ($('#search_type_list :radio:checked').val() || 'images'));
                $(':input', root).each(function() {
                    var o = $(this);
                    var name = o.attr('name');
                    if (name && name.length && name != 'du' && name != 'sdu' && jQuery.trim(o.val()).length != 0) {
                        empty = false;
                    }
                });
            }
        }

        if (empty) {
            $('#searchfield').trigger('blur');
            return false;
        }

        if (holder.css('display') == 'block') {
            var root = $('#advanced-search-' + ($('#search_type_list :radio:checked').val() || 'images'));
            $(':input', root).each(function() {
                var o = $(this);
                if (o.attr('name').length && (o.attr('type') != 'checkbox' || o.attr('checked')) )
                    $('#searchform').append('<input type="hidden" name="' + o.attr('name') + '" value="' + htmlspecialchars(o.val()) + '"/>');
            });
            $('#searchform').append('<input type="hidden" name="a" value="1"/>');
        }
        $(':input[name=search_type]').remove();

        return true;
    });


    $('#subscription-address').keypress(function(e) {
        if (e.which == 13) {
            $('#btn-subscribe-newsletter').click();
            e.preventDefault();
            e.stopPropagation();
        }
    });

    $('#btn-subscribe-newsletter').click(function(e) {
        var v = $('#subscription-address').val();
        if (/\b((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?\b/i.test(v)) {
            $('#subscription-form').submit();
        }
        e.preventDefault();
        e.stopPropagation();
    });
});


