﻿window.onload = function () {
    var country = document.getElementById("ShippingCountry");
    var startDate = document.getElementById("CardStartROW3");
    var cardIssue = document.getElementById("CardIssueROW1");
    var countrySelected = document.getElementById("CountrySelectList");
    var noteUK = document.getElementById("noticeUK");
   /* var localeSettingGB = "localeSetting=en-GB";
    var currencySettingGB = "currencySetting=GBP";
    var localeSettingUS = "localeSetting=en-US";
    var currencySettingUS = "currencySetting=USD";


    if (location.pathname.indexOf(localeSettingGB) >= 0) {
        window.location = "http://store.nurturedpets.com/showcategory.aspx?categoryid=8&localesetting=en-GB&currencysetting=GBP";
    }

    if (location.pathname.indexOf(currencySettingGB) >= 0) {
        window.location = "http://store.nurturedpets.com/showcategory.aspx?categoryid=8&localesetting=en-GB&currencysetting=GBP";
    }

    if (location.pathname.indexOf(localeSettingUS) >= 0) {
        window.location = "http://store.nurturedpets.com/showcategory.aspx?categoryid=7&localesetting=en-US&currencysetting=USD";
    }

    if (location.pathname.indexOf(currencySettingUS) >= 0) {
        window.location = "http://store.nurturedpets.com/showcategory.aspx?categoryid=7&localesetting=en-US&currencysetting=USD";
    }*/

    if (country != null) {
        if (country.value == "United States") {

            startDate.style.display = 'none';
            cardIssue.style.display = 'none';
        }

        if (country.value != "United States") {

            startDate.style.display = '';
            cardIssue.style.display = '';
        }

        if (country.value == "Canada") {

            startDate.style.display = '';
            cardIssue.style.display = '';

        }

        if (countrySelected.value == "United Kingdom") {

            country.value = "United Kingdom";
            noteUK.style.display = 'block';
        }

        if (countrySelected.value == "Canada") {

            country.value = "Canada";
        }
    }


    //If countrySelected exists
    if (countrySelected != null) {
        if (countrySelected.options[countrySelected.selectedIndex].text == "United Kingdom") {
            noteUK.style.display = 'block';
        }
    }
}

function updateFirstName() 
{

var  currentPage = "checkout1.aspx";
if (location.href.indexOf(currentPage) >= 0) {
    var firstName = document.getElementById("FirstName");
    var billingFirstName = document.getElementById("BillingFirstName");

    billingFirstName.value = firstName.value;
}
}

function updateLastName() {

    var currentPage2 = "checkout1.aspx";
    if (location.href.indexOf(currentPage2) >= 0) {
        var lastName = document.getElementById("LastName");
        var billingLastName = document.getElementById("BillingLastName");

        billingLastName.value = lastName.value;
    }
}

function updatePhone() {

    var currentPage4 = "createaccount.aspx";
    if (location.href.indexOf(currentPage4) >= 0) {
        var phone = document.getElementById("Phone");
        var billingPhone = document.getElementById("BillingPhone");

        billingPhone.value = phone.value;
    }
}
