function checkRequired()
{
	var pname = document.form1.pagename.value;
	//var invalidstr = contactinfo();
	var invalidstr = '';
	if (pname == "domesticairfreights") 
	{
		invalidstr =  typeOfShipment();
		invalidstr += loading();
		invalidstr += destination();
		invalidstr += typeOfServiceRequest();
		//invalidstr += deliveryDateRequired();
		invalidstr += descShipment();
	}
	if (pname == 'globallogistics')
	{
		invalidstr =  globalLoading();
		invalidstr += golbalDestination();
		invalidstr += deliveryDateRequired();
		invalidstr += descShipment();	
		invalidstr += descGlobalLogisticsShipment();
		if (hasStorageLocation()) 
		{	
			invalidstr += storageTime();
			invalidstr += storedItemsDimensions();
		}
	}
	
	if (pname == "finearts") 
	{
		invalidstr =  loading();
		invalidstr += destination();
		invalidstr += deliveryDateRequired();
		invalidstr += descShipment();
	}	
	
	if (pname == "warehousings")
	{
		invalidstr = propertiesStoredLocation();
		if (IsWhiteSpace(document.form1.STime.value) == true)
			invalidstr += "Approximate length of time you'll need storage\n";
		invalidstr += itemPackage();
		invalidstr += storedItemsDimensions();			
		invalidstr += warehouseShippingInfo();
	}
	
	if (pname == 'tradeshows')
	{
		invalidstr += tsExhibitInfo();
		invalidstr += loading();		
		invalidstr += destination();
		invalidstr += destinationAdvancedDrayage();		
		invalidstr += deliveryDateRequired();	
		invalidstr += descShipment();
		//invalidstr += storedItemsDimensions();	
	}
	
	if (pname == 'highvalueproducts')
	{
		invalidstr += loading();		
		invalidstr += destination();
		//invalidstr += deliveryDateRequired();	
		invalidstr += descShipment();
		//invalidstr += storedItemsDimensions();		
	}
	
	if (pname == 'mobileexhibits')
	{		
		if (!IsWhiteSpace(document.form1.TSStartDate.value))
			if  (!isValidDate(document.form1.TSStartDate.value))
				invalidstr += 'Desired Tour Start Date (mm/dd/yy)\n';
	}
	
	if (pname == 'corporatemoves')
	{
			invalidstro += moveFrom();
			invalidstr += moveTo();
			invalidstr += miscMoveInfo();	
	}
		
	if (invalidstr != '')
	{
		alert('Please enter a valid\n' + invalidstr)
	}
	else
	{
		document.form1.submit();
	}
}

function destinationAdvancedDrayage()
{
	var strmsg = "";
	
	if (document.form1.DAD[0].checked == false && document.form1.DAD[1].checked == false)
		strmsg += 'Destination Advanced Drayage\n';	
						
	return strmsg;
}

function warehouseShippingInfo()
{
	var strmsg = ""
		
	if (document.form1.shiptoWarehouse[0].checked == false && document.form1.shiptoWarehouse[1].checked == false)
		strmsg += 'Items shipped to warehouse\n';	
	else if (document.form1.shiptoWarehouse[0].checked == true)
	{
		var temp = ""; 
		temp = loading();
		var bValue = twoExtraPickupLocation();
		if (temp.length > 0 && twoExtraPickupLocation() == false)
			strmsg += 'Items Loading From Locations\n';	
	}	
		
	return strmsg;
		
}

function itemPackage()
{
	var strmsg = ""
	
	if (IsWhiteSpace(document.form1.itemPackage.value))
		strmsg += 'How item packaged\n';
		
	return strmsg;
}

function typeOfShipment()
{
	var strmsg = ""
	
	if (document.form1.shipmentType[0].checked == false && document.form1.shipmentType[1].checked == false && document.form1.shipmentType[2].checked == false)
		strmsg += 'Type of Shipment\n';
		
	return strmsg;	
}

function typeOfServiceRequest()
{
	var strmsg = ""
	
	if (document.form1.DAFServices[0].checked == false && document.form1.DAFServices[1].checked == false && document.form1.DAFServices[2].checked == false && document.form1.DAFServices[3].checked == false)
		strmsg += 'Type of Service Requested\n';
		
	return strmsg;	
}

function deliveryDateRequired()
{
	var strmsg = "";
		
	if (isValidDate(document.form1.DDate.value) == false)
		strmsg += 'Delivery Date Required\n';
		
	return strmsg;
}

