var countrycode = new Array();
countrycode['AF'] = 93;
countrycode['AL'] = 355;
countrycode['DZ'] = 213;
countrycode['AS'] = 684;
countrycode['AD'] = 376;
countrycode['AO'] = 244;
countrycode['AI'] = 1;
countrycode['AQ'] = 672;
countrycode['AG'] = 672;
countrycode['AR'] = 54;
countrycode['AM'] = 374;
countrycode['AW'] = 297;
countrycode['AU'] = 61;
countrycode['AT'] = 43;
countrycode['AZ'] = 994;
countrycode['BS'] = 242;
countrycode['BH'] = 973;
countrycode['BD'] = 880;
countrycode['BB'] = 246;
countrycode['BY'] = 375;
countrycode['BE'] = 32;
countrycode['BZ'] = 501;
countrycode['BJ'] = 229;
countrycode['BM'] = 441;
countrycode['BT'] = 975;
countrycode['BO'] = 591;
countrycode['BA'] = 387;
countrycode['BW'] = 267;
countrycode['BV'] = 267;
countrycode['BR'] = 55;
countrycode['IO'] = 246;
countrycode['BN'] = 246;
countrycode['BG'] = 359;
countrycode['BF'] = 226;
countrycode['BI'] = 257;
countrycode['KH'] = 855;
countrycode['CM'] = 237;
countrycode['CA'] = 1;
countrycode['CV'] = 238;
countrycode['KY'] = 809;
countrycode['CF'] = 236;
countrycode['TD'] = 235;
countrycode['CL'] = 56;
countrycode['CN'] = 86;
countrycode['CX'] = 61;
countrycode['CC'] = 61;
countrycode['CO'] = 57;
countrycode['KM'] = 269;
countrycode['CG'] = 242;
countrycode['CD'] = 243;
countrycode['CK'] = 682;
countrycode['CR'] = 506;
countrycode['CI'] = 225;
countrycode['HR'] = 385;
countrycode['CU'] = 53;
countrycode['CY'] = 357;
countrycode['CZ'] = 420;
countrycode['DK'] = 45;
countrycode['DJ'] = 253;
countrycode['DM'] = 1;
countrycode['DO'] = 809;
countrycode['TP'] = 670;
countrycode['EC'] = 593;
countrycode['EG'] = 20;
countrycode['SV'] = 503;
countrycode['GQ'] = 240;
countrycode['ER'] = 291;
countrycode['EE'] = 372;
countrycode['ET'] = 251;
countrycode['FK'] = 500;
countrycode['FO'] = 298;
countrycode['FJ'] = 679;
countrycode['FI'] = 358;
countrycode['FR'] = 33;
countrycode['GF'] = 594;
countrycode['PF'] = 689;
countrycode['TF'] = 33;
countrycode['GA'] = 241;
countrycode['GM'] = 220;
countrycode['GE'] = 995;
countrycode['DE'] = 49;
countrycode['GH'] = 233;
countrycode['GI'] = 350;
countrycode['GR'] = 30;
countrycode['GL'] = 299;
countrycode['GD'] = 809;
countrycode['GP'] = 590;
countrycode['GU'] = 671;
countrycode['GT'] = 502;
countrycode['GN'] = 224;
countrycode['GW'] = 245;
countrycode['GY'] = 592;
countrycode['HT'] = 509;
countrycode['HM'] = 61;
countrycode['VA'] = 39;
countrycode['HN'] = 504;
countrycode['HK'] = 852;
countrycode['HU'] = 36;
countrycode['IS'] = 354;
countrycode['IN'] = 91;
countrycode['ID'] = 62;
countrycode['IR'] = 98;
countrycode['IQ'] = 964;
countrycode['IE'] = 353;
countrycode['IL'] = 972;
countrycode['IT'] = 39;
countrycode['JM'] = 1;
countrycode['JP'] = 81;
countrycode['JO'] = 962;
countrycode['KZ'] = 7;
countrycode['KE'] = 254;
countrycode['KI'] = 686;
countrycode['KP'] = 850;
countrycode['KR'] = 82;
countrycode['KW'] = 965;
countrycode['KG'] = 996;
countrycode['LA'] = 856;
countrycode['LV'] = 371;
countrycode['LB'] = 961;
countrycode['LS'] = 266;
countrycode['LR'] = 231;
countrycode['LY'] = 218;
countrycode['LI'] = 41;
countrycode['LT'] = 370;
countrycode['LU'] = 352;
countrycode['MO'] = 853;
countrycode['MK'] = 389;
countrycode['MG'] = 261;
countrycode['MW'] = 265;
countrycode['MY'] = 60;
countrycode['MV'] = 960;
countrycode['ML'] = 223;
countrycode['MT'] = 356;
countrycode['MH'] = 692;
countrycode['MQ'] = 596;
countrycode['MR'] = 222;
countrycode['MU'] = 230;
countrycode['YT'] = 269;
countrycode['MX'] = 52;
countrycode['FM'] = 691;
countrycode['MD'] = 373;
countrycode['MC'] = 377;
countrycode['MN'] = 976;
countrycode['MS'] = 809;
countrycode['MA'] = 212;
countrycode['MZ'] = 258;
countrycode['MM'] = 95;
countrycode['NA'] = 264;
countrycode['NR'] = 674;
countrycode['NP'] = 977;
countrycode['NL'] = 31;
countrycode['AN'] = 599;
countrycode['NC'] = 687;
countrycode['NZ'] = 64;
countrycode['NI'] = 505;
countrycode['NE'] = 227;
countrycode['NG'] = 234;
countrycode['NU'] = 683;
countrycode['NF'] = 672;
countrycode['MP'] = 670;
countrycode['NO'] = 47;
countrycode['OM'] = 968;
countrycode['PK'] = 92;
countrycode['PW'] = 680;
countrycode['PS'] = 970;
countrycode['PA'] = 507;
countrycode['PG'] = 675;
countrycode['PY'] = 595;
countrycode['PE'] = 51;
countrycode['PH'] = 63;
countrycode['PN'] = 872;
countrycode['PL'] = 48;
countrycode['PT'] = 351;
countrycode['PR'] = 1;
countrycode['QA'] = 974;
countrycode['RE'] = 262;
countrycode['RO'] = 40;
countrycode['RU'] = 7;
countrycode['RW'] = 250;
countrycode['SH'] = 290;
countrycode['KN'] = 1;
countrycode['LC'] = 1;
countrycode['PM'] = 508;
countrycode['VC'] = 1;
countrycode['WS'] = 685;
countrycode['SM'] = 378;
countrycode['ST'] = 239;
countrycode['SA'] = 966;
countrycode['SN'] = 221;
countrycode['CS'] = 381;
countrycode['SC'] = 248;
countrycode['SL'] = 232;
countrycode['SG'] = 65;
countrycode['SK'] = 421;
countrycode['SI'] = 386;
countrycode['SB'] = 677;
countrycode['SO'] = 252;
countrycode['ZA'] = 27;
countrycode['GS'] = 995;
countrycode['ES'] = 34;
countrycode['LK'] = 94;
countrycode['SD'] = 249;
countrycode['SR'] = 597;
countrycode['SJ'] = 79;
countrycode['SZ'] = 268;
countrycode['SE'] = 46;
countrycode['CH'] = 41;
countrycode['SY'] = 963;
countrycode['TW'] = 886;
countrycode['TJ'] = 7;
countrycode['TZ'] = 255;
countrycode['TH'] = 66;
countrycode['TG'] = 228;
countrycode['TK'] = 690;
countrycode['TO'] = 676;
countrycode['TT'] = 868;
countrycode['TN'] = 216;
countrycode['TR'] = 90;
countrycode['TM'] = 993;
countrycode['TC'] = 1;
countrycode['TV'] = 688;
countrycode['UG'] = 256;
countrycode['UA'] = 380;
countrycode['AE'] = 971;
countrycode['GB'] = 44;
countrycode['US'] = 1;
countrycode['UM'] = 1;
countrycode['UY'] = 598;
countrycode['UZ'] = 7;
countrycode['VU'] = 678;
countrycode['VE'] = 58;
countrycode['VN'] = 84;
countrycode['VG'] = 1;
countrycode['VI'] = 1;
countrycode['WF'] = 681;
countrycode['EH'] = 212;
countrycode['YE'] = 969;
countrycode['YU'] = 381;
countrycode['ZM'] = 260;
countrycode['ZW'] = 263;

