<!--
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function valNewBuilder(){
var company = document.frmAddBuilder.txtCompany;
var address = document.frmAddBuilder.txtAddress;
var city = document.frmAddBuilder.txtCity;
var state = document.frmAddBuilder.cboStates[document.frmAddBuilder.cboStates.selectedIndex];
var zip = document.frmAddBuilder.txtZip;
var phone1 = document.frmAddBuilder.txtPhone1;
var phone2 = document.frmAddBuilder.txtPhone2;
var phone3 = document.frmAddBuilder.txtPhone3;
var contact = document.frmAddBuilder.txtContact;
var type = document.frmAddBuilder.cboType[document.frmAddBuilder.cboType.selectedIndex];
var desx = document.frmAddBuilder.memDescription;

if (company.value == ""){
	alert("Please enter your company name.");
	company.focus();
	return false;
	}
if (address.value == ""){
	alert("Please enter your company\'s address.");
	address.focus();
	return false;
	}
if (city.value == ""){
	alert("Please enter your city name.");
	city.focus();
	return false;
	}
if (state.value == ""){
	alert("Please select your state name.");
	document.frmAddBuilder.cboStates.focus();
	return false;
	}
if (zip.value == "" || zip.value.length < 5 || isNaN(zip.value)){
	alert("Please enter a valid zip code.");
	zip.focus();
	zip.select();
	return false;
	}
if (phone1.value == "" || phone1.value.length < 3 || isNaN(phone1.value)){
	alert("Please enter a valid area code.");
	phone1.focus();
	phone1.select();
	return false;
	}
if (phone2.value == "" || phone2.value.length < 3 || isNaN(phone2.value)){
	alert("Please enter a valid phone exchange.");
	phone2.focus();
	phone2.select();
	return false;
	}
if (phone3.value == "" || phone3.value.length < 4 || isNaN(phone3.value)){
	alert("Please enter a valid phone number.");
	phone3.focus();
	phone3.select();
	return false;
	}
if (contact.value == ""){
	alert("Please enter your full name.");
	contact.focus();
	return false;
	}
if (type.value == ""){
	alert("Please select your business type.");
	document.frmAddBuilder.cboType.focus();
	return false;
	}
if (desx.value == ""){
	alert("Please enter a description of your compnay.");
	desx.focus();
	return false;
	}
}

function valNewSupplier(){
var company = document.frmAddBuilder.txtCompany;
var address = document.frmAddBuilder.txtAddress;
var city = document.frmAddBuilder.txtCity;
var state = document.frmAddBuilder.cboStates[document.frmAddBuilder.cboStates.selectedIndex];
var zip = document.frmAddBuilder.txtZip;
var phone1 = document.frmAddBuilder.txtPhone1;
var phone2 = document.frmAddBuilder.txtPhone2;
var phone3 = document.frmAddBuilder.txtPhone3;
var fname = document.frmAddBuilder.txtFirst;
var lname = document.frmAddBuilder.txtLast;
var type = document.frmAddBuilder.cboType[document.frmAddBuilder.cboType.selectedIndex];
var desx = document.frmAddBuilder.memDescription;

if (company.value == ""){
	alert("Please enter your company name.");
	company.focus();
	return false;
	}
if (address.value == ""){
	alert("Please enter your company\'s address.");
	address.focus();
	return false;
	}
if (city.value == ""){
	alert("Please enter your city name.");
	city.focus();
	return false;
	}
if (state.value == ""){
	alert("Please select your state name.");
	document.frmAddBuilder.cboStates.focus();
	return false;
	}
if (zip.value == "" || zip.value.length < 5 || isNaN(zip.value)){
	alert("Please enter a valid zip code.");
	zip.focus();
	zip.select();
	return false;
	}
if (phone1.value == "" || phone1.value.length < 3 || isNaN(phone1.value)){
	alert("Please enter a valid area code.");
	phone1.focus();
	phone1.select();
	return false;
	}
if (phone2.value == "" || phone2.value.length < 3 || isNaN(phone2.value)){
	alert("Please enter a valid phone exchange.");
	phone2.focus();
	phone2.select();
	return false;
	}
if (phone3.value == "" || phone3.value.length < 4 || isNaN(phone3.value)){
	alert("Please enter a valid phone number.");
	phone3.focus();
	phone3.select();
	return false;
	}
if (fname.value == ""){
	alert("Please enter your first name.");
	fname.focus();
	return false;
	}
if (lname.value == ""){
	alert("Please enter your last name.");
	lname.focus();
	return false;
	}
if (type.value == ""){
	alert("Please select your business type.");
	document.frmAddBuilder.cboType.focus();
	return false;
	}
if (desx.value == ""){
	alert("Please enter a description of your compnay.");
	desx.focus();
	return false;
	}
}

