$(document).ready(function () {

    function makeSublist(parent, child, isSubselectOptional, childVal, valBefore, valAfret) {
        $("body").append("<select style='display:none' id='" + parent + child + "'></select>");
        $('#' + parent + child).html($("#" + child + " option"));

        var parentValue = $('#' + parent).attr('value');
        $('#' + child).html($("#" + parent + child + " .sub_" + parentValue).clone());

        childVal = (typeof childVal == "undefined") ? "" : childVal;
        $("#" + child).val(childVal).attr('selected', 'selected');
        $('#' + child).prepend("<option value='0' selected='selected'>" + valBefore + "</option>");

        $('#' + parent).change(function () {
            var parentValue = $('#' + parent).attr('value');
            $('#' + child).html($("#" + parent + child + " .sub_" + parentValue).clone());
            if (isSubselectOptional) $('#' + child).prepend("<option value='0'>" + valAfret + "</option>");
            $('#' + child + ' option:first').attr("selected", "selected");
            $('#' + child).trigger("change");
            $('#' + child).focus();
        });
    }

    makeSublist('ctl00_ctl00_cph1_ctrlHeaderMenu_mLongTail_ddSearch1', 'ctl00_ctl00_cph1_ctrlHeaderMenu_mLongTail_ddSearch2', true, '', $('#LanguageNameForSearch').html(), $('#LanguageNameForSearch2').html());
    makeSublist('ctl00_ctl00_cph1_ctrlHeaderMenu_mLongTail_ddSearch2', 'ctl00_ctl00_cph1_ctrlHeaderMenu_mLongTail_ddSearch3', true, '', $('#LanguageNameForSearch').html(), $('#LanguageNameForSearch2').html());


    
    
    //$("a.popup").fancybox({});
    $('.headermenu_topmenu_ul > li:first').attr({ style: 'background: none;' });
    //category tabs
    $('.product_in_category_main_item').addClass('item_dn');

    $('.product_in_category_main').each(function (index) {
        $(this).children('.product_in_category_main_item').first().addClass('active_tab');
    });
    $('.product_in_category_menu').each(function (index) {
        $(this).children('.product_in_category_menu_item').first().addClass('active');
    });



    $('.product_in_category_menu_item').hover(function () {
        
        $(this).parent().children('.product_in_category_menu_item').removeClass('active');
        $(this).addClass('active');


        var currentTabId = $(this).attr('id');
        $('.' + currentTabId).parent().children('.product_in_category_main_item').removeClass('active_tab');
        $('.' + currentTabId ).addClass('active_tab');
        return false;
    });

});

function DocumentWriteMarqueeStart() {
    sHtml = "<marquee style='width:174px;' scrollamount='2' scrolldelay='0' onmouseout='this.scrollAmount=2;' onmouseover='this.scrollAmount=0;' direction='up'>";
    document.writeln(sHtml);
}
function DocumentWriteMarqueeFinish() {
    sHtml = "</marquee>";
    document.writeln(sHtml);
}