function tsExhibitInfo()
{
	var strmsg = "";
	
	if (IsWhiteSpace(document.form1.TSName.value))
		strmsg += 'Trade Show Name\n';
				
	//if (isValidDate(document.form1.TSStartDate.value) == false)
		//strmsg += 'Show Start Date\n';			
		
	//if (isValidDate(document.form1.TSEndDate.value)  == false)
		//strmsg += 'Show End Date\n';	
	
	if (IsWhiteSpace(document.form1.TSCity.value))
		strmsg += 'Show Exhibit City\n';		
		
	//if (document.form1.TSState.selectedIndex == 0)
		//strmsg += 'Show Exhibit State\n';	
		
	if (document.form1.TSCountry.selectedIndex == 0)
		strmsg += 'Show Exhibit Country\n';	
		
	if (document.form1.TSCountry.options[document.form1.TSCountry.selectedIndex].value == '207')
		if (document.form1.TSState.selectedIndex == 0)
			strmsg += 'Show Exhibit State\n';		
		
	if (IsWhiteSpace(document.form1.TSBooth.value))
		strmsg += 'Show Booth Size\n';		
		
	if (document.form1.TSExhibit[0].checked == false && document.form1.TSExhibit[1].checked == false && document.form1.TSExhibit[2].checked == false)
		strmsg += 'Show Exhibit is (Crated/Blanket/Wrap)\n';					
		
	return strmsg;
}

function submitform(pagename)	{
	var pname = document.form1.pagename.value;
	var retcontactinfo = '';
	//var retcontactinfo = contactinfo();
	
	if (pname !=  'mobileexhibits' && pname != 'corporatemoves')	{
		var retloading = loading();
		if (pname !=  'warehousings')	{
			var retdestination = destination();
			if (pname ==  'tradeshows')	{
				var rettradeshow = tradeshow();
				if (retcontactinfo != '' || retloading != '' || retdestination 				!= '' || rettradeshow != '')	{
					alert('Please enter a valid\n' + retcontactinfo + 					rettradeshow + retloading + retdestination);
				}
			}
			else	{
				if (retcontactinfo != '' || retloading != '' || retdestination 				!= '' )	{
					alert('Please enter a valid\n' + retcontactinfo + 					retloading + retdestination);
				}
			}
		}
		else	{

			if (retcontactinfo != '' || retloading != '')	{
				alert('Please enter a valid\n' + retcontactinfo + retloading 				);	
			} else
				document.form1.submit();
		}

	}
	else	{
		if (pname == 'corporatemoves')
		{
			retcontactinfo = moveFrom();
			retcontactinfo += moveTo();
			retcontactinfo += miscMoveInfo();	
		}
	
		if (retcontactinfo != '')	{
			alert('Please enter a valid\n' + retcontactinfo);
		}else
		{
			document.form1.submit();
		}
	}
}

function contactchk()
{
	var strmsg = "";
	var fname = document.form1.FName.value;
	var lname = document.form1.LName.value;
	var title = document.form1.Title.value;
	var email = document.form1.Email.value;
	berror = false;

	if ( IsWhiteSpace(fname))
	{
		strmsg += "First Name\n";
		berror = true;
	}
	if ( IsWhiteSpace(lname))
	{
		strmsg += "Last Name\n";
		berror = true;
	}
	if ( IsWhiteSpace(title))
	{
		strmsg += "Title\n";
		berror = true;
	}
	if ( IsWhiteSpace(email))
	{
		strmsg += "Email\n";
		berror = true;
	}
	else
	{
		var bEmailRet = isvalidEmail(email);
		if (bEmailRet == false)
		{
			strmsg += "Email\n";
			berror = true;
		}
	}

	if (document.form1.hasCustomerRep[0].checked == false && document.form1.hasCustomerRep[1].checked == false)
	{
		strmsg += "Legacy account/customer service rep\n";
	} 
	else if (document.form1.hasCustomerRep[0].checked == true && IsWhiteSpace(document.form1.CustomerRep.value))
	{
		strmsg += "your customer rep's name\n";
	}

	if (berror == true)
	{
		alert('Please enter a valid\n' + strmsg);
		return;
	}
	document.form1.Issubmit.value = "yes";
	document.form1.submit();
}

