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) {
		Layout_1_cut2_02_over = newImage("images/Layout-1-cut2_02-over.jpg");
		Layout_1_cut2_03_over = newImage("images/Layout-1-cut2_03-over.jpg");
		Layout_1_cut2_03_Layout_1_cut2_08_over = newImage("images/Layout-1-cut2_03-Layout-1-c.jpg");
		Layout_1_cut2_04_over = newImage("images/Layout-1-cut2_04-over.jpg");
		Layout_1_cut2_04_Layout_1_cut2_08_over = newImage("images/Layout-1-cut2_04-Layout-1-c.jpg");
		Layout_1_cut2_05_Layout_1_cut2_04_over = newImage("images/Layout-1-cut2_05-Layout-1-c.jpg");
		Layout_1_cut2_05_over = newImage("images/Layout-1-cut2_05-over.jpg");
		Layout_1_cut2_05_Layout_1_cut2_08_over = newImage("images/Layout-1-cut2_05-Layout--13.jpg");
		Layout_1_cut2_06_over = newImage("images/Layout-1-cut2_06-over.jpg");
		Layout_1_cut2_06_Layout_1_cut2_08_over = newImage("images/Layout-1-cut2_06-Layout-1-c.jpg");
		Layout_1_cut2_07_over = newImage("images/Layout-1-cut2_07-over.jpg");
		Layout_1_cut2_07_Layout_1_cut2_08_over = newImage("images/Layout-1-cut2_07-Layout-1-c.jpg");
		Layout_1_cut2_08_over = newImage("images/Layout-1-cut2_08-over.jpg");
		preloadFlag = true;
	}
}

function validate(thisForm){		
		if (thisForm.fName.value == "" ){
			window.alert("Please enter your FIRST NAME!");
			thisForm.fName.focus();
			return false;
		}
		if (thisForm.lName.value == "" ){
			window.alert("Please enter your LAST NAME!");
			thisForm.lName.focus();
			return false;
		}
		if (thisForm.address.value == "" ){
			window.alert("Please enter your ADDRESS!");
			thisForm.address.focus();
			return false;
		}
		if (thisForm.city.value == "" ){
			window.alert("Please enter your CITY!");
			thisForm.city.focus();
			return false;
		}
		if (thisForm.phone.value == "" ){
			window.alert("Please enter your PHONE NUMBER!");
			thisForm.phone.focus();
			return false;
		}
		if (thisForm.email.value != thisForm.email2.value){
			alert("Your email address does not match! Please confirm!");
			thisForm.email.focus();
			return false;
		}
		if (thisForm.email.value == "" ){
			window.alert("Please enter your email address!");
			thisForm.email.focus();
			return false;
		}
		else {
			var emailexp = /.*\@.*\..*/;
			if (!emailexp.test(thisForm.email.value)) {
				window.alert("Invalid email address! Please enter your correct email address!");
				thisForm.email.focus();
				return false;
			}   
		}
		if (thisForm.username.value == "" ){
			window.alert("Please enter your USERNAME!");
			thisForm.username.focus();
			return false;
		}
		if (thisForm.password.value != thisForm.password2.value){
			alert("Your PASSWORD does not match! Please confirm!");
			thisForm.password.focus();
			return false;
		}		
		if (thisForm.password.value == "" ){
			window.alert("Please enter your PASSWORD!");
			thisForm.password.focus();
			return false;
		}
	}
	
function loadM(thisM){
	document.location.replace('manufacturers.cfm?mID=' + thisM);
}

function validateEmail(thisForm){		
	if (thisForm.email.value == "" ){
		window.alert("Please enter your email address!");
		thisForm.email.focus();
		return false;
	}
	else {
		var emailexp = /.*\@.*\..*/;
		if (!emailexp.test(thisForm.email.value)) {
			window.alert("Invalid email address! Please enter your correct email address!");
			thisForm.email.focus();
			return false;
		}   
	}
}

