var Qtys = new Array(1);

// All Pages For Main Menu
function toggle(e) {
	if (document.getElementById(e).style.display == "none") {
		document.getElementById(e).style.display = "";
	} else {
		document.getElementById(e).style.display = "none";
	}
};


function pick(obj, aColor) {
    obj.style.color = aColor;
};

function unpick(obj, aColor) {
    obj.style.color = aColor;
};

function unpickLink(obj, aColor) {
    if (aColor == "") {
        obj.style.color = cssLinkColor;
    }
    else {
        obj.style.color = aColor;
    }
};



function calendarDateChanged(calendar){
    if (calendar.date > new Date()) {
        alert(pwo_Str_InvalidFutureDate);
        calendar.params.inputField.value = '';
    }
};

function calendarFutureDateChanged(calendar){
    if (calendar.date < new Date()) {
        alert(pwo_Str_InvalidPastDate);
        calendar.params.inputField.value = '';
    }
};

//TODO:Maybe this is required. Not sure, have to check
//function onSelect(calendar, date){
//    var input_field = document.getElementById("date");
//    input_field.value=date;
//    };





// --------------------------------------------------------------------------------
// ----------------------------------- AJAX ---------------------------------------
// --------------------------------------------------------------------------------
function ShowAjaxPopup(aPopupName) {
	var modal = $find(aPopupName);
	modal.show();
};
function HideAjaxPopup(aPopupName) {
	var modal = $find(aPopupName);
	modal.hide();
};





// --------------------------------------------------------------------------------
// --------------------------------- String ---------------------------------------
// --------------------------------------------------------------------------------
function TrimString(sInString) {
	  sInString = sInString.replace( /^\s+/g, "" );
	  return sInString.replace( /\s+$/g, "" );
};
// --------------------------------------------------------------------------------


// --------------------------------------------------------------------------------
// ------------------------------- Integer ----------------------------------------
// --------------------------------------------------------------------------------
// To Stop pasting of Non-digits into a textbox
function maskPaste(objEvent)
{
	var strPasteData;
	var reValidString = /^\d*$/;
	strPasteData = window.clipboardData.getData("Text");
	return reValidString.test(strPasteData);
};


// To Stop typing of Non-digits into a textbox
function maskKeyPress(objEvent)
{
    var iKeyCode;
	var browserName=navigator.appName;
	if (browserName=="Netscape")
	{
		iKeyCode = objEvent.which;
	}

    if (browserName=="Microsoft Internet Explorer")
	{
		iKeyCode = objEvent.keyCode;
	}

    if ((iKeyCode>=48 && iKeyCode<=57) || (iKeyCode==8) ||(iKeyCode==0))
		return true;

	return false;
};
// ------------------------------- Integer ----------------------------------------




// --------------------------------------------------------------------------------
// ------------------------------- Currency ---------------------------------------
// --------------------------------------------------------------------------------
// To Stop typing of Non-digits into a textbox
function currencyMaskKeyPress(objEvent, obj)
{
    var iKeyCode;
	var browserName=navigator.appName;
	if (browserName=="Netscape")
	{
		iKeyCode = objEvent.which;
	}

    if (browserName=="Microsoft Internet Explorer")
	{
		iKeyCode = objEvent.keyCode;
	}

    if ((iKeyCode>=48 && iKeyCode<=57) || (iKeyCode==8) || (iKeyCode==46) ||(iKeyCode==0))
    {
        if (iKeyCode==46) {
            return (obj.value.indexOf(".", 0) == -1);
        }
        else {
    		return true;
        }
    }

	return false;
};


// To Stop pasting of Non-digits into a textbox
function currencyMaskPaste(objEvent)
{
	var strPasteData;
	strPasteData = window.clipboardData.getData("Text");
	var reValidString = /^[.1234567890]*$/;
	return reValidString.test(strPasteData);
};
// ------------------------------- Currency ---------------------------------------



// Login Pages
function setFocus(control) {
	if (document.getElementById(control)) {
        document.getElementById(control).focus();
    }
};


function checkboxToggle(checkbox, e) {
	if (document.getElementById(checkbox).checked) {
		document.getElementById(e).style.display = "";
	} else {
		document.getElementById(e).style.display = "none";
	}
};



function openWindow(Product)
{
	openProductWindow(Product);
};
//TODO:Use this to replace "openWindow" wherever it's used
function openProductWindow(Product)
{
	mywindow = window.open("ProductSpec.aspx?id=" + Product, "ProductSpec", "status=1, resizable=1, width=600, height=400");
	if (window.focus) { mywindow.focus() }
};



//TODO:Use this to replace "track" in DeliveryInfo.aspx
function openDocketTracking(Docket)
{
	mywindow = window.open ("DeliveryTrackTrace.aspx?function=1&id=" + Docket, "DDTrackTrace", "status=1, scrollbars=1, resizable=0, width=680, height=550");
};

function openLookup_ShipTos(CustomerUniqueID) {
	mywindow = window.open("Lookup_ShipTos.aspx?CUID=" + CustomerUniqueID, "Lookup_ShipTos", "status=1, scrollbars=1, resizable=0, width=680, height=550");
};

function openPostcodeSuburbLookup(aSuburb, aState, aPostcode)
{
	mywindow = window.open ("PostcodeSuburbLookup.aspx?Suburb=" + aSuburb + "&State=" + aState + "&Postcode=" + aPostcode, "PostcodeSuburbLookup", "status=1, scrollbars=1, resizable=0, width=650, height=350");
};


function resetForm(aForm, immediateReturn) {
    aForm.reset();
    if (immediateReturn == true) {
        return false;
    }
}

//TODO:Use this to replace "reDirectToTrackTrace" in TrackTrace.aspx
function reDirectToURL(aForm, aURL) {
    aForm.action=aURL;
    aForm.submit();

//    document.forms.TrackAndTrace.action="https://online.toll.com.au/trackandtrace/logon.do";
//    document.forms.TrackAndTrace.submit();
};


function CheckUnCheckAll(AFormName, ARepeaterID, ACheckBoxID, ACheckBoxValue) {
	if (ARepeaterID == 'Repeater_AdvancedSearch_ProductCats') {
		var pattern1 = /^Repeater_AdvancedSearch_ProductCats/i;
		var pattern2 = /CheckBox_AdvancedSearch_ProductCats$/i;
	}
	else if (ARepeaterID == 'Repeater_AdvancedSearch_BusinessUnits') {
		var pattern1 = /^Repeater_AdvancedSearch_BusinessUnits/i;
		var pattern2 = /CheckBox_AdvancedSearch_BusinessUnits$/i;
	}
	else if (ARepeaterID == 'GridView_AddingShipTo_ShipToList') {
		var pattern1 = /^GridView_AddingShipTo_ShipToList/i;
		var pattern2 = /CheckBox_AddingShipTo_Add$/i;
	}
	else if (ARepeaterID == 'GridView_AddingBillTo_BillToList') {
		var pattern1 = /^GridView_AddingBillTo_BillToList/i;
		var pattern2 = /CheckBox_AddingBillTo_Add$/i;
	}
	else if (ARepeaterID == 'GridView_AddingCustomer_CustomerList') {
		var pattern1 = /^GridView_AddingCustomer_CustomerList/i;
		var pattern2 = /CheckBox_AddingCustomer_Add$/i;
	}
	else return false;

	for (var i = 0; i < window.document.forms[AFormName].elements.length; i++) {
		var input = window.document.forms[AFormName].elements[i];

		if (input.type.match(/checkbox/i) && input.id.match(pattern1) && input.id.match(pattern2)) {
			if ((input.checked) && (!ACheckBoxValue)) {
				input.checked = 0;
			} else if ((!(input.checked)) && (ACheckBoxValue)) {
				input.checked = 1;
			}
		}
	};
	return false;
};