function validEmail(email) {
	invalidChars = " /:,;"
	
	if (email == "") {// cannot be empty
				return false
	}
	for (i=0; i<invalidChars.length; i++) {	// does it contain any invalid characters?
	badChar = invalidChars.charAt(i)
		if (email.indexOf(badChar,0) > -1) {
			return false
		}
	}
	atPos = email.indexOf("@",1)			// there must be one "@" symbol
		if (atPos == -1) {
			return false
		}
		if (email.indexOf("@",atPos+1) != -1) {	// and only one "@" symbol
			return false
		}
	periodPos = email.indexOf(".",atPos)
		if (periodPos == -1) {			// and at least one "." after the "@"
			return false
		}
		if (periodPos+3 > email.length)	{	// must be at least 2 characters after the "."
			return false
		}
	return true
}

function valEmail(){
	var fname = document.frmEmail.txtFirst;
	var lname = document.frmEmail.txtLast;
	var email = document.frmEmail.txtEmail;
	var phone1 = document.frmEmail.txtPhone1;
	var phone2 = document.frmEmail.txtPhone2;
	var phone3 = document.frmEmail.txtPhone3;
	var message = document.frmEmail.memMessage;
	
	if (fname.value == "" ) {
		alert("Please enter your first name.");
		fname.focus();
		return false;
		}
	
	if (lname.value == ""){
		alert("Please enter your last name.");
		lname.focus();
		return false;
		}	
	
	if (phone1.value == "" || isNaN(phone1.value) || phone1.value.length < 3){
		alert('Please enter a valid area code.');
		phone1.focus();
		phone1.select();
		return false;
		}
	if (phone2.value == "" || isNaN(phone2.value) || phone2.value.length < 3){
		alert('Please enter phone exchange.');
		phone2.focus();
		phone2.select();
		return false;
		}
	if (phone3.value == "" || isNaN(phone3.value) || phone3.value.length < 4){
		alert('Please a valid phone number.');
		phone3.focus();
		phone3.select();
		return false;
		}
		
	if (!validEmail(email.value)) {
	alert("Please enter a valid e-mail address")
	email.focus()
	email.select()
	return false;
	}
	
	if (message.value == "") {
		alert("Please enter a message.");
		message.focus();
		return false;
		}
}

//random Flash files


function chooseFlash(){
myPix = new Array("images/flash/firehouse.swf","images/flash/brown_bldg.swf","images/flash/church.swf","images/flash/commercial_building.swf","images/flash/farm_building.swf","images/flash/horse_ranch.swf","images/flash/industrial_building.swf","images/flash/office_building.swf","images/flash/residential_buildings.swf","images/flash/storage.swf")

imgCt = myPix.length

	if (document.images){
		randomNum = Math.floor((Math.random() * imgCt))
		document.writeln('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" name="myFlashFile" width="353" height="186" id="myFlashFile">')
      	document.writeln('<param name="movie" value="' + myPix[randomNum] + '">')
      	document.writeln('<param name="quality" value="high">')
      	document.writeln('<embed src="' + myPix[randomNum] + '" width="353" height="186" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" name="myFlashFile"></embed>')
		document.writeln('</object>')
		}
}
//-->


