var imgNoOfPeople = new Array(8);
var imgNoOfCards = new Array(8);
var txtNoOfPeople = new Array(8);
var txtNoOfCards = new Array(8);
var txtOverallFacilityLimit = new Array(6);
var txtPaymentOption = new Array(3);
var txtVelocityPoints = new Array(3);
var recommendationPages = new Array(4);
var errorMessageText = new Array(8);

txtPaymentOption[0] = "";


function initialize() {
    imgNoOfPeople[0] = "";
    imgNoOfPeople[1] = "/vgnmedia/images/Business_Solutions/1person.jpg";
    imgNoOfPeople[2] = "/vgnmedia/images/Business_Solutions/2people.jpg";
    imgNoOfPeople[3] = "/vgnmedia/images/Business_Solutions/3people.jpg";
    imgNoOfPeople[4] = "/vgnmedia/images/Business_Solutions/4people.jpg";
    imgNoOfPeople[5] = "/vgnmedia/images/Business_Solutions/5to10people.jpg";
    imgNoOfPeople[6] = "/vgnmedia/images/Business_Solutions/11to49people.jpg";
    imgNoOfPeople[7] = "/vgnmedia/images/Business_Solutions/50+people.jpg";

    imgNoOfCards[0] = "";
    imgNoOfCards[1] = "/vgnmedia/images/Business_Solutions/1card.jpg";
    imgNoOfCards[2] = "/vgnmedia/images/Business_Solutions/2cards.jpg";
    imgNoOfCards[3] = "/vgnmedia/images/Business_Solutions/3cards.jpg";
    imgNoOfCards[4] = "/vgnmedia/images/Business_Solutions/4cards.jpg";
    imgNoOfCards[5] = "/vgnmedia/images/Business_Solutions/5to10cards.jpg";
    imgNoOfCards[6] = "/vgnmedia/images/Business_Solutions/11to49cards.jpg";
    imgNoOfCards[7] = "/vgnmedia/images/Business_Solutions/50+cards.jpg";

    if (document.images)
    {
        var preloadImgNoOfPeople_1 = new Image(170,152);
        preloadImgNoOfPeople_1.src = imgNoOfPeople[1];
        var preloadImgNoOfPeople_2 = new Image(170,152);
        preloadImgNoOfPeople_2.src = imgNoOfPeople[2];
        var preloadImgNoOfPeople_3 = new Image(170,152);
        preloadImgNoOfPeople_3.src = imgNoOfPeople[3];
        var preloadImgNoOfPeople_4 = new Image(170,152);
        preloadImgNoOfPeople_4.src = imgNoOfPeople[4];
        var preloadImgNoOfPeople_5 = new Image(170,152);
        preloadImgNoOfPeople_5.src = imgNoOfPeople[5];
        var preloadImgNoOfPeople_6 = new Image(170,152);
        preloadImgNoOfPeople_6.src = imgNoOfPeople[6];
        var preloadImgNoOfPeople_7 = new Image(170,152);
        preloadImgNoOfPeople_7.src = imgNoOfPeople[7];

        var preloadImgNoOfCards_1 = new Image(261, 122);
        preloadImgNoOfCards_1 = imgNoOfCards[1];
        var preloadImgNoOfCards_2 = new Image(261, 122);
        preloadImgNoOfCards_2 = imgNoOfCards[2];
        var preloadImgNoOfCards_3 = new Image(261, 122);
        preloadImgNoOfCards_3 = imgNoOfCards[3];
        var preloadImgNoOfCards_4 = new Image(261, 122);
        preloadImgNoOfCards_4 = imgNoOfCards[4];
        var preloadImgNoOfCards_5 = new Image(261, 122);
        preloadImgNoOfCards_5 = imgNoOfCards[5];
        var preloadImgNoOfCards_6 = new Image(261, 122);
        preloadImgNoOfCards_6 = imgNoOfCards[6];
        var preloadImgNoOfCards_7 = new Image(261, 122);
        preloadImgNoOfCards_7 = imgNoOfCards[7];
    }
    // initialize txtNoOfPeople
    txtNoOfPeople[0] = "";
    txtNoOfPeople[1] = "You selected 1 employee ";
    txtNoOfPeople[2] = "You selected 2 employees"
    txtNoOfPeople[3] = "You selected 3 employees";
    txtNoOfPeople[4] = "You selected 4 employees";
    txtNoOfPeople[5] = "You selected between 5 and 10 employees";
    txtNoOfPeople[6] = "You selected between 11 and 49 employees";
    txtNoOfPeople[7] = "You selected over 50 employees";


    // initialize txtNoOfCards
    txtNoOfCards[0] = "";
    txtNoOfCards[1] = "You selected 1 card";
    txtNoOfCards[2] = "You selected 2 cards";
    txtNoOfCards[3] = "You selected 3 cards";
    txtNoOfCards[4] = "You selected 4 cards";
    txtNoOfCards[5] = "You selected between 5 and 10 cards";
    txtNoOfCards[6] = "You selected between 11 and 49 cards";
    txtNoOfCards[7] = "You selected over 50 cards";

    // initialize txtOverallFacilityLimit
    txtOverallFacilityLimit[0] = "";

    txtOverallFacilityLimit[1] = "<h1>$5000</h1><span class='noteText'>With NAB Business Access and NAB Business Card you can allocate different limits to each of your cards. <a href=\'/wps/wcm/connect/nab/nab/home/Business_Solutions/2/1/8\' onClick=\"window.open(\'/wps/wcm/connect/nab/nab/home/Business_Solutions/2/1/8\',\'oflWindow\',\'width=800,height=600,toolbar=no, location=no,directories=no,status=yes,menubar=no,scrollbars=yes,copyhistory=no, resizable=yes\'); return false;\">Find out more.</a><br /><strong>Please note:</strong> you can not allocate different limits with a Velocity NAB Business American Express&#174; Card.</span>";

    txtOverallFacilityLimit[2] = "<h1>Between $6,000 and $10,000</h1><span class='noteText'>With NAB Business Access and NAB Business Card you can allocate different limits to each of your cards. <a href=\'/wps/wcm/connect/nab/nab/home/Business_Solutions/2/1/8\' onClick=\"window.open(\'/wps/wcm/connect/nab/nab/home/Business_Solutions/2/1/8\',\'oflWindow\',\'width=800,height=600,toolbar=no, location=no,directories=no,status=yes,menubar=no,scrollbars=yes,copyhistory=no, resizable=yes\'); return false;\">Find out more.</a><br /><strong>Please note:</strong> you can not allocate different limits with a Velocity NAB Business American Express&#174; Card.</span>";

    txtOverallFacilityLimit[3] = "<h1>Between $11,000 and $19,000</h1><span class='noteText'>With NAB Business Access and NAB Business Card you can allocate different limits to each of your cards. <a href=\'/wps/wcm/connect/nab/nab/home/Business_Solutions/2/1/8\' onClick=\"window.open(\'/wps/wcm/connect/nab/nab/home/Business_Solutions/2/1/8\',\'oflWindow\',\'width=800,height=600,toolbar=no, location=no,directories=no,status=yes,menubar=no,scrollbars=yes,copyhistory=no, resizable=yes\'); return false;\">Find out more.</a><br /><strong>Please note:</strong> you can not allocate different limits with a Velocity NAB Business American Express&#174; Card.</span>";

    txtOverallFacilityLimit[4] = "<h1>Between $20,000 and $49,000</h1><span class='noteText'>With NAB Business Access and NAB Business Card you can allocate different limits to each of your cards. <a href=\'/wps/wcm/connect/nab/nab/home/Business_Solutions/2/1/8\' onClick=\"window.open(\'/wps/wcm/connect/nab/nab/home/Business_Solutions/2/1/8\',\'oflWindow\',\'width=800,height=600,toolbar=no, location=no,directories=no,status=yes,menubar=no,scrollbars=yes,copyhistory=no, resizable=yes\'); return false;\">Find out more.</a><br /><strong>Please note:</strong> you can not allocate different limits with a Velocity NAB Business American Express&#174; Card.</span>";

    txtOverallFacilityLimit[5] = "<h1>Over $50,000</h1><span class='noteText'>With NAB Business Access and NAB Business Card you can allocate different limits to each of your cards. <a href=\'/wps/wcm/connect/nab/nab/home/Business_Solutions/2/1/8\' onClick=\"window.open(\'/wps/wcm/connect/nab/nab/home/Business_Solutions/2/1/8\',\'oflWindow\',\'width=800,height=600,toolbar=no, location=no,directories=no,status=yes,menubar=no,scrollbars=yes,copyhistory=no, resizable=yes\'); return false;\">Find out more.</a><br /><strong>Please note:</strong> you can not allocate different limits with a Velocity NAB Business American Express&#174; Card.</span>";


    // initialize txtPaymentOption
    txtPaymentOption[0] = "";
    txtPaymentOption[1] = "You selected Credit Card";
    txtPaymentOption[2] = "You selected Charge Card";

	// initialize txtVelocityPoints
    txtVelocityPoints[0] = "";
    txtVelocityPoints[1] = "You selected Yes";
    txtVelocityPoints[2] = "You selected No";

    // initialize recommendationPages
    recommendationPages[0] = "";
    //ComCard
    recommendationPages[1] = "/wps/wcm/connect/nab/nab/home/Business_Solutions/2/3";
    //BC
    recommendationPages[2] = "/wps/wcm/connect/nab/nab/home/Business_Solutions/2/2/1";
    //BAC
    recommendationPages[3] = "/wps/wcm/connect/nab/nab/home/Business_Solutions/2/1/2";
	//VBC
	recommendationPages[4] = "/wps/wcm/connect/nab/nab/home/Business_Solutions/2/1/1";

    //initialize errorMessageText
    errorMessageText[0] = "";
    errorMessageText[1] = "Please make a selection";
    errorMessageText[2] = "Please make a selection";
    errorMessageText[3] = "Please make a selection";
    errorMessageText[4] = "Please make a selection";
	errorMessageText[5] = "Please make a selection";

    // Register
    // document.onkeypress = globalOnKeyPressHandler;


    return true;
}

