function postto(URL){
    // Posts to a specified url
    document.f_form.action = URL;
    document.f_form.submit();
}

function fn_ClearQS(RefreshCode){
	// User wants to clear a quick search and return the default searchpd method
	document.f_search.fields_1.value = 0;
	document.f_search.fields_2.value = 0;
	document.f_search.fields_3.value = 0;
	document.f_search.fields_4.value = 0;
	document.f_search.pd_fields_1.selectedIndex = 0;
	document.f_search.pd_fields_2.selectedIndex = 0;
	document.f_search.pd_fields_3.selectedIndex = 0;
	document.f_search.pd_fields_4.selectedIndex = 0;
	document.f_search.relation_1.value = 0;
	document.f_search.relation_2.value = 0;
	document.f_search.relation_3.value = 0;
	document.f_search.relation_4.value = 0;
	document.f_search.pd_relation_1.selectedIndex = 0;
	document.f_search.pd_relation_2.selectedIndex = 0;
	document.f_search.pd_relation_3.selectedIndex = 0;
	document.f_search.pd_relation_4.selectedIndex = 0;
	document.f_search.value_1.value = '';
	document.f_search.value_2.value = '';
	document.f_search.value_3.value = '';
	document.f_search.value_4.value = '';
	document.f_search.andor_2.value = 0;
	document.f_search.andor_3.value = 0;
	document.f_search.andor_4.value = 0;
        document.f_search.andor_2.selectedIndex = 0;
        document.f_search.andor_3.selectedIndex = 0;
        document.f_search.andor_4.selectedIndex = 0;
        document.f_search.qs_lines.value = '1';

	eval(RefreshCode);
}

function fn_AddQS(){
  // User wishes to add a Quick search line to the collection
  if(document.f_search.qs_lines.value <4){
    // There is room for another line
    document.f_search.qs_lines.value = parseInt(document.f_search.qs_lines.value) + 1;
    // Display this line
    var ElemID = 'qs_row_'+document.f_search.qs_lines.value;
    var qsrow = document.getElementById(ElemID);
    qsrow.style.display = 'inline';
  }
}

function fn_DelQSLine(TheLine,RefreshCode){
  // User wishes to delete a line from the quick search
  if(TheLine <= parseInt(document.f_search.qs_lines.value)){
    // OK to delete this line
    // Clear out its values first
    // The refresh of the QS area will therefore delete it
    var pdElemID = 'pd_fields_'+parseInt(TheLine);
    var fldElemID = 'fields_'+parseInt(TheLine);

    var qsrow = document.getElementById(pdElemID);
    var qsvalue = document.getElementById(fldElemID);
    qsrow.selectedIndex = 0;
    qsvalue.value = '';

    eval(RefreshCode);

  }
}

function fn_RecalcProdDetailTotal(){
    // Recalculates the total price of a product
    // based on base price + selected options
    var line_value = 0;
    for(var i=1; i<= parseFloat(document.f_form.no_options.value);i++){
        eval("var unit_value = parseFloat(document.f_form.unit_"+i+".value);");
        eval("var qty = parseFloat(document.f_form.qty_"+i+".value);");
        line_value = line_value + (unit_value * qty);
    }
    line_value = parseFloat(document.f_form.base_system_price.value)+line_value;
    fn_RedisplayTotal(line_value);
}

function fn_RedisplayTotal(theTotal){
    // Redisplays the total on the form (after recalc)
    document.getElementById("tot_price").innerHTML = formatCurrency(theTotal);
}

function formatCurrency(num) {
    num = num.toString().replace(/\$|\,/g,'');
    if(isNaN(num))
        num = "0";

    sign = (num == (num = Math.abs(num)));
    num = Math.floor(num*100+0.50000000001);
    cents = num%100;
    num = Math.floor(num/100).toString();

    if(cents<10)
        cents = "0" + cents;

    for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
        num = num.substring(0,num.length-(4*i+3))+','+
                num.substring(num.length-(4*i+3));

    return (((sign)?'':'-') + '$' + num + '.' + cents);
}

