function checkFields()
{
	frm = document.label;
	for(var i = 0; i < frm.elements.length; i++)
	{
		fieldName   = frm.elements[i].name;
		val			= frm.elements[i].value.toString();
		
		if(val == "")
		{
			switch(fieldName)
			{
				case "booking_n":
					window.alert("Please enter your booking number to proceed.");
					return false;
					break;
				case "ref":
					window.alert("Please enter your ref# number to proceed.");
					return false;
					break;
				
				case "name1":
					window.alert("Consigner Name is empty");
					return false;
					break;
				case "name2":
					window.alert("Consignee Name is empty");
					return false;
					break;
				case "email1":
					window.alert("Consigner Email is empty");
					return false;
					break;
				case "email2":
					window.alert("Consignee Email is empty");
					return false;
					break;
				case "phone1":
					window.alert("Consigner Phone is empty");
					return false;
					break;
				case "phone2":
					window.alert("Consignee Phone is empty");
					return false;
					break;
				case "street1":
					window.alert("Consigner Street is empty");
					return false;
					break;
				case "street2":
					window.alert("Consignee Street is empty");
					return false;
					break;
				case "zip1":
					window.alert("Consigner Zip code is empty");
					return false;
					break;
				case "zip2":
					window.alert("Consignee Zip code is empty");
					return false;
					break;
				case "country1":
					window.alert("Consigner Country is empty");
					return false;
					break;
				case "country2":
					window.alert("Consignee Country is empty");
					return false;
					break;
				case "city1":
					window.alert("Consigner City is empty");
					return false;
					break;
				case "city2":
					window.alert("Consignee City is empty");
					return false;
					break;
			}
		}
		
//		window.alert(frm.elements[i].name);
	}
	return true;
	//window.alert(frm.elements[1].name);
}
function makePreview()
{
	var consigner;
	var consignee;
	var notify_party = "";
	// GETTING FILLED VARIABLES
	gender1		= document.getElementById("gender1").value;
	gender2		= document.getElementById("gender2").value;
	f_d_gender	= document.getElementById("f_d_gender").value;
	name1 		= document.getElementById("name1").value;
	name2 		= document.getElementById("name2").value;
	f_d_name 	= document.getElementById("f_d_name").value;
	email1	 	= document.getElementById("email1").value;
	email2	 	= document.getElementById("email2").value;
	f_d_email 	= document.getElementById("f_d_email").value;
	company1 	= document.getElementById("company1").value;
	company2 	= document.getElementById("company2").value;
	f_d_company	= document.getElementById("f_d_company").value;
	phone1	 	= document.getElementById("phone1").value;
	phone2	 	= document.getElementById("phone2").value;
	f_d_phone 	= document.getElementById("f_d_phone").value;
	city1		= document.getElementById("city1").value;
	city2		= document.getElementById("city2").value;
	f_d_city	= document.getElementById("f_d_city").value;
	street1		= document.getElementById("street1").value;
	street2		= document.getElementById("street2").value;
	f_d_street	= document.getElementById("f_d_street").value;
	state1		= document.getElementById("state1").value;
	zip1		= document.getElementById("zip1").value;
	zip2		= document.getElementById("zip2").value;
	f_d_zip		= document.getElementById("f_d_zip").value;
	country1	= document.getElementById("country1").value;
	country2	= document.getElementById("country2").value;
	f_d_country = document.getElementById("f_d_country").value;
	booking_n	= document.getElementById("booking_n").value;
	ref			= document.getElementById("ref").value;
	// ------------------------
	
	// CONSIGNER
	consigner  = "<b>CONSIGNER CONTACT INFORMATION:</b><br>";
	consigner += gender1 + " " + name1;
	if(email1.toString().length > 0) 	consigner += " (" + email1 + ")";
	if(company1.toString().length > 0)	consigner += "<br>Company: " + company1;
	if(phone1.toString().length > 0)	consigner += "<br>Telephone: " + phone1;
	if(street1.toString().length + state1.toString().length + zip1.toString().length + country1.toString().length + city1.toString().length > 0)
	{
		consigner += "<br>Address:";
		if(city1.toString().length > 0)		consigner += city1
		if(street1.toString().length > 0)	consigner += ", " + street1;
		if(state1.toString().length > 0)	consigner += ", " + state1;
		if(zip1.toString().length > 0)		consigner += ", " + zip1;
		if(country1.toString().length > 0)	consigner += ", " + country1;
	}
	// ---------
	
	// CONSIGNEE
	consignee  = "<b>CONSIGNEE CONTACT INFORMATION</b><br>";
	consignee += gender2 + " " + name2;
	if(email2.toString().length > 0) 	consignee += " (" + email2 + ")";
	if(company2.toString().length > 0)	consignee += "<br>Company: " + company2;
	if(phone2.toString().length > 0)	consignee += "<br>Telephone: " + phone2;
	if(street2.toString().length  + zip2.toString().length + country2.toString().length + city2.toString().length> 0)
	{
		consignee += "<br>Address:";
		if(city2.toString().length > 0)		consigner += city2
		if(street2.toString().length > 0)	consignee += ", " + street2;
		if(zip2.toString().length > 0)		consignee += ", " + zip2;
		if(country2.toString().length > 0)	consignee += ", " + country2;
	}
	// ---------
	
	// SHOW CONSIGNER AND CONSIGNEE
	document.getElementById("consigner_info").innerHTML = consigner;
	document.getElementById("consignee_info").innerHTML = consignee;
	// ----------------------------
	
	// NOTIFY PARTY
	
	if(document.getElementById("dest_details_select").checked)
	{
		notify_party  = "<b>NOTIFY PARTY</b><br>";
		notify_party += f_d_gender + " " + f_d_name;
		if(f_d_email.toString().length > 0) 	notify_party += " (" + f_d_email + ")";
		if(f_d_company.toString().length > 0)	notify_party += "<br>Company: " + f_d_company;
		if(f_d_phone.toString().length > 0)	notify_party += "<br>Telephone: " + f_d_phone;
		if(f_d_street.toString().length  + f_d_zip.toString().length + f_d_country.toString().length + f_d_city.toString().length > 0)
		{
			notify_party += "<br>Address:";
			if(f_d_city.toString().length > 0)		consigner += f_d_city;
			if(f_d_street.toString().length > 0)	notify_party += ", " + f_d_street;
			if(f_d_zip.toString().length > 0)		notify_party += ", " + f_d_zip;
			if(f_d_country.toString().length > 0)	notify_party += ", " + f_d_country;
		}
	}
	document.getElementById("notify_party").innerHTML = notify_party;
	// ------------
	
	// BOOKING Number and REF
	document.getElementById("label_book").innerHTML = "BOOK#" + booking_n;
	document.getElementById("label_ref").innerHTML	= "ref#" + ref;
	// ----------------------
	
}
function clearAll()
{
	document.getElementById("consigner_info").innerHTML = "";
	document.getElementById("consignee_info").innerHTML = "";
	document.getElementById("label_book").innerHTML = "";
	document.getElementById("label_ref").innerHTML	= "[ Please type in the fields below to preview your shipping label ]";
}
