/*	var sDiv=""
	var inEm = 10
	var mClick = 1

function pndo(x, portal, button)
{
	if(mClick==1)
	{
		sDiv = x;

		if (sDiv.style.height=="auto")
		{
			sDiv.style.height="10em";
			sDiv.style.overflow="hidden"
			button.src = "/images/expand_btn.gif";
			button.alt = "Expand";
		}
		else
		{
			pndoAn(x)
			button.src = "/images/close_btn.gif";
			button.alt = "Close";
		}
	}
}

function pndoAn(){
	if (sDiv.offsetHeight < (sDiv.scrollHeight-10))
	{
		sDiv.style.height=(inEm + "em")
		inEm+=1.4;
		setTimeout("pndoAn()","10")
	}
	else
	{
		sDiv.style.height="auto";
		sDiv.style.overflow="visible"
		inEm = 10;
	}
}
*/

/*
function cancelClick(e){
		if (window.event){
			window.event.cancelBubble = true;
			window.event.returnValue = false;
			return;
		}
		if (e){
			e.stopPropagation();
			e.preventDefault();
		}
	}
*/
function dateCheck(month,day,form,update)
	{
	if(month.value == 'XX')
		{
			alert("Please select a ship month.");
		return false;
		}
	else if(day.value == 'XX')
		{
		alert("Please select a ship day.");
		return false;
		}
	else update.disabled=true;form.submit();
	}
function changeBG(){
 	for(var i = 1; i < arguments.length; i++)
		{
		if(document.getElementById||(document.all && !(document.getElementById)))
			{
 		    arguments[i].style.background = "url(images/colors/" + arguments[0] + "_empty_label_frame.gif)";
			}
		}

 }
function changeButtonBG(){
 	for(var i = 1; i < arguments.length; i++)
		{
		if(document.getElementById||(document.all && !(document.getElementById)))
			{
 		    arguments[i].style.background = "url(images/colors/" + arguments[0] + "_empty_lf_sm.gif)";
			}
		}

 }

function ImgSwap(img, bit,clr)
	{
	img.src ="images/nav/" + img.name + (!bit ? "" : (clr == 'gy' ? 3 : 2)) + ".gif";
	}


function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function checkall(runit)
	{
	switch(runit)
		{
		case 1:
			fldArray = new Array("frm_email","email",false,"frm_first_name","fname",false,"frm_last_name","lname",false,"frm_address_1", "blank", false,"frm_city","blank",false,"frm_state","blank",false,"frm_message","blank",false);
			break;
		case 2:
			var placebid = getObject("frm_place_bid");
			var placeinquiry = getObject("frm_place_inquiry");
			var request_rate = getObject("frm_request_rate");
			var bidamount = getObject("frm_bid_amount");
			var inquirytext = getObject("frm_inquiry_text");
                        var tr = getObject("tr_orig");


			if(isEmpty(bidamount.value)) {
				// trucker bid placing for gartran
                                warnInvalid(bidamount, "Please enter a bid rate or amount.");
                                return false;
                        } else {
                            if(!isEmpty(tr.value)){
                            // stripout any non numeric characters
                            bidamt = stripAlphaChars(bidamount.value);
                                if(bidamt>tr.value) {
                                    warnInvalid(bidamount,'Rate must be below or equal to original rate.');
                                    return false;
                                }
                            }
                        }
			fldArray = new Array("frm_email","email",false,"frm_first_name","fname",false,"frm_last_name","lname",false,"frm_phone", "phone",true);
			break;

		default:
			fldArray = new Array("frm_email","email",false);
			break;
		}

	for (x = 0; x < fldArray.length; x++)
		{
		a_obj = fldArray[x];
		x++;
		a_type = fldArray[x];
		x++;
		a_isEmptyOK = fldArray[x];
		if (!checkVal(a_obj, a_type, a_isEmptyOK))
			return false;
		}

	}
function stripAlphaChars(pstrSource) 
{ 
    var m_strOut = new String(pstrSource); 
        m_strOut = m_strOut.replace(/[\$]/g, ''); 

    return m_sOut; 
}
function getObject(objectId) {
    // cross-browser function to get an object's style object given its id
    if(document.getElementById && document.getElementById(objectId)) {
	// W3C DOM
	return document.getElementById(objectId);
	} else if (document.all && document.all(objectId)) {
	// MSIE 4 DOM
	return document.all(objectId);
    } else if (document.layers && document.layers[objectId]) {
	// NN 4 DOM.. note: this won't find nested layers
	return document.layers[objectId];
    } else {
	//for(i=0; i < document.layers.length; i++)
	//	{
	return false;
    }
} // getStyleObject

function changeObjectVisibility(objectId, newVisibility) {
    // get a reference to the cross-browser style object and make sure the object exists
    var styleObject = getObject(objectId);
    if(styleObject) {
	//alert(styleObject);
	styleObject.style.visibility = newVisibility;
	return true;
    } else {
	// we couldn't find the object, so we can't change its visibility
	//alert ("nope");
	return false;
    }
} // changeObjectVisibility

