/*
 * @file
 * @description Contains all functions used by the frontend.
 *
 * @author Keve Kutner <keve.kutner@4digits.hu>
 * @owner  4DIGITS Kft. <http://4digits.hu>
 */

//Config
var AJAXMETHOD          = 'GET'
var AJAXBASEURL         = 'siteAjaxFunctions.php';
var pageNumberAtGallery = 0;
//End config

/**
 * @function
 * @description Gets a param value from the url string.
 *
 * @param name The name of the parameter.
 *
 * @returns string The value of the param.
 */
function gup(name) {
    name        = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
    var regexS  = "[\\?&]" + name + "=([^&#]*)";
    var regex   = new RegExp(regexS);
    var results = regex.exec(window.location.href);

    if (results == null) {
        return "";
    } else {
        return results[1];
    }
}//end gup()

/**
 * @function
 * @description Shows the product categories for a given menu. If showCurrent,
 * catId and vendor is set, it shows the given category, and the given vendor.
 *
 * @param menuId The id of the submenu.
 * @param showCurrent Void or 1. If it's one, then it tells the script to select a given category.
 * @param catId If set, the script will select this category. If not, the first category is selected.
 * @param vendor If set, the given vendor will be selected.
 *
 * @returns void
 */
function showProductCategoriesForMenu(menuId, showCurrent, catId, vendor) {
    if (showCurrent != undefined) {
        //Set title, hash and execute the flash function.
        switch (menuId) {
            case 2:
                document.getElementById('subtitle').innerHTML    = 'Termékek /';
                document.getElementById('subMenuItem').innerHTML = ' Motor és környezete';
                window.location.hash = '#motoreskornyezete';

                document.getElementById('subtitle').style.display    = '';
                document.getElementById('subMenuItem').style.display = '';

                document.title = 'Startauto Kft. Termékek - Start Auto Kft. - Autóalkatrészek és motorkerékpár alkatrészek széles választéka - Motor és környezete';
                document.getElementById('menuaaa').setActivePage('s1btn1', false);
                break;
            case 3:
                document.getElementById('subtitle').innerHTML    = 'Termékek /';
                document.getElementById('subMenuItem').innerHTML = ' Kenés, üzemanyag, hűtés';
                window.location.hash = '#kenesuzemanyaghutes';

                document.getElementById('subtitle').style.display    = '';
                document.getElementById('subMenuItem').style.display = '';

                document.title = 'Startauto Kft. Termékek - Autóalkatrészek és motorkerékpár alkatrészek széles választéka - Kenés, üzemanyag, hűtés';
                document.getElementById('menuaaa').setActivePage('s1btn2', false);
                break;
            case 4:
                document.getElementById('subtitle').innerHTML    = 'Termékek /';
                document.getElementById('subMenuItem').innerHTML = ' Elektromos';
                window.location.hash = '#elektromos';

                document.getElementById('subtitle').style.display    = '';
                document.getElementById('subMenuItem').style.display = '';

                document.title = 'Startauto Kft. Termékek - Autóalkatrészek és motorkerékpár alkatrészek széles választéka - elektromos';
                document.getElementById('menuaaa').setActivePage('s1btn3', false);
                break;
            case 5:
                document.getElementById('subtitle').innerHTML    = 'Termékek /';
                document.getElementById('subMenuItem').innerHTML = ' Fék - Futómű';
                window.location.hash = '#fekfutomu';

                document.getElementById('subtitle').style.display    = '';
                document.getElementById('subMenuItem').style.display = '';

                document.title = 'Startauto Kft. Termékek - Autóalkatrészek és motorkerékpár alkatrészek széles választéka - Fék - Futómű';
                document.getElementById('menuaaa').setActivePage('s1btn4', false);
                break;
            case 6:
                document.getElementById('subtitle').innerHTML    = 'Termékek /';
                document.getElementById('subMenuItem').innerHTML = ' Erőátvitel';
                window.location.hash = '#eroatvitel';

                document.getElementById('subtitle').style.display    = '';
                document.getElementById('subMenuItem').style.display = '';

                document.title = 'Startauto Kft. Termékek - Autóalkatrészek és motorkerékpár alkatrészek széles választéka - Erőátvitel';
                document.getElementById('menuaaa').setActivePage('s1btn5', false);
                break;
            case 7:
                document.getElementById('subtitle').innerHTML    = 'Termékek /';
                document.getElementById('subMenuItem').innerHTML = ' Karosszéria';
                window.location.hash = '#karosszeria';

                document.getElementById('subtitle').style.display    = '';
                document.getElementById('subMenuItem').style.display = '';

                document.title = 'Startauto Kft. Termékek - Autóalkatrészek és motorkerékpár alkatrészek széles választéka - Karosszéria';
                document.getElementById('menuaaa').setActivePage('s1btn6', false);
                break;
            case 8:
                document.getElementById('subtitle').innerHTML    = 'Termékek /';
                document.getElementById('subMenuItem').innerHTML = ' Kipufogó';
                window.location.hash = '#kipufogo';

                document.getElementById('subtitle').style.display    = '';
                document.getElementById('subMenuItem').style.display = '';

                document.title = 'Startauto Kft. Termékek - Autóalkatrészek és motorkerékpár alkatrészek széles választéka - Kipufogó';
                document.getElementById('menuaaa').setActivePage('s1btn7', false);
                break;
            case 9:
                document.getElementById('subtitle').innerHTML    = 'Termékek /';
                document.getElementById('subMenuItem').innerHTML = ' Felszerelés';
                window.location.hash = '#felszereles';

                document.getElementById('subtitle').style.display    = '';
                document.getElementById('subMenuItem').style.display = '';

                document.title = 'Startauto Kft. Termékek - Autóalkatrészek és motorkerékpár alkatrészek széles választéka - Felszerelés';
                document.getElementById('menuaaa').setActivePage('s1btn8', false);
                break;
        }
    }
    
    document.getElementById('allVendorContainer').style.display = 'none';
    document.getElementById('allDataContainer').style.display   = '';

    var successFunc = function(response) {
        var data      = eval("(" + response.responseText + ")");
        var html      = '<ul>';
        var div       = document.getElementById('productList');
        var catToShow = 0;
        var parentLi  = null;

        if (catId == undefined) {
            for (var c in data.categories) {
                //Show the first vendor from the first category
                if (c == 0) {
                    catToShow = data.categories[c].products_category_id;
                    html += "<li class=\"selected\"><a href=\"#\" onclick=\"showVendorsForCategory(" + data.categories[c].products_category_id + ", this.parentNode); return false;\">" + data.categories[c].products_category_name + '</a></li>';
                } else {
                    html += "<li><a href=\"#\" onclick=\"showVendorsForCategory(" + data.categories[c].products_category_id + ", this.parentNode); return false;\">" + data.categories[c].products_category_name + '</a></li>';
                }
            }

            parentLi = 0;
        } else {
            for (var c in data.categories) {
                if (catId == data.categories[c].products_category_id) {
                    catToShow = data.categories[c].products_category_id;
                    html += "<li class=\"selected\"><a href=\"#\" onclick=\"showVendorsForCategory(" + data.categories[c].products_category_id + ", this.parentNode); return false;\">" + data.categories[c].products_category_name + '</a></li>';
                    parentLi = c;
                } else {
                    html += "<li><a href=\"#\" onclick=\"showVendorsForCategory(" + data.categories[c].products_category_id + ", this.parentNode); return false;\">" + data.categories[c].products_category_name + '</a></li>';
                }
            }
        }

        html += '</ul>'

        div.innerHTML = html;
        if (vendor == undefined) {
            showVendorsForCategory(catToShow, document.getElementById('productList').getElementsByTagName('li')[parentLi]);
        } else {
            showVendorsForCategory(catToShow, document.getElementById('productList').getElementsByTagName('li')[parentLi], vendor);
        }
    };

    var failureFunc = function() {
        alert('There was a problem executing your ajax request, please contact the site admin!');
    };

    var progressFunc = function(total, received) {
        var totalHumanReadable    = Math.round(total / 1024 * 100) / 100;
        var receivedHumanReadable = Math.round(received / 1024 * 100) / 100;
    };

    var cm  = new fourDigitAjax();
    var url = AJAXBASEURL + '?module=getProductCategoriesForMenu&menuId=' + menuId;
    cm.request(AJAXMETHOD, url, true, successFunc, failureFunc, progressFunc, null);
}//end showProductCategoriesForMenu()

/**
 * @function
 * @description Shows the vendors in a given category. If vendor is set,
 * a given vendor will be selected instead of the first in the category.
 *
 * @param categoryId The id of the category.
 * @param liToSelect The <li> tag. We use it to apply a given style to the selected one.
 * @param vendor If set, the given vendor will be selected.
 *
 * @returns void
 */
