﻿function getWindowHeight() {
    var windowHeight = 0;
    if (typeof (window.innerHeight) == 'number') {
        windowHeight = window.innerHeight;
    }
    else {
        if (document.documentElement && document.documentElement.clientHeight) {
            windowHeight = document.documentElement.clientHeight;
        }
        else {
            if (document.body && document.body.clientHeight) {
                windowHeight = document.body.clientHeight;
            }
        }
    }
    return windowHeight;
}
function setContent() {
    if (document.getElementById) {
        var windowHeight = getWindowHeight();
        if (windowHeight > 0) {
            var contentElement = document.getElementById('contactUs');
            var contentHeight = contentElement.offsetHeight;
            if (windowHeight - contentHeight > 0) {
                contentElement.style.position = 'absolute';
                contentElement.style.top = ((windowHeight / 2) - (contentHeight / 2)) + 'px';
                contentElement.style.visibility = "visible"
            }
            else {
                contentElement.style.position = 'static';
            }
        }
    }
}
function setPosition() {
    if (document.getElementById) {
        var windowHeight = getWindowHeight();
        if (windowHeight > 0) {
            var contentElement = document.getElementById('contactUs');
            var contentHeight = contentElement.offsetHeight;
            var YoffSet = window.pageYOffset || document.documentElement.scrollTop
            if (windowHeight - contentHeight > 0) {
                contentElement.style.position = 'absolute';
                contentElement.style.top = (((windowHeight / 2) - (contentHeight / 2)) + YoffSet) + 'px';
            }
            else {
                contentElement.style.position = 'static';
            }
        }
    }
}

    
$(document).ready(function () {
    setContent();
});

window.onresize = function () {
    setContent();
}

window.onscroll = function () {
    setPosition();
}

function SwapImage(prefix, midfix, id, zoom) {
    var productImg = document.getElementById("productImage");
    var productLink = document.getElementById("productLink");
    var productZoom = document.getElementById("ZoomIcon");

    if (Boolean(zoom)) {
        productZoom.display = "absolute";
    } else {
        productZoom.display = "none";
    }

    if (midfix == "main") {
        productImg.src = "/images/products/main/s_display_prod_main_" + id + ".jpg";
        productLink.href = "/images/products/main/l_display_prod_main_" + id + ".jpg";
    } else if (midfix != "main" && prefix != "model") {
        productImg.src = "/images/products/additional/s_display_prod_" + midfix + "_" + id + ".jpg";
        productLink.href = "/images/products/additional/l_display_prod_" + midfix + "_" + id + ".jpg";
    } else {
        productImg.src = "/images/products/models/s_display_model_" + midfix + "_" + id + ".jpg";
        productLink.href = "/images/products/models/l_display_model_" + midfix + "_" + id + ".jpg";
    }
}

function SwapName(name) {
    document.getElementById("jProdText").innerHTML = name;
}

function ResetName() {
    document.getElementById("jProdText").innerHTML = "Mouse over for details";
}

function RemoveText(id) {
    if (document.getElementById(id).value == "Search") {
        document.getElementById(id).value = "";
    }
}

function AddText(id) {
    if (document.getElementById(id).value == "") {
        document.getElementById(id).value = "Search";
    }
}