// global error messages
var REQUIRED = "You must fill in all required information.";
var PASSWD = "Please enter a password of at least 6 characters.";
var PASS_MATCH = "Your passwords do not match.";
var EMAIL = "Please enter a valid email address.";
var BAD_PHONE = "Please enter a valid phone number.";
var F_NAME = "Please enter your first name.";
var L_NAME = "Please enter your last name.";
var STATE = "Please enter a US state in postal format.\n (i.e. CA for California)";
var ZIP = "Please enter a valid US zip code\n (i.e. 11111 or 11111-2222)";
// check form values
function checkVal(obj, type, OKifEmpty)
	{
	var str;
	var str2;
	if(obj == "passwords")
		{
		str = getObject("password");
		str2 = getObject("password2");
		}
	else
		str = getObject(obj);

	switch(type)
		{
		case "blank":
			if(isWhitespace(str.value))
				{
				warnInvalid(str, "Please enter a value.");
				return false;
				}
			else
				return true;
			break;

		case "state":
			if(isEmpty(str.value))
				{
				if(OKifEmpty)
					{
					return true;
					}
				else
					{
					warnInvalid(str, STATE);
					return false;
					}
				break;
				}
			else if(!isStateCode(str.value.toUpperCase()))
				{
				warnInvalid(str, STATE);
				return false;
				}
			else
				str.value=str.value.toUpperCase();
				return true;
			break;
		case "zip":
			var zip = stripCharsNotInBag (str.value, digits);
			if(isEmpty(zip))
				{
				if(OKifEmpty)
					{
					return true;
					}
				else
					{
					warnInvalid(str, ZIP);
					return false;
					}
				break;
				}
			else if(!isZIPCode(zip))
				{
				warnInvalid(str, ZIP);
				return false;
				}
			else
				{
				str.value = reformatZIPCode (zip);
				return true;
				}
			break;
		case "password":
			if(isWhitespace(str.value))
				{
				warnInvalid(str, PASSWD);
				return false;
				}
			else if(!isCorrectSize(str.value, 6, 10))
				{
				warnInvalid(str, PASSWD);
				return false;
				}
				else if(str.value != str2.value)
					{
					warnInvalid(str, PASS_MATCH);
					return false;
					}
				else
					{
					return true;
					}
				break;

		case "email":
			var email = str.value;
			if(isEmpty(email))
				{
				if(OKifEmpty)
					{
					return true;
					}
				else
					{
					warnInvalid(str, EMAIL);
					return false;
					}
				break;
				}
			else if(!isEmail(email))
					{
					warnInvalid(str, EMAIL);
					return false;
					}
				else
					{
					return true;
					}
				break;

		case "phone":
			var phone_num = stripCharsNotInBag (str.value, digits);
			if(isEmpty(phone_num))
				{
				if(OKifEmpty)
					{
					return true;
					}
				else
					{
					warnInvalid(str, BAD_PHONE);
					return false;
					}
				}
			else if(!isUSPhoneNumber(phone_num))
				{
				//alert(phone_num);
				warnInvalid(str, BAD_PHONE);
				return false;
				}
			else
				{
				str.value = reformatUSPhone (phone_num)
				return true;
				}
			break;
		case "intphone":
			var phone_num = stripCharsNotInBag (str.value, digits);
			if(isEmpty(phone_num))
				{
				if(OKifEmpty)
					{
					return true;
					}
				else
					{
					warnInvalid(str, BAD_PHONE);
					return false;
					}
				}
			else if(!isInternationalPhoneNumber(phone_num))
				{
				//alert(phone_num);
				warnInvalid(str, BAD_PHONE);
				return false;
				}
			else
				{
				str.value = "+" + phone_num;
				return true;
				}
			break;
		case "fname":
			if (isEmpty(str.value))
				{
				if(OKifEmpty)
					{
					return true;
					}
				else
					{
					warnInvalid(str, F_NAME);
					return false;
					}
				break;
				}
			else if (isWhitespace(str.value))
				{
				warnInvalid(str, F_NAME);
				return false;
				}
			else
				return true;
			break;
		case "lname":
			if (isEmpty(str.value))
				{
				if(OKifEmpty)
					{
					return true;
					}
				else
					{
					warnInvalid(str, L_NAME);
					return false;
					}
				}
			else if (isWhitespace(str.value))
				{
				warnInvalid(str, L_NAME);
				return false;
				}
			else
				return true;
			break;

		default:
			break;
		}
	}

// blank all text fields in a form
 function clearForm(formid)
	{
	formid = getObject(formid);
	formid.reset();
	/*for(i=0; i<formid.elements.length; i++)
		{
		if(formid.elements[i].type == "text" || formid.elements[i].type == "password")
			formid.elements[i].value = "";
		}
	*/
	}