function addElementAt(arrayName, value, nIndex) {
    if (arrayName = "recommendationPages") {
        recommendationPages[nIndex] = value;
    } else if (arrayName == "imgNoOfPeople") {
        imgNoOfPeople[nIndex] = value;
    } else if (arrayName == "imgNoOfCards") {
        imgNoOfCards[nIndex] = value;
    } else if (arrayName == "txtNoOfPeople") {
        txtNoOfPeople[nIndex] = value;
    } else if (arrayName == "txtNoOfCards") {
        txtNoOfCards[nIndex] = value;
    } else if (arrayName == "txtOverallFacilityLimit") {
        txtOverallFacilityLimit[nIndex] = value;
    } else if(arrayName == "txtPaymentOption") {
        txtPaymentOption[nIndex] = value;
	} else if(arrayName == "txtVelocityPoints") {
        txtVelocityPoints[nIndex] = value;
    } else if (arrayName = "errorMessageText") {
        errorMessageText[nIndex] = value;
    }

    return true;
}

function elemD(value) {
    txtOverallFacilityLimit[3] = value;
    return true;
}

function hideDiv(divName) { 
    if(document.layers) {
        document.layers[divName].visibility = "hide";
    } else if(document.getElementById) {
        var hDiv = document.getElementById(divName);
        hDiv.style.visibility = "hidden";
    } else if (document.all) {
        document.all[divName].style.visibility = "hidden";
    }
    return true;
}