function validateClassified(thisForm){	
	if (thisForm.partCategory.options[thisForm.partCategory.selectedIndex].value== "" ){
		window.alert("Please enter a Part Category!");
		thisForm.partCategory.focus();
		return false;
	}
	if (thisForm.manufacturer.options[thisForm.manufacturer.selectedIndex].value == "" ){
		window.alert("Please enter a Manufacturer!");
		thisForm.manufacturer.focus();
		return false;
	}	
	if (thisForm.partNumber.value == "" ){
		window.alert("Please enter a Part Number!");
		thisForm.partNumber.focus();
		return false;
	}
	if (thisForm.partName.value == "" ){
		window.alert("Please enter a Part Name!");
		thisForm.partName.focus();
		return false;
	}
	if (thisForm.partDesc.value == "" ){
		window.alert("Please enter a Part Description!");
		thisForm.partDesc.focus();
		return false;
	}
	if (thisForm.partPrice.value == "" ){
		window.alert("Please enter a Part Price!");
		thisForm.partPrice.focus();
		return false;
	}
}

function popMan(){
	var myWin;
	myWin=window.open('addManufacturer.cfm','thisWin','width=400,height=400');
}

function popSub(){
	var myWin;
	myWin=window.open('subCat.cfm','thisWin','width=400,height=400,scrollbars=yes');
}

function popUp(){
	var myWin;
	myWin=window.open('subCat.cfm','thisWin','width=400,height=400,scrollbars=yes');
}

function CurrencyPopup(QueryString)
  {
    CurrencyWindow = window.open ('', 'CurrencyWindow', 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1,height=170,width=600')
    CurrencyWindow.focus()
    CurrencyWindow.location.href = 'http://www.xe.com/ecc/input.cgi?Template=sw&'+QueryString
  }

function validateMainPost(theForm){
	if(theForm.topic.value==""){
		alert("There must be a topic!");
		theForm.topic.focus();
		return false;
	}
	if(theForm.author.value==""){
		alert("There must be an author!");
		theForm.author.focus();
		return false;
	}
	if(theForm.partcatID.options[theForm.partcatID.selectedIndex].value==""){
		alert("There must be a category!");
		theForm.partcatID.focus();
		return false;
	}
	if(theForm.manID.options[theForm.manID.selectedIndex].value==""){
		alert("There must be a manufacturer!");
		theForm.manID.focus();
		return false;
	}
	if(theForm.partNum.value==""){
		alert("There must be a part number!");
		theForm.partNum.focus();
		return false;
	}
	if(theForm.content.value==""){
		alert("There must be content!");
		theForm.content.focus();
		return false;
	}
	return true;
}

function validatePendingPost(theForm){
	if(theForm.topic.value==""){
		alert("There must be a topic!");
		theForm.topic.focus();
		return false;
	}
	if(theForm.content.value==""){
		alert("There must be content!");
		theForm.content.focus();
		return false;
	}
	return true;
}

function validateChildPost(theForm){
	if(theForm.topic.value==""){
		alert("There must be a topic!");
		theForm.topic.focus();
		return false;
	}
	if(theForm.author.value==""){
		alert("There must be an author!");
		theForm.author.focus();
		return false;
	}
	if(theForm.content.value==""){
		alert("There must be content!");
		theForm.content.focus();
		return false;
	}
	return true;
}

function validateForumSearch(theForm){
	if(theForm.partcatID.options[theForm.partcatID.selectedIndex].value=="ANY" &&
	   theForm.manID.options[theForm.manID.selectedIndex].value=="ANY" &&
	   theForm.partNum.value.replace(/^\s*|\s*$/g,"")=="" && theForm.txt.value.replace(/^\s*|\s*$/g,"")==""){
	   		alert("You must select either a Category, Manufacturer, Part Number, or Contains Text to begin.");
			theForm.partcatID.focus();
			return false;
	   }
	   
	return true;
}