function showVendorsForCategory(categoryId, liToSelect, vendor) {
    var successFunc = function(response) {
        var data      = eval("(" + response.responseText + ")");
        var container = document.getElementById('productLogoContainer');
        var html      = '';
        var cssClass  = 'tabOff';
        var liDiv     = document.getElementById('productList').getElementsByTagName('li');
        var vToShow   = 0;
        var divToShow = 0;

        for (var li in liDiv) {
            if (liDiv[li] == liToSelect) {
                if (liDiv[li] != undefined) {
                    liDiv[li].className = 'selected';
                }
            } else {
                if (liDiv[li] != undefined) {
                    liDiv[li].className = '';
                }
            }
        }

        if (data.vendors == false) {
            document.getElementById('mainContent').innerHTML = '';
        }

        if (vendor == undefined) {
            for (var v in data.vendors) {
                if (v == 0) {
                    cssClass  = 'tabOn';
                    vToShow   = data.vendors[v].vendors_id;
                    divToShow = 0;
                } else {
                    cssClass  = 'tabOff'
                }
                html += '<div class="' + cssClass + '"><a href="#" onclick="showVendorData(' + data.vendors[v].vendors_id + ', this.parentNode, 0); return false;"><img src="lib/util/imageDisplay.php?file=' + data.vendors[v].downloads_hashname + '"/></a></div>';
            }
        } else {
            for (var v in data.vendors) {
                if (data.vendors[v].vendors_id == vendor) {
                    cssClass  = 'tabOn';
                    vToShow   = data.vendors[v].vendors_id;
                    divToShow = v;
                } else {
                    cssClass  = 'tabOff'
                }
                html += '<div class="' + cssClass + '"><a href="#" onclick="showVendorData(' + data.vendors[v].vendors_id + ', this.parentNode, 0); return false;"><img src="lib/util/imageDisplay.php?file=' + data.vendors[v].downloads_hashname + '"/></a></div>';
            }
        }

        container.innerHTML = html;
        showVendorData(vToShow, document.getElementById('productLogoContainer').getElementsByTagName('div')[divToShow], 0);
    };

    var failureFunc = function() {
        alert('There was a problem executing your ajax request, please contact the site admin!');
    };

    var progressFunc = function(total, received) {
        var totalHumanReadable    = Math.round(total / 1024 * 100) / 100;
        var receivedHumanReadable = Math.round(received / 1024 * 100) / 100;
    };

    var cm  = new fourDigitAjax();
    var url = AJAXBASEURL + '?module=getVendorsForCategory&categoryId=' + categoryId;
    cm.request(AJAXMETHOD, url, true, successFunc, failureFunc, progressFunc, null);
}//end showVendorsForCategory()

/**
 * @function
 * @description Shows the details for a given vendor. If type is 0, it will show it
 * in a tabbed view, if it is 1, it show the "full screen" version (the one accessible
 * from the abc page).
 *
 * @param vendorId The id of the vendor.
 * @param parent The <div> tag. We use it to apply a given style to the selected one.
 * @param type Can be 0 or 1.
 *
 * @returns void
 */
function showVendorData(vendorId, parent, type) {
    initLoader('grayer', 'popup', '<b>Oldal töltése...</b>', 180, 60);
    if (type == 0) {
        var logoDivs = document.getElementById('productLogoContainer').getElementsByTagName('div');

        for (var d in logoDivs) {
            if (logoDivs[d] == parent) {
                if (logoDivs[d] != undefined) {
                    logoDivs[d].className = 'tabOn';
                }
            } else {
                if (logoDivs[d] != undefined) {
                    logoDivs[d].className = 'tabOff';
                }
            }
        }

        var successFunc = function(response) {
            var data      = eval("(" + response.responseText + ")");
            var container = document.getElementById('mainContent');
            if (data[0] != undefined && data[0] != null) {
                container.innerHTML = '<h1>' + ((data[0].vendors_name != undefined && data[0].vendors_name != null && data[0].vendors_name != "") ? data[0].vendors_name : "") + '</h1>'
                                    + ((data[0].vendors_vendor_home_page != null && data[0].vendors_vendor_home_page != undefined && data[0].vendors_vendor_home_page != '') ? '<a href="' + data[0].vendors_vendor_home_page + '" target="_blank">' + data[0].vendors_vendor_home_page + '</a>' : '')
                                    + '<p>' + data[0].vendors_description + '</p>';
            }
            destructLoader('grayer', 'popup');
        };

        var failureFunc = function() {
            alert('There was a problem executing your ajax request, please contact the site admin!');
        };

        var progressFunc = function(total, received) {
            var totalHumanReadable    = Math.round(total / 1024 * 100) / 100;
            var receivedHumanReadable = Math.round(received / 1024 * 100) / 100;
        };

        var cm  = new fourDigitAjax();
        var url = AJAXBASEURL + '?module=getVendorData&vendorId=' + vendorId;
        cm.request(AJAXMETHOD, url, true, successFunc, failureFunc, progressFunc, null);
    } else {
        var successFunc = function(response) {
            var data      = eval("(" + response.responseText + ")");
            var container = document.getElementById('allVendorContainer');
            var html      = '';

            for (var p in data.pav) {
                html += '<a class="internalLink" href="#" onclick="showProductCategoriesForMenu(' + data.pav[p].products_category_menu_id + ', 1, ' + data.pav[p].products_category_technical_id + ',' + vendorId + '); return false;">' + data.pav[p].products_category_name + '</a>';

                if (p != data.pav.length -1) {
                    html += ', ';
                }
            }

            document.getElementById('subtitle').innerHTML    = data.vendor[0].vendors_name;
            document.getElementById('subMenuItem').innerHTML = '';

            container.innerHTML = '<div class="productDetails">'
                                + '<a class="back" href="#" onclick="getTempContents(18);return false;">&raquo;&raquo; vissza a listához</a>'
                                + '<div class="col1">'
                                + ((data.vendor[0].downloads_hashname != null) ? '<img src="lib/util/imageDisplay.php?file=' + data.vendor[0].downloads_hashname + '">' : '')
                                + '</div>'
                                + '<div class="col2"><p>'
                                + data.vendor[0].vendors_description
                                + '<br />'
                                + ((data.vendor[0].vendors_vendor_home_page != null && data.vendor[0].vendors_vendor_home_page != undefined && data.vendor[0].vendors_vendor_home_page != '') ? '<a href="' + data.vendor[0].vendors_vendor_home_page + '" target="_blank">' + data.vendor[0].vendors_vendor_home_page + '</a>' : '')
                                + '<img src="design/img/static/bottomLine.png"/>'
                                + '<span class="title"><b>Termékek:</b></span>'
                                + '<p>' + html + '</p>'
                                + '</p>'
                                + '</div>'
                                + '</div>';
            destructLoader('grayer', 'popup');
        };

        var failureFunc = function() {
            alert('There was a problem executing your ajax request, please contact the site admin!');
        };

        var progressFunc = function(total, received) {
            var totalHumanReadable    = Math.round(total / 1024 * 100) / 100;
            var receivedHumanReadable = Math.round(received / 1024 * 100) / 100;
        };

        var cm  = new fourDigitAjax();
        var url = AJAXBASEURL + '?module=getVendorData&vendorId=' + vendorId + '&getBigLogo=1';
        cm.request(AJAXMETHOD, url, true, successFunc, failureFunc, progressFunc, null);
    }
}//end showVendorData()

/**
 * @function
 * @description Shows all vendors with the name and the small logo, in ABC order.
 *
 * @returns void
 */
function showAllVendors() {
    initLoader('grayer', 'popup', '<b>Oldal töltése...</b>', 180, 60);
    var successFunc = function(response) {
        var data      = eval("(" + response.responseText + ")");
        var container = document.getElementById('allVendorContainer');
        
        document.getElementById('allVendorContainer').style.display = '';
        document.getElementById('allDataContainer').style.display   = 'none';
        
        var html = '<div style="float: left; margin-top: 20px; margin-left: 20px; border-right: 1px solid black;">';

        for (var v in data.vendors) {
            if (v != 0 && v % 11 == 0) {
                html += '</div><div style="float: left; border-right: 1px solid black;  margin-top: 20px; margin-left: 10px;">';
            }
            html += '<div><div style="float: left; width: 110px; padding-left: 2px; height: 40px; padding-top: 8px; text-align: left;"><a class="abc" href="#" onclick="showVendorData(' + data.vendors[v].vendors_id + ', this.parentNode, 1); return false;">' + data.vendors[v].vendors_name + '</a></div><div style="float: left; width: 80px; height: 40px;"><a href="#" onclick="showVendorData(' + data.vendors[v].vendors_id + ', this.parentNode, 1); return false;"><img src="lib/util/imageDisplay.php?file=' + data.vendors[v].downloads_hashname + '"/></a></div></div>';
            html += '<div style="clear: left;"></div>'
        }

        html += '</div>';
        container.innerHTML = html;
        destructLoader('grayer', 'popup');
    };

    var failureFunc = function() {
        alert('There was a problem executing your ajax request, please contact the site admin!');
    };

    var progressFunc = function(total, received) {
        var totalHumanReadable    = Math.round(total / 1024 * 100) / 100;
        var receivedHumanReadable = Math.round(received / 1024 * 100) / 100;
    };

    var cm  = new fourDigitAjax();
    var url = AJAXBASEURL + '?module=getAllVendors';
    cm.request(AJAXMETHOD, url, true, successFunc, failureFunc, progressFunc, null);
}//end showAllVendors()