// --------------------------------------------------------------------------------
// ------------------------ Product Catalogue Page --------------------------------
// --------------------------------------------------------------------------------
// Product Catalogue Page Reset
function resetCatalogForm() {
	if (document.getElementById("TextBox_SearchFor")) {
        var ST = document.getElementById("TextBox_SearchFor").value;
    };

    resetForm(document.forms.Form_ProductCat, false);

	if (document.getElementById("TextBox_SearchFor")) {
        document.getElementById("TextBox_SearchFor").value = ST;
    };
    return false;
};



// Product Catalogue: If there are any Items Selected Items (called when AddSelected Button is pressed)
function CheckSelectedQty(){
	var b = false;
   b = ProductCatalogCheckQty();
	if (b == false) {
		alert(ProductCat_Str_NoOrderQtys);
	}
	return b;
};


// Product Catalogue: If there are any Items with Qty > 0 that hasn't been yet been added to the Order
function CheckCatalogQty(){
    if (ProductCatalogCheckQty())
    {
		return (confirm (ProductCat_Str_QtysNotYetPosted));
    }
};


// Product Catalogue: check to see if there are any Items Selected Items
function ProductCatalogCheckQty(){
    for(var i=0;i<window.document.forms['Form_ProductCat'].elements.length;i++){
	    var input = window.document.forms['Form_ProductCat'].elements[i];
		if(input.type.match(/text/i) &&
			input.id.match(/^DataGrid_Products/i) &&
			input.id.match(/TextBox_Quantity$/i) &&
			(!((Math.round(input.value) == 0) || (input.value == ""))))
		{
			return true;
		}
    };
    return false;
};
// ------------------------ Product Catalog Page ----------------------------------


// --------------------------------------------------------------------------------
// ------------------------------ Order Page --------------------------------------
// --------------------------------------------------------------------------------
//TODO:Replace all "document.forms.CurrentOrder" with New Name

// Current Order Page Reset
function resetOrderForm() {
    return resetForm(document.forms.Form_CurrentOrder, true);
};


// Order Page: Taking a snap shot of the quantity (On Load) so as to have something to compare the Values
// with on PostBack
function recordQtys(){
    var count = 0;
	if (document.getElementById("DataGrid_Products"))
    {
		for(var i=0;i<window.document.forms['Form_CurrentOrder'].elements.length;i++)
        {
			var input = window.document.forms['Form_CurrentOrder'].elements[i];
			if (
				input.type.match(/text/i) &&
				input.id.match(/^DataGrid_Products/i) &&
				input.id.match(/TextBox_Quantity$/i)
				)
			{
				if ((Qtys.length) < count + 1){
					Qtys.push(input.value);}
				else {
					Qtys[count] = input.value;}
				count = count + 1;
			}
		}
	}
};


// Order Page: check to see if there are any Items with a changed Qty
function OrderDetailsCheckQty(){
	var j = 0;
	for(var i=0;i<window.document.forms['Form_CurrentOrder'].elements.length;i++)
    {
		var input = window.document.forms['Form_CurrentOrder'].elements[i];
		if (
			input.type.match(/text/i) && 
			input.id.match(/^DataGrid_Products/i) &&
			input.id.match(/TextBox_Quantity$/i)
			)
		{
			if (!(input.value == Qtys[j]))
			{
				return true;
			}
			j = j + 1;
    	}
	};
    return false;
};


// Order Page: If there are no Items with a changed Qty (called when UpdateChanges button is pressed)
function CheckChangedQty(){
	var b = false;
    b = OrderDetailsCheckQty();

	if (b == false) {
		alert(CurrentOrder_Str_NoOrderQtys);
	};
	return b;
};


// Order Page: If there are any Items with a changed Qty that hasn't been yet been updated
function CheckOrderQty(){
    if (OrderDetailsCheckQty())
    {
		return (confirm (CurrentOrder_Str_QtysNotYetPosted));
    }
};
// ------------------------------ Order Page --------------------------------------






// --------------------------------------------------------------------------------
// --------------------- Change Order Ship To With Search -------------------------
// --------------------------------------------------------------------------------
function ExpandClose(aRowID, aImageID) {
    var image = document.getElementById(aImageID);
    var tempStr = image.src.substring((image.src.length - 17), image.src.length);
    
    if (tempStr == "Images/expand.gif") {
        Expand(aRowID, aImageID);
    } else {
        Close(aRowID, aImageID);
    }
}

function Close(aRowID, aImageID) {
    var image = document.getElementById(aImageID);

    toggle(aRowID);
    image.src = "Images/expand.gif";
};

function Expand(aRowID, aImageID) {
    var image = document.getElementById(aImageID);

    toggle(aRowID);
    image.src = "Images/collapse.gif";
};

// ------------------- Change Cat Order Ship To With Search -----------------------





// --------------------------------------------------------------------------------
// --------------------------- Batching Tool Page ---------------------------------
// --------------------------------------------------------------------------------
function BatchingPageCheckCheckBoxes(){
	for(var i=0;i<window.document.forms['Form_CSBatching'].elements.length;i++){
		var input = window.document.forms['Form_CSBatching'].elements[i];
		if(input.type.match(/checkbox/i) &&
			input.id.match(/^Repeater_Unbatched/i)) {
			if (input.checked) {
				return true;
			}
		}
	}
    return false;
};

function CSBatching_CheckCheckBoxes(){
	if (BatchingPageCheckCheckBoxes()) {
		return (confirm (CSBatching_Str_ChangesNotYetPosted));
    }
};


function CheckIfCheckBoxesSelected(){
	var b = false;
    b = BatchingPageCheckCheckBoxes();

	if (b == false) {
		alert('No Order Item has been Selected for Batching');
	}
	return b;
};


function CSBatching_DeclinePromptForReason(){
	var reason=prompt(CSBatching_Str_EnterDelineReason,"");
	if (reason==null) {
		return false;
	} else {
		reason=TrimString(reason);
		if (reason.length < 10) {
			alert(CSBatching_Str_Min10Characters);
			return CSBatching_DeclinePromptForReason();
		}
	};
	window.document.forms['Form_CSBatching'].Label_Hidden.value=reason;
};
// --------------------------- Batching Tool Page ---------------------------------