function showDiv(divName) { 
    if(document.layers) {
        document.layers[divName].visibility = "show";
    } else if(document.getElementById) {
        var hDiv = document.getElementById(divName);
        hDiv.style.visibility = "visible";
    } else if (document.all) {
        document.all[divName].style.visibility = "visible";
    }
    return true;
} 

function displayText(divName, message) {
    if(document.layers) {
        document.layers[divName].textLayer.document.write(message);
    } else if(document.getElementById) {
        var hDiv = document.getElementById(divName);
        hDiv.innerHTML = message;
    } else if (document.all) {
        document.all[divName].innerHTML = message;
    }
}

function displayError(divName, message) {
    if(document.layers) {
        document.layers[divName].textLayer.document.write(message);
    } else if(document.getElementById) {
        var hDiv = document.getElementById(divName);
        hDiv.innerHTML = message;
    } else if (document.all) {
        document.all[divName].innerHTML = message;
    }
}

function frmSubmit() {
    var nSelNoOfPeople = document.frmProductSelector.selNoOfPeople.selectedIndex;
    var nSelNoOfCards = document.frmProductSelector.selNoOfCards.selectedIndex;
    var nSelPaymentOption = document.frmProductSelector.selPaymentOption.selectedIndex;
    var nSelOverallFacilityLimit = document.frmProductSelector.selOverallFacilityLimit.selectedIndex;
	var nSelVelocityPoints = document.frmProductSelector.selVelocityPoints.selectedIndex;

    var bIsValid = validateSelection(nSelNoOfPeople, nSelNoOfCards, nSelOverallFacilityLimit, nSelPaymentOption, nSelVelocityPoints);
    if (!bIsValid) {
        return false;
    }

    var nRecommendation = recommendCard(nSelNoOfPeople, nSelNoOfCards, nSelOverallFacilityLimit, nSelPaymentOption, nSelVelocityPoints);
    var url = "";
    if ((nRecommendation > 0) && (nRecommendation < 5)) {
        url = recommendationPages[nRecommendation];
    } else {
        alert('Unexpected Result');
    }

    if (url != "") {
        document.frmProductSelector.action = url;
        document.frmProductSelector.submit();
    }
}


