  function toggleCheck(msgSet) {
    var checkVal = msgSet.control.checked;
    for (i = 1; i < msgSet.elements.length; i++) {
      msgSet.elements[i].checked = checkVal;
    }
  }


var hK_agent = navigator.userAgent.toLowerCase();
var hK_major = parseInt(navigator.appVersion);
var hK_ie = ((hK_agent.indexOf("msie") != -1));
var hK_version = (hK_ie && (hK_major == 4) && (hK_agent.indexOf("msie 6.") != -1) );


if ((hK_version == true))
	if (parent.frames.length != 0)
	window.top.location.href = document.location;

NS4 = (document.layers) ? true : false;
if (NS4)
	document.write("<link rel='STYLESHEET' type='text/css' href='mpcNetscape.css'>")
else
	document.write("<link rel='STYLESHEET' type='text/css' href='mpc.css'>")
	
	

function addCodeCheck(theForm)
{

if (theForm.code.value == "")
  {
    alert("Please enter a value for the \"Customer Code\" field.");
    theForm.code.focus();
    return (false);
  }
if (theForm.name.value == "")
  {
    alert("Please enter a value for the \"Customer Name\" field.");
    theForm.name.focus();
    return (false);
  }
  return (true);
}
function addAddressCheck(theForm)
{

if (theForm.code.value == "")
  {
    alert("Please enter a value for the \"Customer Code\" field.");
    theForm.code.focus();
    return (false);
  }
  return (true);
}
	
	

function clearText(query){
if (query.defaultValue==query.value)
query.value = ""
} 

// Open
var hK;
function hkOpen(winurl,winname,winfeatures)
{
	hK = window.open(winurl,winname,winfeatures);
 	setTimeout('hK.focus();',250);
}
//

function newImage(arg) {
if (document.images) {
rslt = new Image();
rslt.src = arg;
return rslt;
}
}

function changeImages() {
if (document.images && (preloadFlag == true)) {
for (var i=0; i<changeImages.arguments.length; i+=2) {
document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
}
}
}

var preloadFlag = false;
function preloadImages() {
if (document.images) {
// Top Navigation
nav_home_over = newImage("navigation/nav_home_over.gif");
nav_company_over = newImage("navigation/nav_company_over.gif");
nav_services_over = newImage("navigation/nav_services_over.gif");
nav_products_over = newImage("navigation/nav_products_over.gif");
nav_contact_over = newImage("navigation/nav_contact_over.gif");
nav_opportunities_over = newImage("navigation/nav_opportunities_over.gif");
nav_support_over = newImage("navigation/nav_support_over.gif");

preloadFlag = true;
}
}


function IsValidEmail (strEmail){
		var bIsValid=true;
		var Space1=" ";
		var At1="@";
		var Dot1=".";
		var strTemp=new String(strEmail);
		if (strTemp.length < 5) 
				bIsValid = false;
		
		if (strTemp.indexOf(Space1)>0)
				bIsValid = false;
		
		if (strTemp.indexOf(At1)<2)
				bIsValid = false;
		
		if (strTemp.lastIndexOf(Dot1) < strTemp.indexOf(At1, 1) + 1)
				bIsValid = false;
		return bIsValid; 
}

function checkdate(theDate)
{
var valid = 1
value = theDate
	var dateregex=/^[ ]*[0]?(\d{1,2})\/(\d{1,2})\/(\d{4,})[ ]*$/;
		var match=value.match(dateregex);
			if (match) 
				{
				var tmpdate=new Date(match[3],parseInt(match[1])-1,match[2]);
				if (tmpdate.getDate()==parseInt(match[2]) && tmpdate.getFullYear()==parseInt(match[3]) && (tmpdate.getMonth()+1)==parseInt(match[1]))
				{ 
			return valid
			}
		}
	}
	