// --------------------------------------------------------------------------------
// --------------------------- Custom Fields Page ---------------------------------
// --------------------------------------------------------------------------------
function ShowVerifyButton(){
	if (document.getElementById("verifyButton").style.visibility == "hidden")
	{
		document.getElementById("verifyButton").style.visibility = "visible";
		document.getElementById("submitPreview").style.visibility = "hidden";
	}
};


function ToggleVerifyButton(){
	if (document.getElementById("Label_VerifyNavBar"))
	{
		document.getElementById("verifyButton").style.visibility = "hidden";
		document.getElementById("submitPreview").style.visibility = "visible";
	} else {
		document.getElementById("submitPreview").style.visibility = "hidden";
	}
};
// --------------------------- Custom Fields Page ---------------------------------



// --------------------------------------------------------------------------------
// ----------------------------- RFQDetails Page ----------------------------------
// --------------------------------------------------------------------------------
// RFQDetails: Calculate Total Qty Cost
function CalculateTotalQtyCost(inputElement){
    var totalCost = 0;
    var prepressCost = 0;
    var labelName;

    if (document.getElementById("TextBox_PrepressQuote")) {
        if ((document.getElementById("CheckBox_QuotePrepress")) &&
           ((document.getElementById("CheckBox_QuotePrepress")).checked == 1)) {
                prepressCost = 0;
                (document.getElementById("TextBox_PrepressQuote")).value = '';
        }
        else {
            var PrepressPriceElement = document.getElementById("TextBox_PrepressQuote");
            PrepressPriceElement.value = PrepressPriceElement.value.replace( /[.]$/, "" );

            if (!(((Math.round(PrepressPriceElement.value*10000)/10000) == 0) || (PrepressPriceElement.value == ""))) {
                prepressCost = parseFloat(PrepressPriceElement.value);
            };
        };
    };

    if ((inputElement.id == "TextBox_PrepressQuote") || (inputElement.id == "CheckBox_QuotePrepress")) {
        for (var i=0;i<window.document.forms['Form_SupplierRFQDetails'].elements.length;i++) {
            var input = window.document.forms['Form_SupplierRFQDetails'].elements[i];
            if (input.type.match(/checkbox/i) &&
                input.id.match(/^DataGrid_RFQQtys/i) &&
                input.id.match(/CheckBox_QuoteQty$/i) &&
                (input.checked == 1)) {

                totalCost = 0;

                var  aElementID = input.id;
                aElementID = aElementID.replace( /CheckBox_QuoteQty$/, "" );
                aElementID = aElementID.replace( /^DataGrid_RFQQtys/, "" );

                if (document.getElementById("DataGrid_RFQQtys" + aElementID + "RunPrice")) {
                    (document.getElementById("DataGrid_RFQQtys" + aElementID + "RunPrice")).value = '';
                }

                if (document.getElementById("DataGrid_RFQQtys" + aElementID + "FreightPrice")) {
                    (document.getElementById("DataGrid_RFQQtys" + aElementID + "FreightPrice")).value = '';
                }
                labelName = "DataGrid_RFQQtys" + aElementID + "Label_QtyTotal";
                if (document.getElementById(labelName)) {
                    document.getElementById(labelName).innerHTML = "";
                }
            } else {
                if  (input.type.match(/text/i) &&
                    input.id.match(/^DataGrid_RFQQtys/i) &&
                    (input.id.match(/RunPrice$/i) || (input.id.match(/FreightPrice$/i)))) {
                    totalCost = prepressCost;

                    var aElementID = input.id;
                    aElementID = aElementID.replace( /RunPrice$/, "" );
                    aElementID = aElementID.replace( /FreightPrice$/, "" );
                    aElementID = aElementID.replace( /^DataGrid_RFQQtys/, "" );

                    if ((document.getElementById("DataGrid_RFQQtys" + aElementID + "CheckBox_QuoteQty")) &&
                        ((document.getElementById("DataGrid_RFQQtys" + aElementID + "CheckBox_QuoteQty")).checked == 1)) {

                        if (document.getElementById("DataGrid_RFQQtys" + aElementID + "RunPrice")) {
                            (document.getElementById("DataGrid_RFQQtys" + aElementID + "RunPrice")).value = "";
                        };

                        if (document.getElementById("DataGrid_RFQQtys" + aElementID + "FreightPrice")) {
                            (document.getElementById("DataGrid_RFQQtys" + aElementID + "FreightPrice")).value = "";
                        };

                        labelName = "DataGrid_RFQQtys" + aElementID + "Label_QtyTotal";
                        if (document.getElementById(labelName)) {
                            document.getElementById(labelName).innerHTML = "";
                        }
                    } else {
                        if (document.getElementById("DataGrid_RFQQtys" + aElementID + "RunPrice")) {
                            var RunPriceElement = document.getElementById("DataGrid_RFQQtys" + aElementID + "RunPrice");
                            RunPriceElement.value = RunPriceElement.value.replace( /[.]$/, "" );

                            if (!(((Math.round(RunPriceElement.value*10000)/10000) == 0) || (RunPriceElement.value == ""))) {
                                totalCost = totalCost + parseFloat(RunPriceElement.value);
                            };
                        };

                        if (document.getElementById("DataGrid_RFQQtys" + aElementID + "FreightPrice")) {
                            var FreightPriceElement = document.getElementById("DataGrid_RFQQtys" + aElementID + "FreightPrice");
                            FreightPriceElement.value = FreightPriceElement.value.replace( /[.]$/, "" );

                            if (!(((Math.round(FreightPriceElement.value*10000)/10000) == 0) || (FreightPriceElement.value == ""))) {
                                totalCost = totalCost + parseFloat(FreightPriceElement.value);
                            };
                        };

                        labelName = "DataGrid_RFQQtys" + aElementID + "Label_QtyTotal";
                        totalCost = Math.round(totalCost*10000)/10000;

                        if (document.getElementById(labelName) && ((totalCost == 0) && document.getElementById("TextBox_PrepressQuote") &&
                           (document.getElementById("CheckBox_QuotePrepress")) &&
                           ((document.getElementById("CheckBox_QuotePrepress")).checked == 1))) {
                            document.getElementById(labelName).innerHTML = "";
                        } else {
                            document.getElementById(labelName).innerHTML = pwo_Str_CurrencySign + totalCost;
                        }
                    };
                };
            };
        };
    }
    else {
        totalCost = prepressCost;

        var inputElementID = inputElement.id;
        inputElementID = inputElementID.replace( /RunPrice$/, "" );
        inputElementID = inputElementID.replace( /FreightPrice$/, "" );
        inputElementID = inputElementID.replace( /CheckBox_QuoteQty$/, "" );
        inputElementID = inputElementID.replace( /^DataGrid_RFQQtys/, "" );

        if ((document.getElementById("DataGrid_RFQQtys" + inputElementID + "CheckBox_QuoteQty")) &&
            (document.getElementById("DataGrid_RFQQtys" + inputElementID + "CheckBox_QuoteQty")).checked == 1) {
            totalCost = 0;

            if (document.getElementById("DataGrid_RFQQtys" + inputElementID + "RunPrice")) {
                (document.getElementById("DataGrid_RFQQtys" + inputElementID + "RunPrice")).value = '';
            };

            if (document.getElementById("DataGrid_RFQQtys" + inputElementID + "FreightPrice")) {
                (document.getElementById("DataGrid_RFQQtys" + inputElementID + "FreightPrice")).value = '';
            };

            labelName = "DataGrid_RFQQtys" + inputElementID + "Label_QtyTotal";
            if (document.getElementById(labelName)) {
                document.getElementById(labelName).innerHTML = "";
            }
        }
        else {
            if (document.getElementById("DataGrid_RFQQtys" + inputElementID + "RunPrice")) {
                var RunPriceElement = document.getElementById("DataGrid_RFQQtys" + inputElementID + "RunPrice");
                RunPriceElement.value = RunPriceElement.value.replace( /[.]$/, "" );

                if (!(((Math.round(RunPriceElement.value*10000)/10000) == 0) || (RunPriceElement.value == ""))) {
                    var totalCost = totalCost + parseFloat(RunPriceElement.value);
                };
            };
            if (document.getElementById("DataGrid_RFQQtys" + inputElementID + "FreightPrice")) {
                var FreightPriceElement = document.getElementById("DataGrid_RFQQtys" + inputElementID + "FreightPrice");
                FreightPriceElement.value = FreightPriceElement.value.replace( /[.]$/, "" );

                if (!(((Math.round(FreightPriceElement.value*10000)/10000) == 0) || (FreightPriceElement.value == ""))) {
                    totalCost = totalCost + parseFloat(FreightPriceElement.value);
                };
            };
            labelName = "DataGrid_RFQQtys" + inputElementID + "Label_QtyTotal";
            totalCost = Math.round(totalCost*10000)/10000;
            if (document.getElementById(labelName)) {
                document.getElementById(labelName).innerHTML = pwo_Str_CurrencySign + totalCost;
            }
        };
    };
};