function setImage(hSelect, hImage, imageName, divName) {
    imageIndex = hSelect.selectedIndex;
    if(imageIndex < 0) {
        return false;
    }
    if(imageIndex == 0) {
        hideDiv(divName);
    } else {
        if (document.images) {
            if (imageName == "imgNoOfPeople") {
                hImage.src = imgNoOfPeople[imageIndex];
                hImage.alt = txtNoOfPeople[imageIndex];
            } else if(imageName == "imgNoOfCards") {
                hImage.src = imgNoOfCards[imageIndex];
                hImage.alt = txtNoOfCards[imageIndex];
            }
            //hImage.src = eval(imageName + "_" + imageIndex);
            showDiv(divName);
        }
    }

    return true;
}

function setText(hSelect, arrayName, divName) {
    nIndex = hSelect.selectedIndex;
    if(nIndex < 0) {
        return false;
    }
    if (arrayName == "txtNoOfPeople") {
        displayText(divName, txtNoOfPeople[nIndex]);
    } else if (arrayName == "txtNoOfCards") {
        displayText(divName, txtNoOfCards[nIndex]);
    } else if(arrayName == "txtOverallFacilityLimit") {
        displayText(divName, txtOverallFacilityLimit[nIndex]);
    } else if(arrayName == "txtPaymentOption") {
        displayText(divName, txtPaymentOption[nIndex]);
    } else if(arrayName == "txtVelocityPoints") {
        displayText(divName, txtVelocityPoints[nIndex]);
    }

    return true;
}