function fn_ChangeOptionQty(SessionID,SystemID,OptionID,LineNo,qty){
    // User wants to change quantities etc for an order
    eval("var orig_qty = parseFloat(document.f_form.qty_"+LineNo+".value);");
    var new_qty = orig_qty + qty;
    if(new_qty < 0){
        new_qty = 0;
    }
    document.getElementById("dispqty_"+LineNo).innerHTML = new_qty;
    eval("document.f_form.qty_"+LineNo+".value = new_qty;");

    // Final calcs
    fn_RecalcProdDetailTotal();
}

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) {
		areyjones_07_over = newImage("/images/areyjones/areyjones_07-over.gif");
		areyjones_08_over = newImage("/images/areyjones/areyjones_08-over.gif");
		areyjones_09_over = newImage("/images/areyjones/areyjones_09-over.gif");
		areyjones_10_over = newImage("/images/areyjones/areyjones_10-over.gif");
		preloadFlag = true;
	}
}


function fn_PlaceOrder(){
	// Places this order
	if(document.f_summary.UsedFor.value != ''){
		// All OK...
		document.f_summary.action = '/Order/place_order';
		document.f_summary.submit();	
	}else{
		// No Used For value entered
		alert("Please enter what this system will be used for.");
	}
}

function fn_PDF(){
	// User wants a PDF of this order
	if(document.f_summary.UsedFor.value != ''){
		// All OK...
		document.f_summary.action = '/Order/pdf_order/';
		document.f_summary.submit();	
	}else{
		// No Used For value entered
		alert("Please enter what this system will be used for.");
	}
}

function fn_BCPDF(OrderNo,SessionID){
	// User wants to generate a PDF of the order (Baldwin specific version)
	document.f_summary.action = '/Order/pdf_order/'+SessionID+'/'+OrderNo;
	document.f_summary.submit();		
}

function fn_Login(){
	// User wants to login to the system
	if(document.f_login.vt_LoginID.value != ''){
		if(document.f_login.vt_Password.value != ''){
			if(document.f_login.vt_CustNo.value != ''){
				// All looks good... Post it
				document.f_login.submit();
			}else{
				alert("Please enter your Account No");
			}
		}else{
			alert("Please enter your password");
		}
	}else{
		alert("Please enter your login ID");
	}
}

function fn_SaveBrand(){
	// User wants to save their Brand Entries
	if(document.f_update.brand_name.value != ''){
		// OK to save
		document.f_update.submit();
	}else{
		alert("Please enter a name for the Brand");
	}
}

function fn_SaveSystem(){
	// User wants to save their system entry
	if(document.f_update.system_title.value != ''){
		if(document.f_update.system_brand.value != 'Select'){
			if(document.f_update.system_type.value != 'Select'){
				// All looks good... submit			
				document.f_update.submit();
			}else{
				// No system type selected
				alert("Please select a system type");
			}
		}else{
			// No system brand selected
			alert("Please select a brand");
		}
	}else{
		// No System Title entered
		alert("Please enter a System Title");
	}
}

function fn_SaveOption(){
	// User wants to save their system option entry
	if(document.f_update.option_shortdesc.value != ''){
		if(document.f_update.option_longdesc.value != ''){
			if(document.f_update.option_system.value != 'Select'){
				if(document.f_update.option_type.value != 'Select'){
					// All looks good... submit
					document.f_update.submit();
				}else{
					// No type selected
					alert("Please select an option type");
				}
			}else{
				// No system selected
				alert("Please select the applicable system");
			}
		}else{
			// No Long Desc entered
			alert("Please enter a long description");
		}
	}else{
		// No Short Desc entered
		alert("Please enter a short description");
	}
}

function fn_SaveAccessory(){
	// User wants to save their accessory entry
	if(document.f_update.system_title.value != ''){
		if(document.f_update.system_brand.value != 'Select'){
                        // All looks good... submit
                        document.f_update.submit();
		}else{
			// No system brand selected
			alert("Please select a brand");
		}
	}else{
		// No System Title entered
		alert("Please enter a System Title");
	}
}

function fn_Refresh(){
	// General function to refresh the current form with the current HREF action string + 'R' at the end
	document.f_update.action = top.location.href + '/R';
	document.f_update.submit();
}

