﻿/* ------------------------------------------------------------- */
// creates a url (including querystring) that incorporates values from html elements 
//  specified in the delimited fieldString parameter provided...
function ConvertFormToQuerystring(targetUrl, fieldPrefix, fieldString, delimiter) {
    var fArray = new Array();
    fArray = fieldString.split(delimiter);
    var qs = targetUrl + '?';
    for (var i = 0; i < fArray.length - 1; i++) {
        ctrlId = fieldPrefix + fArray[i];
        ctrl = document.getElementsByName(ctrlId)[0];
        qs += fArray[i] + '=' + ctrl.value + '&';
    }
    var retval = escape(qs.substr(0, qs.length - 1));
    return retval;
}
/* ------------------------------------------------------------- */
function setFormValue(controlName, newValue, matchConditionalValue, conditionalValueToMatch) {
        var ctrl = eval('document.aspnetForm.' + controlName);
        if (!matchConditionalValue | ctrl.value==conditionalValueToMatch) {
            ctrl.value = newValue;
        }
    try {
        } catch (ex) {
    }
}
/* ------------------------------------------------------------- */
function findSelectedValue(element) {
    retVal = '';
    try {
        retVal = document.getElementsByName(element)[0].value;
    }
    catch (err) {

    }
    return retVal;
}
/* ------------------------------------------------------------- */
/* ------------------------------------------------------------- */

/* generic validation handler (used in shipping address controls) */

var errorMessageControl = '';

function hideErrorMessage() {
    try {
        document.getElementById(errorMessageControl).style.display = 'none';
    } catch (Error) {

    }
}

function unhideErrorMessage(controlId) {
    errorMessageControl = controlId;
    var isBlockedByError = IsValidatorInvalid();
    if (isBlockedByError) {
        document.getElementById(controlId).style.display = 'block';
    }
}

function IsValidatorInvalid() {
    Page_ClientValidate();
    var i;
    for (i = 0; i < Page_Validators.length; i++) {
        if (!Page_Validators[i].isvalid) {
            return true
        }
    }
    return false;
}
/* ------------------------------------------------------------- */

