﻿function switchImage(obj) {
    var curImgPath = obj.src;
    var path = curImgPath.substring(0, curImgPath.lastIndexOf('/') + 1);
    var imageWithExt = curImgPath.substring(curImgPath.lastIndexOf('/') + 1, curImgPath.length);
    var image = imageWithExt.substring(0, imageWithExt.lastIndexOf('.'));
    var postfix = 'Over';

    if (image.substring(image.length - postfix.length, image.length) == postfix) {
        obj.src = path + image.substring(0, image.length - postfix.length) + imageWithExt.substring(imageWithExt.lastIndexOf('.'), imageWithExt.length);
    } else {
        obj.src = path + image + postfix + imageWithExt.substring(imageWithExt.lastIndexOf('.'), imageWithExt.length);
    }
}

function SetRightContentSpacer() {
    var rightContentSpacer = document.getElementById('DivRightContentSpacer');
    var companyAddress = document.getElementById('DivCompanyAddress');
    var rightContentImage = document.getElementById('DivRightContentImage');
    var rightContentText = document.getElementById('DivRightContentText');
    var leftContentPage = document.getElementById('DivLeftContentPage');
    var leftContentText = document.getElementById('DivContentText');

    var addresBottomMargin = 30;
    var rightContentTextHeight = 0;

    if (rightContentSpacer != null && companyAddress != null && rightContentImage != null && leftContentPage != null && leftContentText != null) {

        if (rightContentText != null) {
            rightContentTextHeight = rightContentText.offsetHeight;
        }

        if (leftContentPage.offsetHeight - rightContentImage.offsetHeight - companyAddress.offsetHeight - rightContentTextHeight - addresBottomMargin > 0) {
            rightContentSpacer.style.height = leftContentPage.offsetHeight - rightContentImage.offsetHeight - rightContentTextHeight - companyAddress.offsetHeight - addresBottomMargin + 'px';
        }
        else {
            leftContentText.style.height = rightContentImage.offsetHeight + rightContentTextHeight + companyAddress.offsetHeight + addresBottomMargin;
        }
    }
}

function SetContentTextMinHeight(height) {
    var contentText = document.getElementById('DivContentText');
    if (contentText != null) {

        if (contentText.offsetHeight < height) {
            contentText.style.height = height + 'px';
        }
    }
}

/*script for specification service -->*/
function ShowHideProducts(catNumber) {
    var productPanel = document.getElementById('pnlPrd' + catNumber);

    if (productPanel != null) {
        if (productPanel.style.display == 'block') {
            productPanel.style.display = 'none';
        }
        else {
            productPanel.style.display = 'block';
        }
    }

    SetRightContentSpacer()
}
/*<-- script for specification service*/

/*script for language selection -->*/
function CancelBubble() {
    //cancel bubble event code
    if (window.event) {
        if (!window.event.cancelBubble) {
            window.event.cancelBubble = true;
        }
    }
    else {
        try {
            e.preventDefault();
            e.stopPropagation();
        }
        catch (err) { }
    }
}

function showLanguageSelection() {
    CancelBubble();

    var langMenu = document.getElementById("divLanguageDropdown");

    LanguageSelectionInProgress = true;

    langMenu.style.display = 'block';
    langMenu.style.cursor = 'pointer';
}

function leaveLanguageChoice() {
    CancelBubble();

    var timerInterval = "";

    LanguageSelectionInProgress = false;

    timerInterval = window.setTimeout('hideLanguageSelection()', 1000);
}

function EnterLanguageSelection() {
    CancelBubble();

    LanguageSelectionInProgress = true;
}

function LeaveLanguageSelection() {
    CancelBubble();

    LanguageSelectionInProgress = false;

    timerInterval = window.setTimeout('hideLanguageSelection()', 1000);
}

function hideLanguageSelection() {
    CancelBubble();

    if (!LanguageSelectionInProgress) {
        var langMenu = document.getElementById("divLanguageDropdown");

        langMenu.style.display = 'none';
        langMenu.style.cursor = 'pointer';
    }
}

function EnterLanguageBar(divObject) {
    divObject.style.backgroundColor = "#F1F3F2";
}

function LeaveLanguageBar(divObject) {
    divObject.style.backgroundColor = "white";
}
/*<-- script for language selection*/
