﻿/*var timeout = 500;
var hidetimer = 0;
var currentElement;

function ShowHelp(x) {
    if (hidetimer) {
        window.clearTimeout(hidetimer);
        hidetimer = null;
    }

    if (currentElement)
        document.getElementById(currentElement).style.display = "none";

    currentElement = x;
    document.getElementById(currentElement).style.display = "inline";
}*/

/*function HideHelp() {
    document.getElementById(currentElement).style.display = "none";
}

function HideHelpDelay(x) {
    currentElement = x;
    hidetimer = window.setTimeout(HideHelp, timeout);
}*/


function stopRKey(evt) {
    var evt = (evt) ? evt : ((event) ? event : null);
    var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
    if ((evt.keyCode == 13) && (node.type == "text")) { return false; }
}

document.onkeypress = stopRKey;


function checkLength(control, charlength) {
    maxnum = charlength; // The maximum number of characters.

    div = document.getElementById(control);

    charleft = document.getElementById("CharacterCounter");
    charleft.innerHTML = maxnum - div.value.length;

    if (charleft.value <= 0)
        charleft.value = "max";

    if (div.value.length > maxnum)
        div.value = div.value.substring(0, maxnum - 1);

}

function checkLength(control, charlength, counterId) {
    maxnum = charlength; // The maximum number of characters.

    div = document.getElementById(control);

    charleft = document.getElementById(counterId);
    charleft.innerHTML = maxnum - div.value.length;

    if (charleft.value <= 0)
        charleft.value = "max";

    if (div.value.length > maxnum)
        div.value = div.value.substring(0, maxnum - 1);

}


function LargeAmountCheck(x) {
    var elem = document.getElementById(x);
    var amount = elem.value;

    amount = amount.replace(",", "");
    amount = amount.replace("$", "");
    amount = amount.replace("€", "");
    amount = amount.replace("£", "");

    if (elem.value.indexOf(",") != -1 && amount <= 1000) {
        alert("Please make sure you have not entered any special characters i.e. comma's etc... the format should be 20.00 or 20");
    }

    if (amount != "" && amount > 1000) {
        alert("Wow, that is a generous donation but we just wanted to check that you wish to donate $" + amount + "?\n\nIf this is incorrect, please make sure you have not entered any special characters i.e. comma's etc... the format should be 20.00 or 20");
    }

    elem.value = amount;
}

function openTC() {
    window.open("/terms.aspx", "TermsAndConditions", "menubar=1,resizable=1,width=800,height=500,scrollbars=yes");
}

function openPaymentTerms(x) {
    window.open("/paymentterms.aspx", "PaymentTerms", "menubar=1,resizable=1,width=780,height=500,scrollbars=yes");
}

function openCompetitionTerms() {
    window.open("/competitionterms.aspx", "CompetitionTerms", "menubar=1,resizable=1,width=780,height=500,scrollbars=yes");
}

function removeSpaces(string) {
    return string.split(' ').join('');
}