﻿function checkout(formID) {
    document.getElementById(formID).action = "/basket/your-basket.aspx";
    document.getElementById(formID).submit();
    window.location = "/Default.aspx?ID=309";

}



function discount(productPrice, productDisocuntPrice, prodID) {
    if (productPrice != productDisocuntPrice) {
        document.getElementById("priceDiscount" + prodID).style.display = "inline";
        document.getElementById("priceDiscount" + prodID).style.fontWeight = "bold";
        document.getElementById("price" + prodID).style.color = "#c985a3";
        document.getElementById("price" + prodID).style.textDecoration = "line-through";
        document.getElementById("overlayPriceDiscount" + prodID).style.display = "inline";
        document.getElementById("overlayPriceDiscount" + prodID).style.fontWeight = "bold";
        document.getElementById("overlayPrice" + prodID).style.color = "#c985a3";
        document.getElementById("overlayPrice" + prodID).style.textDecoration = "line-through";
    }
}

function showProductPopup(ID) {
    /* document.getElementById(ID).style.display = "inline"; */
    ID = "#" + ID;
    $(document).ready(function () {
        $(ID).slideToggle("slow");

    });
}

function focusThis(element) {
    var elementObj = document.getElementById(element);
    elementObj.focus();
}




$(function () {
    var orderlines = $("span.orderlinesCount");
    if (orderlines != null && $("span.orderlinesCount").text() != "") {
        $("#buy-online .collapsed").removeClass("collapsed");
        /*		$("#buy-online .collapsed").each(function(){
        $this.removeClass("collapsed")
        });*/
    }
});


function CoreFaqSlide(id) {
    var responsobj = "faqRespons" + id;
    var str = document.getElementById("faqLink" + id).className;
    var contains = str.indexOf("faqLinkActive");
    $('#' + responsobj).toggle(400);
    if (contains >= 0) {
        document.getElementById("faqLink" + id).className = "faqLink";
    }
    else {
        document.getElementById("faqLink" + id).className = "faqLinkActive";
    }
}


function ResizeBox(ParagraphID, ParagraphHeader) {
    var height = ParagraphHeader.substring(0, ParagraphHeader.indexOf('}'));
    height = height.replace('{', '');
    if (navigator.appName == "Microsoft Internet Explorer") {
        var _ieheight = parseInt(height) + 20;
        height = _ieheight;
    }

    //alert(document.getElementById(ParagraphID).children[0].style.background);
    if (document.getElementById(ParagraphID).children[0].className == "bgImage") {
        //document.getElementById(ParagraphID).children[0].className = "";
        document.getElementById(ParagraphID).children[0].style.height = height + "px";
    }

    var pos = ParagraphHeader.indexOf('{');
    if (pos >= 0) {
        // Fjernet af LAK, da dette overskriver IE fix ?
        //var height = ParagraphHeader.substring(0, ParagraphHeader.indexOf('}'));
        //height = height.replace('{','');
        document.getElementById(ParagraphID).style.height = height + "px";
    }

}
function adjustHeight(img, id) {
    var _img = new Image();
    _img.onload = function () {
        if (navigator.appName == "Microsoft Internet Explorer") {
            
            $('#' + id).css("Height", this.height);
            $('#' + id).css("Width", this.width);
        }
        else {
             $('#' + id).css("minHeight", this.height);
             $('#' + id).css("maxWidth", this.width);
        }
    }
    _img.src = img;
}

/* 	
This script will fix the problem with IE7 not supporting table / table-cell on ul li lists.
*/
function CorrectHortizontalMenuOLD() {

    /* Properties */
    var _containerWidth = 960; //857
    var _identifier = "#menu-primary ul li a";
    var _elementpadding = 46;
    //var _totalpadding = 46; 
    var _totalpadding = 0;

    /* #region MenuCount */
    var _lCount = 0;
    $(_identifier).each(function () {
        _lCount++;
    });
    /* #endregion */

    /* #region Denmark (this region is a hotfix to specefic issue with imedeen DK) */
    if (_lCount == 3) {
        _totalpadding = 35;
    }
    /* #endregion */

    _totalpadding = _elementpadding * _lCount;

    /* #region SetWidthOnLi */
    var _eleWidth = Math.floor(_containerWidth / _lCount);

    _eleWidth = _eleWidth - _elementpadding;

    $(_identifier).each(function () {
        //$(this).css('min-width', _eleWidth + 'px');
        $(this).css('width', _eleWidth + 'px');
        //$(this).css('padding-left', _elementpadding / 2 + 'px');
        //$(this).css('padding-right', _elementpadding / 2 + 'px');

    });
    /* #endregion */
}

/* 	
This script will fix the problem with IE7 not supporting table / table-cell on ul li lists.
*/
function CorrectHortizontalMenu() {

    /* Properties */
    var _containerWidth = 959; //857
    var _identifier = "#menu-primary ul li a";
    var _elementpadding = 20;
    var _menuItemAvage = 0;
    var _containerRemains = _containerWidth;
    var _smallItems = 0;

    // Antallet af menupunkter ialt
    var _lCount = 0;
    $(_identifier).each(function () {
        _lCount++;
    });
    
    // Gennemsnit størrelsen for menupunkterne
    _menuItemAvage = _containerWidth / _lCount;

    //alert("containerRemains : " + _containerRemains);
    //alert("_menuItemAvage : " + _menuItemAvage);

    // Sætter alle menupunkter der er større end menuline / antal menupunkter
    //alert(_menuItemAvage);
    $(_identifier).each(function () {

        //alert(($(this).width() +  _elementpadding) + " > " + _menuItemAvage);
        if (($(this).width() + _elementpadding) > _menuItemAvage) {
            //alert("true");
            $(this).css('width', $(this).width() + _elementpadding + 'px');
            $(this).css('padding-left', _elementpadding / 2 + 'px');
            $(this).css('padding-right', _elementpadding / 2 + 'px');
            _containerRemains = _containerRemains - ($(this).width() + _elementpadding);
        }
        else {
            $(this).addClass("small");
            _smallItems++;
            //alert("false");
        }
    });
    var _newMenuItemSize = _containerRemains / _smallItems;
    _newMenuItemSize = _newMenuItemSize - _elementpadding;
    //alert("_containerRemains : " + _containerRemains + " / " + "_smallItems : " + _smallItems + "_newMenuItemSize : " + _newMenuItemSize);

    $(_identifier).each(function () {

        if ($(this).hasClass("small"))
        {
            $(this).css('width', _newMenuItemSize + 'px');
            $(this).css('padding-left', _elementpadding / 2 + 'px');
            $(this).css('padding-right', _elementpadding / 2 + 'px');
        }
    });
}