// RFQDetails: Calculate Total Qty Cost
function CalculateTotalQtyEstimateCost(inputElement){
    var totalCost = 0;
    var prepressCost = 0;
    var freightEstimate = 0;
    var labelName;

    if (document.getElementById("TextBox_PrepressQuote")) {
        if ((document.getElementById("CheckBox_QuotePrepress")) &&
           ((document.getElementById("CheckBox_QuotePrepress")).checked == 1)) {
            prepressCost = 0;

            (document.getElementById("TextBox_PrepressQuote")).value = '';
        }
        else {
            var PrepressPriceElement = document.getElementById("TextBox_PrepressQuote");
            PrepressPriceElement.value = PrepressPriceElement.value.replace( /[.]$/, "" );

            if (!(((Math.round(PrepressPriceElement.value*10000)/10000) == 0) || (PrepressPriceElement.value == ""))) {
                prepressCost = parseFloat(PrepressPriceElement.value);
            };
        };
    };

    if (document.getElementById("TextBox_FreightEstimate")) {
        if ((document.getElementById("CheckBox_EstimateFreight")) &&
           ((document.getElementById("CheckBox_EstimateFreight")).checked == 1)) {
            freightEstimate = 0;

            (document.getElementById("TextBox_FreightEstimate")).value = '';
        }
        else {
            var FreightPriceElement = document.getElementById("TextBox_FreightEstimate");
            FreightPriceElement.value = FreightPriceElement.value.replace( /[.]$/, "" );

            if (!(((Math.round(FreightPriceElement.value*10000)/10000) == 0) || (FreightPriceElement.value == ""))) {
                freightEstimate = parseFloat(FreightPriceElement.value);
            };
        };
    };


    if ((inputElement.id == "TextBox_PrepressQuote") || (inputElement.id == "TextBox_FreightEstimate") ||
        (inputElement.id == "CheckBox_QuotePrepress") || (inputElement.id == "CheckBox_EstimateFreight")) {
        for(var i=0;i<window.document.forms['Form_SupplierRFQDetails'].elements.length;i++){
            var input = window.document.forms['Form_SupplierRFQDetails'].elements[i];
            if (input.type.match(/checkbox/i) &&
                input.id.match(/^DataGrid_RFQQtys/i) &&
                input.id.match(/CheckBox_QuoteQty$/i) &&
                (input.checked == 1)) {

                totalCost = 0;

                var aElementID = input.id;
                aElementID = aElementID.replace( /CheckBox_QuoteQty$/, "" );
                aElementID = aElementID.replace( /^DataGrid_RFQQtys/, "" );

                if (document.getElementById("DataGrid_RFQQtys" + aElementID + "RunPrice")) {
                    (document.getElementById("DataGrid_RFQQtys" + aElementID + "RunPrice")).value = ''
                };

                labelName = "DataGrid_RFQQtys" + aElementID + "Label_QtyTotal";
                if (document.getElementById(labelName)) {
                    document.getElementById(labelName).innerHTML = "";
                }
            } else {
                if  (input.type.match(/text/i) &&
                    input.id.match(/^DataGrid_RFQQtys/i) &&
                    input.id.match(/RunPrice$/i))
                {
                    totalCost = prepressCost + freightEstimate;

                    var aElementID = input.id;
                    aElementID = aElementID.replace( /RunPrice$/, "" );
                    aElementID = aElementID.replace( /^DataGrid_RFQQtys/, "" );

                    if (document.getElementById("DataGrid_RFQQtys" + aElementID + "RunPrice")) {
                        var RunPriceElement = document.getElementById("DataGrid_RFQQtys" + aElementID + "RunPrice");
                        RunPriceElement.value = RunPriceElement.value.replace( /[.]$/, "" );

                        if (!(((Math.round(RunPriceElement.value*10000)/10000) == 0) || (RunPriceElement.value == ""))) {
                            totalCost = totalCost + parseFloat(RunPriceElement.value);
                        };
                    };

                    labelName = "DataGrid_RFQQtys" + aElementID + "Label_QtyTotal";
                    totalCost = Math.round(totalCost*10000)/10000;

                    if (document.getElementById(labelName)) {
                        document.getElementById(labelName).innerHTML = pwo_Str_CurrencySign + totalCost;
                    };
                };
            };
        };
    }
    else {
        totalCost = prepressCost + freightEstimate;

        var inputElementID = inputElement.id;
        inputElementID = inputElementID.replace( /RunPrice$/, "" );
        inputElementID = inputElementID.replace( /^DataGrid_RFQQtys/, "" );
        inputElementID = inputElementID.replace( /CheckBox_QuoteQty$/, "" );


        if (document.getElementById("DataGrid_RFQQtys" + inputElementID + "RunPrice")) {
            if ((document.getElementById("DataGrid_RFQQtys" + inputElementID + "CheckBox_QuoteQty")) &&
                (document.getElementById("DataGrid_RFQQtys" + inputElementID + "CheckBox_QuoteQty")).checked == 1) {
                totalCost = 0;
                (document.getElementById("DataGrid_RFQQtys" + inputElementID + "RunPrice")).value = "";
                labelName = "DataGrid_RFQQtys" + inputElementID + "Label_QtyTotal";
                if (document.getElementById(labelName)) {
                    document.getElementById(labelName).innerHTML = "";
                }
            }
            else {
                var RunPriceElement = document.getElementById("DataGrid_RFQQtys" + inputElementID + "RunPrice");
                RunPriceElement.value = RunPriceElement.value.replace( /[.]$/, "" );

                if (!(((Math.round(RunPriceElement.value*10000)/10000) == 0) || (RunPriceElement.value == ""))) {
                    var totalCost = totalCost + parseFloat(RunPriceElement.value);
                };
                labelName = "DataGrid_RFQQtys" + inputElementID + "Label_QtyTotal";
                totalCost = Math.round(totalCost*10000)/10000;
                if (document.getElementById(labelName)) {
                    document.getElementById(labelName).innerHTML = pwo_Str_CurrencySign + totalCost;
                }
            };
        };
    };
};