/**
 * @function
 * @description Wrapper function for content retrieving by Ajax.
 *
 * @param contentId The id defined in design/flash/menudata.xml.
 *
 * @returns void
 */
function getTempContents(contentId) {
    if (contentId == 1) {
        var divs = document.getElementsByTagName('div');

        for (var d = 0;d < divs.length;d++) {
            if (divs[d].className == 'title') {
                divs[d].style.display = 'none';
                break;
            }
        }
    } else {
        var divs = document.getElementsByTagName('div');

        for (var d = 0;d < divs.length;d++) {
            if (divs[d].className == 'title') {
                divs[d].style.display = '';
                break;
            }
        }
    }

    switch (contentId) {
        case 1:
            initLoader('grayer', 'popup', '<b>Oldal töltése...</b>', 180, 60);
            //Főoldal
            document.getElementById('subtitle').innerHTML    = '';
            document.getElementById('subMenuItem').innerHTML = '';
            window.location.hash = '#fooldal';

            document.getElementById('subtitle').style.display    = 'none';
            document.getElementById('subMenuItem').style.display = 'none';

            document.title = 'Startauto Kft. - Autóalkatrészek és motorkerékpár alkatrészek széles választéka - Főoldal';

            var successFunc = function(response) {
                var data      = eval("(" + response.responseText + ")");
                var container = document.getElementById('allVendorContainer');
                var html      = '<div class="mainpage">';
                var linkTest  = /[a-zA-Z]{1,}/g;

                document.getElementById('allVendorContainer').style.display = '';
                document.getElementById('allDataContainer').style.display   = 'none';

                //Topsection begin
                html += '<div class="topsection">';

                //Add webshop logo
                html += '<div class="col1" onclick="' + ((!linkTest.test(data.mainbanner[0].mainpage_url)) ? 'getTempContents(' + data.mainbanner[0].mainpage_url + '); return false;"' : "window.open('" + data.mainbanner[0].mainpage_url + "', 'externalLink'); return false;" + '"') + '>';
                html += '<img src="design/img/dynamic/' + data.mainbanner[0].downloads_hashname + '">';
                html += '</div>'

                //Add 2 small images and corresponding text
                if (data.textbox[0] != undefined) {
                    html += '<div class="col2">';
                    if (data.textbox[0].mainpage_download_id != '' && data.textbox[0].mainpage_download_id != '0') {
                        html += '<a href="lib/util/pdfDownload.php?file='+ data.textbox[0].mainpage_download_id + '" target="_blank"><img src="design/img/dynamic/' + data.textbox[0].downloads_hashname + '"/></a>';
                    } else {
                        html += '<a href="#" onclick="' + ((!linkTest.test(data.textbox[0].mainpage_url)) ? 'getTempContents(' + data.textbox[0].mainpage_url + '); return false;"' : "window.open('" + data.textbox[0].mainpage_url + "', 'externalLink'); return false;" + '"') + '><img src="design/img/dynamic/' + data.textbox[0].downloads_hashname + '"/></a>';
                    }
                    html += '<p>' + data.textbox[0].mainpage_text + '</p>';
                    if (data.textbox[0].mainpage_download_id != '' && data.textbox[0].mainpage_download_id != '0') {
                        html += '<a class="nextbutton" href="lib/util/pdfDownload.php?file='+ data.textbox[0].mainpage_download_id + '" target="_blank">tovább</a>';
                    } else {
                        html += '<a class="nextbutton" href="#" onclick="' + ((!linkTest.test(data.textbox[0].mainpage_url)) ? 'getTempContents(' + data.textbox[0].mainpage_url + '); return false;"' : "window.open('" + data.textbox[0].mainpage_url + "', 'externalLink'); return false;" + '"') + '>tovább</a>';
                    }
                    html += '</div>';
                }

                if (data.textbox[1] != undefined) {
                    html += '<div class="col3">';
                    if (data.textbox[1].mainpage_download_id != '' && data.textbox[1].mainpage_download_id != '0') {
                        html += '<a href="lib/util/pdfDownload.php?file='+ data.textbox[1].mainpage_download_id + '" target="_blank"><img src="design/img/dynamic/' + data.textbox[1].downloads_hashname + '"/></a>';
                    } else {
                        html += '<a href="#" onclick="' + ((!linkTest.test(data.textbox[1].mainpage_url)) ? 'getTempContents(' + data.textbox[1].mainpage_url + '); return false;"' : "window.open('" + data.textbox[1].mainpage_url + "', 'externalLink'); return false;" + '"') + '><img src="design/img/dynamic/' + data.textbox[1].downloads_hashname + '"/></a>';
                    }
                    html += '<p>' + data.textbox[1].mainpage_text + '</p>';
                    if (data.textbox[1].mainpage_download_id != '' && data.textbox[1].mainpage_download_id != '0') {
                        html += '<a class="nextbutton" href="lib/util/pdfDownload.php?file='+ data.textbox[1].mainpage_download_id + '" target="_blank">tovább</a>';
                    } else {
                        html += '<a class="nextbutton" href="#" onclick="' + ((!linkTest.test(data.textbox[1].mainpage_url)) ? 'getTempContents(' + data.textbox[1].mainpage_url + '); return false;"' : "window.open('" + data.textbox[1].mainpage_url + "', 'externalLink'); return false;" + '"') + '>tovább</a>';
                    }
                    html += '</div>';
                }

                //Topsection end
                html += '</div>';

                //Left section begin
                html += '<div class="left">';

                //Add wide banners
                html += '<div class="widebanner">';
                
                for (var w = 0;w < data.widebanner.length;w++) {
                    if (data.widebanner[w].download_details != '') {
                        html += '<a href="lib/util/pdfDownload.php?file=' + data.widebanner[w].download_details[0].downloads_hashname + '" target="_blank"><img src="design/img/dynamic/' + data.widebanner[w].downloads_hashname + '"/></a>';
                    } else {
                        html += '<a href="#" onclick="' + ((!linkTest.test(data.widebanner[w].mainpage_url)) ? 'getTempContents(' + data.widebanner[w].mainpage_url + '); return false;"' : "window.open('" + data.widebanner[w].mainpage_url + "', 'externalLink'); return false;" + '"') + '"/><img src="design/img/dynamic/' + data.widebanner[w].downloads_hashname + '"/></a>';
                    }
                }

                if (data.widebanner.length == 0) {
                    html += '<a href="#" onclick="return false;"/><img src="design/img/static/blank.png"/></a>';
                }

                //Wide banner end
                html += '</div>';

                //Add small banners
                for (var s = 0;s < data.smallbanner.length;s++) {
                    if (s % 3 == 0) {
                        if (s != 0) {
                            html += '</div>';
                        }
                        html += '<div class="smallbanner">';
                    }

                    if (data.smallbanner[s].download_details != '') {
                        html += '<a href="lib/util/pdfDownload.php?file=' + data.smallbanner[s].download_details[0].downloads_hashname + '" target="_blank"><img src="design/img/dynamic/' + data.smallbanner[s].downloads_hashname + '"/></a>';
                    } else {
                        html += '<a href="#" onclick="' + ((!linkTest.test(data.smallbanner[s].mainpage_url)) ? 'getTempContents(' + data.smallbanner[s].mainpage_url + '); return false;"' : "window.open('" + data.smallbanner[s].mainpage_url + "', 'externalLink'); return false;" + '"') + '><img src="design/img/dynamic/' + data.smallbanner[s].downloads_hashname + '"/></a>';
                    }
                }

                if (data.smallbanner.length == 0) {
                    html += '<div class="smallbanner">';
                    html += '<a href="#" onclick="return false;"/><img src="design/img/static/blank.png"/></a>';
                }

                //Left section end
                html += '</div></div>';

                //Add side banners
                html += '<div class="right">';

                for (var h = 0;h < data.highbanner.length;h++) {
                    if (data.highbanner[h].download_details != '') {
                        html += '<a href="lib/util/pdfDownload.php?file=' + data.highbanner[h].download_details[0].downloads_hashname + '" target="_blank"><img src="design/img/dynamic/' + data.highbanner[h].downloads_hashname + '"/></a>';
                    } else {
                        html += '<a href="#" onclick="' + ((!linkTest.test(data.highbanner[h].mainpage_url)) ? 'getTempContents(' + data.highbanner[h].mainpage_url + '); return false;"' : "window.location='" + data.highbanner[h].mainpage_url + "'; return false;" + '" target="_blank"') + '><img src="design/img/dynamic/' + data.highbanner[h].downloads_hashname + '"/></a>';
                    }
                }

                if (data.highbanner.length == 0) {
                    html += '<a href="#" onclick="return false;"/><img src="design/img/static/blank.png"/></a>';
                }

                //Side banners end
                html += '</div>';

                //Add mainpage div closer tag
                html += '</div>';

                container.innerHTML = html;
                destructLoader('grayer', 'popup');
            };

            var failureFunc = function() {
                alert('There was a problem executing your ajax request, please contact the site admin!');
            };

            var progressFunc = function(total, received) {
                var totalHumanReadable    = Math.round(total / 1024 * 100) / 100;
                var receivedHumanReadable = Math.round(received / 1024 * 100) / 100;
            };

            var cm  = new fourDigitAjax();
            var url = AJAXBASEURL + '?module=getMainPageElements';
            cm.request(AJAXMETHOD, url, true, successFunc, failureFunc, progressFunc, null);
            break;
        case 2:
            document.getElementById('subtitle').innerHTML    = 'Rólunk';
            document.getElementById('subMenuItem').innerHTML = '';
            window.location.hash = '#rolunk';

            document.getElementById('subtitle').style.display    = '';
            document.getElementById('subMenuItem').style.display = '';

            document.title = 'Startauto Kft. - Autóalkatrészek és motorkerékpár alkatrészek széles választéka - Rólunk';
            getTempContents(11);
            break;
        case 3:
            initLoader('grayer', 'popup', '<b>Oldal töltése...</b>', 180, 60);
            document.getElementById('subtitle').innerHTML    = 'StartSys';
            document.getElementById('subMenuItem').innerHTML = '';
            window.location.hash = '#startsys';

            document.getElementById('subtitle').style.display    = '';
            document.getElementById('subMenuItem').style.display = '';

            document.title = 'Startauto Kft. - Autóalkatrészek és motorkerékpár alkatrészek széles választéka - Start Sys';

            var successFunc = function(response) {
                var data      = eval("(" + response.responseText + ")");
                var container = document.getElementById('allVendorContainer');

                document.getElementById('allVendorContainer').style.display = '';
                document.getElementById('allDataContainer').style.display   = 'none';

                container.innerHTML = data[0].contents_content;
                destructLoader('grayer', 'popup');
            };

            var failureFunc = function() {
                alert('There was a problem executing your ajax request, please contact the site admin!');
            };

            var progressFunc = function(total, received) {
                var totalHumanReadable    = Math.round(total / 1024 * 100) / 100;
                var receivedHumanReadable = Math.round(received / 1024 * 100) / 100;
            };

            var cm  = new fourDigitAjax();
            var url = AJAXBASEURL + '?module=getTempContents&contentId=11';
            cm.request(AJAXMETHOD, url, true, successFunc, failureFunc, progressFunc, null);
            break;
        case 4:
            initLoader('grayer', 'popup', '<b>Oldal töltése...</b>', 180, 60);
            document.getElementById('subtitle').innerHTML    = 'Letöltések';
            document.getElementById('subMenuItem').innerHTML = '';
            window.location.hash = '#letoltesek';

            document.getElementById('subtitle').style.display    = '';
            document.getElementById('subMenuItem').style.display = '';

            document.title = 'Startauto Kft. - Autóalkatrészek és motorkerékpár alkatrészek széles választéka - Letöltések';
            var successFunc = function(response) {
                var data      = eval("(" + response.responseText + ")");
                var container = document.getElementById('allVendorContainer');

                document.getElementById('allVendorContainer').style.display = '';
                document.getElementById('allDataContainer').style.display   = 'none';

                container.innerHTML = data[0].contents_content;
                updateStartsys();
                destructLoader('grayer', 'popup');
                document.getElementById('menuaaa').setActivePage('btn4', false);
            };

            var failureFunc = function() {
                alert('There was a problem executing your ajax request, please contact the site admin!');
            };

            var progressFunc = function(total, received) {
                var totalHumanReadable    = Math.round(total / 1024 * 100) / 100;
                var receivedHumanReadable = Math.round(received / 1024 * 100) / 100;
            };

            var cm  = new fourDigitAjax();
            var url = AJAXBASEURL + '?module=getTempContents&contentId=5';
            cm.request(AJAXMETHOD, url, true, successFunc, failureFunc, progressFunc, null);
            break;
        case 5:
            document.getElementById('subtitle').innerHTML    = 'Webáruház';
            document.getElementById('subMenuItem').innerHTML = ' / Belépés';
            window.location.hash = '#webaruhaz';

            document.getElementById('subtitle').style.display    = '';
            document.getElementById('subMenuItem').style.display = '';

            document.title = 'Startauto Kft. - Autóalkatrészek és motorkerékpár alkatrészek széles választéka - Webáruház / Belépés';

            getTempContents(28);
            break;
        case 6:
            initLoader('grayer', 'popup', '<b>Oldal töltése...</b>', 180, 60);
            document.getElementById('subtitle').innerHTML    = 'Hírek';
            document.getElementById('subMenuItem').innerHTML = '';
            window.location.hash = '#hirek';

            document.getElementById('subtitle').style.display    = '';
            document.getElementById('subMenuItem').style.display = '';

            document.title = 'Startauto Kft. - Autóalkatrészek és motorkerékpár alkatrészek széles választéka - Hírek';

            var successFunc = function(response) {
                var data      = eval("(" + response.responseText + ")");
                var container = document.getElementById('allVendorContainer');
                var html      = '';
                var image     = '';
                var link     = '';
                
                document.getElementById('allVendorContainer').style.display = '';
                document.getElementById('allDataContainer').style.display   = 'none';

               // container.innerHTML = data[0].contents_content;
                for(var v in data){
                    image = data[v].news_logo_id != 0 ? '<img src="lib/util/imageDisplay.php?file=' + data[v].news_logo_id.downloads_hashname + '"/>' : ''; 
                    link = data[v].news_downloads_id != 0 ? '<div class="btnholder"><a href="lib/util/pdfView.php?file=' + data[v].news_downloads_id.downloads_hashname + '" target="_blank"><img src="design/img/static/seeBtn.png"/></a><a href="lib/util/pdfDownload.php?file=' + data[v].news_downloads_id.downloads_hashname + '" target="_blank"><img src="design/img/static/pdf.png"/></a></div>' : '';
                    html += '<div class="newsholder">' + image + '<h1>' + data[v].news_title + '</h1><p>' + data[v].news_content + '</p>' + link + '</div>';
                }
               
               
                container.innerHTML = '<div class="news">' + html + '</div>';
                destructLoader('grayer', 'popup');
            };

            var failureFunc = function() {
                alert('There was a problem executing your ajax request, please contact the site admin!');
            };

            var progressFunc = function(total, received) {
                var totalHumanReadable    = Math.round(total / 1024 * 100) / 100;
                var receivedHumanReadable = Math.round(received / 1024 * 100) / 100;
            };

            var cm  = new fourDigitAjax();
            var url = AJAXBASEURL + '?module=getAllNews';
            cm.request(AJAXMETHOD, url, true, successFunc, failureFunc, progressFunc, null);
            break;
        case 7:
            initLoader('grayer', 'popup', '<b>Oldal töltése...</b>', 180, 60);
            document.getElementById('subtitle').innerHTML    = 'Start Szervíz';
            document.getElementById('subMenuItem').innerHTML = '';
            window.location.hash = '#startszerviz';

            document.getElementById('allVendorContainer').style.display = '';
            document.getElementById('allDataContainer').style.display   = 'none';

            document.title = 'Startauto Kft. - Autóalkatrészek és motorkerékpár alkatrészek széles választéka - Start Szervíz';
            var successFunc = function(response) {
                var data      = eval("(" + response.responseText + ")");
                var container = document.getElementById('allVendorContainer');

                document.getElementById('allVendorContainer').style.display = '';
                document.getElementById('allDataContainer').style.display   = 'none';

                container.innerHTML = data[0].contents_content;
                destructLoader('grayer', 'popup');
            };

            var failureFunc = function() {
                alert('There was a problem executing your ajax request, please contact the site admin!');
            };

            var progressFunc = function(total, received) {
                var totalHumanReadable    = Math.round(total / 1024 * 100) / 100;
                var receivedHumanReadable = Math.round(received / 1024 * 100) / 100;
            };

            var cm  = new fourDigitAjax();
            var url = AJAXBASEURL + '?module=getTempContents&contentId=8';
            cm.request(AJAXMETHOD, url, true, successFunc, failureFunc, progressFunc, null);
            break;
        case 8:
            initLoader('grayer', 'popup', '<b>Oldal töltése...</b>', 180, 60);
            document.getElementById('subtitle').innerHTML    = 'Kapcsolat';
            document.getElementById('subMenuItem').innerHTML = '';
            window.location.hash = '#kapcsolat';

            document.getElementById('allVendorContainer').style.display = '';
            document.getElementById('allDataContainer').style.display   = '';

            document.title = 'Startauto Kft. - Autóalkatrészek és motorkerékpár alkatrészek széles választéka - Kapcsolat';

            var successFunc = function(response) {
                var data      = eval("(" + response.responseText + ")");
                var container = document.getElementById('allVendorContainer');

                document.getElementById('allVendorContainer').style.display = '';
                document.getElementById('allDataContainer').style.display   = 'none';

                container.innerHTML = data[0].contents_content;
                destructLoader('grayer', 'popup');
            };

            var failureFunc = function() {
                alert('There was a problem executing your ajax request, please contact the site admin!');
            };

            var progressFunc = function(total, received) {
                var totalHumanReadable    = Math.round(total / 1024 * 100) / 100;
                var receivedHumanReadable = Math.round(received / 1024 * 100) / 100;
            };

            var cm  = new fourDigitAjax();
            var url = AJAXBASEURL + '?module=getTempContents&contentId=15';
            cm.request(AJAXMETHOD, url, true, successFunc, failureFunc, progressFunc, null);
            break;
        case 9:
            initLoader('grayer', 'popup', '<b>Oldal töltése...</b>', 180, 60);
            document.getElementById('subtitle').innerHTML    = 'Linkek';
            document.getElementById('subMenuItem').innerHTML = '';
            window.location.hash = '#linkek';

            document.getElementById('subtitle').style.display    = '';
            document.getElementById('subMenuItem').style.display = '';

            document.title = 'Startauto Kft. - Autóalkatrészek és motorkerékpár alkatrészek széles választéka - Linkek';
            var successFunc = function(response) {
                var data      = eval("(" + response.responseText + ")");
                var container = document.getElementById('allVendorContainer');

                document.getElementById('allVendorContainer').style.display = '';
                document.getElementById('allDataContainer').style.display   = 'none';

                container.innerHTML = data[0].contents_content;
                destructLoader('grayer', 'popup');
            };

            var failureFunc = function() {
                alert('There was a problem executing your ajax request, please contact the site admin!');
            };

            var progressFunc = function(total, received) {
                var totalHumanReadable    = Math.round(total / 1024 * 100) / 100;
                var receivedHumanReadable = Math.round(received / 1024 * 100) / 100;
            };

            var cm  = new fourDigitAjax();
            var url = AJAXBASEURL + '?module=getTempContents&contentId=10';
            cm.request(AJAXMETHOD, url, true, successFunc, failureFunc, progressFunc, null);
            break;
        case 10:
            initLoader('grayer', 'popup', '<b>Oldal töltése...</b>', 180, 60);
            document.getElementById('subtitle').innerHTML    = 'Racing';
            document.getElementById('subMenuItem').innerHTML = '';
            window.location.hash = '#racing';

            document.getElementById('allVendorContainer').style.display = '';
            document.getElementById('allDataContainer').style.display   = 'none';

            document.title = 'Startauto Kft. - Autóalkatrészek és motorkerékpár alkatrészek széles választéka - Racing';
            var successFunc = function(response) {
                var data      = eval("(" + response.responseText + ")");
                var container = document.getElementById('allVendorContainer');

                document.getElementById('allVendorContainer').style.display = '';
                document.getElementById('allDataContainer').style.display   = 'none';

                container.innerHTML = data[0].contents_content;
                destructLoader('grayer', 'popup');
            };

            var failureFunc = function() {
                alert('There was a problem executing your ajax request, please contact the site admin!');
            };

            var progressFunc = function(total, received) {
                var totalHumanReadable    = Math.round(total / 1024 * 100) / 100;
                var receivedHumanReadable = Math.round(received / 1024 * 100) / 100;
            };

            var cm  = new fourDigitAjax();
            var url = AJAXBASEURL + '?module=getTempContents&contentId=17';
            cm.request(AJAXMETHOD, url, true, successFunc, failureFunc, progressFunc, null);
            break;
        case 11:
            initLoader('grayer', 'popup', '<b>Oldal töltése...</b>', 180, 60);
            document.getElementById('subtitle').innerHTML    = 'Rólunk /';
            document.getElementById('subMenuItem').innerHTML = ' Bemutatkozás';
            window.location.hash = '#bemutatkozas';

            document.getElementById('subtitle').style.display    = '';
            document.getElementById('subMenuItem').style.display = '';

            document.title = 'Startauto Kft. - Autóalkatrészek és motorkerékpár alkatrészek széles választéka - Rólunk / Bemutatkozás';
            var successFunc = function(response) {
                var data      = eval("(" + response.responseText + ")");
                var container = document.getElementById('allVendorContainer');

                document.getElementById('allVendorContainer').style.display = '';
                document.getElementById('allDataContainer').style.display   = 'none';

                container.innerHTML = data[0].contents_content;
                destructLoader('grayer', 'popup');
            };

            var failureFunc = function() {
                alert('There was a problem executing your ajax request, please contact the site admin!');
            };

            var progressFunc = function(total, received) {
                var totalHumanReadable    = Math.round(total / 1024 * 100) / 100;
                var receivedHumanReadable = Math.round(received / 1024 * 100) / 100;
            };

            var cm  = new fourDigitAjax();
            var url = AJAXBASEURL + '?module=getTempContents&contentId=1';
            cm.request(AJAXMETHOD, url, true, successFunc, failureFunc, progressFunc, null);
            break;
        case 12:
            initLoader('grayer', 'popup', '<b>Oldal töltése...</b>', 180, 60);
            document.getElementById('subtitle').innerHTML    = 'Rólunk /';
            document.getElementById('subMenuItem').innerHTML = ' Történelem';
            window.location.hash = '#tortenelem';

            document.getElementById('subtitle').style.display    = '';
            document.getElementById('subMenuItem').style.display = '';

            document.title = 'Startauto Kft. - Autóalkatrészek és motorkerékpár alkatrészek széles választéka - Rólunk / Történelem';
            var successFunc = function(response) {
                var data      = eval("(" + response.responseText + ")");
                var container = document.getElementById('allVendorContainer');

                document.getElementById('allVendorContainer').style.display = '';
                document.getElementById('allDataContainer').style.display   = 'none';

                container.innerHTML = data[0].contents_content;
                document.getElementById('menuaaa').setActivePage('s2btn2', false);
                destructLoader('grayer', 'popup');
            };

            var failureFunc = function() {
                alert('There was a problem executing your ajax request, please contact the site admin!');
            };

            var progressFunc = function(total, received) {
                var totalHumanReadable    = Math.round(total / 1024 * 100) / 100;
                var receivedHumanReadable = Math.round(received / 1024 * 100) / 100;
            };

            var cm  = new fourDigitAjax();
            var url = AJAXBASEURL + '?module=getTempContents&contentId=6';
            cm.request(AJAXMETHOD, url, true, successFunc, failureFunc, progressFunc, null);
            break;
        case 13:
            initLoader('grayer', 'popup', '<b>Oldal töltése...</b>', 180, 60);
            document.getElementById('subtitle').innerHTML    = 'Rólunk /';
            document.getElementById('subMenuItem').innerHTML = ' Group Auto Union International (GAUI)  – Start Autó Kft.(Group Auto Union Hungary)';
            window.location.hash = '#gaui';

            document.getElementById('subtitle').style.display    = '';
            document.getElementById('subMenuItem').style.display = '';

            document.title = 'Startauto Kft. - Autóalkatrészek és motorkerékpár alkatrészek széles választéka - Rólunk / GAUI';
            var successFunc = function(response) {
                var data      = eval("(" + response.responseText + ")");
                var container = document.getElementById('allVendorContainer');

                document.getElementById('allVendorContainer').style.display = '';
                document.getElementById('allDataContainer').style.display   = 'none';

                container.innerHTML = data[0].contents_content;
                destructLoader('grayer', 'popup');
            };

            var failureFunc = function() {
                alert('There was a problem executing your ajax request, please contact the site admin!');
            };

            var progressFunc = function(total, received) {
                var totalHumanReadable    = Math.round(total / 1024 * 100) / 100;
                var receivedHumanReadable = Math.round(received / 1024 * 100) / 100;
            };

            var cm  = new fourDigitAjax();
            var url = AJAXBASEURL + '?module=getTempContents&contentId=3';
            cm.request(AJAXMETHOD, url, true, successFunc, failureFunc, progressFunc, null);
            break;
        case 14:
            initLoader('grayer', 'popup', '<b>Oldal töltése...</b>', 180, 60);
            document.getElementById('subtitle').innerHTML    = 'Rólunk /';
            document.getElementById('subMenuItem').innerHTML = ' Galéria';
            window.location.hash = '#galeria';

            document.getElementById('subtitle').style.display    = '';
            document.getElementById('subMenuItem').style.display = '';

            document.title = 'Startauto Kft. - Autóalkatrészek és motorkerékpár alkatrészek széles választéka - Rólunk / Galéria';
            var successFunc = function(response) {
                var data       = eval("(" + response.responseText + ")");
                var container  = document.getElementById('allVendorContainer');
                var html       = '';
                var col1       = '';
                var col2       = '';
                var col3       = '';
                var leftArrow  = '';
                var rightArrow = '';
                
                document.getElementById('allVendorContainer').style.display = '';
                document.getElementById('allDataContainer').style.display   = 'none';

                if(data.msg == undefined) {
                    for(var v in data.gallery){
                        if( v%3 == 0 ){
                            col1 += '<a href="design/img/dynamic/' + data.gallery[v].downloads_hashname + '"><img class="galleryImg" src="design/img/dynamic/tn_' + data.gallery[v].downloads_hashname + '"/></a>';
                        }
                        if( v%3 == 1 ){
                            col2 += '<a href="design/img/dynamic/' + data.gallery[v].downloads_hashname + '"><img class="galleryImg" src="design/img/dynamic/tn_' + data.gallery[v].downloads_hashname + '"/></a>';
                        }
                        if( v%3 == 2 ){
                            col3 += '<a href="design/img/dynamic/' + data.gallery[v].downloads_hashname + '"><img class="galleryImg" src="design/img/dynamic/tn_' + data.gallery[v].downloads_hashname + '"/></a>';
                        }
                    }
                    if(data.pageinfo != 1){
                        html = pageNumberAtGallery + 1 + ' of '+ data.pageinfo;
                        if(pageNumberAtGallery != 0 ){
                            leftArrow  = '<span onclick="previousPageGallery();"><img src="design/img/static/arrowLeft.png" style="cursor:hand; cursor: pointer;"/></span>';
                        }
                        if(pageNumberAtGallery+1 != data.pageinfo ){
                            rightArrow = '<span onclick="nextPageGallery();"><img src="design/img/static/arrowRight.png" style="cursor:hand; cursor: pointer;"/></span>';
                        }
                    }
                } else {
                      html += data.msg;
                }
                
                container.innerHTML = '<div class="gallery"><div class="picNum" id="picNum">' + html + '</div><div class="leftArrow">' + leftArrow + '</div><div class="threecol"><div class="col1">' + col1 + '</div><div class="col2">' + col2 + '</div><div class="col3">' + col3 + '</div></div><div class="rightArrow">' + rightArrow + '</div></div>';
                
                setupZoom();
                destructLoader('grayer', 'popup');
            };

            var failureFunc = function() {
                alert('There was a problem executing your ajax request, please contact the site admin!');
            };

            var progressFunc = function(total, received) {
                var totalHumanReadable    = Math.round(total / 1024 * 100) / 100;
                var receivedHumanReadable = Math.round(received / 1024 * 100) / 100;
            };

            var cm  = new fourDigitAjax();
            var url = AJAXBASEURL + '?module=getGallery&page=' + pageNumberAtGallery;
            cm.request(AJAXMETHOD, url, true, successFunc, failureFunc, progressFunc, null);
            break;
        case 15:
            initLoader('grayer', 'popup', '<b>Oldal töltése...</b>', 180, 60);
            document.getElementById('subtitle').innerHTML    = 'Karrier';
            document.getElementById('subMenuItem').innerHTML = '';
            window.location.hash = '#karrier';

            document.getElementById('subtitle').style.display    = '';
            document.getElementById('subMenuItem').style.display = '';

            document.title = 'Startauto Kft. - Autóalkatrészek és motorkerékpár alkatrészek széles választéka - Karrier';
            var successFunc = function(response) {
                var data      = eval("(" + response.responseText + ")");
                var container = document.getElementById('allVendorContainer');
                var html = '';
                
                document.getElementById('allVendorContainer').style.display = '';
                document.getElementById('allDataContainer').style.display   = 'none';

                html += '<div class="career">';
                html += '		<div class="topDiv">';
                html += '			<p class="subtext">' + data.mainpage.careers_title + '</p>';
                html += '			<img src="design/img/dynamic/' + data.mainpage.careers_description3 + '"/>';
                html += '			<p class="normaltext">' + data.mainpage.careers_description1.replace(/<\/?p>/gi, '') + '</p>';
                html += '		</div>';
                html += '		<div class="bottomDiv">';
                html += '			<p class="subtext"><b></b></p>';
                
                for(var v in data.careers){

                    html += '			<div class="tablediv">';
                    html += '				<p class="col1">';
                    html += '					<span class="title"><b>' + data.careers[v].careers_title + '</b></span>';
                    html += '					<b>Leírás:</b><br>' + data.careers[v].careers_description1;
                    html += '				</p>';
                    html += '				<p class="col2">';
                    html +=                                 data.careers[v].careers_description3;
                    html += '				</p>';
                    html += '				<p class="col3">' + data.careers[v].careers_description2 + '</p>';
                    html += '			</div>';
                }
                
                html += '			<p class="subtext"><b>' + data.mainpage.careers_description2 + '</b></p>';
                html += '		</div>';
                html += '</div>';
    
                container.innerHTML = html;
                destructLoader('grayer', 'popup');
            };

            var failureFunc = function() {
                alert('There was a problem executing your ajax request, please contact the site admin!');
            };

            var progressFunc = function(total, received) {
                var totalHumanReadable    = Math.round(total / 1024 * 100) / 100;
                var receivedHumanReadable = Math.round(received / 1024 * 100) / 100;
            };

            var cm  = new fourDigitAjax();
            var url = AJAXBASEURL + '?module=getCareers';
            cm.request(AJAXMETHOD, url, true, successFunc, failureFunc, progressFunc, null);
            break;
        case 16:
            initLoader('grayer', 'popup', '<b>Oldal töltése...</b>', 180, 60);
            document.getElementById('subtitle').innerHTML    = 'Kollégáink';
            document.getElementById('subMenuItem').innerHTML = '';
            window.location.hash = '#kollegaink';

            document.getElementById('subtitle').style.display           = '';
            document.getElementById('allVendorContainer').style.display = '';
            document.getElementById('allDataContainer').style.display   = 'none';

            document.title = 'Startauto Kft. - Autóalkatrészek és motorkerékpár alkatrészek széles választéka - Kollégáink';

            var successFunc = function(response) {
                var data      = eval("(" + response.responseText + ")");
                var container = document.getElementById('allVendorContainer');
                var red = '';

                document.getElementById('allDataContainer').style.display   = 'none';
                container.style.display = '';
                var html = '<div class="employees"><div class="listdiv">';

                for(var i in data){
                    html += '<div style="clear:both;"></div><p style="margin-top:40px; margin-bottom : 20px;">' + data[i][0].employee_area_name + '</p>';
                    html += '<div class="listheader"><p class="col1">Név</p><p class="col2">Beosztás/Terület</p><p class="col3">Mobil</p><p class="col4">Telefon</p><p class="col5">E-mail</p></div>';

                    for(var k in data[i]){
                        red = data[i][k].employees_red == 1 ? 'style="color:red;"' : '';
                        html += '<div class="listitem"><p class="col1" ' + red + '>' + data[i][k].employees_name + '</p><p class="col2" ' + red + '>' + data[i][k].employees_position + '</p><p class="col3">' + data[i][k].employees_phone1 + '</p><p class="col4">' + data[i][k].employees_phone2 + '</p><p class="col5"><a href="mailto:' + data[i][k].employees_email + '">' + data[i][k].employees_email + '</a></p><div style="clear: both;"></div></div>';
                    }
                }
                 html += '</div></div>';



                container.innerHTML = html;
                destructLoader('grayer', 'popup');
            };

            var failureFunc = function() {
                alert('There was a problem executing your ajax request, please contact the site admin!');
            };

            var progressFunc = function(total, received) {
                var totalHumanReadable    = Math.round(total / 1024 * 100) / 100;
                var receivedHumanReadable = Math.round(received / 1024 * 100) / 100;
            };

            var cm  = new fourDigitAjax();
            var url = AJAXBASEURL + '?module=getEmployees';
            cm.request(AJAXMETHOD, url, true, successFunc, failureFunc, progressFunc, null);
            break;
        case 17:
            initLoader('grayer', 'popup', '<b>Oldal töltése...</b>', 180, 60);
            document.getElementById('subtitle').innerHTML    = 'Országos hálózat';
            document.getElementById('subMenuItem').innerHTML = '';
            window.location.hash = '#orszagoshalozat';

            document.getElementById('allVendorContainer').style.display = '';
            document.getElementById('allDataContainer').style.display   = 'none';

            document.title = 'Startauto Kft. - Autóalkatrészek és motorkerékpár alkatrészek széles választéka - Országos hálózat';

            var successFunc = function(response) {
                var data      = eval("(" + response.responseText + ")");
                var container = document.getElementById('allVendorContainer');

                document.getElementById('allVendorContainer').style.display = '';
                document.getElementById('allDataContainer').style.display   = 'none';

                container.innerHTML = data[0].contents_content;

                var so = new SWFObject("design/flash/map.swf", "map", "820", "440", "8", "#000000");
                so.addParam('wmode', 'transparent');
                so.addParam('allowScriptAccess', "always");
                so.write("map");

                destructLoader('grayer', 'popup');
            };

            var failureFunc = function() {
                alert('There was a problem executing your ajax request, please contact the site admin!');
            };

            var progressFunc = function(total, received) {
                var totalHumanReadable    = Math.round(total / 1024 * 100) / 100;
                var receivedHumanReadable = Math.round(received / 1024 * 100) / 100;
            };

            var cm  = new fourDigitAjax();
            var url = AJAXBASEURL + '?module=getTempContents&contentId=19';
            cm.request(AJAXMETHOD, url, true, successFunc, failureFunc, progressFunc, null);
            break;
        case 18:
            document.getElementById('subtitle').innerHTML    = 'Termékek';
            document.getElementById('subMenuItem').innerHTML = '';
            window.location.hash = '#termekek';

            document.getElementById('subtitle').style.display    = '';
            document.getElementById('subMenuItem').style.display = '';

            document.title = 'Startauto Kft. - Autóalkatrészek és motorkerékpár alkatrészek széles választéka - Termékek';
            showAllVendors();
            break;
        case 19:
            document.getElementById('subtitle').innerHTML    = 'Termékek /';
            document.getElementById('subMenuItem').innerHTML = ' Motor és környezete';
            window.location.hash = '#motoreskornyezete';

            document.getElementById('subtitle').style.display    = '';
            document.getElementById('subMenuItem').style.display = '';

            document.title = 'Startauto Kft. - Autóalkatrészek és motorkerékpár alkatrészek széles választéka - Termékek / Motor és környezete';
            showProductCategoriesForMenu(2);
            break;
        case 20:
            document.getElementById('subtitle').innerHTML    = 'Termékek /';
            document.getElementById('subMenuItem').innerHTML = ' Kenés, üzemanyag, hűtés';
            window.location.hash = '#kenesuzemanyaghutes';

            document.getElementById('subtitle').style.display    = '';
            document.getElementById('subMenuItem').style.display = '';

            document.title = 'Startauto Kft. - Autóalkatrészek és motorkerékpár alkatrészek széles választéka - Termékek / Kenés, üzemanyag, hűtés';
            showProductCategoriesForMenu(3);
            break;
        case 21:
            document.getElementById('subtitle').innerHTML    = 'Termékek /';
            document.getElementById('subMenuItem').innerHTML = ' Elektromos';
            window.location.hash = '#elektromos';

            document.getElementById('subtitle').style.display    = '';
            document.getElementById('subMenuItem').style.display = '';

            document.title = 'Startauto Kft. - Autóalkatrészek és motorkerékpár alkatrészek széles választéka - Termékek / elektromos';
            showProductCategoriesForMenu(4);
            break;
        case 22:
            document.getElementById('subtitle').innerHTML    = 'Termékek /';
            document.getElementById('subMenuItem').innerHTML = ' Fék - Futómű';
            window.location.hash = '#fekfutomu';

            document.getElementById('subtitle').style.display    = '';
            document.getElementById('subMenuItem').style.display = '';

            document.title = 'Startauto Kft. - Autóalkatrészek és motorkerékpár alkatrészek széles választéka - Termékek / Fék - Futómű';
            showProductCategoriesForMenu(5);
            break;
        case 23:
            document.getElementById('subtitle').innerHTML    = 'Termékek /';
            document.getElementById('subMenuItem').innerHTML = ' Erőátvitel';
            window.location.hash = '#eroatvitel';

            document.getElementById('subtitle').style.display    = '';
            document.getElementById('subMenuItem').style.display = '';

            document.title = 'Startauto Kft. - Autóalkatrészek és motorkerékpár alkatrészek széles választéka - Termékek / Erőátvitel';
            showProductCategoriesForMenu(6);
            break;
        case 24:
            document.getElementById('subtitle').innerHTML    = 'Termékek /';
            document.getElementById('subMenuItem').innerHTML = ' Karosszéria';
            window.location.hash = '#karosszeria';

            document.getElementById('subtitle').style.display    = '';
            document.getElementById('subMenuItem').style.display = '';

            document.title = 'Startauto Kft. - Autóalkatrészek és motorkerékpár alkatrészek széles választéka - Termékek / Karosszéria';
            showProductCategoriesForMenu(7);
            break;
        case 25:
            document.getElementById('subtitle').innerHTML    = 'Termékek /';
            document.getElementById('subMenuItem').innerHTML = ' Kipufogó';
            window.location.hash = '#kipufogo';

            document.getElementById('subtitle').style.display    = '';
            document.getElementById('subMenuItem').style.display = '';

            document.title = 'Startauto Kft. - Autóalkatrészek és motorkerékpár alkatrészek széles választéka - Termékek / Kipufogó';
            showProductCategoriesForMenu(8);
            break;
        case 26:
            document.getElementById('subtitle').innerHTML    = 'Termékek /';
            document.getElementById('subMenuItem').innerHTML = ' Felszerelés';
            window.location.hash = '#felszereles';

            document.getElementById('subtitle').style.display    = '';
            document.getElementById('subMenuItem').style.display = '';

            document.title = 'Startauto Kft. - Autóalkatrészek és motorkerékpár alkatrészek széles választéka - Termékek / Felszerelés';
            showProductCategoriesForMenu(9);
            break;
        case 27:
            document.getElementById('subtitle').innerHTML    = 'Valvoline';
            document.getElementById('subMenuItem').innerHTML = '';
            window.location.hash = '#valvoline';

            document.getElementById('subtitle').style.display    = '';
            document.getElementById('subMenuItem').style.display = '';

            document.title = 'Startauto Kft. - Autóalkatrészek és motorkerékpár alkatrészek széles választéka - Valvoline';
            var successFunc = function(response) {
                var data      = eval("(" + response.responseText + ")");
                var container = document.getElementById('allVendorContainer');

                document.getElementById('allVendorContainer').style.display = '';
                document.getElementById('allDataContainer').style.display   = 'none';

                container.innerHTML = data[0].contents_content;
                destructLoader('grayer', 'popup');
                document.getElementById('menuaaa').setActivePage(0, false);
            };

            var failureFunc = function() {
                alert('There was a problem executing your ajax request, please contact the site admin!');
            };

            var progressFunc = function(total, received) {
                var totalHumanReadable    = Math.round(total / 1024 * 100) / 100;
                var receivedHumanReadable = Math.round(received / 1024 * 100) / 100;
            };

            var cm  = new fourDigitAjax();
            var url = AJAXBASEURL + '?module=getTempContents&contentId=7';
            cm.request(AJAXMETHOD, url, true, successFunc, failureFunc, progressFunc, null);
            break;
        case 28:
            initLoader('grayer', 'popup', '<b>Oldal töltése...</b>', 180, 60);
            document.getElementById('subtitle').innerHTML    = 'Webáruház /';
            document.getElementById('subMenuItem').innerHTML = ' Belépés';
            window.location.hash = '#webaruhazbelepes';

            document.getElementById('subtitle').style.display    = '';
            document.getElementById('subMenuItem').style.display = '';

            document.title = 'Startauto Kft. - Autóalkatrészek és motorkerékpár alkatrészek széles választéka - Webáruház / Belépés';
            var successFunc = function(response) {
                var data      = eval("(" + response.responseText + ")");
                var container = document.getElementById('allVendorContainer');

                document.getElementById('allVendorContainer').style.display = '';
                document.getElementById('allDataContainer').style.display   = 'none';

                container.innerHTML = data[0].contents_content;
                destructLoader('grayer', 'popup');
                document.getElementById('menuaaa').setActivePage('s3btn1', false);
            };

            var failureFunc = function() {
                alert('There was a problem executing your ajax request, please contact the site admin!');
            };

            var progressFunc = function(total, received) {
                var totalHumanReadable    = Math.round(total / 1024 * 100) / 100;
                var receivedHumanReadable = Math.round(received / 1024 * 100) / 100;
            };

            var cm  = new fourDigitAjax();
            var url = AJAXBASEURL + '?module=getTempContents&contentId=14';
            cm.request(AJAXMETHOD, url, true, successFunc, failureFunc, progressFunc, null);
            break;
        case 29:
            initLoader('grayer', 'popup', '<b>Oldal töltése...</b>', 180, 60);
            document.getElementById('subtitle').innerHTML    = 'Webáruház /';
            document.getElementById('subMenuItem').innerHTML = ' Viszonteladói jelszó kérés';
            window.location.hash = '#webaruhazjelszokeres';

            document.getElementById('subtitle').style.display    = '';
            document.getElementById('subMenuItem').style.display = '';

            document.title = 'Startauto Kft. - Autóalkatrészek és motorkerékpár alkatrészek széles választéka - Webáruház / Viszonteladói jelszó kérés';
            var successFunc = function(response) {
                var data      = eval("(" + response.responseText + ")");
                var container = document.getElementById('allVendorContainer');

                document.getElementById('allVendorContainer').style.display = '';
                document.getElementById('allDataContainer').style.display   = 'none';

                container.innerHTML = data[0].contents_content;
                destructLoader('grayer', 'popup');
                document.getElementById('menuaaa').setActivePage('s3btn2', false);
            };

            var failureFunc = function() {
                alert('There was a problem executing your ajax request, please contact the site admin!');
            };

            var progressFunc = function(total, received) {
                var totalHumanReadable    = Math.round(total / 1024 * 100) / 100;
                var receivedHumanReadable = Math.round(received / 1024 * 100) / 100;
            };

            var cm  = new fourDigitAjax();
            var url = AJAXBASEURL + '?module=getTempContents&contentId=13';
            cm.request(AJAXMETHOD, url, true, successFunc, failureFunc, progressFunc, null);
            break;
        case 30:
            initLoader('grayer', 'popup', '<b>Oldal töltése...</b>', 180, 60);
            document.getElementById('subtitle').innerHTML    = 'Webáruház /';
            document.getElementById('subMenuItem').innerHTML = ' Vásárlási feltételek';
            window.location.hash = '#webaruhazfeltetelek';

            document.getElementById('subtitle').style.display    = '';
            document.getElementById('subMenuItem').style.display = '';

            document.title = 'Startauto Kft. - Autóalkatrészek és motorkerékpár alkatrészek széles választéka - Webáruház / Vásárlási feltételek';
            var successFunc = function(response) {
                var data      = eval("(" + response.responseText + ")");
                var container = document.getElementById('allVendorContainer');

                document.getElementById('allVendorContainer').style.display = '';
                document.getElementById('allDataContainer').style.display   = 'none';

                container.innerHTML = data[0].contents_content;
                destructLoader('grayer', 'popup');
                document.getElementById('menuaaa').setActivePage('s3btn3', false);
            };

            var failureFunc = function() {
                alert('There was a problem executing your ajax request, please contact the site admin!');
            };

            var progressFunc = function(total, received) {
                var totalHumanReadable    = Math.round(total / 1024 * 100) / 100;
                var receivedHumanReadable = Math.round(received / 1024 * 100) / 100;
            };

            var cm  = new fourDigitAjax();
            var url = AJAXBASEURL + '?module=getTempContents&contentId=12';
            cm.request(AJAXMETHOD, url, true, successFunc, failureFunc, progressFunc, null);
            break;
       case 31:
            initLoader('grayer', 'popup', '<b>Oldal töltése...</b>', 180, 60);
            document.getElementById('subtitle').innerHTML    = 'Akciók';
            document.getElementById('subMenuItem').innerHTML = '';
            window.location.hash = '#akcio1';

            document.getElementById('allVendorContainer').style.display = '';
            document.getElementById('allDataContainer').style.display   = 'none';

            document.title = 'Startauto Kft. - Autóalkatrészek és motorkerékpár alkatrészek széles választéka - Akciók';

            var successFunc = function(response) {
                var data      = eval("(" + response.responseText + ")");
                var container = document.getElementById('allVendorContainer');

                document.getElementById('allVendorContainer').style.display = '';
                document.getElementById('allDataContainer').style.display   = 'none';

                container.innerHTML = data[0].contents_content;
                destructLoader('grayer', 'popup');
                document.getElementById('menuaaa').setActivePage(0, false);
            };

            var failureFunc = function() {
                alert('There was a problem executing your ajax request, please contact the site admin!');
            };

            var progressFunc = function(total, received) {
                var totalHumanReadable    = Math.round(total / 1024 * 100) / 100;
                var receivedHumanReadable = Math.round(received / 1024 * 100) / 100;
            };

            var cm  = new fourDigitAjax();
            var url = AJAXBASEURL + '?module=getTempContents&contentId=20';
            cm.request(AJAXMETHOD, url, true, successFunc, failureFunc, progressFunc, null);
            break;
       case 32:
            initLoader('grayer', 'popup', '<b>Oldal töltése...</b>', 180, 60);
            document.getElementById('subtitle').innerHTML    = 'Akciók';
            document.getElementById('subMenuItem').innerHTML = '';
            window.location.hash = '#akcio2';

            document.getElementById('allVendorContainer').style.display = '';
            document.getElementById('allDataContainer').style.display   = 'none';

            document.title = 'Startauto Kft. - Autóalkatrészek és motorkerékpár alkatrészek széles választéka - Akciók';

            var successFunc = function(response) {
                var data      = eval("(" + response.responseText + ")");
                var container = document.getElementById('allVendorContainer');

                document.getElementById('allVendorContainer').style.display = '';
                document.getElementById('allDataContainer').style.display   = 'none';

                container.innerHTML = data[0].contents_content;
                destructLoader('grayer', 'popup');
                document.getElementById('menuaaa').setActivePage(0, false);
            };

            var failureFunc = function() {
                alert('There was a problem executing your ajax request, please contact the site admin!');
            };

            var progressFunc = function(total, received) {
                var totalHumanReadable    = Math.round(total / 1024 * 100) / 100;
                var receivedHumanReadable = Math.round(received / 1024 * 100) / 100;
            };

            var cm  = new fourDigitAjax();
            var url = AJAXBASEURL + '?module=getTempContents&contentId=21';
            cm.request(AJAXMETHOD, url, true, successFunc, failureFunc, progressFunc, null);
            break;
       case 33:
            initLoader('grayer', 'popup', '<b>Oldal töltése...</b>', 180, 60);
            document.getElementById('subtitle').innerHTML    = 'Akciók';
            document.getElementById('subMenuItem').innerHTML = '';
            window.location.hash = '#akcio3';

            document.getElementById('allVendorContainer').style.display = '';
            document.getElementById('allDataContainer').style.display   = 'none';

            document.title = 'Startauto Kft. - Autóalkatrészek és motorkerékpár alkatrészek széles választéka - Akciók';

            var successFunc = function(response) {
                var data      = eval("(" + response.responseText + ")");
                var container = document.getElementById('allVendorContainer');

                document.getElementById('allVendorContainer').style.display = '';
                document.getElementById('allDataContainer').style.display   = 'none';

                container.innerHTML = data[0].contents_content;
                destructLoader('grayer', 'popup');
                document.getElementById('menuaaa').setActivePage(0, false);
            };

            var failureFunc = function() {
                alert('There was a problem executing your ajax request, please contact the site admin!');
            };

            var progressFunc = function(total, received) {
                var totalHumanReadable    = Math.round(total / 1024 * 100) / 100;
                var receivedHumanReadable = Math.round(received / 1024 * 100) / 100;
            };

            var cm  = new fourDigitAjax();
            var url = AJAXBASEURL + '?module=getTempContents&contentId=22';
            cm.request(AJAXMETHOD, url, true, successFunc, failureFunc, progressFunc, null);
            break;
        default:
            break;
    }
}//end getTempContents()