function fn_DisplayButtonMsg(ConfirmAlert,MsgField,AdditionalMsg){
       // ConfirmAlert = 0 for Alert   message
       //              = 1 for Confirm message
       //              = 2 for Request message
       // Replace  "|" with a new line (carage return) in the displayed message
       // Boolean is returned
       //Replace the | delimitor with a new line
       var Msg;
       NumOfArguments=fn_DisplayButtonMsg.arguments.length;
       Msg = MsgField;
       var MsgArray = Msg.split("|");
       ArraySize = MsgArray.length;
       Msg = "";
        for(i=0;i<ArraySize;i++){
           var Msg = Msg + MsgArray[i]+"\n";
           }
        if(NumOfArguments>2){
           Msg =Msg+AdditionalMsg;}

        if(ConfirmAlert==0){
          return alert(Msg);}

        if(ConfirmAlert==1){
           return confirm(Msg);}

        if(ConfirmAlert==2){
           return window.prompt(Msg,"");
		}
}

function fn_DeleteConfirm(ConfirmMsg){
	// Confirm a delete
	return fn_DisplayButtonMsg(1,ConfirmMsg,'');
}

function fn_DeleteOption(a_client_no){
	// The user has requested to delete an option
	if(fn_DeleteConfirm('Please confirm to delete the selected option')){
		// User has confirmed the delete
		document.f_update.action = '/Admin/deleteOption/'+a_client_no+'/'+document.f_update.option_id.value;
		document.f_update.submit();
	}
}

function fn_DeleteSystem(a_client_no){
	// The user has requested to delete an option
	if(fn_DeleteConfirm('Please confirm to delete the selected system')){
		// User has confirmed the delete
		document.f_update.action = '/Admin/deleteSystem/'+a_client_no+'/'+document.f_update.system_id.value;
		document.f_update.submit();
	}
}

function fn_DeleteAccessory(a_client_no){
	// The user has requested to delete an option
	if(fn_DeleteConfirm('Please confirm to delete the selected accessory')){
		// User has confirmed the delete
		document.f_update.action = '/Admin/deleteAccessories/'+a_client_no+'/'+document.f_update.system_id.value;
		document.f_update.submit();
	}
}


function fn_PlaceOrder(){
	// Places this order
	if(document.f_summary.UsedFor.value != ''){
		// All OK...
		document.f_summary.action = '/Order/print_order/'+document.f_session.sesionid.value+'/'+document.f_summary.vBrandID.value+'/'+document.f_summary.vTypeID.value+'/'+document.f_summary.vSysID.value;
		document.f_summary.submit();	
	}else{
		// No Used For value entered
		alert("Please enter what this system will be used for.");
	}
}

function fn_Print(){
		// Ready to print
	   bV = parseInt(navigator.appVersion)
	   if (bV >= 4){
	   	 window.print();
		}else{
			alert("Your browser is not compatible with printing this page.  Select PRINT from the File menu on your browser to print this document.");
		}
}

function fn_PDF(){
	// User wants a PDF of this order
	if(document.f_summary.UsedFor.value != ''){
		// All OK...
		document.f_summary.action = '/Order/pdf_order/'+document.f_session.sessionid.value;
		document.f_summary.submit();	
	}else{
		// No Used For value entered
		alert("Please enter what this system will be used for.");
	}
}

function fn_PrintOrder(SessionID,OrderNo){
	// User wants to print an order - do this in a clean window
	
	// Now open in its own window
	//alert("The URI bit to work with is "+URIString.value+" and the args are "+URIString.value.substring(23));
	winref = window.open('/Order/printorder/'+SessionID+'/'+OrderNo,'mywin','left=70,top=70,width=700,height=500,toolbar=1,resizable=0,scrollbars');
}

function fn_UploadPriceList(){
    // User wants to submit the upload price list page
    if(document.f_upload_pricelist.system_brand[document.f_upload_pricelist.system_brand.selectedIndex].value != 'Select'){
        if(document.f_upload_pricelist.system_type[document.f_upload_pricelist.system_type.selectedIndex].value != 'Select'){
            // Looks ok...
            document.f_upload_pricelist.submit();
        }else{
            alert("Please select a type");
        }
    }else{
        alert("Please select a brand");
    }
}

