// form subbmition
submittedFlag = false


function submitForm(obj) {
    if (!submittedFlag) {
        while (obj.tagName != "FORM") {
            obj = obj.parentNode
        }
        obj.submit()
    }
    submittedFlag = true
}
function getProductQty(formID) {
    obj = document.getElementById("F" + formID)
    return (obj.product_qty.value)
}
function validateForm(obj) {
    if (document.getElementById("accept_terms").checked) {
        submitForm(obj)
    } else {
        alert(document.getElementById("accept_terms_message").getAttribute("value"))
    }
}

//showing and hiding stuff
function hideElement(element_id) {
    if (document.getElementById && document.getElementById(element_id) && document.getElementById(element_id).style) {
        document.getElementById(element_id).style.visibility = "hidden";
        document.getElementById(element_id).style.display = "none"
    };
}
function showElement(element_id) {
    if (document.getElementById && document.getElementById(element_id) && document.getElementById(element_id).style) {
        document.getElementById(element_id).style.visibility = "visible";
        document.getElementById(element_id).style.display = ""
    };
}

// for stor popups referense
function setFormCaller(obj) {
    openerForm = obj
    needupdate = true
}

// popup openers
function opendemo() {
    window.open("howtodemo/howtodemo.html", "howtodemo", "addressbar=no,top=5,left=5,width=790,height=430,resize=yes")
}
function openlicense() {
    window.open("LiscenceAgreement.asp", "liscenceagreement", "addressbar=no,top=15,left=5,width=500,height=430,resize=yes,scrollbars=yes")
}
function openliscence() {
    window.open("LiscenceAgreement.asp", "liscenceagreement", "addressbar=no,top=15,left=5,width=500,height=430,resize=yes,scrollbars=yes")
}
function openNewlicence() {
    window.open("images/catalog/cylinders/UserLicence_60L_UK.pdf", "Cylinder_60L_Licence", "addressbar=no,scrollbars=yes,top=5,left=5,width=790,height=430,resize=yes")
}

//

function showMessage() {
    hideElement("messagecont")
    newMessage = document.getElementById("message").getAttribute("message")
    if (newMessage != "") {
        showElement("messagecont")
        document.getElementById('messageTD').innerHTML = newMessage
        for (var i = 1; i < 6; i++) {
            nexth = i * (69 / 5)
            moveAction = "document.getElementById('messagecont').style.height='" + nexth + "px';document.getElementById('messagecont').style.top='-" + nexth + "px'"
            window.setTimeout(moveAction, i * 50)
        }
        window.setTimeout("closeMessage()", i * 50 + 3300)
    }

}

function closeMessage() {
    for (var i = 1; i < 6; i++) {
        nexth = 69 - i * (69 / 5)
        moveAction = "document.getElementById('messagecont').style.height='" + nexth + "px';document.getElementById('messagecont').style.top='-" + nexth + "px'"
        window.setTimeout(moveAction, i * 50)
    }
    window.setTimeout("hideElement('messagecont')", 5 * 50)
}
function fulls() {
    if (window.history.length <= 1) {
        window.moveTo(0, 0);
        if (document.all) {

            window.resizeTo(screen.availWidth, screen.availHeight);
        }
        else if (document.layers || document.getElementById) {
            if (window.outerHeight < screen.availHeight || window.outerWidth < screen.availWidth) {
                window.outerHeight = screen.availHeight;
                window.outerWidth = screen.availWidth;
            }
        }
    }
}
// banner handling
function trackClick(AdName, PageID, AdURL) {
    try {
        pageTracker._trackEvent('AdClick', '' + AdName + '', '' + PageID + '');
        window.location = AdURL;
    } catch (e) { }
}