/**
 * @TODO Move to utils.js
 *
 * @function
 * @description Hide / show a given html element.
 *
 * @param elementId The id of the element.
 *
 * @returns void
 */
function toggleVisibilityFor(elementId) {
    document.getElementById(elementId).style.display = ((document.getElementById(elementId).style.display == '') ? 'none' : '');
}//end toggleVisibilityFor()

/**
 * @function
 * @description Gathers and send the data filled into the contact form. Contains
 * a basic check to make sure all fields are filled.
 *
 * @returns void
 */
function sendContactForm() {
    var name  = document.getElementById('name').value;
    var telno = document.getElementById('telno').value;
    var email = document.getElementById('email').value;
    var msg   = document.getElementById('msg').value;

    if (name == '' || telno == '' || email == '' || msg == '') {
        alert('Kérem minden mezőt töltsön ki!');
        return;
    } else {
        var successFunc = function(response) {
            var data = eval("(" + response.responseText + ")");

            document.forms.contact.reset();
            alert(data.msg);
        };

        var failureFunc = function() {
            alert('There was a problem executing your ajax request, please contact the site admin!');
        };

        var progressFunc = function(total, received) {
            var totalHumanReadable    = Math.round(total / 1024 * 100) / 100;
            var receivedHumanReadable = Math.round(received / 1024 * 100) / 100;
        };

        var params = 'name=' + encodeURI(name)
                   + '&telno=' + encodeURI(telno)
                   + '&email=' + encodeURI(email)
                   + '&msg=' + encodeURI(msg);

        var cm  = new fourDigitAjax();
        var url = AJAXBASEURL + '?module=getInTouch'
        cm.request('POST', url, true, successFunc, failureFunc, progressFunc, params);
    }
}//end sendContactForm()

