var countries=new Array(
'AF','Afghanistan',2,
'AL','Albania',4,
'DZ','Algeria',1,
'AD','Andorra',4,
'AO','Angola',1,
'AG','Antigua & Barbuda',5,
'AR','Argentina',5,
'AM','Armenia',2,
'AU','Australia',3,
'AT','Austria',4,
'AZ','Azerbaijan',2,
'BS','Bahamas',5,
'BH','Bahrain',2,
'BD','Bangladesh',2,
'BB','Barbados',5,
'BY','Belarus',4,
'BE','Belgium',4,
'BZ','Belize',5,
'BJ','Benin',1,
'BT','Bhutan',2,
'BO','Bolivia',5,
'BA','Bosnia & Herzegovina',4,
'BW','Botswana',1,
'BR','Brazil',5,
'BN','Brunei',2,
'BG','Bulgaria',4,
'BF','Burkina Faso',1,
'MM','Burma (Myanmar)',2,
'BI','Burundi',1,
'KH','Cambodia',2,
'CM','Cameroon',1,
'CA','Canada',5,
'CV','Cape Verde',1,
'CF','Central African Republic',1,
'TD','Chad',1,
'CL','Chile',5,
'CN','China',2,
'CO','Colombia',5,
'KM','Comoros',1,
'CG','Congo',1,
'CR','Costa Rica',5,
'HR','Croatia',4,
'CU','Cuba',5,
'CY','Cyprus',4,
'CZ','Czech Republic',4,
'DK','Denmark',4,
'DJ','Djibouti',1,
'DM','Dominica',5,
'DO','Dominican Republic',5,
'TL','East Timor',2,
'EC','Ecuador',5,
'EG','Egypt',1,
'SV','El Salvador',5,
'GQ','Equatorial Guinea',1,
'ER','Eritrea',1,
'EE','Estonia',4,
'ET','Ethiopia',1,
'FJ','Fiji',3,
'FI','Finland',4,
'FR','France',4,
'GA','Gabon',1,
'GM','Gambia',1,
'GE','Georgia',2,
'DE','Germany',4,
'GH','Ghana',1,
'GR','Greece',4,
'GD','Grenada',5,
'GT','Guatemala',5,
'GN','Guinea',1,
'GW','Guinea-Bissau',1,
'GY','Guyana',5,
'HT','Haiti',5,
'HN','Honduras',5,
'HK','Hong Kong',2,
'HU','Hungary',4,
'IS','Iceland',4,
'IN','India',2,
'ID','Indonesia',2,
'IR','Iran',2,
'IQ','Iraq',2,
'IE','Ireland',4,
'IL','Israel',2,
'IT','Italy',4,
'CI','Ivory Coast',1,
'JM','Jamaica',5,
'JP','Japan',2,
'JO','Jordan',2,
'KZ','Kazakhstan',2,
'KE','Kenya',1,
'KI','Kiribati',3,
'KW','Kuwait',2,
'KG','Kyrgyzstan',2,
'LA','Laos',2,
'LV','Latvia',4,
'LB','Lebanon',2,
'LS','Lesotho',1,
'LR','Liberia',1,
'LY','Libya',1,
'LI','Liechtenstein',4,
'LT','Lithuania',4,
'LU','Luxembourg',4,
'MK','Macedonia',4,
'MG','Madagascar',1,
'MW','Malawi',1,
'MY','Malaysia',2,
'MV','Maldives',2,
'ML','Mali',1,
'MT','Malta',4,
'MH','Marshall Islands',3,
'MR','Mauritania',1,
'MU','Mauritius',1,
'MX','Mexico',5,
'FM','Micronesia',3,
'MD','Moldavia',4,
'MC','Monaco',4,
'MN','Mongolia',2,
'MA','Morocco',1,
'MZ','Mozambique',1,
'NA','Namibia',1,
'NR','Nauru',3,
'NP','Nepal',2,
'NL','Netherlands',4,
'NZ','New Zealand',3,
'NI','Nicaragua',5,
'NE','Niger',1,
'NG','Nigeria',1,
'KP','North Korea',2,
'NO','Norway',4,
'OM','Oman',2,
'PK','Pakistan',2,
'PW','Palau',3,
'PA','Panama',5,
'PG','Papua New Guinea',3,
'PY','Paraguay',5,
'E','Peru',5,
'PH','Philippines',2,
'PL','Poland',4,
'PT','Portugal',4,
'PR','Puerto Rico',5,
'QA','Qatar',2,
'RO','Romania',4,
'RU','Russia',4,
'RW','Rwanda',1,
'KN','Saint Kitts-Nevis',5,
'LC','Saint Lucia',5,
'VC','Saint Vincent',5,
'WS','Samoa',3,
'SM','San Marino',4,
'ST','Sao Tomé and Principe',1,
'SA','Saudi Arabia',2,
'SE','Senegal',1,
'CS','Serbia & Montenegro',4,
'SC','Seychelles',1,
'SL','Sierra Leone',1,
'SG','Singapore',2,
'SK','Slovak Republic',4,
'SI','Slovenia',4,
'SB','Solomon Islands',3,
'SO','Somalia',1,
'ZA','South Africa',1,
'KR','South Korea',2,
'ES','Spain',4,
'LK','Sri Lanka',2,
'SD','Sudan',1,
'SR','Suriname',5,
'SZ','Swaziland',1,
'SE','Sweden',4,
'CH','Switzerland',4,
'SY','Syria',2,
'TW','Taiwan',2,
'TJ','Tajikistan',2,
'TZ','Tanzania',1,
'TH','Thailand',2,
'TG','Togo',1,
'TO','Tonga',3,
'TT','Trinidad & Tobago',5,
'TN','Tunisia',1,
'TR','Turkey',4,
'TM','Turkmenistan',2,
'TV','Tuvalu',3,
'UG','Uganda',1,
'UA','Ukraine',4,
'AE','United Arab Emirates',2,
'GB','United Kingdom',4,
'US','United States',5,
'UY','Uruguay',5,
'UZ','Uzbekistan',2,
'VU','Vanuatu',3,
'VA','Vatican State',4,
'VE','Venezuela',5,
'VN','Vietnam',2,
'YE','Yemen',2,
'ZM','Zambia',1,
'ZW','Zimbabwe',1
);

