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)
		{
			//alert(document[changeImages.arguments[i]].src);
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}


var preloadFlag = false;
function preloadImages()
{
	if (document.images)
	{
		arrow_01_over = newImage("images/Mainpage_Tables/arrow_01-over.gif");
		Search_On = newImage("images/Mainpage_Tables/Search_On.gif");	
		More_Info_On = newImage("images/Mainpage_Tables/More_Info_On.gif");												
		down_on = newImage("images/Mainpage_Tables/down_off-over.gif");												
		up_on = newImage("images/Mainpage_Tables/up_off-over.gif");
		preloadFlag = true;
	}
}


function Open_Popup(w,h,url,scroll){
	xpos=(screen.availWidth - w)/2;
	ypos=(screen.availHeight - h)/2;
	settings="height=" + h + ",width=" + w + ",top=" + ypos + ",left=" + xpos + ",resizeable=0,menubar=0,toolbar=0,location=0,directories=0,scrollbars=" + scroll + ",status=0";
	window.open(url,"",settings);
}


function ValidateSearch()
{
	str = document.ps.pn.value;
	dstr = document.ps.description.value;
	if(dstr.length == 0)
	{
		if(str.length < 2)
		{
			alert("You must type at least 2 characters when searching by part number.");
			document.ps.pn.focus();
			return (false);
		}
	}
	return (true);
	
}


function ValidateSearchM()
{
	str = document.mps.pn[0].value;
	dstr = document.mps.description[0].value;
	if(dstr.length == 0)
	{
		if(str.length < 2)
		{
			alert("You must type at least 2 characters when searching by part number.");
			document.mps.pn[0].focus();
			return (false);
		}
	}

	for(i=1; i<document.mps.pn.length;i++)
	{
		str = document.mps.pn[i].value;
		dstr = document.mps.description[i].value;
		if(dstr.length == 0)
		{
			if(str.length > 0)
			{
				if(str.length < 2)
				{
					alert("You must type at least 2 characters when searching by part number.");
					document.mps.pn[i].focus();
					return (false);
				}
			}
		}
	}
	return (true);
}


function validate_upload_form(whichForm)
{
	if (Upload.file1.value == "")
	  {
		alert("You must choose the file to upload. Click the \"Browse\" button.");
		return (false);
	  }
	return (true);
}


function validate_app_form(whichForm)
{
	if (app.Name.value == ""){
		alert("Please provide your \"Name\" for the application.");
		app.Name.focus();
		return (false);
	}

	if (app.Email.value == ""){
		alert("Please provide your \"Email Address\" for the application.");
		app.Email.focus();
		return (false);
	}
	
	if (app.Phone_1.value == ""){

		alert("Please provide a \"Phone Number\" where you can be reached.");
		app.Phone_1.focus();
		return (false);
	}

	if (app.Employment_Type[0].checked == 0){
		if (app.Employment_Type[1].checked == 0){
			alert("Please select the \"Employment Type\" you desire.");
			return (false);
		}
	}


	if (app.Former_Employer_1.value == ""){
		alert("Please provide the \"Company\" name of your most recent employer.");
		app.Former_Employer_1.focus();
		return (false);
	}
	if (app.Start_Date_1.value == ""){
		alert("Please provide the \"Start Date\" of your most recent employer.");
		app.Start_Date_1.focus();
		return (false);
	}
	if (app.End_Date_1.value == ""){
		alert("Please provide the \"End Date\" of your most recent employer.");
		app.End_Date_1.focus();
		return (false);
	}


	if (app.Former_Employer_2.value == ""){
		alert("Please provide the \"Company\" name of your previous employer.");
		app.Former_Employer_2.focus();
		return (false);
	}
	if (app.Start_Date_2.value == ""){
		alert("Please provide the \"Start Date\" of your previous employer.");
		app.Start_Date_2.focus();
		return (false);
	}
	if (app.End_Date_2.value == ""){
		alert("Please provide the \"End Date\" of your previous employer.");
		app.End_Date_2.focus();
		return (false);
	}

	return (true);
}


function bodyonload()
{
	document.getElementById('section1b').style.display='none';
	document.getElementById('section2b').style.display='none';
	document.getElementById('section3b').style.display='none';
	document.getElementById('section4b').style.display='none';
	ToggleDiv(document.getElementById('section1b'),document.getElementById('section1a'));		
}


function handOn(section){		
	document.all(section).style.cursor = 'hand';
}

function handOff(section){		
	document.all(section).style.cursor = '';
}

function validate_form(update_rfq)
{
  for (i=0;i<4;i++) {
	 section = i + 1;
	 if (isFinite(SubmitRFQ.qty[i].value))
	 {
		if (SubmitRFQ.qty[i].value > 0)
		{
			if (SubmitRFQ.pn[i].value == "")
			  {
				alert("You have entered a quantity in the \"Addition Part Request #" + section + "\".\n Please enter a \"PART NUMBER\" for this section OR change the quantity to 0.");
				SubmitRFQ.pn[i].focus();
				return (false);
			  }
			if (SubmitRFQ.description[i].value == "")
			  {
				alert("You have entered a quantity in the \"Addition Part Request #" + section + "\".\n Please enter a \"DESCRIPTION\" for this section OR change the quantity to 0.");
				SubmitRFQ.description[i].focus();
				return (false);
			  }
		}
	 }
	 else{
		alert("The quantity you entered in the Addition Part Request #" + section + " is invalid.\nPlease enter a number in the quantity field.");
		SubmitRFQ.qty[i].focus();
		return (false);
	 }
  }
  return (true);
}
