var countrycodes = [
        ['1 - American Samoa', 'American Samoa'],
        ['1 - Anguilla', 'Anguilla'],
        ['1 - Antigua and Barbuda', 'Antigua and Barbuda'],
        ['1 - Bahamas (Commonwealth of the)', 'Bahamas (Commonwealth of the)'],
        ['1 - Barbados', 'Barbados'],
        ['1 - Bermuda', 'Bermuda'],
        ['1 - British Virgin Islands', 'British Virgin Islands'],
        ['1 - Canada', 'Canada'],
        ['1 - Cayman Islands', 'Cayman Islands'],
        ['1 - Dominica (Commonwealth of)', 'Dominica (Commonwealth of)'],
        ['1 - Dominican Republic', 'Dominican Republic'],
        ['1 - Grenada', 'Grenada'],
        ['1 - Guam', 'Guam'],
        ['1 - Jamaica', 'Jamaica'],
        ['1 - Montserrat', 'Montserrat'],
        ['1 - Northern Mariana Islands (Commonwealth of the)',
                'Northern Mariana Islands (Commonwealth of the)'],
        ['1 - Puerto Rico', 'Puerto Rico'],
        ['1 - Saint Kitts and Nevis', 'Saint Kitts and Nevis'],
        ['1 - Saint Lucia', 'Saint Lucia'],
        ['1 - Saint Vincent and the Grenadines',
                'Saint Vincent and the Grenadines'],
        ['1 - Trinidad and Tobago', 'Trinidad and Tobago'],
        ['1 - Turks and Caicos Islands', 'Turks and Caicos Islands'],
        ['1 - United States of America', 'United States of America'],
        ['1 - United States Virgin Islands', 'United States Virgin Islands'],
        ['20 - Egypt (Arab Republic of)', 'Egypt (Arab Republic of)'],
        ['212 - Morocco (Kingdom of)', 'Morocco (Kingdom of)'],
        ['213 - Algeria ', 'Algeria (People\'s Democratic Republic of)'],
        ['216 - Tunisia', 'Tunisia'],
        ['218 - Libya ', 'Libya (Socialist People\'s Libyan Arab Jamahiriya)'],
        ['220 - Gambia (Republic of the)', 'Gambia (Republic of the)'],
        ['221 - Senegal (Republic of)', 'Senegal (Republic of)'],
        ['222 - Mauritania (Islamic Republic of)',
                'Mauritania (Islamic Republic of)'],
        ['223 - Mali (Republic of)', 'Mali (Republic of)'],
        ['224 - Guinea (Republic of)', 'Guinea (Republic of)'],
        ['225 - Côte d\'Ivoire', 'Côte d\'Ivoire (Republic of)'],
        ['226 - Burkina Faso', 'Burkina Faso'],
        ['227 - Niger (Republic of the)', 'Niger (Republic of the)'],
        ['228 - Togolese Republic', 'Togolese Republic'],
        ['229 - Benin (Republic of)', 'Benin (Republic of)'],
        ['230 - Mauritius (Republic of)', 'Mauritius (Republic of)'],
        ['231 - Liberia (Republic of)', 'Liberia (Republic of)'],
        ['232 - Sierra Leone', 'Sierra Leone'],
        ['233 - Ghana', 'Ghana'],
        ['234 - Nigeria (Federal Republic of)', 'Nigeria (Federal Republic of)'],
        ['235 - Chad (Republic of)', 'Chad (Republic of)'],
        ['236 - Central African Republic', 'Central African Republic'],
        ['237 - Cameroon (Republic of)', 'Cameroon (Republic of)'],
        ['238 - Cape Verde (Republic of)', 'Cape Verde (Republic of)'],
        ['239 - Sao Tome and Principe (Democratic Republic of)',
                'Sao Tome and Principe (Democratic Republic of)'],
        ['240 - Equatorial Guinea (Republic of)',
                'Equatorial Guinea (Republic of)'],
        ['241 - Gabonese Republic', 'Gabonese Republic'],
        ['242 - Congo (Republic of the)', 'Congo (Republic of the)'],
        ['243 - Democratic Republic of the Congo',
                'Democratic Republic of the Congo'],
        ['244 - Angola (Republic of)', 'Angola (Republic of)'],
        ['245 - Guinea-Bissau (Republic of)', 'Guinea-Bissau (Republic of)'],
        ['246 - Diego Garcia', 'Diego Garcia'],
        ['247 - Ascension', 'Ascension'],
        ['248 - Seychelles (Republic of)', 'Seychelles (Republic of)'],
        ['249 - Sudan (Republic of the)', 'Sudan (Republic of the)'],
        ['250 - Rwanda (Republic of)', 'Rwanda (Republic of)'],
        ['251 - Ethiopia (Federal Democratic Republic of)',
                'Ethiopia (Federal Democratic Republic of)'],
        ['252 - Somali Democratic Republic', 'Somali Democratic Republic'],
        ['253 - Djibouti (Republic of)', 'Djibouti (Republic of)'],
        ['254 - Kenya (Republic of)', 'Kenya (Republic of)'],
        ['255 - Tanzania (United Republic of)', 'Tanzania (United Republic of)'],
        ['256 - Uganda (Republic of)', 'Uganda (Republic of)'],
        ['257 - Burundi (Republic of)', 'Burundi (Republic of)'],
        ['258 - Mozambique (Republic of)', 'Mozambique (Republic of)'],
        ['259 - Spare code', 'Spare code'],
        ['260 - Zambia (Republic of)', 'Zambia (Republic of)'],
        ['261 - Madagascar (Republic of)', 'Madagascar (Republic of)'],
        ['262 - French Departments and Territories in the Indian Ocean',
                'French Departments and Territories in the Indian Ocean'],
        ['263 - Zimbabwe (Republic of)', 'Zimbabwe (Republic of)'],
        ['264 - Namibia (Republic of)', 'Namibia (Republic of)'],
        ['265 - Malawi', 'Malawi'],
        ['266 - Lesotho (Kingdom of)', 'Lesotho (Kingdom of)'],
        ['267 - Botswana (Republic of)', 'Botswana (Republic of)'],
        ['268 - Swaziland (Kingdom of)', 'Swaziland (Kingdom of)'],
        ['269 - Comoros (Union of the)', 'Comoros (Union of the)'],
        ['269 - Mayotte', 'Mayotte'],
        ['27 - South Africa (Republic of)', 'South Africa (Republic of)'],
        ['290 - Saint Helena', 'Saint Helena'],
        ['290 - Tristan da Cunha', 'Tristan da Cunha'],
        ['291 - Eritrea', 'Eritrea'],
        ['297 - Aruba', 'Aruba'],
        ['298 - Faroe Islands', 'Faroe Islands'],
        ['299 - Greenland (Denmark)', 'Greenland (Denmark)'],
        ['30 - Greece', 'Greece'],
        ['31 - Netherlands (Kingdom of the)', 'Netherlands (Kingdom of the)'],
        ['32 - Belgium', 'Belgium'],
        ['33 - France', 'France'],
        ['34 - Spain', 'Spain'],
        ['350 - Gibraltar', 'Gibraltar'],
        ['351 - Portugal', 'Portugal'],
        ['352 - Luxembourg', 'Luxembourg'],
        ['353 - Ireland', 'Ireland'],
        ['354 - Iceland', 'Iceland'],
        ['355 - Albania (Republic of)', 'Albania (Republic of)'],
        ['356 - Malta', 'Malta'],
        ['357 - Cyprus (Republic of)', 'Cyprus (Republic of)'],
        ['358 - Finland', 'Finland'],
        ['359 - Bulgaria (Republic of)', 'Bulgaria (Republic of)'],
        ['36 - Hungary (Republic of)', 'Hungary (Republic of)'],
        ['370 - Lithuania (Republic of)', 'Lithuania (Republic of)'],
        ['371 - Latvia (Republic of)', 'Latvia (Republic of)'],
        ['372 - Estonia (Republic of)', 'Estonia (Republic of)'],
        ['373 - Moldova (Republic of)', 'Moldova (Republic of)'],
        ['374 - Armenia (Republic of)', 'Armenia (Republic of)'],
        ['375 - Belarus (Republic of)', 'Belarus (Republic of)'],
        ['376 - Andorra (Principality of)', 'Andorra (Principality of)'],
        ['377 - Monaco (Principality of)', 'Monaco (Principality of)'],
        ['378 - San Marino (Republic of)', 'San Marino (Republic of)'],
        ['379 - Vatican City State', 'Vatican City State'],
        ['380 - Ukraine', 'Ukraine'],
        ['381 - Serbia (Republic of)', 'Serbia (Republic of)'],
        ['382 - Montenegro (Republic of)', 'Montenegro (Republic of)'],
        ['385 - Croatia (Republic of)', 'Croatia (Republic of)'],
        ['386 - Slovenia (Republic of)', 'Slovenia (Republic of)'],
        ['387 - Bosnia and Herzegovina', 'Bosnia and Herzegovina'],
        ['388 - Group of countries, shared code',
                'Group of countries, shared code'],
        ['389 - The Former Yugoslav Republic of Macedonia',
                'The Former Yugoslav Republic of Macedonia'],
        ['39 - Italy', 'Italy'],
        ['39 - Vatican City State', 'Vatican City State'],
        ['40 - Romania', 'Romania'],
        ['41 - Switzerland (Confederation of)',
                'Switzerland (Confederation of)'],
        ['420 - Czech Republic', 'Czech Republic'],
        ['421 - Slovak Republic', 'Slovak Republic'],
        ['423 - Liechtenstein (Principality of)',
                'Liechtenstein (Principality of)'],
        ['43 - Austria', 'Austria'],
        ['44 - United Kingdom of Great Britain and Northern Ireland',
                'United Kingdom of Great Britain and Northern Ireland'],
        ['45 - Denmark', 'Denmark'],
        ['46 - Sweden', 'Sweden'],
        ['47 - Norway', 'Norway'],
        ['48 - Poland (Republic of)', 'Poland (Republic of)'],
        ['49 - Germany (Federal Republic of)', 'Germany (Federal Republic of)'],
        ['500 - Falkland Islands (Malvinas)', 'Falkland Islands (Malvinas)'],
        ['501 - Belize', 'Belize'],
        ['502 - Guatemala (Republic of)', 'Guatemala (Republic of)'],
        ['503 - El Salvador (Republic of)', 'El Salvador (Republic of)'],
        ['504 - Honduras (Republic of)', 'Honduras (Republic of)'],
        ['505 - Nicaragua', 'Nicaragua'],
        ['506 - Costa Rica', 'Costa Rica'],
        ['507 - Panama (Republic of)', 'Panama (Republic of)'],
        [
                508,
                'Saint Pierre and Miquelon (Collectivité territoriale de la République française)'],
        ['509 - Haiti (Republic of)', 'Haiti (Republic of)'],
        ['51 - Peru', 'Peru'],
        ['52 - Mexico', 'Mexico'],
        ['53 - Cuba', 'Cuba'],
        ['54 - Argentine Republic', 'Argentine Republic'],
        ['55 - Brazil (Federative Republic of)',
                'Brazil (Federative Republic of)'],
        ['56 - Chile', 'Chile'],
        ['57 - Colombia (Republic of)', 'Colombia (Republic of)'],
        ['58 - Venezuela (Bolivarian Republic of)',
                'Venezuela (Bolivarian Republic of)'],
        ['590 - Guadeloupe (French Department of)',
                'Guadeloupe (French Department of)'],
        ['591 - Bolivia (Republic of)', 'Bolivia (Republic of)'],
        ['592 - Guyana', 'Guyana'],
        ['593 - Ecuador', 'Ecuador'],
        ['594 - French Guiana (French Department of)',
                'French Guiana (French Department of)'],
        ['595 - Paraguay (Republic of)', 'Paraguay (Republic of)'],
        ['596 - Martinique (French Department of)',
                'Martinique (French Department of)'],
        ['597 - Suriname (Republic of)', 'Suriname (Republic of)'],
        ['598 - Uruguay (Eastern Republic of)', 'Uruguay (Eastern Republic of)'],
        ['599 - Netherlands Antilles', 'Netherlands Antilles'],
        ['60 - Malaysia', 'Malaysia'],
        ['61 - Australia', 'Australia'],
        ['62 - Indonesia (Republic of)', 'Indonesia (Republic of)'],
        ['63 - Philippines (Republic of the)', 'Philippines (Republic of the)'],
        ['64 - New Zealand', 'New Zealand'],
        ['65 - Singapore (Republic of)', 'Singapore (Republic of)'],
        ['66 - Thailand', 'Thailand'],
        ['670 - Democratic Republic of Timor-Leste',
                'Democratic Republic of Timor-Leste'],
        ['672 - Australian External Territories',
                'Australian External Territories'],
        ['673 - Brunei Darussalam', 'Brunei Darussalam'],
        ['674 - Nauru (Republic of)', 'Nauru (Republic of)'],
        ['675 - Papua New Guinea', 'Papua New Guinea'],
        ['676 - Tonga (Kingdom of)', 'Tonga (Kingdom of)'],
        ['677 - Solomon Islands', 'Solomon Islands'],
        ['678 - Vanuatu (Republic of)', 'Vanuatu (Republic of)'],
        ['679 - Fiji (Republic of)', 'Fiji (Republic of)'],
        ['680 - Palau (Republic of)', 'Palau (Republic of)'],
        ['681 - Wallis and Futuna ',
                'Wallis and Futuna (Territoire français d\'outre-mer)'],
        ['682 - Cook Islands', 'Cook Islands'],
        ['683 - Niue', 'Niue'],
        ['685 - Samoa (Independent State of)', 'Samoa (Independent State of)'],
        ['686 - Kiribati (Republic of)', 'Kiribati (Republic of)'],
        ['687 - New Caledonia ',
                'New Caledonia (Territoire français d\'outre-mer)'],
        ['688 - Tuvalu', 'Tuvalu'],
        ['689 - French Polynesia ',
                'French Polynesia (Territoire français d\'outre-mer)'],
        ['690 - Tokelau', 'Tokelau'],
        ['691 - Micronesia (Federated States of)',
                'Micronesia (Federated States of)'],
        ['692 - Marshall Islands (Republic of the)',
                'Marshall Islands (Republic of the)'],
        ['7 - Kazakhstan (Republic of)', 'Kazakhstan (Republic of)'],
        ['7 - Russian Federation', 'Russian Federation'],
        ['800 - International Freephone Service',
                'International Freephone Service'],
        ['808 - International Shared Cost Service (ISCS)',
                'International Shared Cost Service (ISCS)'],
        ['81 - Japan', 'Japan'],
        ['82 - Korea (Republic of)', 'Korea (Republic of)'],
        ['84 - Viet Nam (Socialist Republic of)',
                'Viet Nam (Socialist Republic of)'],
        ['850 - Democratic People\'s of Korea',
                'Democratic People\'s Republic of Korea'],
        ['852 - Hong Kong, China', 'Hong Kong, China'],
        ['853 - Macao, China', 'Macao, China'],
        ['855 - Cambodia (Kingdom of)', 'Cambodia (Kingdom of)'],
        ['856 - Lao People\s Democratic Republic',
                'Lao People\'s Democratic Republic'],
        ['86 - China (Peoples Republic of', 'China (People\'s Republic of)'],
        ['880 - Bangladesh (People\'s Republic of',
                'Bangladesh (People\'s Republic of)'],
        ['886 - Taiwan, China', 'Taiwan, China'],
        ['888 - Telecommunications for Disaster Relief (TDR)',
                'Telecommunications for Disaster Relief (TDR)'],
        ['90 - Turkey', 'Turkey'],
        ['91 - India (Republic of)', 'India (Republic of)'],
        ['92 - Pakistan (Islamic Republic of)',
                'Pakistan (Islamic Republic of)'],
        ['93 - Afghanistan', 'Afghanistan'],
        ['94 - Sri Lanka (Democratic Socialist Republic of)',
                'Sri Lanka (Democratic Socialist Republic of)'],
        ['95 - Myanmar (Union of)', 'Myanmar (Union of)'],
        ['960 - Maldives (Republic of)', 'Maldives (Republic of)'],
        ['961 - Lebanon', 'Lebanon'],
        ['962 - Jordan (Hashemite Kingdom of)', 'Jordan (Hashemite Kingdom of)'],
        ['963 - Syrian Arab Republic', 'Syrian Arab Republic'],
        ['964 - Iraq (Republic of)', 'Iraq (Republic of)'],
        ['965 - Kuwait (State of)', 'Kuwait (State of)'],
        ['966 - Saudi Arabia (Kingdom of)', 'Saudi Arabia (Kingdom of)'],
        ['967 - Yemen (Republic of)', 'Yemen (Republic of)'],
        ['968 - Oman (Sultanate of)', 'Oman (Sultanate of)'],
        ['971 - United Arab Emirates', 'United Arab Emirates'],
        ['972 - Israel (State of)', 'Israel (State of)'],
        ['973 - Bahrain (Kingdom of)', 'Bahrain (Kingdom of)'],
        ['974 - Qatar (State of)', 'Qatar (State of)'],
        ['975 - Bhutan (Kingdom of)', 'Bhutan (Kingdom of)'],
        ['976 - Mongolia', 'Mongolia'], ['977 - Nepal', 'Nepal'],
        ['98 - Iran (Islamic Republic of)', 'Iran (Islamic Republic of)'],
        ['992 - Tajikistan (Republic of)', 'Tajikistan (Republic of)'],
        ['993 - Turkmenistan', 'Turkmenistan'],
        ['994 - Azerbaijani Republic', 'Azerbaijani Republic'],
        ['995 - Georgia', 'Georgia'],
        ['996 - Kyrgyz Republic', 'Kyrgyz Republic'],
        ['998 - Uzbekistan (Republic of)', 'Uzbekistan (Republic of)']]