function descShipment()
{
	var strmsg = "";
	var hasDesc = false;
	
	WQty1 = document.form1.WQty1.value;
	WL1 = document.form1.WL1.value;
	WW1 = document.form1.WW1.value;
	WH1 = document.form1.WH1.value;
	WWt1 = document.form1.WWt1.value;	
	hasDesc = isItemDimensionsEmpty(WQty1,WL1,WW1,WH1,WWt1);
	
	if (hasDesc == false)
	{
		WQty2 = document.form1.WQty2.value;
		WL2 = document.form1.WL2.value;
		WW2 = document.form1.WW2.value;
		WH2 = document.form1.WH2.value;
		WWt2 = document.form1.WWt2.value;	
		hasDesc = isItemDimensionsEmpty(WQty2,WL2,WW2,WH2,WWt2);
	}
	
	if (hasDesc == false)
	{
		WQty3 = document.form1.WQty3.value;
		WL3 = document.form1.WL3.value;
		WW3 = document.form1.WW3.value;
		WH3 = document.form1.WH3.value;
		WWt3 = document.form1.WWt3.value;	
		hasDesc = isItemDimensionsEmpty(WQty3,WL3,WW3,WH3,WWt3);
	}
	
	if (hasDesc == false)
	{
		WQty4 = document.form1.WQty4.value;
		WL4 = document.form1.WL4.value;
		WW4 = document.form1.WW4.value;
		WH4 = document.form1.WH4.value;
		WWt4 = document.form1.WWt4.value;	
		hasDesc = isItemDimensionsEmpty(WQty4,WL4,WW4,WH4,WWt4);
	}	
	
	if (hasDesc == false)
	{
		hasDesc = !IsWhiteSpace(document.form1.SMisc.value);
	}
	
	if (hasDesc == false)
		strmsg = "Describe your shipment\n";
		
	return strmsg;
}

function hasStorageLocation() 
{
	var bValue = false;
	if (!IsWhiteSpace(document.form1.SCity.value))
		bValue = true;		
	if ( document.form1.SState.value != 'none' && !IsWhiteSpace(document.form1.SState.value))
		bValue = true;
	return bValue;
}

function storageTime()
{
	var strmsg = "";
	if (IsWhiteSpace(document.form1.STime.value))
		strmsg += "length of time for storage\n";
	return strmsg;
}

function descGlobalLogisticsShipment()
{
	var strmsg = "";
	if (IsWhiteSpace(document.form1.IntEstShipment.value))
		strmsg += "Estimate value of shipment\n";
	return strmsg;
}

function storedItemsDimensions()
{
	var strmsg = "";
	var hasStorage = false;
	
	var SQty = document.form1.SQty1.value;
	var SL = document.form1.SL1.value;
	var SW = document.form1.SW1.value;
	var SH = document.form1.SH1.value;
	var SWt = document.form1.SWt1.value;	
	hasStorage = isItemDimensionsEmpty(SQty,SL,SW,SH,SWt);
	
	if (hasStorage == false)
	{
		SQty = document.form1.SQty2.value;
		SL = document.form1.SL2.value;
		SW = document.form1.SW2.value;
		SH = document.form1.SH2.value;
		SWt = document.form1.SWt2.value;	
		hasStorage = isItemDimensionsEmpty(SQty,SL,SW,SH,SWt);
	}
	
	if (hasStorage == false)
	{
		SQty = document.form1.SQty3.value;
		SL = document.form1.SL3.value;
		SW = document.form1.SW3.value;
		SH = document.form1.SH3.value;
		SWt = document.form1.SWt3.value;	
		hasStorage = isItemDimensionsEmpty(SQty,SL,SW,SH,SWt);
	}
	
	if (hasStorage == false)
	{
		SQty = document.form1.SQty4.value;
		SL = document.form1.SL4.value;
		SW = document.form1.SW4.value;
		SH = document.form1.SH4.value;
		SWt = document.form1.SWt4.value;	
		hasStorage = isItemDimensionsEmpty(SQty,SL,SW,SH,SWt);
	}	
	
	if (hasStorage == false)
	{
		hasStorage = !IsWhiteSpace(document.form1.SMisc2.value);
	}
	
	if (hasStorage == false)
		strmsg = "Dimensions of items to be stored\n";
		
	return strmsg;
}

function isItemDimensionsEmpty(SQty,SL,SW,SH,SWt)
{
	if (!IsWhiteSpace(SQty) && !IsWhiteSpace(SL) && !IsWhiteSpace(SW) && !IsWhiteSpace(SH) && !IsWhiteSpace(SWt))
		return true;	
	else
		return false;	
}

function miscMoveInfo()
{
	var strmsg = "";
	var CTMoveDate = document.form1.CTMoveDate.value;

	if (isValidDate(CTMoveDate) == false)
		strmsg += 'Target Move Date\n';
		
	return strmsg;
}

