function showAlert() {
    alert('test');
}

//if checks adds the value to cookie, if unchecked removes the value from cooki
function manageCheckboxvalues(elem, name, days) {
    var checkbox = elem;
    if (checkbox.checked) {
        if (readCookie(name) != null) {
            createCookie(name, days, readCookie(name) + checkbox.value);
        }
        else {
            createCookie(name, days, checkbox.value);
        }
    }
    else {
        var cookieValue = readCookie(name);
        if (cookieValue.indexOf(checkbox.value) >= 0) {
            var checkBoxValueRemovedCookieString = ReplaceAll(cookieValue, checkbox.value, ' ');
            createCookie(name, days, checkBoxValueRemovedCookieString);
        }
    }
}

//Remove value from cookie
function removeValuefromCookie(cookieName, valueToBeRemoved) {
    valueToBeRemoved = ReplaceAll(valueToBeRemoved, "+", " ");
    var cookieValue = readCookie(cookieName);
    var checkBoxValueRemovedCookieString = ReplaceAll(cookieValue, valueToBeRemoved, ' ');
    createCookie(cookieName, 2, checkBoxValueRemovedCookieString);
}

//Create product comparison
function createProductComparisonUrl(elem, url, cookieName) {
    var link = elem;
    link.href = url + readCookie(cookieName);
}

//Create product comparison label
function createProductComparisonUrl(elem, url, cookieName, errLabelId) {
    var errLabel = document.getElementById(errLabelId);
    var productsToCompare = 0;
    if (readCookie(cookieName) != null) {
        productsToCompare += readCookie(cookieName).toString().split(',').length - 1;
    }

    var link = elem;
    if (productsToCompare < 2 && errLabel != null) {
        document.getElementById(errLabelId).innerHTML = "Less than 2 items have been selected for comparison";
        link.href = "#";
    }
    else {
        link.href = url + readCookie(cookieName);
    }
}

//creates the cookie
function createCookie(name, days, value) {
    if (days) {
        var date = new Date();
        date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
        var expires = "; expires=" + date.toGMTString();
    }
    else var expires = "";
    document.cookie = name + "=" + value + expires + "; path=/";
}

//reads the cookie value
function readCookie(name) {
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    for (var i = 0; i < ca.length; i++) {
        var c = ca[i];
        while (c.charAt(0) == ' ') c = c.substring(1, c.length);
        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
    }
    return null;
}

//removes the cookie with specified name
function eraseCookie(name) {
    createCookie(name, -1, "");
}

//function that goes through the cookie and check the values
function parseCookieAndCheckComparisonBoxes(name) {
    var cookieValue = readCookie(name);
    for (var index = 0; index < document.forms[0].comparison.length; index++) {
        var currentcheckbox = document.forms[0].comparison[index];
        if (cookieValue.indexOf(currentcheckbox.value) >= 0) {
            document.forms[0].comparison[index].checked = true;
        }
    }
}

//replace all funcction
function ReplaceAll(Source, stringToFind, stringToReplace) {
    var temp = Source;
    var index = temp.indexOf(stringToFind);
    while (index != -1) {
        temp = temp.replace(stringToFind, stringToReplace);
        index = temp.indexOf(stringToFind);
    }

    return temp;

}

function showTab(tab) {
    document.getElementById('tab2').style.display = 'none';
    document.getElementById('tab3').style.display = 'none';
    document.getElementById('tab1').style.display = 'none';
    document.getElementById(tab).style.display = 'block';
    return false;
}

 