function RFQDetailsCheckQuotedPrices(){
    if (document.getElementById("TextBox_PrepressQuote") &&
       document.getElementById("CheckBox_QuotePrepress") &&
       (document.getElementById("CheckBox_QuotePrepress").checked != 1) &&
       ((TrimString(document.getElementById("TextBox_PrepressQuote").value) == "") || (Math.round(document.getElementById("TextBox_PrepressQuote").value) == 0)))
    {
        alert(RFQDetails_Str_PrepressNotQuoted);
        return false;
    };

  
    if (document.getElementById("TextBox_FreightEstimate") &&
       document.getElementById("CheckBox_EstimateFreight") &&
       (document.getElementById("CheckBox_EstimateFreight").checked != 1) &&
       ((TrimString(document.getElementById("TextBox_FreightEstimate").value) == "") || (Math.round(document.getElementById("TextBox_FreightEstimate").value) == 0)))
    {
        alert(RFQDetails_Str_FreightNotEstimated);
        return false;
    };


    if (document.getElementById("TextBox_SupplierRef") &&
       (TrimString(document.getElementById("TextBox_SupplierRef").value) == ""))
    {
        alert(RFQDetails_Str_ReferenceMissing);
        return false;
    };

    var declinedCount = 0;
    var qtyCount = 0;

    for (var i = 0; i < window.document.forms['Form_SupplierRFQDetails'].elements.length; i++) {

        var input = window.document.forms['Form_SupplierRFQDetails'].elements[i];

        if (input.type.match(/checkbox/i) &&
           input.id.match(/^DataGrid_RFQQtys/i) &&
           input.id.match(/CheckBox_QuoteQty$/i)) {

            qtyCount = qtyCount + 1;

            if (input.checked == 1) {
                declinedCount = declinedCount + 1;
            }
            else {
            	var aElementID = input.id;
                aElementID = aElementID.replace( /CheckBox_QuoteQty$/, "" );
                aElementID = aElementID.replace( /^DataGrid_RFQQtys/, "" );

                if (document.getElementById("DataGrid_RFQQtys" + aElementID + "RunPrice") &&
                   ((TrimString(document.getElementById("DataGrid_RFQQtys" + aElementID + "RunPrice").value) == "") || (Math.round(document.getElementById("DataGrid_RFQQtys" + aElementID + "RunPrice").value) == 0)))
                {
                    alert(RFQDetails_Str_RunPriceNotQuoted);
                    return false;
                };

                if (document.getElementById("DataGrid_RFQQtys" + aElementID + "FreightPrice") &&
                   ((TrimString(document.getElementById("DataGrid_RFQQtys" + aElementID + "FreightPrice").value) == "") || (Math.round(document.getElementById("DataGrid_RFQQtys" + aElementID + "FreightPrice").value) == 0)))
                {
                    alert(RFQDetails_Str_FreightNotQuoted);
                    return false;
                };
            };
        };
    };

    if (declinedCount == qtyCount) {
        alert(RFQDetails_Str_AllQtysDeclined);
        return false;
    };
};
// ----------------------------- RFQDetails Page ----------------------------------






// --------------------------------------------------------------------------------
// ----------------------- SupplierJobDeliveries Page -----------------------------
// --------------------------------------------------------------------------------
function onSelect(calendar, date){
    var input_field = document.getElementById("date");
    input_field.value=date;
    };

function hiseShowDeliveryDynamicControls(options, calendar, qtyTextBox, qtyLabel, connote) {
    if (document.getElementById(options).selectedIndex == 0) {
        document.getElementById(calendar).style.visibility = "hidden";
        document.getElementById(qtyTextBox).style.visibility = "hidden";
        document.getElementById(qtyLabel).style.visibility = "hidden";
        document.getElementById(connote).style.display = "none";
    } else {
        document.getElementById(calendar).style.visibility = "visible";
        document.getElementById(connote).style.display = "";

        if (document.getElementById(options).selectedIndex == 2) {
            document.getElementById(qtyTextBox).style.visibility = "visible";
            document.getElementById(qtyLabel).style.visibility = "visible";
        } else {
            document.getElementById(qtyTextBox).style.visibility = "hidden";
            document.getElementById(qtyLabel).style.visibility = "hidden";
        }
    }
};


function CalculateRemainingQty(TotalQty, inputElement){
	var aElementID = inputElement.id;
    aElementID = aElementID.replace( /TextBox_Qty_1$/, "" );
    aElementID = aElementID.replace( /^Repeater_DeliveryLocations/, "" );

    if (document.getElementById("Repeater_DeliveryLocations" + aElementID + "TextBox_Qty_2")) {
        (document.getElementById("Repeater_DeliveryLocations" + aElementID + "TextBox_Qty_2")).value = TotalQty - inputElement.value;
    };
};