function moveFrom()
{
	var strmsg = "";
	var CMFCity = document.form1.CMFCity.value;
	var CMFState = document.form1.CMFState.value;
	var CMFProvince = document.form1.CMFProvince.value;
	var CMFCountry = document.form1.CMFCountry.value;
		
	if (IsWhiteSpace(CMFCity))
		strmsg += "Move From City\n";
	if (CMFCountry == '207')
		if (CMFState == 'none' && IsWhiteSpace(CMFProvince))
			strmsg += "Move From State/Province\n";
	if (CMFCountry == '0')
		strmsg += "Move From Country\n";
		
	return strmsg;
}

function moveTo()
{
	var strmsg = "";
	var CMTCity = document.form1.CMTCity.value;
	var CMTState = document.form1.CMTState.value;
	var CMTProvince = document.form1.CMTProvince.value;
	var CMTCountry = document.form1.CMTCountry.value;
		
	if (IsWhiteSpace(CMTCity))
		strmsg += "Move to City\n";
	if (CMTCountry == '207')
		if (CMTState == 'none' && IsWhiteSpace(CMTProvince))
			strmsg += "Move to State/Province\n";
	if (CMTCountry == '0')
		strmsg += "Move to Country\n";
		
	return strmsg;
	
}

function contactinfo()
{

	var strmsg = "";
	var fname = document.form1.FName.value;
	var lname = document.form1.LName.value;
	var title = document.form1.Title.value;
	var email = document.form1.Email.value;
	
	

if ( IsWhiteSpace(fname))
{
	strmsg += "First Name\n";
}
if ( IsWhiteSpace(lname))
{
	strmsg += "Last Name\n";
}
if ( IsWhiteSpace(title))
{
	strmsg += "Title\n";
}
if ( IsWhiteSpace(email))
{
	strmsg += "Email\n";
}
else
{
	var bEmailRet = isvalidEmail(email);
	if (bEmailRet == false)
	{
		strmsg += "Email\n";
	}
}
return strmsg;
}

function propertiesStoredLocation()
{
	var strmsg = "";
	var SCity = document.form1.SCity.value;
	var SState = document.form1.SState.value;
	var SProvince = document.form1.SProvince.value;
	var SCountry = document.form1.SCountry.value;
			
	if (IsWhiteSpace(SCity))
		strmsg += "Properties stored in City\n";
	if (SCountry == '207')
		if (SState == 'none' && IsWhiteSpace(SProvince))
			strmsg += "Properties stored in State/Province\n";
	if (SCountry == '0')
		strmsg += "Properties stored in Country\n";
		
	return strmsg;
	
}

function globalLoading()
{
	var strmsg = "";
	var LFCity1 = document.form1.LFCity1.value;
	var LFCountry1 = document.form1.LFCountry1.options[document.form1.LFCountry1.selectedIndex].value;
	
	if ( IsWhiteSpace(LFCity1))
		strmsg += "Loading From City\n";
		
	if ( IsWhiteSpace(LFCountry1) || LFCountry1 == '0')
		strmsg += "Loading From Country\n";
	
	return strmsg;
}

function loading()
{
	var strmsg = "";
	var LFCity1 = document.form1.LFCity1.value;
	var LFState1 = document.form1.LFState1.options[document.form1.LFState1.selectedIndex].value;
	//var LFProvince1 = document.form1.LFProvince1.value;
	var LFCountry1 = document.form1.LFCountry1.options[document.form1.LFCountry1.selectedIndex].value;	
	if ( IsWhiteSpace(LFCity1))
		strmsg += "Loading From City\n";
	
	if	(LFCountry1 == '207')
	{
		if ( IsWhiteSpace(LFState1))
		{
			strmsg += "Loading From State\n";
		}
		else
		{
			if (LFState1 == 'none')
			{
				strmsg += "Loading From State\n";
			}
		}
	}
	//if ( IsWhiteSpace(LFProvince1))
	//{
		//strmsg += "Loading From Province\n";
	//}
	//if ( IsWhiteSpace(LFCountry1))
	//{
		//strmsg += "Loading From Country\n";
	//}
	return strmsg;
}

function twoExtraPickupLocation()
{
	var strmsg = "";
	var isFilled = false;

	var LFCity2 = document.form1.LFCity2.value;
	var LFState2 = document.form1.LFState2.options[document.form1.LFState2.selectedIndex].value;

	if ( !IsWhiteSpace(LFCity2) && !IsWhiteSpace(LFState2))
		isFilled = true;
	else
	{
		var LFCity3 = document.form1.LFCity3.value;
		var LFState3 = document.form1.LFState3.options[document.form1.LFState3.selectedIndex].value;

		if ( !IsWhiteSpace(LFCity3) && !IsWhiteSpace(LFState3))
			isFilled = true;		
	}	

	return isFilled
}