Ext.onReady(function() {

    Ext.QuickTips.init();

    // turn on validation errors beside the field globally
    Ext.form.Field.prototype.msgTarget = 'side';

    var top = new Ext.FormPanel({
        labelAlign : 'top',
        frame : true,
        title : 'Enquiry Details',
        bodyStyle : 'padding:5px 5px 0',
        width : 450,
        monitorValid : true,
        url : "contact.php",

        items : [{
                    layout : 'column',
                    items : [{
                                columnWidth : .5,
                                layout : 'form',
                                items : [{
                                            xtype : 'textfield',
                                            fieldLabel : 'First Name',
                                            name : 'first',
                                            allowBlank : false,
                                            anchor : '90%',
                                            tabIndex : 1
                                        }, {
                                            xtype : 'textfield',
                                            fieldLabel : 'Company',
                                            name : 'company',
                                            allowBlank : false,
                                            anchor : '90%',
                                            tabIndex : 3
                                        }, {
                                            xtype : 'combo',
                                            store : countrycodes,
                                            typeAhead : true,
                                            mode : 'local',
                                            hiddenName : 'countrycode',
                                            forceSelection : true,
                                            triggerAction : 'all',
                                            selectOnFocus : true,
                                            fieldLabel : 'Tel: (country code)',
                                            allowBlank : false,
                                            anchor : '90%',
                                            tabIndex : 5
                                        }]
                            }, {
                                columnWidth : .5,
                                layout : 'form',
                                items : [{
                                            xtype : 'textfield',
                                            fieldLabel : 'Last Name',
                                            name : 'last',
                                            allowBlank : false,
                                            anchor : '90%',
                                            tabIndex : 2
                                        }, {
                                            xtype : 'textfield',
                                            fieldLabel : 'Email',
                                            name : 'email',
                                            allowBlank : false,
                                            vtype : 'email',
                                            anchor : '90%',
                                            tabIndex : 4
                                        }, {
                                            xtype : 'numberfield',
                                            fieldLabel : 'Tel (number)',
                                            name : 'telephone',
                                            allowBlank : false,
                                            anchor : '90%',
                                            tabIndex : 6
                                        }]
                            }]
                }, {
                    xtype : 'textfield',
                    fieldLabel : 'Requirements',
                    allowBlank : false,
                    height : 150,
                    name : 'comment',
                    anchor : '95%',
                    tabIndex : 7
                }],

        buttons : [{
            text : 'Submit',
            formBind : true,
            handler : function() {
                top.getForm().submit({
                    params : {
                        ip : ip
                    },
                    success : function(form, action) {
                        Ext.MessageBox
                                .alert(
                                        "Thank You",
                                        "Your enquiry was submitted and we will contact you shortly",
                                        function() {
                                            window.location = "index.php"
                                        })
                    },
                    failure : function(form, action) {
                        switch (action.failureType) {
                            case Ext.form.Action.CLIENT_INVALID :
                                Ext.Msg
                                        .alert("Failure",
                                                "Form fields may not be submitted with invalid values");
                                break;
                            case Ext.form.Action.CONNECT_FAILURE :
                                Ext.Msg.alert("Failure",
                                        "Ajax communication failed");
                                break;
                            case Ext.form.Action.SERVER_INVALID :
                                Ext.Msg.alert("Failure", action.result.msg);
                        }
                    }
                });
            }
        }]
    });

    top.render('inputform');

})