function checkSupplierJobDeliveryQty() {
    var count = 0;
    for (var i = 0; i < window.document.forms['Form_SupplierJobDeliveries'].elements.length; i++) {

    	var input = window.document.forms['Form_SupplierJobDeliveries'].elements[i];

		if (input.type.match(/select/i) &&
		    input.id.match(/^Repeater_DeliveryLocations/i) &&
            input.id.match(/DropDownList_JobCompleted$/i) &&
            (input.disabled!=true)) {
		    if (input.selectedIndex != 0) {
                count = count + 1;
                var aElementID = input.id;
                aElementID = aElementID.replace( /DropDownList_JobCompleted$/, "" );
                aElementID = aElementID.replace( /^Repeater_DeliveryLocations/, "" );

                //alert("Repeater_DeliveryLocations" + aElementID + "Label_RFQDeliveryNo");
                var DeliveryNumber = document.getElementById("Repeater_DeliveryLocations" + aElementID + "Label_RFQDeliveryNo").innerHTML;

                if (document.getElementById("Repeater_DeliveryLocations" + aElementID + "TextBox_DateCompleted") &&
                   (document.getElementById("Repeater_DeliveryLocations" + aElementID + "TextBox_DateCompleted").value == "")) {
                    alert(SupplierJobDeliveries_Str_DeliveryDateMissing.replace(/%JSValue-DeliveryNumber%/, DeliveryNumber));
				    return false;
                }; // end: if _TextBox_DateCompleted is blank

    		    if (input.selectedIndex == 2) {

                    if (document.getElementById("Repeater_DeliveryLocations" + aElementID + "TextBox_Qty")) {
                        if ((document.getElementById("Repeater_DeliveryLocations" + aElementID + "TextBox_Qty").value == "") ||
                           (Math.round(document.getElementById("Repeater_DeliveryLocations" + aElementID + "TextBox_Qty").value) == 0)) {
                            alert(SupplierJobDeliveries_Str_PartialDeliveryQtyMissing.replace(/%JSValue-DeliveryNumber%/, DeliveryNumber));
                            return false;
                        } else {
                            var requestedQty = document.getElementById("Repeater_DeliveryLocations" + aElementID + "Label_DeliveryQty").innerHTML;
                            requestedQty = requestedQty.replace(/\,/, "");

                            if (Math.round(document.getElementById("Repeater_DeliveryLocations" + aElementID + "TextBox_Qty").value) == Math.round(requestedQty)) {
                                if (!confirm(SupplierJobDeliveries_Str_ConfirmFullDelivery.replace(/%JSValue-DeliveryNumber%/, DeliveryNumber)))
                                {
                                    return false;
                                };
                            } else if (Math.round(document.getElementById("Repeater_DeliveryLocations" + aElementID + "TextBox_Qty").value) > Math.round(requestedQty)) {
                                alert(SupplierJobDeliveries_Str_ConfirmedQtyTooBig.replace(/%JSValue-DeliveryNumber%/, DeliveryNumber));
                                return false;
                            };


                        };
                    }; // end: if (document.getElementById("Repeater_DeliveryLocations" + aElementID + "TextBox_Qty"))

                }; // end: if (input.selectedIndex == 2)
                
		    }; // end: if (input.selectedIndex != 0)
		} else if (input.type.match(/checkbox/i) &&
		    input.id.match(/^Repeater_DeliveryLocations/i) &&
            input.id.match(/CheckBox_DeliveryCompleted$/i)) {

			if (input.checked) {
                count = count + 1;
                var aElementID = input.id;
                aElementID = aElementID.replace( /CheckBox_DeliveryCompleted$/, "" );
                aElementID = aElementID.replace( /^Repeater_DeliveryLocations/, "" );

                var DeliveryNumber = document.getElementById("Repeater_DeliveryLocations" + aElementID + "Label_RFQDeliveryNo").innerHTML;

                if (document.getElementById("Repeater_DeliveryLocations" + aElementID + "TextBox_NumberSequenceFrom_1") &&
                   (document.getElementById("Repeater_DeliveryLocations" + aElementID + "TextBox_NumberSequenceFrom_1").value == "")) {

                    // if TextBox_NumberSequenceFrom_2 is visible, that means that it is a partial Delivery
                    if (document.getElementById("Repeater_DeliveryLocations" + aElementID + "TextBox_NumberSequenceFrom_2")) {
                        alert(SupplierJobDeliveries_Str_PartialDeliveryNumberSequenceFromMissing.replace(/%JSValue-DeliveryNumber%/, DeliveryNumber));
                    } else {
                        alert(SupplierJobDeliveries_Str_FullDeliveryNumberSequenceFromMissing.replace(/%JSValue-DeliveryNumber%/, DeliveryNumber));
                    };
				    return false;
                };

                if (document.getElementById("Repeater_DeliveryLocations" + aElementID + "TextBox_NumberSequenceTo_1") &&
                   (document.getElementById("Repeater_DeliveryLocations" + aElementID + "TextBox_NumberSequenceTo_1").value == "")) {

                    // if TextBox_NumberSequenceFrom_2 is visible, that means that it is a partial Delivery
                    if (document.getElementById("Repeater_DeliveryLocations" + aElementID + "TextBox_NumberSequenceFrom_2")) {
                        alert(SupplierJobDeliveries_Str_PartialDeliveryNumberSequenceToMissing.replace(/%JSValue-DeliveryNumber%/, DeliveryNumber));
                    } else {
                        alert(SupplierJobDeliveries_Str_FullDeliveryNumberSequenceToMissing.replace(/%JSValue-DeliveryNumber%/, DeliveryNumber));
                    };
				    return false;
                };

                if ((document.getElementById("Repeater_DeliveryLocations" + aElementID + "TextBox_Qty_1")) && (document.getElementById("Repeater_DeliveryLocations" + aElementID + "TextBox_Qty_2")))
                {
                    if ((document.getElementById("Repeater_DeliveryLocations" + aElementID + "TextBox_Qty_1").value == "") ||
                       (Math.round(document.getElementById("Repeater_DeliveryLocations" + aElementID + "TextBox_Qty_1").value) == 0))
                    {
                        alert(SupplierJobDeliveries_Str_PartialDeliveryQtyMissing.replace(/%JSValue-DeliveryNumber%/, DeliveryNumber));
                        return false;
                    }
                    else
                    {
                        var requestedQty = document.getElementById("Repeater_DeliveryLocations" + aElementID + "Label_DeliveryQty").innerHTML;
                        requestedQty = requestedQty.replace(/\,/, "");

                        if (Math.round(document.getElementById("Repeater_DeliveryLocations" + aElementID + "TextBox_Qty_1").value) == Math.round(requestedQty))
                        {
                            if (!confirm(SupplierJobDeliveries_Str_ConfirmFullDelivery.replace(/%JSValue-DeliveryNumber%/, DeliveryNumber)))
                            {
                                return false;
                            };
                        }
                        else if (Math.round(document.getElementById("Repeater_DeliveryLocations" + aElementID + "TextBox_Qty_1").value) > Math.round(requestedQty))
                        {
                            alert(SupplierJobDeliveries_Str_ConfirmedQtyTooBig.replace(/%JSValue-DeliveryNumber%/, DeliveryNumber));
                            return false;
                        };
                    };
                };

                if (document.getElementById("Repeater_DeliveryLocations" + aElementID + "TextBox_DateCompleted_1") &&
                   (TrimString(document.getElementById("Repeater_DeliveryLocations" + aElementID + "TextBox_DateCompleted_1").value) == "")) {
                    alert(SupplierJobDeliveries_Str_DeliveryDateMissing.replace(/%JSValue-DeliveryNumber%/, DeliveryNumber));
				    return false;
                }; // end: if _TextBox_DateCompleted_1 found & value = ''

                if (document.getElementById("Repeater_DeliveryLocations" + aElementID + "TextBox_NumberSequenceFrom_2") &&
                   (document.getElementById("Repeater_DeliveryLocations" + aElementID + "TextBox_NumberSequenceFrom_2").value == "")) {
                    alert(SupplierJobDeliveries_Str_UndeliveredNumberSequenceFromMissing.replace(/%JSValue-DeliveryNumber%/, DeliveryNumber));
				    return false;
                }; // end: if _TextBox_NumberSequenceFrom_2 found & value = ''

                if (document.getElementById("Repeater_DeliveryLocations" + aElementID + "TextBox_NumberSequenceTo_2") &&
                   (document.getElementById("Repeater_DeliveryLocations" + aElementID + "TextBox_NumberSequenceTo_2").value == "")) {
                    alert(SupplierJobDeliveries_Str_UndeliveredNumberSequenceToMissing.replace(/%JSValue-DeliveryNumber%/, DeliveryNumber));
				    return false;
                }; // end: if _TextBox_NumberSequenceTo_2 found & value = ''


            }; // end: if (input.checked)

        };// end: if relevant Checkbox found

	}; // end: For loop

    if (count == 0) {
        alert(SupplierJobDeliveries_Str_NoDeliveryChanges);
        return false;
    };
    return true;
};
// ----------------------- SupplierJobDeliveries Page -----------------------------