// contact script
function contactCheck(theForm)
{
 if (theForm.name.value == "")
  {
    alert("Please enter a value for the \"Name\" field.");
    theForm.name.focus();
    return (false);
  }
     if (theForm.company.value == "")
  {
    alert("Please enter a value for the \"Company\" field.");
    theForm.company.focus();
    return (false);
  }
   if (theForm.address.value == "")
  {
    alert("Please enter a value for the \"Address\" field.");
    theForm.address.focus();
    return (false);
  }
    if (theForm.city.value == "")
  {
    alert("Please enter a value for the \"City\" field.");
    theForm.city.focus();
    return (false);
  }
    if (theForm.state.value == "")
  {
    alert("Please enter a value for the \"State\" field.");
    theForm.state.focus();
    return (false);
  }
    if (theForm.zip.value == "")
  {
    alert("Please enter a value for the \"Zip\" field.");
    theForm.zip.focus();
    return (false);
  }
      if (theForm.phone.value == "")
  {
    alert("Please enter a value for the \"Phone\" field.");
    theForm.phone.focus();
    return (false);
  }
  
	if (theForm.email.value == "")
  	{
    alert("Please enter a value for the \"Email\" field.");
    theForm.email.focus();
    return (false);
  	}
	var ValidEmail=IsValidEmail (theForm.email.value);
	if ((ValidEmail==false) && (theForm.email.value != "")){
	alert("You have entered in a invalid email address");
	theForm.email.focus();
	return (false);
	}
if (theForm.reason.value == "")
  {
    alert("Please enter a value for the \"Specify Request Type\" field.");
    theForm.reason.focus();
    return (false);
  }
  
  return (true);
}
// register script
function registerCheck(theForm)
{

if (theForm.username.value == "")
  {
    alert("Please enter a value for the \"Email Address (username)\" field.");
    theForm.username.focus();
    return (false);
  }
	var ValidEmail=IsValidEmail (theForm.username.value);
	if ((ValidEmail==false) && (theForm.username.value != "")){
	alert("You have entered in a invalid email address");
	theForm.username.focus();
	return (false);
	}
			
	if (theForm.password1.value == "")
  {
    alert("Please enter a value for the \"Password\" field.");
    theForm.password1.focus();
    return (false);
  }
   if (theForm.password2.value == "")
  {
    alert("Please enter a value for the \"Confirm Password\" field.");
    theForm.password2.focus();
    return (false);
  }
    if (theForm.password1.value != theForm.password2.value)
  {
    alert("Your passwords do not match.  Please re-confirm your password.");
    theForm.password2.focus();
    return (false);
  }
 if (theForm.name.value == "")
  {
    alert("Please enter a value for the \"Name\" field.");
    theForm.name.focus();
    return (false);
  }
     if (theForm.company.value == "")
  {
    alert("Please enter a value for the \"Company\" field.");
    theForm.company.focus();
    return (false);
  }
   if (theForm.address1.value == "")
  {
    alert("Please enter a value for the \"Address\" field.");
    theForm.address1.focus();
    return (false);
  }

    if (theForm.city.value == "")
  {
    alert("Please enter a value for the \"City\" field.");
    theForm.city.focus();
    return (false);
  }
    if (theForm.state.value == "")
  {
    alert("Please enter a value for the \"State\" field.");
    theForm.state.focus();
    return (false);
  }
    if (theForm.zip.value == "")
  {
    alert("Please enter a value for the \"Zip\" field.");
    theForm.zip.focus();
    return (false);
  }
      if (theForm.country.value == "")
  {
    alert("Please enter a value for the \"Country\" field.");
    theForm.country.focus();
    return (false);
  }
      if (theForm.phone.value == "")
  {
    alert("Please enter a value for the \"Phone\" field.");
    theForm.phone.focus();
    return (false);
  }
 
  return (true);
}

function deleteCheck(theForm)
{
if (theForm.deleteLock.checked == false)
  {
    alert("If you are sure you want to delete this item and all items associated with it.\nCheck the \"Delete Lock\" box and hit the delete button again.");
    return (false);
  }
  return (true);
}