function getCCNumber(cc)
{
  if (countrycode[cc]) {document.eoiform.phone1.value = countrycode[cc];}
}
function cleanNumericField(field) {
  field.value = field.value.replace(/[^0-9]/g,'');
}

var currErrorDiv = null;
function highlightErrorDiv (div)
{
  // unhighlight any current wrong fields
  if (currErrorDiv != null) {
    currErrorDiv.className = "";
  }
  // highlight this field and give it focus
  currErrorDiv = document.getElementById(div);
  if (currErrorDiv) {
    currErrorDiv.className = "error";
  }
  else {
    currErrorDiv = null;
  }
}


function valform()
{
  var form = document.eoiform;
  if (form.domainname.value == '') {
    highlightErrorDiv('domaindiv');
    form.domainname.focus();
    alert('Please enter a domain name');
    return false;
  }
  if(form.domainname.value.length < 3) {
    highlightErrorDiv('domaindiv');
    form.domainname.focus();
    alert('Domain Name must be at least 3 characters long, contain only letters, digits, hyphens and not start or end with a hyphen.')
    return false;
  }
  var first=form.domainname.value.charAt(0);
  var length=form.domainname.value.length;
  var l=length-1;
  var last=form.domainname.value.charAt(l);
  if(!first.match(/^[0-9A-Za-z]$/) || !last.match(/^[0-9A-Za-z]$/)) {
    highlightErrorDiv('domaindiv');
    form.domainname.focus();
    alert('Domain names must start or end with alpha/numeric characters');
    return false;
  }
  if(!form.domainname.value.match(/^(.*)\.([a-z]{2,4}$|\.[a-z]{2,4}\.[a-z]{2,4}$)/)) {
    highlightErrorDiv('domaindiv');
    form.domainname.focus();
    alert('Please enter a valid Domain name');
    return false;
  }
  if (form.firstname.value == '') {
    highlightErrorDiv('namediv');
    form.firstname.focus();
    alert('Please enter your full name');
    return false;
  }
  if (form.companyname.value == '') {
    highlightErrorDiv('companydiv');
    form.firstname.focus();
    alert('Please enter your company name');
    return false;
  }
  if (form.country.value == '') {
    highlightErrorDiv('countrydiv');
    form.country.focus();
    alert('Please select your country');
    return false;
  }
  if (form.phone1.value == '') {
    highlightErrorDiv('phonediv');
    form.phone1.focus();
    alert('Please enter your phone country code number');
    return false;
  }
  if (form.phone1.value != countrycode[form.country.value]) {
    highlightErrorDiv('phonediv');
    form.phone1.focus();
    alert('Your Phone Country Code should be ' + countrycode[form.country.value]);
    return false;
  }
  if (form.phone2.value == '') {
    highlightErrorDiv('phonediv');
    form.phone2.focus();
    alert('Please enter your Phone Number');
    return false;
  }
  if (form.phone2a.value == '') {
    alert('Please enter your Phone Number Area Code');
    return false;
  }
  if (form.email.value == '') {
    highlightErrorDiv('emaildiv');
    form.email.focus();
    alert('Please enter your email address');
    return false;
  }
  if (!form.email.value.match(/^[0-9A-Za-z]([-_.]?[0-9A-Za-z])*@[0-9a-z]([-.]?[0-9a-z])*\.[a-z]{2,4}$/)) {
    highlightErrorDiv('emaildiv');
    form.email.focus();
    alert('Please enter a valid email address');
    return false;
  }
  form.SubmitButton.value = 'Please Wait';
  form.SubmitButton.disabled = 'true';
  return true;
}