// --------------------------------------------------------------------------------
// ----------------------------- Issues Type Page ---------------------------------
// --------------------------------------------------------------------------------
//TODO:Rename to something else
function toggleExpandCollapseImage(row, image){
    if (document.getElementById(row).style.display == "none") {
        document.getElementById(row).style.display = "";
    } else {
        document.getElementById(row).style.display = "none";
    };

    if (document.getElementById(image).src.match(/plus_icon.gif$/i))
    {
        document.getElementById(image).src = "Images/minus_icon.gif";
    } else {
        document.getElementById(image).src = "Images/plus_icon.gif";
    };
};

// ----------------------------- Issues Type Page ---------------------------------




// --------------------------------------------------------------------------------
// --------------------------- Report Details Page --------------------------------
// --------------------------------------------------------------------------------
function ReportsDetailPageSelectAllHideCheckboxes(){
    for (var nfl = 0; nfl < window.document.forms['Form_ReportDetails'].getElementsByTagName('div').length; nfl++) {
        var tempLabel = window.document.forms['Form_ReportDetails'].getElementsByTagName('div')[nfl];
		if (tempLabel.id.match(/^myCheckbox/i) && (tempLabel.className == "checkboxArea")) {
            rechangeCheckboxes(tempLabel.id.substring(10, tempLabel.id.length));
        }
    }
};

function ReportsDetailPageDeSelectAllHideCheckboxes(){
    for(var nfl = 0; nfl < window.document.forms['Form_ReportDetails'].getElementsByTagName('div').length; nfl++) {
        var tempLabel = window.document.forms['Form_ReportDetails'].getElementsByTagName('div')[nfl];
		if (tempLabel.id.match(/^myCheckbox/i) && (tempLabel.className == "checkboxAreaChecked")) {
            rechangeCheckboxes(tempLabel.id.substring(10, tempLabel.id.length));
        }
    }
};
// --------------------------- Report Details Page --------------------------------




// --------------------------------------------------------------------------------
// ---------------------- CSOrderItemDisclaimer Page ------------------------------
// --------------------------------------------------------------------------------
// CSOrderItemDisclaimer: Disclaimer Checkbox is ticked
function CheckCSOrderItemDisclaimer(){
	if (document.getElementById("CheckBox_DisclaimerRead").checked == false) {
		alert(CSOrderItemDisclaimer_Str_TickCheckbox);
        return false;
	}
};




// --------------------------------------------------------------------------------
// ---------------------- ProductionJobProductSpec Page -----------------------------
// --------------------------------------------------------------------------------
function CustomerJobProductSpecCheckQty(){
    if (document.getElementById("TextBox_Quantity")) {
        var QtyInput = document.getElementById("TextBox_Quantity");
        if ( (document.getElementById("CheckBox_ModsRequired").checked == false) &&
             ((Math.round(QtyInput.value) == 0) || (QtyInput.value == ""))
           )
        {
            alert(CustomerJobProductSpec_Str_NoOrderQty);
            return false;
        } else {
            return true;
        }
    }
};


function CustomerJobProductSpecReOrderConfirm(){
    if (CustomerJobProductSpecCheckQty())
    {
        if (document.getElementById("CheckBox_ModsRequired").checked == false) {
            var Qty = document.getElementById("TextBox_Quantity").value;
            return (confirm (CustomerJobProductSpec_Str_ConfirmReOrder.replace(/%JSValue-ReOrderQty%/, Qty)));
        } else {
            return true;
        }
    } else {
        return false;
    }
};
// ---------------------- CustomerJobProductSpec Page -----------------------------




// --------------------------------------------------------------------------------
//---------------------- CustomerProductJobHistory Page ---------------------------
// --------------------------------------------------------------------------------
function CustomerProductJobHistoryCheckQty(){
    if (document.getElementById("TextBox_Quantity")) {
        var QtyInput = document.getElementById("TextBox_Quantity");
        if ( (document.getElementById("CheckBox_ModsRequired").checked == false) &&
             ((Math.round(QtyInput.value) == 0) || (QtyInput.value == ""))
           )
        {
            alert(CustomerProductJobHistory_Str_NoOrderQty);
            return false;
        } else {
            return true;
        }
    }
};



function CustomerProductJobHistoryReOrderConfirm(){
    if (CustomerProductJobHistoryCheckQty())
    {
        if (document.getElementById("CheckBox_ModsRequired").checked == false) {
            var Qty = document.getElementById("TextBox_Quantity").value;
            return (confirm (CustomerProductJobHistory_Str_ConfirmReOrder.replace(/%JSValue-ReOrderQty%/, Qty)));
        } else {
            return true;
        }
    } else {
        return false;
    }
};
//---------------------- CustomerProductJobHistory Page ---------------------------




// --------------------------------------------------------------------------------
//---------------------- CustomerProductJobHistory Page ---------------------------
// --------------------------------------------------------------------------------
function ProductionWorkReOrderReOrderConfirm(){
    var Qty = document.getElementById("TextBox_Quantity").value;
    if ((Math.round(Qty) == 0) || (Qty == "")) {
        alert(ProductionWorkReOrder_Str_NoOrderQty);
        return false;
    }
    else {
        return (confirm (ProductionWorkReOrder_Str_ConfirmReOrder.replace(/%JSValue-ReOrderQty%/, Qty)));
    }
};
//---------------------- CustomerProductJobHistory Page ---------------------------