var list = document.form1.country;
var cbox = document.form1.region;
var regTab = [0,1,5,2,4,3];// Justify region codes

function regionCheck(index) {

if (index>0) {
cbox[0].checked = false;

list[0].disabled = true;
list[0].selectedIndex = -1;
list[0].options.length = 0;
list[0].options[ list[0].options.length ] = new Option( '(N/A)' ,0,0 );

} else {
for ( ic=1; ic < list.length; ic++ ) {

cbox[ic].checked = false;
list[ic].disabled = true;

list[ic].selectedIndex = -1;
list[ic].options.length = 0;
list[ic].options[ list[ic].options.length ] = new Option( '(N/A)' ,0,0 );
}
}
}

function fillcountries(index) {

list[index].selectedIndex = -1;
list[index].options.length = 0;
locs = list[index].options;

locs[ locs.length ] = new Option( '(All)' ,0,0 );
for ( lc=0; lc < countries.length; lc += 3 ) {
if (countries[ lc+2 ]==regTab[index] || regTab[index]==0) locs[ locs.length ] = new Option( countries[ lc+1 ], countries[ lc ] );
}
}

function cbToggle(index) {
cbox[index].checked = cbox[index].checked ? false : true;
}

function listEnDisable(index) {
//list[index].disabled = list[index].disabled ? false : true;
list[index].disabled = !cbox[index].checked

if (list[index].disabled) {
list[index].selectedIndex = -1;
list[index].options.length = 0;
list[index].options[ list[index].options.length ] = new Option( '(N/A)' ,0,0 );
}
}

function clickLinkGeo(index) {
cbToggle(index);
listEnDisable(index);
regionCheck(index);

if (!list[index].disabled) {
fillcountries(index)
}
}

function diableothers(index){
	if(index != 0){
	cbox[0].checked = false;
	list[0].disabled = true;	
		}
		
	if(index != 1){
	cbox[1].checked = false;
	list[1].disabled = true;	
		}
	if(index != 2){
	cbox[2].checked = false;
	list[2].disabled = true;	
		}
	if(index != 3){
	cbox[3].checked = false;
	list[3].disabled = true;	
		}
	if(index != 4){
	cbox[4].checked = false;
	list[4].disabled = true;	
		}
	if(index != 5){
	cbox[5].checked = false;
	list[5].disabled = true;	
		}
	listEnDisable(index);
	regionCheck(index);
	if (!list[index].disabled) {
	fillcountries(index)
	}
	
	}

function clickCheckGeo(index) {
listEnDisable(index);
regionCheck(index);

if (!list[index].disabled) {
fillcountries(index)
}
}

function grpDisable(listId, grpId) {
var list = document.getElementById(grpId);
list.disabled = !listId[0].selected;
}

function fillCurrentCountries(index,costr) {

list.selectedIndex = -1;
list.options.length = 0;
locs = list.options;
tc= false;
//alert(index+'-'+costr+'-'+costr.substring(0, 2));
for ( lc=0; lc < countries.length; lc += 3 ) {
if (countries[ lc+2 ]==index || index==0) {
cid = costr.substring(0, 2);
tc = countries[ lc ]==cid  ? true : false;
locs[ locs.length ] = new Option( countries[ lc+1 ], countries[ lc ] + ',' + countries[ lc+1 ],false,tc);
if (tc) {
for ( rt=0; rt < regTab.length; rt++) {
if (regTab[rt]==countries[ lc+2 ]) cbox.selectedIndex=rt;
}
}
}
}
}



function test4(){
var list1 = document.form1.pipe;
var list2 = document.form1.listGrp;
var list3 = document.form1.listGrp2;

if(list1.value == "0"){
list2.disabled = false;
list3.disabled = true;
}
else if(list1.value == "7"){
list2.disabled = true;
list3.disabled = false;
}
else
{
	list2.disabled = true;
	list3.disabled = true;
}


}


function selectContinentFromContry(cid) {
for ( lc=0; lc < countries.length; lc += 3 ) {
if (countries[ lc ]==cid.substring(0,2)) {
for ( rt=0; rt < regTab.length; rt++) {
if (regTab[rt]==countries[ lc+2 ]) cbox.selectedIndex=rt;
}
}
}
}