function fn_DelPriceList(PLNo){
    // User wants to delete a price list
    if(fn_DisplayButtonMsg(1,'Please confirm to delete this price list')){
        document.f_pricelists.action = '/admin/delete_pricelist/'+PLNo;
        document.f_pricelists.submit();
    }
}

function fn_OCILogin(){
	// User wants to login to the system
	if(document.f_login.hook_url.value != ''){
		// All looks good... Post it
		document.f_login.action = '/Welcome';
		document.f_login.submit();
	}else{
		alert("Missing HOOK_URL value");
	}
}

function fn_ValidateClientLogin(){
	// Handles user login validation - designed for LA County but will work with any user/email type starting form
	if(document.f_start.vt_LoginID.value != ''){
		// All ok - begin
		document.f_start.action = '/Welcome/user_start_process';
		document.f_start.submit();
	}else{
		alert("Please enter your email address");
	}
}

function fn_ProcessOrder(){
	// User wants to process their current order
	document.f_summary.action = '/Order/process/'+document.f_session.sessionid.value;
	document.f_summary.submit();
}

function fn_SubmitToSRM(){
	// Submits the current order page to SAP SRM
	if(document.f_ocisummary.action != ''){
		document.f_ocisummary.submit();
	}else{
		alert('Unable to submit order.  No form action found.');
	}
}

function fn_ValidateUserStart(){
	// Handles user login validation - designed for LA County but will work with any user/email type starting form
	if(document.f_start.useremail.value != ''){
		// All ok - begin
		document.f_start.action = '/Welcome/user_start_process';
		if (typeof(vt_LoginID) != "undefined") {
			document.f_start.useremail.value = document.f_start.vt_LoginID.value;
			document.f_start.userpassword.value = document.f_start.vt_Password.value;	
		}
		document.f_start.submit();
	}else{
		alert("Please enter your email address");
	}
}

function fn_ValidateUserOrderLogin(){
	// Handles user login validation - designed for LA County but will work with any user/email type starting form
	if(document.f_form.vt_CustEmail.value != ''){
		// All ok - begin
		document.f_form.action = '/Welcome/user_login_checkout/'+document.f_form.SessionID.value+'/'+document.f_form.cart_no.value;
		document.f_form.submit();
	}else{
		alert("Please enter your email address");
	}
}

function fn_BCCompleteOrder(){
	// User wants to complete an order
	if(document.f_summary.vt_Memo.value != ''){
		if(document.f_summary.vt_School.value != ''){
			if(fn_DisplayButtonMsg(1,document.f_summary.ConfMsg.value)){
				document.f_summary.action = '/Order/complete_order/'+document.f_summary.SessionID.value+'/'+document.f_summary.CartNo.value;
				document.f_summary.submit();
			}
		}else{
			alert("Please enter the School Site & Contact Name");
		}
	}else{
		alert("Please enter your intended usage information");
	}
}

function fn_LAUSDCompleteOrder(){
	// User wants to complete an order
        var vt_UsedForValueFld = document.getElementById("UsedForid");
	if(vt_UsedForValueFld.value != ''){
            if(fn_DisplayButtonMsg(1,'Please confirm to finalize this quotation')){
                    document.f_summary.UsedFor.value = vt_UsedForValueFld.value;
                    document.f_summary.action = '/Order/complete_order/'+document.f_summary.SessionID.value+'/'+document.f_summary.CartNo.value;
                    document.f_summary.submit();
            }
	}else{
            alert("Please enter your intended usage information");
	}
}

function fn_CompleteOrder(){
	// User wants to complete an order
	if(fn_DisplayButtonMsg(1,'Please confirm to finalize this quotation')){
		document.f_summary.action = '/Order/complete_order/'+document.f_summary.SessionID.value+'/'+document.f_summary.CartNo.value;
		document.f_summary.submit();
	}
}

function fn_CartDelLine(LineNo){
	// User wants to remove a line from their shopping cart
	if(fn_DisplayButtonMsg(1,'Please confirm to delete the selected line from your shopping cart')){
		// User confirmed
		document.f_summary.action = '/Order/del_line/'+document.f_summary.SessionID.value+'/'+LineNo;
		document.f_summary.submit();
	}
}

