var tld_list = {
//"most_popular": {"com":1, "net":1, "org":1},
"most_popular": {"com":1, "net":1, "org":1, "info":1, "biz":1, "co.uk":1, "com.au":1, "us":1, "ca":1, "de":1, "eu":1, "mobi":1, "we.bs":1},
"universal": {"com":1, "net":1, "org":1, "info":1, "biz":1, "name":1, "mobi":1, "asia":1, "we.bs":1},
"country_code": {"us":1, "tv":1, "net.cn":1, "org.cn":1, "cc":1, "cn":1, "me.uk":1, "eu":1, "org.tw":1, "idv.tw":1, "org.uk":1, "ca":1, "com.tw":1, "co.uk":1, "com.cn":1, "com.mx":1, "de":1, "me":1, "in":1, "net.au":1, "net.nz":1, "org.nz":1, "be":1, "jp":1, "nu":1, "tw":1, "se":1, "ws":1, "nl":1, "com.au":1, "co.nz":1, "at":1},
"all":1,
"none":0
};
var searched = '';
var domainCache = {};
var buttons1 = {};
var buttons2 = {};
function back_action() {
$('#domain_owner_details').css('display', 'none');
$('#domain_search').css('display', '');
$('#domain_dialog').dialog('option', 'buttons', buttons1);
//$('#magic_div').text('.');
}
function owner_details() {
if (
($('#registrantfirstname').val() == '' && $('#registrantlastname').val() == '') &&
($('#selected_owner_details').text() != '' || $('#client_firstname').val() != '' || $('#client_lastname').val() != '')
) {
$('#registrantorganizationname').val($('#client_company_name').val());
$('#registrantfirstname').val($('#client_firstname').val());
$('#registrantlastname').val($('#client_lastname').val());
$('#registrantaddress1').val($('#client_address1').val());
$('#registrantaddress2').val($('#client_address2').val());
$('#registrantcity').val($('#client_city').val());
$('#registrantstateprovince').val($('#client_state').val());
$('#registrantstateprovince_us').val($('#client_state_us').val());
$('#registrantpostalcode').val($('#client_zip').val());
$('#registrantcountry').val($('#client_country').val()).change();
$('#registrantemailaddress').val($('#client_email').val());
$('#registrantphone').val($('#client_phone').val());
}
}
// callback used in cancel url
function domainCheck(sld, tld, callback) {
if ($('#tlds-results-table tr').length % 2) var evenClass = '';
else var evenClass = ' even';
if (!$("#" + sld + '_' + tld.replace(/\./g, '_'))[0])
$('#tlds-results-table').append(
'
' +
'| ' +
'' +
' | ' +
'' +
'' +
'' +
' | ' +
' | ' +
'' +
'' +
'' +
' | ' +
'
');
if (domainCache[sld] != undefined && domainCache[sld][tld] != undefined) {
addRow(sld, tld, domainCache[sld][tld]);
} else {
$.get("ajax.php?action=domain_check&sld=" + sld + '&tld=' + tld, function(data) {
if (data['status']) {
if (domainCache[sld] == undefined) domainCache[sld] = {};
domainCache[sld][tld] = data;
addRow(sld, tld, data);
if (callback) callback(sld + '.' + tld);
} else {
var trId = '#' + sld + '_' + tld.replace(/\./g, '_');
$(trId + ' td:eq(1)').html(sld + '.' + tld + ' - ' + data['msg']);
$(trId + ' td.period').removeClass('loading');
}
}, 'json');
}
}
function addRow(sld, tld, data) {
var trId = '#' + sld + '_' + tld.replace(/\./g, '_');
if (!data['status']) {
$(trId + ' td:eq(1)').html(sld + '.' + tld + ' - ' + data['msg']);
$(trId + ' td.period').removeClass('loading');
return;
}
if (data['domain'] == 0) {
$(trId + ' td:first input').css('visibility', 'visible');
$(trId + ' td:eq(1) span').html(register_msg).css('color', 'green');
$(trId + ' td.period').removeClass('loading');
domain_options(sld, tld);
} else if (domainsInfo[tld]['transfer']) {
$(trId + ' td:first input').css('visibility', 'visible');
$(trId + ' td:eq(1) span').html(transfer_msg).css('color', 'red');
$(trId + ' td.period').removeClass('loading');
$(trId + ' td.sum').addClass('transfer-sum');
$(trId + ' td:eq(1)').append('');
if (domainsInfo[tld]['epp'])
$(trId + ' p.epp').html('');
domain_options(sld, tld);
} else {
$(trId + ' td:eq(1)').html(sld + '.' + tld + ' - ' + transfer_not_supported_msg);
$(trId + ' td.period').removeClass('loading');
}
/*
$('input:checkbox:first', $(trId)).click(function(){
if ($(this).css('visibility') == 'hidden') return;
if ($(this).attr('checked'))
$(trId).addClass('selected');
else
$(trId).removeClass('selected');
});
*/
if (searched == sld + '.' + tld)
$('#check_domain_' + searched.replace(/\./g, '\\.')).click().change();
if (domain_search_params.epp != '')
$(trId + ' p.epp input').val(domain_search_params.epp);
if (domain_search_params.idp[tld] == 1)
$(trId + ' p.idp input').click();
}
function domain_period_text(period_months) {
var period_years = parseInt(period_months.replace('period_', '')) / 12;
if (period_years == 1)
return period_years + ' ' + year_msg;
return period_years + ' ' + years_msg;
}
function domain_options(sld, tld) {
var trId = '#' + sld + '_' + tld.replace(/\./g, '_');
var tr = $(trId);
var tldPrice = $(trId + ' span.tld-price');
var periodSelect = $(trId + ' td.period').html('').find('select');
var firstPrice = false;
var price_option = tr.find('input.transfer_domain').size() ? 'prices_transfer' : 'prices_register';
if ('undefined' == typeof registerdomainProducts[tld][price_option])
price_option = 'prices';
for (period in registerdomainProducts[tld][price_option]) {
if (firstPrice === false)
firstPrice = registerdomainProducts[tld][price_option][period][currency];
periodSelect.append('' +
'' +
whois_protect_msg +
'');
$(trId + ' p.tld-price-id-protect').html(sprintf(currency_symbols[currency] + '%0.2f', idpProduct.prices[periodSelect.val()][currency]));
$('p.idp input:checkbox', $(trId)).click(function() {
if ($(this).is(':checked'))
$(trId + ' td.sum p').css('visibility', 'visible');
else
$(trId + ' td.sum p').css('visibility', 'hidden');
});
}
}
function choose_domains() {
var trId, tld, domain, domain_, period, tbl = '';
$('input.register_transfer:checked').each(function(){
domain = $(this).val();
domain_ = domain.replace(/\./g, '_');
if ($('#selected_' + domain_)[0])
remove_selected_domain(domain);
trId = '#' + domain_;
tld = $(trId).attr('tld');
period = $('select.domain_period', $(trId)).val();
action = '' + register_msg + '';
if ($(trId + ' input.transfer_domain')[0]) {
action = '' + transfer_msg + '';
if (domainsInfo[tld]['epp'])
action = action + '';
}
idp_div = '';
idp_price = '';
if ($(trId + ' p.idp input').attr('checked')) {
idp_div = '' + whois_protect_msg + '
';
idp_price = '' + $(trId + ' td.sum p').html() + '
';
}
tbl = tbl + '' +
'| ' +
action + ' ' + domain + '' + idp_div +
' | ' +
'' +
domain_period_text(period) +
'' +
' | ' +
'' +
'' +
$(trId + ' span.tld-price').html() + '' + idp_price +
' | ' +
'' +
' | ' +
(domainProducts[tld] ?
'' +
'' +
' | ' : '') +
'
';
});
if (tbl != '') {
if ($('#selected_domains_table')[0])
$('#selected_domains_table').append(tbl);
else
$('#selected_domains').html('');
$('input.choose_promo:first', $('#selected_domains_table')).click();
$('#change_whois_details_div').css('display', '');
$('#domain_terms').css('display', '');
if ($("input[name^='id_protect']", $('#selected_domains_table')).length > 0)
$('#idp_terms').css('display', '');
}
}
function remove_selected_domain(domain, clear_extra) {
$('#selected_' + domain.replace(/\./g, '_')).remove();
updateTotalPrices();
if (clear_extra && extra_attributes[domain])
delete extra_attributes[domain];
if ($('tr.domain_tr', $('#selected_domains_table')).length == 0) {
$('#change_whois_details_div').css('display', 'none');
$('#domain_terms').css('display', 'none');
$('#idp_terms').css('display', 'none');
}
}
function registrant_owner_details() {
if ($('#selected_owner_details').text() == '' && $('#client_firstname').val() == '' && $('#client_lastname').val() == '') {
var change = false;
if ($('#client_country option:selected').attr('euro') != $('#registrantcountry option:selected').attr('euro'))
change = true;
$('#client_company_name').val($('#registrantorganizationname').val()).attr('validated', 1).css('border', '1px solid green');
$('#client_firstname').val($('#registrantfirstname').val()).attr('validated', 1).css('border', '1px solid green');
$('#client_lastname').val($('#registrantlastname').val()).attr('validated', 1).css('border', '1px solid green');
$('#client_address1').val($('#registrantaddress1').val()).attr('validated', 1).css('border', '1px solid green');
$('#client_address2').val($('#registrantaddress2').val()).attr('validated', 1).css('border', '1px solid green');
$('#client_city').val($('#registrantcity').val()).attr('validated', 1).css('border', '1px solid green');
$('#client_state').val($('#registrantstateprovince').val()).attr('validated', 1).css('border', '1px solid green');
$('#client_state_us').val($('#registrantstateprovince_us').val()).attr('validated', 1).css('border', '1px solid green');
$('#client_zip').val($('#registrantpostalcode').val()).attr('validated', 1).css('border', '1px solid green');
$('#client_country').val($('#registrantcountry').val()).attr('validated', 1).css('border', '1px solid green');
$('#client_email').val($('#registrantemailaddress').val()).attr('validated', 1).css('border', '1px solid green');
$('#client_phone').val($('#registrantphone').val()).attr('validated', 1).css('border', '1px solid green');
select_owner_details();
if (change)
$('#client_country').change();
if ($('#client_country option:selected').attr('euro') == 1)
$('#owner_dialog').dialog('open');
}
}
function validate_extra() {
var ret = true;
$('input:visible,select:visible', $('#extra_holder')).each(function(){
if ($(this).is(':checkbox')) {
if (!$(this).attr('checked')) ret = false;
} else {
if ($(this).val() == '') ret = false;
}
});
return ret;
}
//$(function(){
buttons1[close_msg] = function(){ $(this).dialog('close') };
buttons1[whois_msg] = function(){
if ($('input.register_transfer:checked').length == 0) {
showMsg('error', please_select_domains_msg);
return;
}
$('#domain_search').css('display', 'none');
$('#domain_owner_details').css('display', '');
$(this).dialog('option', 'buttons', buttons2);
//$('#magic_div').text('.');
$('#extra_attributes').empty();
var extra_domains = $('input.register_transfer_extra:checked');
if (extra_domains.length > 0) {
var selected_extra_params = '';
extra_domains.each(function(){
if (extra_attributes[$(this).val()])
selected_extra_params = selected_extra_params + '&' + extra_attributes[$(this).val()];
});
loadSafe($('#extra_attributes'), 'ajax.php?action=extra_attributes&' + extra_domains.serialize() + selected_extra_params);
}
};
buttons2[back_msg] = function(){
back_action();
};
buttons2[proceed_msg] = function(){
var thiz = $(this);
do_proceed = function() {
if (!validate_all($('#whois_form'))) {
//showMsg('error', invalid_whois_details_msg);
return;
}
if (!validate_extra()) {
showMsg('error', invalid_domain_extra_required_params_msg);
return;
}
thiz.dialog('close');
$('form.attributes_form', $('#extra_holder')).each(function(){
extra_attributes[$(this).attr('domain')] = $(this).serialize();
});
choose_domains();
updateTotalPrices();
registrant_owner_details();
$('#submit_whois').click(); //browser form history patch
}
if (validate_count == 0) {
do_proceed();
do_proceed = undefined;
}
};
$('#domain_dialog').dialog('option', 'buttons', buttons1);
$('#sld').focus().change(function() { domainCache = {}; });
$('input.register_transfer').live('change', function(){
if ($(this).css('visibility') == 'hidden')
return;
if ($(this).is(':checked'))
$(this).closest('tr').addClass('selected');
else
$(this).closest('tr').removeClass('selected');
});
$('#domain_search_form').submit(function(){
searched = $.trim($('#sld').val()).toLowerCase().replace(/^www\./, '');
var matches = searched.match(/([a-z0-9-]+)(?:\.([a-z0-9-.]+))?$/);
if (!matches) {
showMsg('error', invalid_domain_msg);
return false;
};
$('#tlds-results-table').empty();
$('#sld').val(matches[0]);
$('input.extensions[value="' + matches[2] + '"]', $(this)).attr('checked', true);
if (matches[2]) domainCheck(matches[1], matches[2]);
$("input.extensions:checked", $(this)).each(function(){
if (!matches[2] || matches[2] != $(this).val()) domainCheck(matches[1], $(this).val());
});
return false;
});
$('#check_multiple').click(function() {
var domains = $('#search_textarea').val().split(/[\r\n\,;]+/);
$('#tlds-results-table').empty();
for (i in domains) {
var matches = $.trim(domains[i]).toLowerCase().replace(/^www\./, '').match(/([a-z0-9-.]+)/);
if (matches) {
if (matches[0].indexOf('.') != -1)
$('input.extensions[value="' + matches[0].substring((matches[0].indexOf('.') + 1)) + '"]').attr('checked', true);
if (domains[i].indexOf('.') != -1) {
domainCheck(matches[0].substring(0,matches[0].indexOf('.')), (matches[0].substring((matches[0].indexOf('.') + 1))));
} else {
$("input.extensions:checked").each(function(){
domainCheck(matches[0], $(this).val());
});
}
}
}
return false;
});
$('#domain_search_form .show_hide_textarea').click(function() {
$('#search_input').toggle();
$('#search_textarea_div').toggle();
return false;
});
$("input[name='extension_type']").click(function(){
var clicked = tld_list[$(this).val()];
if (typeof clicked == 'number') {
$("input.extensions").attr('checked', clicked ? true : false);
} else {
$("input.extensions").each(function(){
if (clicked[$(this).val()] == 1)
$(this).attr('checked', true);
else
$(this).attr('checked', false);
});
}
});
$('#most_popular').click();
$('td.remove_selected_domain').live('click', function(){
var dom = $(this).parent().attr('id').replace('selected_', '').replace(/_/g, '.');
remove_selected_domain(dom, true);
});
$('input.choose_promo').live('click', function(){
choose_promo($(this).val());
$('span.promo_text', $('#selected_domains_table')).css('font-weight', 'normal');
$(this).next().css('font-weight', 'bold');
});
$('#change_whois_details').click(function(){
$('#domain_search').css('display', 'none');
$('#domain_owner_details').css('display', '');
$('#domain_dialog').dialog('option', 'buttons', buttons2);
//$('#magic_div').text('.');
$('#extra_attributes').empty();
var extra_params = '';
for (var dom in extra_attributes)
extra_params += '&domains[]=' + dom + '&' + extra_attributes[dom];
if (extra_params != '')
loadSafe($('#extra_attributes'), 'ajax.php?action=extra_attributes' + extra_params);
$('#domain_dialog').dialog('open');
});
//});