var debug = false;
if(debug) alert("initialize.js\nDebug mode on");


//**************************************************
// initialize()
//**************************************************
function initialize()
{
	if(debug) alert("initialize()");

	buildCountry(); //calls loadCountry()
//	buildState(); //calls loadState()
//	buildIndustry(); //calls loadIndustry()
//	buildSubIndustry();	//calls loadSubIndustry() and buildSize() and buildDepartment() and buildProductInterestType()

	//Enable the Post Process function
	field=document._mktf._POST;
	field.value="T";
	
	//turn debug off
	if(debug) alert("postprocess.js\nTurning Debug mode off...");
	var debug = false;
	
}


//**************************************************
// buildCountry() - To create the Country dropdown
//**************************************************
function buildCountry()
{
	if(debug) alert("buildCountry()");

	var HTML = "";

	//Countries
	var countryArray = new Array(
		"Afghanistan", "Albania", "Algeria", "Andorra", "Angola", "Antigua and Barbuda", "Argentina", "Armenia", "Australia", "Austria", "Azerbaijan", 
		"Bahamas", "Bahrain", "Bangladesh", "Barbados", "Belarus", "Belgium", "Belize", "Benin", "Bermuda", "Bhutan", "Bolivia", "Bosnia and Herzegovina", "Botswana", "Brazil", "Brunei Darussalam", "Bulgaria", "Burkina Faso", "Burma", "Burundi", 
		"Cambodia", "Cameroon", "Canada", "Cape Verde", "Central African Republic", "Chad", "Chile", "China", "Colombia", "Comoros", "Congo", "Costa Rica", "Côte d'Ivoire", "Croatia", "Cuba", "Cyprus", "Czech Republic", 
		"Denmark", "Djibouti", "Dominica", "Dominican Republic", 
		"Ecuador", "Egypt", "El Salvador", "Equatorial Guinea", "Eritrea", "Estonia", "Ethiopia", 
		"Fiji", "Finland", "France", 
		"Gabon", "Gambia", "Georgia", "Germany", "Ghana", "Greece", "Grenada", "Guatemala", "Guinea", "Guinea-Bissau", "Guyana", 
		"Haiti", "Honduras", "Hong Kong, SAR", "Hungary", 
		"Iceland", "India", "Indonesia", "Iran", "Iraq", "Ireland", "Israel", "Italy", 
		"Jamaica", "Japan", "Jordan", 
		"Kazakhstan", "Kenya", "Kiribati", "Korea,  North", "Korea,  South", "Kuwait", "Kyrgystan", 
		"Laos", "Latvia", "Lebanon", "Lesotho", "Liberia", "Libya", "Liechtenstein", "Lithuania", "Luxembourg", 
		"Macedonia", "Madagascar", "Malawi", "Malaysia", "Maldives", "Mali", "Malta", "Marshall Islands", "Mauritania", "Mauritius", "Mexico", "Micronesia", "Moldova", "Monaco", "Mongolia", "Morocco", "Mozambique", "Myanmar", 
		"Namibia", "Nauru", "Nepal", "Netherlands", "Netherlands Antilles", "New Zealand", "Nicaragua", "Niger", "Nigeria", "Norway", 
		"Oman", 
		"Pakistan", "Palau", "Panama", "Papua New Guinea", "Paraguay", "Peru", "Philippines", "Poland", "Portugal", "Puerto Rico", 
		"Qatar", 
		"Republic of Moldova", "Romania", "Russia Federation", "Rwanda", 
		"Saint Kitts and Nevis", "Saint Lucia", "Saint Vincent and the Grenadines", "Samoa", "San Marino", "São Tomé and Príncipe", "Saudi Arabia", "Senegal", "Serbia and Montenegro", "Seychelles", "Sierra Leone", "Singapore", "Slovakia", "Slovenia", "Solomon Islands", "Somalia", "South Africa", "Spain", "Sri Lanka", "Sudan", "Suriname", "Swaziland", "Sweden", "Switzerland", "Syria", 
		"Taiwan", "Tajikistan", "Tanzania", "Thailand", "Timor-Leste", "Togo", "Tonga", "Trinidad and Tobago", "Tunisia", "Turkey", "Turkmenistan", "Tuvalu", 
		"Uganda", "Ukraine", "United Arab Emirates", "United Kingdom", "United States of America", "Uruguay", "Uzbekistan", 
		"Vanuatu", "Venezuela", "Viet Nam", 
		"Yemen", 
		"Zambia", "Zimbabwe"
		
	);
	
	HTML = "<SELECT NAME='M1_Country'>";
	HTML += "<option value=''>-Please Select One-</option>";
	for(i = 0; i < countryArray.length; i++)
	{
		HTML += "<option value='" + countryArray[i] + "'>" + countryArray[i] + "</option>";
	}
	HTML += "</SELECT>";

	document.getElementById("country").innerHTML = HTML;
	
	//document.all.country.innerHTML = HTML;  << old code, only for IE
	
	loadCountry();
}


//**************************************************
// loadCountry() - Load values from hidden fields
//**************************************************
function loadCountry()
{
	if(debug) alert("loadCountry()");
	
	var m1_cnt = document._mktf.COUNTRY.value;

	if(debug) alert("document._mktf.COUNTRY.value =" + m1_cnt);

	if (m1_cnt  != "")
	{
		for (var i = 0; i < document._mktf.M1_Country.length; i++)
		{

			if(debug) alert("document._mktf.M1_Country.options[i].value = " + document._mktf.M1_Country.options[i].value + " and m1_cnt = " + m1_cnt);
			if (document._mktf.M1_Country.options[i].value == m1_cnt)
			{
				if(debug) alert("match found!");

				document._mktf.M1_Country.selectedIndex = i;
				
				if(debug) alert("document._mktf.M1_Country.selectedIndex = " + document._mktf.M1_Country.selectedIndex);

				break;
			}
		}
	}
}