function fn_KeepShopping(){
	// User wants to return to the start of the shopping process again
	document.f_summary.action = '/Order/keep_shopping/'+document.f_summary.SessionID.value+'/'+document.f_summary.vBrandID.value;
	document.f_summary.submit();
}

function fn_UpdateQty(LineNo,NewQty){
	// User wants to update the quantity of a line
	document.f_summary.action = '/Order/update_qty/'+document.f_summary.SessionID.value+'/'+LineNo+'/'+NewQty;
	document.f_summary.submit();
}

function fn_ForgotPassword(){
	// User has forgotten their password
	if(document.f_forgot.useremail.value != ''){
		document.f_forgot.action = '/Welcome/forgotpasswordprocess';
		document.f_forgot.submit();
	}else{
		alert("Please enter your email address");
	}
}

function fn_GotoForgotPassword(){
	// User wants to retrieve their password from Order Login page
	document.f_form.action = '/Welcome/forgotpassword';
	document.f_form.submit();
}

function fn_GotoRegisterAccount(){
	// User wants to register a new account
	document.f_form.action = '/Welcome/createaccount';
	document.f_form.submit();
}

function fn_SendTo(URLAddress){
	// For the registration - sends the user to a specified URL as a post
	document.f_form.action = URLAddress;
	document.f_form.submit();
}

function fn_ValidateCreateAccount(){
	// User is submitting a create account request
	if(document.f_customer.cust_email.value != ''){
		if(document.f_customer.cust_pass1.value != ''){
			if(document.f_customer.cust_pass2.value != ''){
				if(document.f_customer.cust_name.value != ''){
					if(document.f_customer.cust_phone.value != ''){
						if(document.f_customer.cust_billaddr.value != ''){
							if(document.f_customer.cust_billcitystate.value != ''){
								if(document.f_customer.cust_billzip.value != ''){
									if(document.f_customer.cust_shipaddr.value != ''){
										if(document.f_customer.cust_shipcitystate.value != ''){
											if(document.f_customer.cust_shipzip.value != ''){
												// check that the passwords match
												if(document.f_customer.cust_pass1.value == document.f_customer.cust_pass2.value){
                                                                                                    if(document.f_customer.auth_code.value != ''){
                                                                                                        if(document.f_customer.auth_code.value.toUpperCase() == 'COR123'){
                                                                                                            // All ok to process
                                                                                                            document.f_customer.action = '/Welcome/createaccountprocess/';
                                                                                                            document.f_customer.submit();
                                                                                                        }else{
                                                                                                            alert("Invalid Authorization code");
                                                                                                        }
                                                                                                    }else{
                                                                                                        alert("Please enter your authorization code");
                                                                                                    }
												}else{
													alert("Your passwords do not match");
												}
											}else{
												alert("Please enter your shipping address zip code");
											}
										}else{
											alert("Please enter your shipping address city & state");
										}
									}else{
										alert("Please enter your shipping address");
									}
								}else{
									alert("Please enter your billing address zip code");
								}
							}else{
								alert("Please enter your billing address city & state");
							}
						}else{
							alert("Please enter your billing address");
						}
					}else{
						alert("Please enter your telephone number");
					}
				}else{
					alert("Please enter your name");
				}
			}else{
				alert("Please re-type in your password");
			}
		}else{
			alert("Please enter your password");
		}
	}else{
		alert("Please enter your email address");
	}
}

function fn_BillToShip(ButtonState){
	// User wants to copy bill address data to ship address
	if(ButtonState){
		// The button is checked
		document.f_customer.cust_shipaddr.value = document.f_customer.cust_billaddr.value;
		document.f_customer.cust_shipcitystate.value = document.f_customer.cust_billcitystate.value;
		document.f_customer.cust_shipzip.value = document.f_customer.cust_billzip.value;
		// Select the appropriate pulldown value
		document.f_customer.cust_shipcountrypd[document.f_customer.cust_shipcountrypd.selectedIndex].value = document.f_customer.cust_billcountrypd[document.f_customer.cust_billcountrypd.selectedIndex].value;
	}
}