function golbalDestination()
{
	var strmsg = "";
	var DCity = document.form1.DCity.value;
	var DCountry = document.form1.DCountry.options[document.form1.DCountry.selectedIndex].value;	
	
	if ( IsWhiteSpace(DCity))
		strmsg += "Destination City\n";
		
	if ( IsWhiteSpace(DCountry) || DCountry == '0')
		strmsg += "Destination Country\n";

	return strmsg;
}

function destination()
{
var strmsg = "";
var DCity = document.form1.DCity.value;
var DState = document.form1.DState.options[document.form1.DState.selectedIndex].value;	
//var DProvince = document.form1.DProvince.value;
var DCountry = document.form1.DCountry.options[document.form1.DCountry.selectedIndex].value;		
if ( IsWhiteSpace(DCity))
{
strmsg += "Destination City\n";
}
if (DCountry == '207')
{
	if ( IsWhiteSpace(DState))
	{
		strmsg += "Destination State\n";
	}
	else
	{
		if (DState == 'none')
		{
			strmsg += "Destination State\n";
		}
	}
}
//if ( IsWhiteSpace(DProvince))
//{
//strmsg += "Destination Province\n";
//}
//if ( IsWhiteSpace(DCountry))
//{
//strmsg += "Destination Country\n";
//}
return strmsg;
}


function tradeshow()
{
var strmsg = "";
var tsname = document.form1.TSName.value;
var tsstartdate = document.form1.TSStartDate.value;
var tsenddate = document.form1.TSEndDate.value;
var tscity = document.form1.TSCity.value;
var tsstate = document.form1.TSState.options[document.form1.TSState.selectedIndex].value;	var tsprovince = document.form1.TSProvince.value;
var tscountry = document.form1.TSCountry.options[document.form1.TSCountry.selectedIndex].value;
var tsbooth = document.form1.TSBooth.value;
if ( IsWhiteSpace(tsname))
{
strmsg += "Trade Show Name\n";	
}
if ( IsWhiteSpace(tsstartdate))
{
strmsg += "Show Start Date\n";
}
else
{
var bStartDate = isValidDate(tsstartdate)
if (bStartDate == false)
{
strmsg += "Show Start Date\n";
}
}
if ( IsWhiteSpace(tsenddate))
{
strmsg += "Show End Date\n";
}
else
{
var bEndDate = isValidDate(tsenddate)
if (bEndDate == false)
{
strmsg += "Show End Date\n";
}
}
if ( IsWhiteSpace(tscity))
{
strmsg += "Trade Show City\n";
}
if ( IsWhiteSpace(tsstate))
{
strmsg += "Trade Show State\n";
}
if ( IsWhiteSpace(tsprovince))
{
strmsg += "Trade Show Province\n";
}
if ( IsWhiteSpace(tscountry))
{
strmsg += "Trade Show Country\n";
}
if ( IsWhiteSpace(tsbooth))
{
strmsg += "Trade Show BoothSize\n";
}
return strmsg;
}



function IsWhiteSpace(str)	{
	var isWS = true;
		for (i = 0; i < str.length; i++)	{
			c = str.charAt(i);
		if (!(c == " " || c == "\n" || c == "\t" || c == "\r" || c == "\f"))	{
			isWS = false;
			break;
		}
	
}
return isWS;
}



function isvalidEmail(emailad)	{
	var filter=/^[\w\.\-_]+@([\w\.\-_]+\.)+[A-Za-z]{2,3}$/
	if (filter.test(emailad))	{
	}
	else	{
		return false
	}
return true
}



function isValidDate(inputdate)		{
	if (inputdate.indexOf("/") != -1)	{
		strDateArray = inputdate.split("/");
		if (strDateArray.length != 3)	{
			return false;
		}
		else	{
			smonth = strDateArray[0]-1;
			sdate = strDateArray[1];
			syear = strDateArray[2];
			if (syear.length > 2)	{
				return false;
			}
		}
	syear = padYear(syear);
	var test = new Date(syear,smonth,sdate);
	if ( (y2k(test.getYear()) == syear) && (smonth == test.getMonth())  )
		return true;
	else
		return false;
	}
	else
		return false;
}


function padYear(year)	{
	if (year < 70)	{
		if (year.length == 1)	{
		year = 200 + year;
		}
		else	{
			year = 20 + year;
		}
	}
	else	{
		year = 19 + year;
	}
return year;
}



function y2k(number)	{
	return (number < 1000) ? number + 1900 : number;
}