function recommendCard(nSelNoOfPeople, nSelNoOfCards, nSelOverallFacilityLimit, nSelPaymentOption, nSelVelocityPoints) {
    var nRecommendation = -1;

    if (isEligibleForComCard(nSelNoOfPeople, nSelNoOfCards, nSelOverallFacilityLimit, nSelPaymentOption, nSelVelocityPoints)) {
        nRecommendation = 1;
    } else if (isEligibleForVBC(nSelNoOfPeople, nSelNoOfCards, nSelOverallFacilityLimit, nSelPaymentOption, nSelVelocityPoints)) {
        nRecommendation = 4;
    } else if (isEligibleForBC(nSelNoOfPeople, nSelNoOfCards, nSelOverallFacilityLimit, nSelPaymentOption, nSelVelocityPoints)) {
        nRecommendation = 2;
    } else if (isEligibleForBAC(nSelNoOfPeople, nSelNoOfCards, nSelOverallFacilityLimit, nSelPaymentOption, nSelVelocityPoints)) {
        nRecommendation = 3;
	} else {
        alert('Error in Logic');
    }

    return nRecommendation;
}

function validateSelection(nSelNoOfPeople, nSelNoOfCards, nSelOverallFacilityLimit, nSelPaymentOption, nSelVelocityPoints) {
    var bIsValid = true;

    if(nSelNoOfPeople == 0) {
        displayError('divErrorMessage_1', errorMessageText[1]);
	showDiv('divErrorMessage_1');
        showDiv('divErrorImage_1');
	bIsValid = false;
    } else {
		hideDiv('divErrorMessage_1');
        hideDiv('divErrorImage_1');
    }

    if(nSelNoOfCards == 0) {
        displayError('divErrorMessage_2', errorMessageText[2]);
	showDiv('divErrorMessage_2');
        showDiv('divErrorImage_2');
	bIsValid = false;
    //  Bug fix, People < Cards condition can exist
    //} else if((nSelNoOfPeople > 0) && (nSelNoOfCards > nSelNoOfPeople)) {
    //    displayError('divErrorMessage_2', errorMessageText[5]);
    //	showDiv('divErrorMessage_2');
    //    showDiv('divErrorImage_2');
    //	bIsValid = false;	
    } else {
		hideDiv('divErrorMessage_2');
        hideDiv('divErrorImage_2');
    }

    if(nSelOverallFacilityLimit == 0) {
        displayError('divErrorMessage_3', errorMessageText[3]);
	showDiv('divErrorMessage_3');
        showDiv('divErrorImage_3');
	bIsValid = false;
    } else {
		hideDiv('divErrorMessage_3');
        hideDiv('divErrorImage_3');
    }

    if(nSelPaymentOption == 0) {
        displayError('divErrorMessage_4', errorMessageText[4]);
	showDiv('divErrorMessage_4');
        showDiv('divErrorImage_4');
	bIsValid = false;
    } else {
		hideDiv('divErrorMessage_4');
        hideDiv('divErrorImage_4');
    }

	if(nSelVelocityPoints == 0) {
        displayError('divErrorMessage_5', errorMessageText[5]);
	showDiv('divErrorMessage_5');
        showDiv('divErrorImage_5');
	bIsValid = false;
    } else {
		hideDiv('divErrorMessage_5');
        hideDiv('divErrorImage_5');
    }

    //Invalid Selection combination

    return bIsValid;
}

function isEligibleForComCard(nSelNoOfPeople, nSelNoOfCards, nSelOverallFacilityLimit, nSelPaymentOption, nSelVelocityPoints) {
    var bIsEligible = false;

    // Logic for changed requirement where only 50+ cards recommend ComCard
    if (nSelNoOfCards == 7) {
        bIsEligible = true;
    }
    return bIsEligible;
}

function isEligibleForBC(nSelNoOfPeople, nSelNoOfCards, nSelOverallFacilityLimit, nSelPaymentOption, nSelVelocityPoints) {
    var bIsEligible = false;

    if ((nSelNoOfCards == 6)) {
        bIsEligible = true;
        // change nSelPaymentOption 1 to 2
    } else if(nSelPaymentOption == 2) {
		bIsEligible = true;
    }
    return bIsEligible;
}

function isEligibleForBAC(nSelNoOfPeople, nSelNoOfCards, nSelOverallFacilityLimit, nSelPaymentOption, nSelVelocityPoints) {
    var bIsEligible = false;

    // Change according to new requirement where ComCard is recommended only if 50+ cards are selected
    if ((!(nSelNoOfCards == 6)) && (nSelPaymentOption == 1)) {
         bIsEligible = true;
    }
    return bIsEligible;
}