function fn_CustServiceBack(){
	// User wants to return to the customer service main menu
	document.f_ordersearch.action = '/Welcome/mainmenu/'+document.f_ordersearch.SessionID.value;
	document.f_ordersearch.submit();
}


function fn_CustServiceStart(){
	// User wants to return to the customer service main menu
	document.f_poreview.action = '/Welcome/mainmenu/'+document.f_poreview.session_id.value;
	document.f_poreview.submit();
}

function fn_DelPOLine(LineNo,PONo){
	// Deletes a Purchase Order Line
	if(fn_DisplayButtonMsg(1,'Please confirm to delete the selected line from the purchase order')){
		document.f_poedit.action = '/Admin/del_line_from_po/'+PONo+'/'+LineNo;
		document.f_poedit.submit();
	}
}

function fn_ValidatePOLine(){
	// Validate the data entry from a PO Line 
	var OKToSubmit = false;
	if(document.f_editpo.line_qty.value >0){
		if(document.f_editpo.line_desc.value != ''){
			if(document.f_editpo.tracking_info.value != ''){
				if(document.f_editpo.ship_carrier.value != 'Select'){
					OKToSubmit = true;
				}else{
					// You can't have a shipping tracking info field without selecting a carrier
					alert("Please select a carrier for the tracking info");
				}
			}else{
				OKToSubmit = true;
			}
			
			if(OKToSubmit){
				// All looks ok - submit the form
				document.f_editpo.action = '/Admin/save_po_line/'+document.f_editpo.line_id.value+'/'+document.f_editpo.po_id.value;
				document.f_editpo.submit();
			}
		}else{
			alert("The line description cannot be blank");
		}
	}else{
		// Line quantity invalid
		alert("Invalid line quantity.  Must be greater than 0");
	}
}

function fn_ValidatePOLineForAdd(){
	// Validate the data entry from a PO Line 
	if(document.f_editpo.line_qty.value >0){
		// Qty is valid - save it
		document.f_editpo.action = '/Admin/save_default_lines/'+document.f_editpo.po_id.value+'/'+document.f_editpo.qty_to_create.value;
		document.f_editpo.submit();
	}else{
		// Line quantity invalid
		alert("Invalid line quantity.  Must be greater than 0");
	}
}

function fn_ValidateNewPO(){
	// Validates the data entry for a new PO 
	var QtyToCreate = 0;
	var SubmitOK = false;
	if(document.f_newpo.vt_PONo.value != ''){
		if(document.f_newpo.ordertype[document.f_newpo.ordertype.selectedIndex].value != 'Select'){
			if(document.f_newpo.vt_LineQty.value != ''){
				QtyToCreate = parseInt(document.f_newpo.vt_LineQty.value);
				// Submit
				SubmitOK = true;
			}else{
				// No line qty provided - assume 0
				QtyToCreate = 0;
				// Submit
				SubmitOK = true;
			}
		}else{
			// No type selected
			alert("Please select a type");
		}
	}else{
		alert("Please enter an Order Number");
	}
	
	if(SubmitOK){
		// Submit the form
		document.f_newpo.action = '/Admin/save_new_po/'+QtyToCreate;
		document.f_newpo.submit();
	}
}

function fn_ConfirmDeletePO(){
	// User wants to delete a PO - validate this first
	if(fn_DisplayButtonMsg(1,'WARNING:  This will delete the entire Purchase Order and is irreversible.  Please confirm that this is exactly what you want to do.')){
		if(fn_DisplayButtonMsg(1,'You are absolutely sure, right?  This is not un-doable.')){
			document.f_poedit.action = '/Admin/delete_entire_po/'+document.f_poedit.po_id.value;
			document.f_poedit.submit();
		}
	}	
}

function fn_ExportPO(){
	// User wants to export a Purchase Order to a CSV file
	document.f_poedit.action = '/Admin/export_po/'+document.f_poedit.po_id.value;
	document.f_poedit.submit();
}