function startOver(theForm)
{
if (theForm.startOverLock.checked == false)
  {
    alert("If you are sure you want to start over all your data will be removed.\nCheck the \"Start Over Lock\" box and hit the start over button again to continue.");
    return (false);
  }
  return (true);
}

// rma script
//function repairsCheckStep1(theForm)
//{
//alert("Please do not use your back button or forward button until you have completed //the RMA Request!");
//}


// rma script
function repairsCheckStep2(theForm)
{
	if ((theForm.warranty[0].checked == false) && (theForm.warranty[1].checked == false )) {
		alert ( "Please select yes or no for warranty infomation." );
		window.location.href = "#warranty";
		return (false);
	}

	if ((theForm.accruedFlightHours[0].checked == false) && (theForm.accruedFlightHours[1].checked == false )) {
		alert ( "Please select yes or no for flight hours infomation." );
		window.location.href = "#accruedFlightHours";
		return (false);
	}
	if ((theForm.license[0].checked == false) && (theForm.license[1].checked == false )) {
		alert ( "Please select yes or no for export license infomation." );
		window.location.href = "#license";
		return (false);
	}
  return (true);
}


// rma script
function repairsCheckStep3(theForm)
{
	if (theForm.customerPartNumber.value == ""  && theForm.mpcPartNumber.value == "")
  {
    alert("Please enter a value for \"Customer Part Number\" and/or \"MPC Part Number\" field.");
    theForm.customerPartNumber.focus();
    return (false);
  }
	if (theForm.serialNumber.value == "")
  {
    alert("Please enter a value for the \"Serial Number\" field.\nIf you do not know your serial number please type in \"Unknown\".");
    theForm.serialNumber.focus();
    return (false);
  }

	if (theForm.serialNumber.value.length > 49)
  {
    alert("Please enter length < 50 for the \"Serial Number\" field.\n ");
    theForm.serialNumber.focus();
    return (false);
  }

  	if (theForm.poNumber.value == "")
  {
    alert("Please enter a value for the \"Part Number\" field.");
    theForm.poNumber.focus();
    return (false);
  }
	if (theForm.reasonReturn.value == "" && theForm.upLoad.value == "")
  {
    alert("Please enter in a \"Reason for Return\" or \"Attach you document\".");
    theForm.reasonReturn.focus();
    return (false);
  }
  	if (theForm.reasonReturn.value != "" && theForm.upLoad.value != "")
  {
    alert("Please choose between typing in your \"Reason for Return\" or \"Attach you document\".");
    theForm.reasonReturn.focus();
    return (false);
  }

if (theForm.deliveryDate.value != "")
  {
  if (!checkdate(theForm.deliveryDate.value)) {
		valid = 0
		alert("The date must be a valid date in the format MM/DD/YYYY");
		theForm.deliveryDate.focus();
    	return (false);
	}
	}  
	
if (theForm.warrantyFlag.value != "" )
{
 	if (theForm.warrantyInfo.value == "")
  {
    alert("Please enter a value for the \"Explanation of Warranty\" field.");
    theForm.warrantyInfo.focus();
    return (false);
  }
  if (theForm.removalDate.value != "")
  {
  if (!checkdate(theForm.removalDate.value)) {
		valid = 0
		alert("The date must be a valid date in the format MM/DD/YYYY");
		theForm.removalDate.focus();
    	return (false);
	}
	} 
  }
  
 
	
if (theForm.licenseFlag.value != "" )
{
 	if (theForm.licenseDes.value == "")
  {
    alert("Please enter a value for the \"Description of Part\" field.");
    theForm.licenseDes.focus();
    return (false);
  }
if (!hkNumberOnly(theForm.licenseDollar.value)) {
		valid = 0
		alert("Please Enter in Numbers Only for the \"Dollar\" field.")
		theForm.licenseDollar.focus();
    	return (false);
	}
  	if (theForm.licenseFreight.value == "")
  {
    alert("Please enter a value for the \"Freight Forwarder (DHL, FedEx, Etc...)\" field.");
    theForm.licenseFreight.focus();
    return (false);
  }
  }
  
  return (true);
}
// rma script