function isEligibleForVBC(nSelNoOfPeople, nSelNoOfCards, nSelOverallFacilityLimit, nSelPaymentOption, nSelVelocityPoints) {
    var bIsEligible = false;

    if ((nSelNoOfPeople != 7) && ((nSelNoOfCards == 1) || (nSelNoOfCards == 2)) && (nSelVelocityPoints == 1)) {
         bIsEligible = true;
    }
    return bIsEligible;
}

function globalOnKeyPressHandler(e) {
    if (document.all) {
        e = window.event;
    }
    
    var key;
    // if (document.layers)
    key = e.which;
    
    if (document.all) {
        key = e.keyCode
    }

    var chr = String.fromCharCode(key);
    if (key == 13) {
        frmSubmit();
    }

    return true;
}

function globalOnKeyPressHandlerNonSelector(e) {
    if (document.all) {
        e = window.event;
    }
    
    var key;
    key = e.which;
    
    if (document.all) {
        key = e.keyCode
    }

    var chr = String.fromCharCode(key);
    if (key == 13) {
	// alert('Character representation of pressed was ' + chr);
        sendToUrlWithState();
    }

    return true;
}


function getQueryVariable(variable) {
  var query = window.location.search.substring(1);
  var vars = query.split("&");
  for (var i=0;i<vars.length;i++) {
    var pair = vars[i].split("=");
    if (pair[0] == variable) {
      return pair[1];
    }
  } 
  return "";
}

function restoreState() {
    var stateSelNoOfPeople = getQueryVariable("selNoOfPeople");
    var stateSelNoOfCards = getQueryVariable("selNoOfCards");
    var stateSelOverallFacilityLimit = getQueryVariable("selOverallFacilityLimit");
    var stateSelPaymentOption = getQueryVariable("selPaymentOption");
	var stateSelVelocityPoints = getQueryVariable("selVelocityPoints");

	if (stateSelNoOfPeople != "") {
		if (stateSelNoOfPeople<0 ||stateSelNoOfPeople>7) {
            stateSelNoOfPeople = 0;
        }
        document.frmProductSelector.selNoOfPeople.selectedIndex = stateSelNoOfPeople;
    }
    setImage(document.frmProductSelector.selNoOfPeople, document.frmProductSelector.imgNoOfPeople, 'imgNoOfPeople', 'divImgNoOfPeople');
    setText(document.frmProductSelector.selNoOfPeople, 'txtNoOfPeople', 'divTxtNoOfPeople');

    if (stateSelNoOfCards != "") {
        if (stateSelNoOfCards<0 || stateSelNoOfCards>7) {
            stateSelNoOfCards = 0;
        }
        document.frmProductSelector.selNoOfCards.selectedIndex = stateSelNoOfCards;
    }
    setImage(document.frmProductSelector.selNoOfCards, document.frmProductSelector.imgNoOfCards, 'imgNoOfCards', 'divImgNoOfCards');
    setText(document.frmProductSelector.selNoOfCards, 'txtNoOfCards', 'divTxtNoOfCards');

    if (stateSelOverallFacilityLimit != "") {
        if (stateSelOverallFacilityLimit<0 || stateSelOverallFacilityLimit>5) {
            stateSelOverallFacilityLimit = 0
        }
        document.frmProductSelector.selOverallFacilityLimit.selectedIndex = stateSelOverallFacilityLimit;
    }
    setText(document.frmProductSelector.selOverallFacilityLimit, 'txtOverallFacilityLimit', 'divTxtOverallFacilityLimit');

    if (stateSelPaymentOption != "") {
        if (stateSelPaymentOption<0 || stateSelPaymentOption>2) {
            stateSelPaymentOption = 0;
        }
        document.frmProductSelector.selPaymentOption.selectedIndex = stateSelPaymentOption;
    }
    setText(document.frmProductSelector.selPaymentOption, 'txtPaymentOption', 'divTxtPaymentOption');

	if (stateSelVelocityPoints != "") {
        if (stateSelVelocityPoints<0 || stateSelVelocityPoints>2) {
            stateSelVelocityPoints = 0;
        }
        document.frmProductSelector.selVelocityPoints.selectedIndex = stateSelVelocityPoints;
    }
    setText(document.frmProductSelector.selVelocityPoints, 'txtVelocityPoints', 'divTxtVelocityPoints');

    return true;
}