function fn_ValidatePart(){
	// Validates the edit part form
	if(document.f_editpart.part_desc.value != ''){
		// This is ok to save
		document.f_editpart.action = '/Admin/save_part';
		document.f_editpart.submit();
	}else{
		alert("You must enter a Part descrption");
	}
}

function fn_DeletePart(){
	// User wants to delete a part
	if(document.f_editpart.part_id.value != 0){
		if(fn_DisplayButtonMsg(1,'Please confirm to delete this part record.')){
			document.f_editpart.action = '/Admin/del_part/'+document.f_editpart.part_id.value;
			document.f_editpart.submit();
		}
			
	}else{
		alert("You must be editing an existing part to delete it");
	}
}

function fn_ViewCart(SessionID){
	// User wants to view their shopping cart
	document.f_session.action = '/Order/show_shoppingcart/'+SessionID;
	document.f_session.submit();
}

function fn_ViewBCart(SessionID,BrandID){
	// User wants to view their shopping cart
	document.f_session.action = '/Order/show_shoppingcart/'+SessionID+'/'+BrandID;
	document.f_session.submit();
}

function fn_ValidateConflict(){
	// User wants to save a conflict record
	if((document.f_editconflict.option_conflict1.value != '') && (document.f_editconflict.option_conflict1.value != 'Select')){
		if((document.f_editconflict.option_conflict2.value != '') && (document.f_editconflict.option_conflict2.value != 'Select')){
			// We're good - we can save this....
			document.f_editconflict.action = '/Admin/save_conflict';
			document.f_editconflict.submit();
		}else{
			alert("Please select System Option 2");
		}
	}else{
		alert("Please select System Option 1");
	}
}

function fn_DeleteConflict(){
	// User wants to delete a conflict record
	if(document.f_editconflict.conflict_id.value != ''){
		if(fn_DisplayButtonMsg(1,'Please confirm to delete this conflict record.')){
			document.f_editconflict.action = '/Admin/del_conflict/'+document.f_editconflict.conflict_id.value;
			document.f_editconflict.submit();
		}
			
	}else{
		alert("You must be editing an existing conflict to delete it");
	}
}

function fn_LAUSDTrackSubmit(TheOrderNo){
    // User wants to track a purchase order
    if(TheOrderNo.value != ''){
        document.f_form.action = '/custservice/track/'+TheOrderNo.value;
        document.f_form.submit();
    }else{
        alert("Please enter a purchase order number");
    }
}

function fn_LAUSDShowAsset(SerialNo){
    // User wants to look up an asset
    if(SerialNo != ''){
        document.f_assetselect.action = '/custservice/asset_search/serial/'+SerialNo;
        document.f_assetselect.submit();
    }else{
        alert("Please enter a serial number");
    }
}

function fn_LAUSDSearchAssetTag(AssetTag){
    // User wants to look up an asset by Asset Tag
    if(AssetTag != ''){
        document.f_assetselect.action = '/custservice/asset_search/asset_tag/'+AssetTag;
        document.f_assetselect.submit();
    }else{
        alert("Please enter an Asset Tag");
    }
}

function fn_LAUSDShowPOAsset(PONo){
    // User wants to look up an asset by Purchase Order No
    if(PONo != ''){
        document.f_assetselect.action = '/custservice/asset_search/po/'+PONo;
        document.f_assetselect.submit();
    }else{
        alert("Please enter a Purchase Order number");
    }
}

function fn_SearchOnEnter(event,doThis){
    var keyCode;
    if (event && event.which){
      // Use for Firefox and Chrome
        keyCode = event.which;
    } else {
      // Use for IE
        keyCode = event.keyCode;
    }
    if (keyCode == 13){
        eval(doThis);
    }
}

function fn_DoPOFind(){
    // User wants to do a find on purchase orders
    if(document.f_form.vt_PO.value != ''){
        fn_LAUSDTrackSubmit(document.f_form.vt_PO);
    }
}

function fn_StartQuote(){
    // Starts a new quote
    top.location.href = '/welcome/start_new_quote';
}

function fn_ShowPOSearch(){
	// User wishes to see a refreshed Knowledge listing
	document.f_search.action = '/custservice/do_po_search';
	document.f_search.submit();
}