// Change password
function myPassword(theForm)
{

if (theForm.username.value == "")
  {
    alert("Please enter a value for the \"Username\" field.");
    theForm.username.focus();
    return (false);
  }
	var ValidEmail=IsValidEmail (theForm.username.value);
	if ((ValidEmail==false) && (theForm.username.value != "")){
	alert("You have entered in a invalid username (email address)");
	theForm.username.focus();
	return (false);
	}
	if (theForm.currentpassword.value == "")
  {
    alert("Please enter a value for the \"Current Password\" field.");
    theForm.currentpassword.focus();
    return (false);
  }
	if (theForm.password1.value == "")
  {
    alert("Please enter a value for the \"Password\" field.");
    theForm.password1.focus();
    return (false);
  }
   if (theForm.password2.value == "")
  {
    alert("Please enter a value for the \"Confirm Password\" field.");
    theForm.password2.focus();
    return (false);
  }
    if (theForm.password1.value != theForm.password2.value)
  {
    alert("Your passwords do not match.  Please re-confirm your password.");
    theForm.password2.focus();
    return (false);
  } 
  return (true);
}


function myAccountCheck(theForm)
{

if (theForm.username.value == "")
  {
    alert("Please enter a value for the \"Email Address (username)\" field.");
    theForm.username.focus();
    return (false);
  }
	var ValidEmail=IsValidEmail (theForm.username.value);
	if ((ValidEmail==false) && (theForm.username.value != "")){
	alert("You have entered in a invalid email address");
	theForm.username.focus();
	return (false);
	}
	if (theForm.password.value == "")
  {
    alert("Please enter a value for the \"Password\" field.");
    theForm.password.focus();
    return (false);
  }		
 if (theForm.name.value == "")
  {
    alert("Please enter a value for the \"Name\" field.");
    theForm.name.focus();
    return (false);
  }
     if (theForm.company.value == "")
  {
    alert("Please enter a value for the \"Company\" field.");
    theForm.company.focus();
    return (false);
  }
   if (theForm.address1.value == "")
  {
    alert("Please enter a value for the \"Address\" field.");
    theForm.address1.focus();
    return (false);
  }

    if (theForm.city.value == "")
  {
    alert("Please enter a value for the \"City\" field.");
    theForm.city.focus();
    return (false);
  }
    if (theForm.state.value == "")
  {
    alert("Please enter a value for the \"State\" field.");
    theForm.state.focus();
    return (false);
  }
    if (theForm.zip.value == "")
  {
    alert("Please enter a value for the \"Zip\" field.");
    theForm.zip.focus();
    return (false);
  }
      if (theForm.country.value == "")
  {
    alert("Please enter a value for the \"Country\" field.");
    theForm.country.focus();
    return (false);
  }
      if (theForm.phone.value == "")
  {
    alert("Please enter a value for the \"Phone\" field.");
    theForm.phone.focus();
    return (false);
  }
 
  return (true);
}

// Common Scripts
//upload check
function uploadCheck(theForm)
{
	if (theForm.upload.value == "")
  {
    alert("Please use the browse button to upload a file");
    theForm.upload.focus();
    return (false);
  }
  if((theForm.upload.value.lastIndexOf(".doc")==-1) && (theForm.upload.value.lastIndexOf(".txt")==-1)  && (theForm.upload.value.lastIndexOf(".pdf")==-1))
{
alert("You can upload only Doc, Txt or PDF extention files")
return false
}
  return (true);
}

function hkNumberOnly(TheNumber) {
var valid = 1
var hkGoodNumbers = "0123456789,."
var i = 0
if (TheNumber=="") {
valid = 0
	}
for (i =0; i <= TheNumber.length -1; i++) {
if (hkGoodNumbers.indexOf(TheNumber.charAt(i)) == -1) {
valid = 0
}
	}
return valid
}