//random images if no Flash


function choosePics(){

myPics = new Array("images/images/camper_home.jpg","images/images/commercial_building.jpg","images/images/firehouse.jpg","images/images/garages.jpg","images/images/horse_ranch.jpg","images/images/industrial_building.jpg","images/images/office_building.jpg","images/images/small_storage.jpg")

imgCt = myPics.length

	if (document.images){
		randomNum = Math.floor((Math.random() * imgCt))
		document.writeln('<img src="' + myPics[randomNum] + '">')
		}
}

//sniffer
function MM_checkPlugin() { //v4.0
  var ok=false;
  var plgIn = "Shockwave Flash";
  var autoGo = true;
  document.MM_returnValue = false;
  with (navigator) 
  	if (appName.indexOf('Microsoft')==-1 || (plugins && plugins.length)) {
    	ok=(plugins && plugins[plgIn]);
  		} 
	else if (appVersion.indexOf('3.1')==-1) { //not Netscape or Win3.1
    	if (plgIn.indexOf("Flash")!=-1 && window.MM_flash!=null) ok=window.MM_flash;
    	else if (plgIn.indexOf("Director")!=-1 && window.MM_dir!=null) ok=window.MM_dir;
    	else ok=autoGo; }
	if (!ok) {
		//alert('No plug in');
		choosePics();
	}
	else if(ok){
		//alert('Flash available');
		 chooseFlash();
	}
}

	
//registration form validation
function regVal(){
	var firstname = document.frmReg.txtFirstName;
	var lastname = document.frmReg.txtLastName;
	var profession = document.frmReg.cboProfession[document.frmReg.cboProfession.selectedIndex];
	var other = document.frmReg.txtOther;
	var company = document.frmReg.txtCompany;
	var email = document.frmReg.txtEmail;
	var password = document.frmReg.txtPassword;
	var confirmpw = document.frmReg.txtConfirm;
	var phone1 = document.frmReg.txtPhone1;
	var phone2 = document.frmReg.txtPhone2;	
	var phone3 = document.frmReg.txtPhone3;	
	var fax1 = document.frmReg.txtFax1;	
	var fax2 = document.frmReg.txtFax2;
	var fax3 = document.frmReg.txtFax3;
	var altphone1 = document.frmReg.txtAltPhone1;
	var altphone2 = document.frmReg.txtAltPhone2;
	var altphone3 = document.frmReg.txtAltPhone3;
	var address = document.frmReg.txtAddress;
	var city = document.frmReg.txtCity;
	var state = document.frmReg.cboState[document.frmReg.cboState.selectedIndex];
	var zip = document.frmReg.txtZip;
	var country = document.frmReg.cboCountry[document.frmReg.cboCountry.selectedIndex];

	if (firstname.value==""){
		alert("Please enter your first name.");
		firstname.focus();
		return false;
		}
	if (lastname.value==""){
		alert("Please enter your last name.");
		lastname.focus();
		return false;
		}
	if (profession.value=="Other" && other.value==""){
		alert("You selected \"Other\" as your profession.\nPlease enter what your profession is.");
		other.focus();
		return false;
		}
	/*if (profession.value=="" && other.value!=""){
		//alert("hey");
		eval("other.value=='tt'");
		return false;
		}	*/	
	if (!validEmail(email.value)) {
		alert("Please enter a valid e-mail address")
		email.focus()
		email.select()
		return false;
		}
	if (password.value==""){
		alert("Please enter a password to use for the Metal Building Network.");
		password.focus();
		return false;
		}
	if (confirmpw.value==""){
		alert("Please re-enter your password for confirmation.");
		confirmpw.focus();
		return false;
		}
	if (password.value != confirmpw.value){
		alert("Your password and confirmation do not match.");
		password.focus();
		password.select();
		return false;
		}
	if (phone1.value == "" || isNaN(phone1.value) || phone1.value.length < 3){
		alert('Please enter a valid area code.');
		phone1.focus();
		phone1.select();
		return false;
		}
	if (phone2.value == "" || isNaN(phone2.value) || phone2.value.length < 3){
		alert('Please enter phone exchange.');
		phone2.focus();
		phone2.select();
		return false;
		}
	if (phone3.value == "" || isNaN(phone3.value) || phone3.value.length < 4){
		alert('Please a valid phone number.');
		phone3.focus();
		phone3.select();
		return false;
		}
	if (address.value==""){
		alert("Please enter your address.");
		address.focus();
		return false;
		}
	if (city.value==""){
		alert("Please enter your city name.");
		city.focus();
		return false;
		}
	if (state.value==""){
		alert("Please select your State or Province.");
		document.frmReg.cboState.focus();
		return false;
		}
	if (zip.value == "" || zip.value.length < 5 || isNaN(zip.value)){
		alert("Please enter a valid zip code.");
		zip.focus();
		zip.select();
		return false;
		}
	if (country.value==""){
		alert("Please select your country.");
		document.frmReg.cboCountry.focus();
		return false;
		}
	return true;
}

