


function trap() 
{
}
function CCValidation(source, args) 
{ 
	args.IsValid = document.getElementById("cbCCAgree").checked; 
}
function CCSValidation(source, args) 
{ 
	args.IsValid = document.getElementById("cbCCSAgree").checked; 
}
function Net30Validation(source, args) 
{ 
	args.IsValid = document.getElementById("cbNet30Agree").checked; 
}

function Search()
{
	if (document.getElementById("q").value == "")
	{
		alert("Search box is empty.");
		return false;
	}
	else
	{
		var searchdata = document.getElementById("q");
		var querystring = "ListModelParts.aspx?q=" + escape(searchdata.value);
		url=querystring;
		location.href = url;
		return true;
	}
}
function CheckBoth()
{
	var pid = "txtPID";
	var qty = "txtQty";
	error = false;
	for (i=1; i <= 10; i++)
	{
		if (document.getElementById(pid + parseInt(i)).value != "" && document.getElementById(qty + parseInt(i)).value == "")
		{
			//alert(pid + parseInt(i));
			error = true;
			document.getElementById("row" + parseInt(i)).style.backgroundColor = "#FFCCCC";
		}
		else if (document.getElementById(pid + parseInt(i)).value == "" && document.getElementById(qty + parseInt(i)).value != "")
		{
			//alert(pid + parseInt(i));
			error = true;
			document.getElementById("row" + parseInt(i)).style.backgroundColor = "#FFCCCC";
		}
		else
		{
			document.getElementById("row" + parseInt(i)).style.backgroundColor = "#ffffe5";
		}
	}
	if (error)
	{
		var errbox = confirm("Both Product ID and Quantity must have values!\nClick \"OK\" to exclude the lines and continue OR\nClick \"Cancel\" to correct them");
		return errbox;
	}	
}
function quantity(obj)
{
	priceInput = obj.id.replace(/txtQty/, "hidePID");
	priceSpan = obj.id.replace(/txtQty/, "pricePID");
	totalSpan = obj.id.replace(/txtQty/, "totPID");
	
	if (document.getElementById(priceSpan).innerHTML != "Part not found." && document.getElementById(priceSpan).innerHTML != "")
	{
		price = document.getElementById(priceInput).value;
		price = price.replace("$", "");
		cost = parseFloat(price);
		qty = parseFloat(obj.value);
		totalcost = cost * qty;
		totalcost = CurrencyFormatted(totalcost);
		document.getElementById(totalSpan).innerHTML = "$" + totalcost;
		return true;
	}
	else
	{
		return false;
	}
}
function CurrencyFormatted(amount)
{
	var i = parseFloat(amount);
	if(isNaN(i)) { i = 0.00; }
	var minus = '';
	if(i < 0) { minus = '-'; }
	i = Math.abs(i);
	i = parseInt((i + .005) * 100);
	i = i / 100;
	s = new String(i);
	if(s.indexOf('.') < 0) { s += '.00'; }
	if(s.indexOf('.') == (s.length - 2)) { s += '0'; }
	s = minus + s;
	return s;
}