function sendToUrlWithState(urlName) {
    var stateSelNoOfPeople = getQueryVariable("selNoOfPeople");
    var stateSelNoOfCards = getQueryVariable("selNoOfCards");
    var stateSelOverallFacilityLimit = getQueryVariable("selOverallFacilityLimit");
    var stateSelPaymentOption = getQueryVariable("selPaymentOption");
	var stateSelVelocityPoints = getQueryVariable("selVelocityPoints");

    if (stateSelNoOfPeople != "" && (stateSelNoOfPeople>=0 && stateSelNoOfPeople<8)) {
        document.frmProductSelector.selNoOfPeople.value = stateSelNoOfPeople;
    }

    if (stateSelNoOfCards != "" && (stateSelNoOfCards>=0 && stateSelNoOfCards<8)) {
        document.frmProductSelector.selNoOfCards.value = stateSelNoOfCards;
    }

    if (stateSelOverallFacilityLimit != "" && (stateSelOverallFacilityLimit>=0 && stateSelOverallFacilityLimit<6)) {
       document.frmProductSelector.selOverallFacilityLimit.value = stateSelOverallFacilityLimit;
    }

    if (stateSelPaymentOption != "" && (stateSelPaymentOption>=0 && stateSelPaymentOption<3)) {
       document.frmProductSelector.selPaymentOption.value = stateSelPaymentOption;
    }

    if (stateSelVelocityPoints != "" && (stateSelVelocityPoints>=0 && stateSelVelocityPoints<3)) {
       document.frmProductSelector.selVelocityPoints.value = stateSelVelocityPoints;
    }

    if (urlName != "") {
        document.frmProductSelector.action = urlName;
        document.frmProductSelector.submit();
    }

    return true;
}

function sendToUrlWithState() {
    var stateSelNoOfPeople = getQueryVariable("selNoOfPeople");
    var stateSelNoOfCards = getQueryVariable("selNoOfCards");
    var stateSelOverallFacilityLimit = getQueryVariable("selOverallFacilityLimit");
    var stateSelPaymentOption = getQueryVariable("selPaymentOption");
	var stateSelVelocityPoints = getQueryVariable("selVelocityPoints");
    var urlName = "";

    if (stateSelNoOfPeople != "" && (stateSelNoOfPeople>=0 && stateSelNoOfPeople<8)) {
        document.frmProductSelector.selNoOfPeople.value = stateSelNoOfPeople;
    }

    if (stateSelNoOfCards != "" && (stateSelNoOfCards>=0 && stateSelNoOfCards<8)) {
        document.frmProductSelector.selNoOfCards.value = stateSelNoOfCards;
    }

    if (stateSelOverallFacilityLimit != "" && (stateSelOverallFacilityLimit>=0 && stateSelOverallFacilityLimit<6)) {
       document.frmProductSelector.selOverallFacilityLimit.value = stateSelOverallFacilityLimit;
    }

    if (stateSelPaymentOption != "" && (stateSelPaymentOption>=0 && stateSelPaymentOption<3)) {
       document.frmProductSelector.selPaymentOption.value = stateSelPaymentOption;
    }

	if (stateSelVelocityPoints != "" && (stateSelVelocityPoints>=0 && stateSelVelocityPoints<3)) {
       document.frmProductSelector.selVelocityPoints.value = stateSelVelocityPoints;
    }

    urlName = document.frmProductSelector.action;

    if (urlName != "") {
        document.frmProductSelector.submit();
    }

    return true;
}
