function validate_required(field,alerttxt){

	with(field){

		if(value==null || value==""){

			alert(alerttxt)

			return false;

		}

		else {

			return true

		}

	}

}

function validate_email(field, alerttxt){

	with(field){

		apos=value.indexOf("@")

		dotpos=value.lastIndexOf(".")

		if(apos<1 ||dotpos<2){

			alert(alerttxt)

			return false

		}

		else {

			return true

		}

	}

}

function validate_checkbox(field){

	with(field){

		if(!checked){

			return false

		}

		else {

			return true

		}

	}

}

function validate_select(field,alerttxt){

	with(field){

		if(value=="NS" || value==null){

			alert(alerttxt)

			return false

		}

		else{

			return true

		}

	}

}

function validateNewsLetter(thisForm) {

	with(thisForm){

		if(validate_required(name,"Name must be filled out!")==false){

			email.focus();

			return false;

		}

		if(validate_email(email,"Not a valid e-mail address!")==false){

			email.focus();

			return false;

		}

		if((validate_checkbox(tech)==false) && (validate_checkbox(news)==false)){

			alert("Please check one of the types of newsletters!");

			newsconfirm.focus();

			return false;

		}

		if(validate_checkbox(newsconfirm)==false){

			alert("Please select: 'Yes, I would like to recieve the above checkedmarked items!'");

			newsconfirm.focus();

			return false;

		}

	}

}



function validateRegister(thisForm) {

	with(thisForm){

		if(validate_required(name,"Name must be filled out!")==false){

			name.focus();

			return false;

		}

		if(validate_required(location,"Location must be filled out!")==false){

			email.focus();

			return false;

		}

		if(validate_required(address,"Address must be filled out!")==false){

			email.focus();

			return false;

		}

		if(validate_required(city,"City must be filled out!")==false){

			email.focus();

			return false;

		}

		if(validate_required(state,"State must be filled out!")==false){

			email.focus();

			return false;

		}

		if(validate_required(zip,"Zip must be filled out!")==false){

			email.focus();

			return false;

		}

		if(validate_required(phone,"Phome Number must be filled out!")==false){

			email.focus();

			return false;

		}

		if(validate_email(email,"Email must be filled out!")==false){

			email.focus();

			return false;

		}

		if(validate_select(companyType,"Select a Company Type!")==false){

			email.focus();

			return false;

		}

		if(validate_required(password,"Password must be filled out!")==false){

			email.focus();

			return false;

		}

	}

}



function validateBasys(thisForm){

	with(thisForm){

		if(validate_required(username,"Name must be filled out!")==false){

			email.focus();

			return false;

		}

		if(validate_required(password,"Password must be filled out!")==false){

			email.focus();

			return false;

		}

	}

}



function validateSpareInAir(thisForm){

	with(thisForm){

		if(validate_checkbox(keep,"Name must be filled out!")==false){

			email.focus();

			return false;

		}

		else if(validate_checkbox(returnComponent,"Password must be filled out!")==false){

			email.focus();

			return false;

		}

	}

}



function checkAuthorize(){

	if(document.orderForm.authorize_name.value !=''){

		if(document.orderForm.authorize.checked == true)

			document.orderForm.submit();

		else

			alert("Please check the Authorized box to complete form.");

	}

	else

		alert("Please print your name as an Authorized Signature");

		

}



function address(){

	if(document.orderForm.sameAddress.checked == true){

		document.orderForm.shipLocation.value = document.orderForm.billLocation.value;

		document.orderForm.shipAddress.value = document.orderForm.billAddress.value;

		document.orderForm.shipCity.value = document.orderForm.billCity.value;

		document.orderForm.shipState.value = document.orderForm.billState.value;

		document.orderForm.shipZip.value = document.orderForm.billZip.value;

		document.orderForm.shipName.value = document.orderForm.billName.value;

		document.orderForm.shipPhone.value = document.orderForm.billPhone.value;

		document.orderForm.shipFax.value = document.orderForm.billFax.value;

	}

	else{

		document.orderForm.shipLocation.value = '';

		document.orderForm.shipAddress.value = '';

		document.orderForm.shipCity.value = '';

		document.orderForm.shipState.value = '';

		document.orderForm.shipZip.value = '';

		document.orderForm.shipName.value = '';

		document.orderForm.shipPhone.value = '';

		document.orderForm.shipFax.value = '';

	}

}



function calculateTotal(qty, price, output){

	var quantity = eval(document.getElementById(qty).value);

	var unitPrice = eval(price);

	var total = quantity * unitPrice;
	
	//if( document.getElementById(output).value > 0 )
		document.getElementById('orderTotal').value = document.getElementById('orderTotal').value - document.getElementById(output).value;
		
	document.getElementById(output).value = total.toFixed(2);

	var orderTotal = eval(document.getElementById('orderTotal').value);

	orderTotal = orderTotal + total;

	document.getElementById('orderTotal').value = orderTotal.toFixed(2);

}



function correctHeight(){

	

	var myheight = document.getElementById('div1').offsetHeight;

	

	if(document.getElementById('masterDiv')){

		if(document.getElementById('div1').offsetHeight > document.getElementById('sidebarContainer').offsetHeight){

			document.getElementById('sidebarContainer').style.height = myheight+'px;';

		}

	}

}