function valNewClassified(){
	var section = document.frmAddAd.cboSection[document.frmAddAd.cboSection.selectedIndex];
	var firstname = document.frmAddAd.txtFname;
	var lastname = document.frmAddAd.txtLname;
	var position = document.frmAddAd.txtPosition;
	var companyname = document.frmAddAd.txtCompany;
	var address = document.frmAddAd.txtAddress;
	var city = document.frmAddAd.txtCity;
	var state = document.frmAddAd.txtState;
	var zip = document.frmAddAd.txtZip;
	var phone1 = document.frmAddAd.txtPhone1;
	var phone2 = document.frmAddAd.txtPhone2;
	var phone3 = document.frmAddAd.txtPhone3;
	var desc = document.frmAddAd.memDescription;
	
	if (section.value==""){
		alert("Please select what section of the classifieds you wish to post to.");
		document.frmAddAd.cboSection.focus();
		return false;
		}	
	if (firstname.value==""){
		alert("Please enter your first name.");
		firstname.focus();
		return false;
		}
	if (lastname.value==""){
		alert("Please enter your last name.");
		lastname.focus();
		return false;
		}
	if (position.value==""){
		alert("Please enter the name of your posting.");
		position.focus();
		return false;
		}
	if (companyname.value=="") {
		alert("Please enter the name of your company.");
		companyname.focus();
		return false;
		}
	if (address.value==""){
		alert("Please enter the address of your business.");
		address.focus();
		return false;
		}
	if (city.value==""){
		alert("Please enter you city name.");
		city.focus();
		return false;
		}
	if (state.value==""){
		alert("Please enter your state.");
		state.focus();
		return false;
		}
	if (zip.value == "" || zip.value.length < 5 || isNaN(zip.value)){
		alert("Please enter a valid zip code.");
		zip.focus();
		zip.select();
		return false;
		}
	if (phone1.value == "" || isNaN(phone1.value) || phone1.value.length < 3){
		alert("Please enter a valid area code.");
		phone1.focus();
		phone1.select();
		return false;
		}
	if (phone2.value == "" || isNaN(phone2.value) || phone2.value.length < 3){
		alert("Please enter phone exchange.");
		phone2.focus();
		phone2.select();
		return false;
		}
	if (phone3.value == "" || isNaN(phone3.value) || phone3.value.length < 4){
		alert("Please a valid phone number.");
		phone3.focus();
		phone3.select();
		return false;
		}
	if (desc.value == "") {
		alert("Please enter a description for your ad placement.")
		desc.focus();
		return false;
		}
		return true;
}

function getThisYear(){
	var mydate=new Date()
	var year=mydate.getYear()
	if (year < 1000)
		year+=1900

	document.write(year)
	}