// --------------------------------------------------------------------------------
// ------------------------ AdminTools_AssignedCustomers --------------------------
// --------------------------------------------------------------------------------
function ShowPopup_ViewCustomer(aCustomerUniqueID, aCustomerName, aFullAddress, isMainAddress, showRemove, removeControlToClick) {
	if (document.getElementById("Label_ShipToMoreDetails_CustomerName")) {
		document.getElementById("Label_ShipToMoreDetails_CustomerName").innerHTML = aCustomerName;
	};

	if (document.getElementById("Label_ShipToMoreDetails_FullAddress")) {
		document.getElementById("Label_ShipToMoreDetails_FullAddress").innerHTML = aFullAddress;
	};

	if ((document.getElementById("Button_ShipToMoreDetails_SetAsDefault")) && (document.getElementById("Label_ShipToMoreDetails_IsDefault"))) {
		if (isMainAddress == 0) {
			document.getElementById("Button_ShipToMoreDetails_SetAsDefault").disabled = false;
			document.getElementById("Label_ShipToMoreDetails_IsDefault").style.display = "none";
		} else {
			document.getElementById("Button_ShipToMoreDetails_SetAsDefault").disabled = true;
			document.getElementById("Label_ShipToMoreDetails_IsDefault").style.display = "";
		}
	};

	if (document.getElementById("Button_ShipToMoreDetails_Remove")) {
		if (showRemove == 0) {
			document.getElementById("Button_ShipToMoreDetails_Remove").style.display = "none";
		} else {
			document.getElementById("Button_ShipToMoreDetails_Remove").style.display = "";

			if ((removeControlToClick != "") && (document.getElementById(removeControlToClick))) {
				document.getElementById("Button_ShipToMoreDetails_Remove").setAttribute("onclick", "HidePopup_ViewCustomer(); document.getElementById('" + removeControlToClick + "').onclick(); return false;");
			}
		}
	};

	if (document.getElementById("HiddenInput_CurrentCustomerUniqueID")) {
		document.getElementById("HiddenInput_CurrentCustomerUniqueID").value = aCustomerUniqueID;
	};

	ShowAjaxPopup("ModalPopupExtender_LinkButton_ViewCustomer");
};


function ShowPopup_RemoveCustomer(aCustomerUniqueID, aCustomerName, isMainAddress, deliveryCount, showRemoveWarning) {
	if (document.getElementById("Label_ConfirmRemoveShipTo_CustomerName")) {
		document.getElementById("Label_ConfirmRemoveShipTo_CustomerName").innerHTML = aCustomerName;
	};

	if ((document.getElementById("Label_ConfirmRemoveShipTo_NoUndo")) && (showRemoveWarning == 1)) {
		document.getElementById("Label_ConfirmRemoveShipTo_NoUndo").style.display = ""
	} else {
		document.getElementById("Label_ConfirmRemoveShipTo_NoUndo").style.display = "none"
	};

	if ((document.getElementById("Label_ConfirmRemoveShipTo_MainAddress")) && (isMainAddress == 1)) {
		document.getElementById("Label_ConfirmRemoveShipTo_MainAddress").style.display = ""
	} else {
		document.getElementById("Label_ConfirmRemoveShipTo_MainAddress").style.display = "none"
	};

	if ((document.getElementById("Label_ConfirmRemoveShipTo_CountWarning")) && (deliveryCount <= 1)) {
		document.getElementById("Label_ConfirmRemoveShipTo_CountWarning").style.display = ""
	} else {
		document.getElementById("Label_ConfirmRemoveShipTo_CountWarning").style.display = "none"
	};

	if (document.getElementById("HiddenInput_CurrentCustomerUniqueID")) {
		document.getElementById("HiddenInput_CurrentCustomerUniqueID").value = aCustomerUniqueID;
	};

	ShowAjaxPopup("ModalPopupExtender_LinkButton_RemoveCustomer");
};



function HidePopup_ViewCustomer() {
	HideAjaxPopup("ModalPopupExtender_LinkButton_ViewCustomer");
};







function AdminTools_AddingCustomers_Checked_Checkboxes(customerType) {
	for (var i = 0; i < window.document.forms['HtmlForm_AdminTools_AssignedCustomers'].elements.length; i++) {
		var input = window.document.forms['HtmlForm_AdminTools_AssignedCustomers'].elements[i];
		if (input.type.match(/checkbox/i) &&
			input.id.match(/^GridView_AddingCustomer_CustomerList/i) &&
			input.id.match(/CheckBox_AddingCustomer_Add$/i) &&
			(input.checked)) {
			return true;
		}
	};
	return false;
};

function Check_AdminTools_AddingCustomers_Checkboxes(customerType) {
	if (AdminTools_AddingCustomers_Checked_Checkboxes(customerType)) {
		if (customerType == 3) {
			return (confirm(AdminTools_AddingShipTos_CustomersNotYetPosted));
		}
		else if (customerType == 1) {
			return (confirm(AdminTools_AddingBusinessUnits_CustomersNotYetPosted));
		}
		else if (customerType == 2) {
			return (confirm(AdminTools_AddingBillTos_CustomersNotYetPosted));
		} else {
			return ("You have not yet added your selections. To continue" + "\n" + "and ignore the your selections, press OK. To Add," + "\n" + "Press Cancel and Click on Add Selected");
		}
	} else {
		return true;
	};
};




function AdminTools_AddingShipTos_Checked_Checkboxes() {
	for (var i = 0; i < window.document.forms['HtmlForm_AdminTools_AssignedCustomers'].elements.length; i++) {
		var input = window.document.forms['HtmlForm_AdminTools_AssignedCustomers'].elements[i];
		if (input.type.match(/checkbox/i) &&
			input.id.match(/^GridView_AddingShipTo_ShipToList/i) &&
			input.id.match(/CheckBox_AddingShipTo_Add$/i) &&
			(input.checked)) {
			return true;
		}
	};
	return false;
};

function Check_AdminTools_AddingShipTos_Checkboxes() {
	if (AdminTools_AddingShipTos_Checked_Checkboxes()) {
		return (confirm(AdminTools_AddingShipTos_CustomersNotYetPosted));
	} else {
		return true;
	};
};


function UncheckHeaderCheckBox(aCheckBox, aHeaderCheckBox) {
	if ((document.getElementById(aCheckBox)) && (document.getElementById(aHeaderCheckBox)) &&
		(!(document.getElementById(aCheckBox).checked)) &&
		(document.getElementById(aHeaderCheckBox).checked)) {
		document.getElementById(aHeaderCheckBox).checked = false;
	};
};


function AdminTools_AddingBillTos_Checked_Checkboxes() {
	for (var i = 0; i < window.document.forms['HtmlForm_AdminTools_AssignedCustomers'].elements.length; i++) {
		var input = window.document.forms['HtmlForm_AdminTools_AssignedCustomers'].elements[i];
		if (input.type.match(/checkbox/i) &&
			input.id.match(/^GridView_AddingBillTo_BillToList/i) &&
			input.id.match(/CheckBox_AddingBillTo_Add$/i) &&
			(input.checked)) {
			return true;
		}
	};
	return false;
};


function Check_AdminTools_AddingBillTos_Checkboxes() {
	if (AdminTools_AddingBillTos_Checked_Checkboxes()) {
		return (confirm(AdminTools_AddingBillTos_CustomersNotYetPosted));
	} else {
		return true
	};
};
// ------------------------ AdminTools_AssignedCustomers --------------------------

