function ShowLotPopUp(ItemID, ImageUrl) {
    var PopUpContainer = document.getElementById(ItemID);
    var PopUpImageUrl = ImageUrl;
    PopUpContainer.innerHTML = "<img src=" + ImageUrl + " alt=''>";
    PopUpContainer.style.visibility = "visible";
}

function HideLotPopUp(ItemID) {
    document.getElementById(ItemID).style.visibility = "hidden";
}

/* Function TextSearch.                            */
/* Used in CategoryMenuControl.ascx and internally */
function TextSearch() { 
	var searchText;
	var searchTextParsed;

	searchText = document.getElementById('SearchTextBox').value;
	searchText = encodeURI(searchText);
	searchTextParsed = searchText.replace(/&/g, '%26');
	document.location.href = 'ItemList/ItemList.Aspx?STA=3&FText=' + searchTextParsed ;
}

function TextSearch2() {
    var searchText2;
    var searchTextParsed2;
    
    searchText2 = document.getElementById('SearchInput').value;
    searchText2 = encodeURI(searchText2);
    searchTextParsed2 = searchText2.replace(/&/g, '%26');
    document.location.href = 'ItemList/ItemList.Aspx?STA=3&FText=' + searchTextParsed2;
} 
   
/* Function DoEnter.                */ 
/* Used in CategoryMenuControl.ascx */     
function DoEnter(event) {
    if (event && event.keyCode == 13){
        TextSearch();
    }
    return !(event && event.keyCode == 13);
}

function DoEnter2(event) {
    
    if (event && event.keyCode == 13) {
        
        TextSearch2();
    }
    return !(event && event.keyCode == 13);
}

function CultureFormat(Amount, LanguageID, Precision) {
    var separateCharacter = ''; // separator for integer value
    var intDecSplitCharacter = ''; // split between the interger and decimal values
    var convertetAmount = ''; // amount convertet to integer with separate character
    var decimalAmount = ''; // the decimal value of the amount
    var result = ''; // final result


    switch (LanguageID) {
        case 1: case 4:
            // Danish and German value conversion
            separateCharacter = ".";
            intDecSplitCharacter = ",";
            break;
        case 2:
            // English value conversion
            separateCharacter = ",";
            intDecSplitCharacter = ".";
            break;
        case 3: case 5:
            // Swedish and Norwegian value conversion
            separateCharacter = " ";
            intDecSplitCharacter = ",";
            break;
    }

    // Round the amount to requested precision
    var decimals = 0;
    decimals = Math.pow(10, Precision)
    Amount = Math.round(Amount * decimals) / decimals;

    Amount += ''; // Convert Amount from float to string

    // Split Amount into string containing the integer value and a string containing the decimal value
    if (Amount.indexOf(".") > 0) {
        decimalAmount = Amount.substring((Amount.indexOf(".") + 1), Amount.length);
        Amount = Amount.substring(0, Amount.indexOf("."));
    }

    // Add separator characters to the integer value of the amount e.g.: 1000000 => 1.000.000
    while (Amount.length > 3) {
        convertetAmount = separateCharacter + Amount.substring((Amount.length - 3), Amount.length) + convertetAmount;
        Amount = Amount.substring(0, (Amount.length - 3));
    }

    // Add the integer value containing the separator characters to result string
    result = Amount + convertetAmount;

    // Format the decimal of the amount to have same length as the requested precision
    // E.g. ,4 will be convertet to ,40 with a precision of 2
    while (decimalAmount.length < Precision) decimalAmount += '0';

    // Add the decimals of the amount to the result if precision is above 0
    if (decimalAmount.length > 0) {
        result += intDecSplitCharacter + decimalAmount;
    }

    return result;

}

function urlencode(str) {
    return escape(str).replace('+', '%2B').replace('%20', '+').replace('*', '%2A').replace('/', '%2F').replace('@', '%40');
}