/**
 * @function
 * @description Gets all up-to-date info from a php script and fills it into the
 * startsys dowload details table.
 *
 * @returns void
 */
function updateStartsys() {
    var successFunc = function(response) {
        var data = eval("(" + response.responseText + ")");
        var html = '';

        html += '<p class="col1">' + data.progName + '</p>'
              + '<p class="col2">' + data.progDesc + '</p>'
              + '<p class="col3">' + data.progDate + '</p>'
              + '<p class="col4">' + data.progSize + '</p>'
              + '<a href="' + data.progLink + '"></a>';

        document.getElementById('katalogusProgi').innerHTML = html;

        html = '<p class="col1">' + data.pictName + '</p>'
             + '<p class="col2">' + data.pictDesc + '</p>'
             + '<p class="col3">' + data.pictDate + '</p>'
             + '<p class="col4">' + data.pictSize + '</p>'
             + '<a href="' + data.pictLink + '"></a>';

        document.getElementById('kepesProgi').innerHTML = html;
    };

    var failureFunc = function() {
        alert('There was a problem executing your ajax request, please contact the site admin!');
    };

    var progressFunc = function(total, received) {
        var totalHumanReadable    = Math.round(total / 1024 * 100) / 100;
        var receivedHumanReadable = Math.round(received / 1024 * 100) / 100;
    };

    var cm  = new fourDigitAjax();
    var url = AJAXBASEURL + '?module=hekkStartsys'
    cm.request(AJAXMETHOD, url, true, successFunc, failureFunc, progressFunc, null);
}//end updateStartsys()


/**
 * @function
 * @description Show next page on gallery.
 *
 * @returns void
 */
function nextPageGallery() {
    pageNumberAtGallery++;
    getTempContents(14);
}//end nextPageGallery()

/**
 * @function
 * @description Show previous page on gallery.
 *
 * @returns void
 */
function previousPageGallery() {
    pageNumberAtGallery--;
    getTempContents(14);
}//end nextPageGallery()

