//----------------------------------------------------------------
// search
//----------------------------------------------------------------
function doSearch() {
    var search_param = jQuery('#search_param').val();
    
    if( search_param != '' ) {
        jQuery.ajax({
            url: '/procs/topSearchProducts.asp',
            data: 'search_param='+ search_param +'&lang='+ MEVS.getLang() +'',
            success: function(j){
        
                if( j.error_code == 0 ) {
    
                    var strContent = '';
                    
                    strContent += '<div class="top">';
                    
                    if( j.products.length == 1 ) {
                        strContent += '<div class="header">'+ j.products.length +' '+ MEVS.getText('search_result_header') +'</div>';
                    } else {
                        strContent += '<div class="header">'+ j.products.length +' '+ MEVS.getText('search_results_header') +'</div>';
                    }
                    strContent += '<div class="close"><a href="javascript:void(0);" onclick="closeSearch();"><img src="/img/icons/search-close.gif" alt="" width="16" height="16" border="0"></a></div>';
                    strContent += '</div>';
                    
                    strContent += '<div class="products">';
                    
                    for (var i = 0; i < j.products.length; i++) {
                        strContent += '<div class="product">';
                        strContent += '<div class="image"><a href="'+ j.products[i].url +'"><img src="/img/products/thumbnail/'+ j.products[i].image + '" width="60" height="40" alt="" border="0" /></a></div>';
                        strContent += '<div class="content"><a href="'+ j.products[i].url +'" class="arrow">' + j.products[i].name + '</a><br />'+ j.products[i].area +'<br />'+ j.products[i].cat_name +'</div>';
                        strContent += '</div>';
                    }

                    strContent += '</div>';
                    strContent += '<div class="footer">'+ MEVS.getText('search_results_footer') +'</div>';
                    
                    jQuery('#search_results').html(strContent).show();
      
                } else {
                }
                
            },
            error: function(o,e,k){
                //alert(MEVS.getText('error_form'));
            }
        });
    }
}

function closeSearch() {
    jQuery('#search_results').hide().empty();
}

function submitSearch() {
    var frm  = document.forms["search-form"];
    frm.submit();
}        

//----------------------------------------------------------------
// dealer locator
//----------------------------------------------------------------

function displayMap(map_id) {
    jQuery("#mapcomplete").attr({ 
        src: '/img/map/map_'+ map_id +'.gif'
    });
}

function hideMap() {
    jQuery("#mapcomplete").attr({ 
        src: '/img/map/map.gif'
    });
}

function getAdress(zipcode) {

    jQuery.jGrowl( MEVS.getText('dealer') +' ...');
    
    jQuery.ajax({
        url: '/procs/getHomecinemaPartner.asp',
        data: 'zipcode='+ zipcode +'',
        success: function(j){
    
            if( j.error_code == 0 ) {
                var strContent = '';
                
                if( j.partner.length > 0 ) {

                    for (var i = 0; i < j.partner.length; i++) {
                        strContent += '<p style="margin-bottom: 15px;">';
                        
                        strContent += '<b>'+ j.partner[i].company +'</b><br />'+ j.partner[i].street +'<br />'+ j.partner[i].zipcode +' '+ j.partner[i].city +'';
                        strContent += '<br>'+ j.text_phone +': '+ j.partner[i].phone +'';
                        
                        if(j.partner[i].fax != '') {
                            strContent += '<br>'+ j.text_fax +': '+ j.partner[i].fax +'';
                        }
                        if(j.partner[i].email != '') {
                            strContent += '<br>'+ j.text_email +': <a href="mailto:'+ j.partner[i].email +'" onFocus="if(this.blur)this.blur();">'+ j.partner[i].email +'</a>';
                        }
                        if(j.partner[i].web != '') {
                            strContent += '<br><a href="http://'+ j.partner[i].web +'" target="_blank" onFocus="if(this.blur)this.blur();">'+ j.partner[i].web +'</a>';
                        }
                        strContent += '</p>';
                    }
                    
                    jQuery("#dealer-adress").html(strContent);
                    
                } else {
                }
                            
            } else {
            }
            
            jQuery.jGrowl('close');
        }
    });

}

//----------------------------------------------------------------
// support
//----------------------------------------------------------------

function getGlossary(strCharacter) {

    if( strCharacter != '' ) {
        
        jQuery("#glossary").empty();
        jQuery.jGrowl( MEVS.getText('glossary') +' ...');
        
        jQuery.ajax({
            url: '/procs/getGlossary.asp',
            data: 'character='+ strCharacter +'&lang='+ MEVS.getLang() +'',
            success: function(j){
        
                if( j.error_code == 0 ) {
                    var strContent = '';
                    
                    if( j.glossary.length > 0 ) {
                        for (var i = 0; i < j.glossary.length; i++) {
                            strContent += '<p class="text"><b>'+ j.glossary[i].headline +'</b><br />'+ j.glossary[i].copy +'</p>';
                        }
                        
                        jQuery("#glossary").html(strContent).show();
                    
                    } else {
                        jQuery("#glossary").html('<p>'+ j.glossary_default + '</p>').show();
                    }

                    jQuery('#glossary_'+ glossaryChar +'').addClass('grey');
                    jQuery('#glossary_'+ strCharacter + '').removeClass('grey');
                    glossaryChar = strCharacter;                   

                } else {
                }
                
                jQuery.jGrowl('close');
            }
        });
    }
}

function getDownloads(section) {
    var strContent  = '';

    if( jQuery('#product_id_'+ section +'').val() != '0' ) {

        jQuery.jGrowl( MEVS.getText('downloads') +' ...');
        jQuery('#downloads').removeClass('warning').empty();

        jQuery.ajax({
            url: '/procs/getDownloads.asp',
            data: 'product_area='+ jQuery('#product_area_'+ section +'').val() + '&product_id='+ jQuery('#product_id_'+ section +'').val() +'&lang='+ MEVS.getLang() +'',
            success: function(j){
        
                if( j.error_code == 0 ) {

                    if( j.downloads.length > 0 ) {

                        if( j.product.length > 0 ) {
                            
                            if( MEVS.getLang() == 'de' ) {
                                updateBreadcrumb('p', j.product[0].area + '/'+ j.product[0].href, j.product[0].name, MEVS.get('base_href'));
                                updatePageLink(MEVS.get('treelevel')+1, j.product[1].href, j.product[1].name);
                            } else {
                                updateBreadcrumb('p', j.product[0].area + '/'+ j.product[1].href, j.product[1].name, MEVS.get('base_href'));
                                updatePageLink(MEVS.get('treelevel')+1, j.product[0].href, j.product[0].name);
                            }
                            
                        }
                        strContent += '<p><b>'+ j.download_title +'</b></p>';
                        
                        for (var i = 0; i < j.downloads.length; i++) {
                            strContent += '<div class="'+ j.downloads[i].icon +' download-items">';
                            strContent += '<div class="download-link"><a href="'+ j.downloads[i].file +'" class="download-link" target="_blank" onFocus="if(this.blur)this.blur();">'+ j.downloads[i].name +'</a></div>';
                            strContent += '<div class="download-filesize-colum">'+ j.downloads[i].filesize +'</div>';
                            strContent += '</div>';
                            strContent += '<div class="clear"></div>';
                        }
                        
                        /*strContent += '<ul>';
                        
                        for (var i = 0; i < j.downloads.length; i++) {
                            strContent += '<li class="'+ j.downloads[i].icon +' download-item"><a href="'+ j.downloads[i].file +'" class="download-link" target="_blank" onFocus="if(this.blur)this.blur();">'+ j.downloads[i].name +'</a> <span class="download-filesize-general">'+ j.downloads[i].filesize +'</span></li>';
                        }
                        strContent += '</ul>';
                        */

                        jQuery("#downloads").html(strContent);

                    } else {
                        jQuery("#downloads").addClass('warning').html(j.downloads_default);
                    }
                                       
                } else {
                    jQuery('#downloads').addClass('warning').html(j.error_msg);
                }
                
                jQuery.jGrowl('close');
            },
            error: function(o,e,k){
                jQuery('#downloads').addClass('warning').html(MEVS.getText('error_form'));
                jQuery.jGrowl('close');
            }
        });
    } else {
        jQuery('#product_id_'+ section +'').attr('selectedIndex',0);
    }
} 

function getDownloadsArchive(section) {
    var strContent  = '';
    var strHeadline = '';
    
    if( jQuery('#product_id_'+ section +'').val() != '0' ) {
        
        jQuery('#product_id_'+ section +'').removeAttr('disabled');
        jQuery('#downloads').removeClass('warning').empty();
        
        jQuery.jGrowl( MEVS.getText('downloads') +' ...');
        
        jQuery.ajax({
            url: '/procs/getDownloadsArchive.asp',
            data: 'product_id='+ jQuery('#product_id_'+ section +'').val() +'&lang='+ MEVS.getLang() +'',
            success: function(j){
        
                if( j.error_code == 0 ) {

                    if( j.downloads.length > 0 ) {

                        if( j.product.length > 0 ) {
                            
                            if( MEVS.getLang() == 'de' ) {
                                updateBreadcrumb('p', j.product[0].area + '/'+ j.product[0].href, j.product[0].name, MEVS.get('base_href'));
                                updatePageLink(MEVS.get('treelevel')+1, j.product[1].href, j.product[1].name);
                            } else {
                                updateBreadcrumb('p', j.product[0].area + '/'+ j.product[1].href, j.product[1].name, MEVS.get('base_href'));
                                updatePageLink(MEVS.get('treelevel')+1, j.product[0].href, j.product[0].name);
                            }
                        }
                        
                        strContent += '<ul>';
                                                
                        for (var i = 0; i < j.downloads.length; i++) {
                        
                            if( strHeadline == '' ) {
                                strHeadline = '<p><b>'+ j.download_title +' '+ j.downloads[i].name +'</b></p>';
                                strContent += strHeadline;
                            }
                            strContent += '<li class="'+ j.downloads[i].icon +' download-item"><a href="'+ j.downloads[i].file +'" target="_blank" class="download-link" onFocus="if(this.blur)this.blur();">'+ j.downloads[i].type +'</a> <span class="download-filesize-general">'+ j.downloads[i].filesize +'</span></li>';
                        }
                        strContent += '</ul>';

                        jQuery("#downloads").html(strContent);
                                              
                    } else {
                        jQuery('#downloads').addClass('warning').html(j.downloads_default);
                    }
                    
                } else {
                    jQuery('#downloads').addClass('warning').html(j.error_msg);
                }
                
                jQuery.jGrowl('close');
            },
            error: function(o,e,k){
                jQuery('#downloads').addClass('warning').html(MEVS.getText('error_form'));
                jQuery.jGrowl('close');
            }
        });
    } else {
        jQuery('#product_id_'+ section +'').attr('selectedIndex',0);
    }
} 


//----------------------------------------------------------------
// news
//----------------------------------------------------------------

function getPressReleases() {

    if( jQuery('#product_area').val() != '0' ) {
        
        jQuery('#press_releases').removeClass('warning').empty();
        
        jQuery.jGrowl( MEVS.getText('press_releases') +' ...');
        
        jQuery.ajax({
            url: '/procs/getPressReleases.asp',
            data: 'product_area='+ jQuery('#product_area').val() +'&lang='+ MEVS.getLang() +'',
            success: function(j){
        
                if( j.error_code == 0 ) {
                    var strContent = '';
                    
                    if( j.cat.length > 0 ) {
                        if( MEVS.getLang() == 'de' ) {
                            updateBreadcrumb('c', j.cat[0].href, j.cat[0].name, MEVS.get('base_href'));
                            updatePageLink(MEVS.get('treelevel')+1, j.cat[1].href, j.cat[1].name);
                        } else {
                            updateBreadcrumb('c', j.cat[1].href, j.cat[1].name, MEVS.get('base_href'));
                            updatePageLink(MEVS.get('treelevel')+1, j.cat[0].href, j.cat[0].name);
                        }
                    }
                    
                    if( j.press.length > 0 ) {
                        for (var i = 0; i < j.press.length; i++) {
                            //strContent += '<p style="margin: 10px 0px 15px 0px; padding: 0px;"><span class="textred">'+ j.press[i].date +' |</span> <a href="'+ j.press[i].url +'" class="grey" onFocus="if(this.blur)this.blur();">'+ j.press[i].headline +'</a></p>';
                            strContent += '<div class="news-item">';
                            strContent += '<div class="news-date">'+ j.press[i].date +'</div>';
                            strContent += '<div class="news-title">'+ j.press[i].headline +'';
                            strContent += '<p style="margin: 5px 0px 0px 0px; padding: 0px;"><a href="'+ j.press[i].url +'" onfocus="if(this.blur)this.blur();" class="arrow">'+ j.press[i].link_more +'</a>';
                            strContent += '</div>';
                            strContent += '</div>';
                            strContent += '<div class="clear"></div>';
                        }
                        
                        jQuery("#press_releases").html(strContent).show();
                    
                    } else {
                        jQuery("#press_releases").html(j.press_default).show();
                    }
                                       
                } else {
                    jQuery('#press_releases').addClass('warning').html(j.error_msg);
                }
                
                jQuery.jGrowl('close');
            },
            error: function(o,e,k){
                jQuery('#press_releases').addClass('warning').html(MEVS.getText('error_form'));
                jQuery.jGrowl('close');
            }
        });
    }
}

function getNewsletter() {

    if( jQuery('#product_area').val() != '0' ) {
        
        jQuery("#download-menu").empty();
        jQuery("#download").empty().removeClass('warning').addClass('download-container');

        jQuery.jGrowl( MEVS.getText('newsletter') +' ...');
        
        jQuery.ajax({
            url: '/procs/getMarketingnews.asp',
            data: 'product_area='+ jQuery('#product_area').val() +'&lang='+ MEVS.getLang() +'',
            success: function(j){
        
                if( j.error_code == 0 ) {
                    var strContent  = "<ul id=\"marketing-news\" class=\"pages\">";
                    var newsOnPage  = 13;
                    var newsURL     = '';
                    
                    if( j.marketingnews.length > 0 ) {
                        
                        if( j.cat.length > 0 ) {
                            if( MEVS.getLang() == 'de' ) {
                                updateBreadcrumb('c', j.cat[0].href, j.cat[0].name, MEVS.get('base_href'));
                                updatePageLink(MEVS.get('treelevel'), j.cat[1].href, j.cat[1].name);
                            } else {
                                updateBreadcrumb('c', j.cat[1].href, j.cat[1].name, MEVS.get('base_href'));
                                updatePageLink(MEVS.get('treelevel'), j.cat[0].href, j.cat[0].name);
                            }
                        }
                    
                        for (var i = 0; i < j.marketingnews.length; i++) {
                        
                            if ( (i % newsOnPage) == 0  ) {
                                strContent += "<li>";
                            }
                            
                            if( j.marketingnews[i].type == 'newsletter' ) {
                                newsURL = 'javascript:void(0);" onclick="showNewsletter('+ j.marketingnews[i].id +', \''+ j.marketingnews[i].headline  +'\')"';
                            } else {
                                newsURL = j.marketingnews[i].pdf +'" target="_blank"';
                            }
                            strContent += '<p style="margin: 0px 0px 0px 0px; padding: 5px 0px 5px 0px;"><span class="textred">'+ j.marketingnews[i].date +' |</span> <a href="'+ newsURL +'" class="grey" onFocus="if(this.blur)this.blur();">'+ j.marketingnews[i].headline +'</a></p>';
                            strContent += "";

                            if ( (i % newsOnPage) == newsOnPage-1 ) {
                                strContent += "</li>";
                            }
                        }
                        
                        if ( (i % newsOnPage) > 0 && (i % newsOnPage) < newsOnPage ) {
                            strContent += "</li>";
                        }
                        strContent += "</ul>";
                        jQuery("#download").html(strContent);

                        jQuery("#marketing-news").wslide({
                        	width: 500,
                        	height: 350,
                        	duration: 2000,
                            autolink: 'download-menu'
                        });
                        
                        if( j.marketingnews.length < newsOnPage+1 ) {
                            jQuery("#download-menu").empty();
                        }

                    } else {
                        jQuery('#download').addClass('warning').html(j.downloads_default);
                    }
                                        
                } else {
                    jQuery('#download').addClass('warning').html(j.error_msg);
                }
                
                jQuery.jGrowl('close');
                jQuery('#download').removeClass('download-container');
            },
            error: function(o,e,k){
                jQuery('#download').removeClass('download-container').addClass('warning').html(MEVS.getText('error_form'));
                jQuery.jGrowl('close');
            }
        });
    }
}


function showNewsletter(newsletter_id, newsletter_headline) {
    jQuery('#newsletterContent').html('<div class="loading">'+ MEVS.getText('loading_newsletter') +'</div>');
    jQuery('#newsletterDialog').jqmShow();

    jQuery.ajax({
        url: '/procs/getNewsletter.asp',
        data: 'lang='+ MEVS.getLang() +'&newsletter='+ newsletter_id +'',
        dataType: 'html',
        success: function(html){
            jQuery('#newsletterContent').html('<h1>'+ newsletter_headline + '</h1>' + html + '');
        },
        error: function(o,e,k){
            jQuery('#newsletterContent').html('<div class="warning-dialog">'+ MEVS.getText('error_form') +'</div>');
        }
    });
}


function initMaterialSearch() {
    if( jQuery('#material_type').val() != '0' ) {
        if( jQuery('#material_type').val() != '0' && jQuery('#product_area').val() != '0' ) {
            getMaterial();
        } else {
            jQuery('#product_area').removeAttr('disabled');
            jQuery('#product_archive').removeAttr('disabled');
            jQuery('#product_area').attr('selectedIndex',0);
        }       
    } else {
        jQuery('#product_area').attr('disabled', 'disabled');
        jQuery('#product_archive').attr('disabled', 'disabled');
    }
}

function getMaterial() {

    if( jQuery('#material_type').val() != '0' ) {
        jQuery('#product_area').removeAttr('disabled');
        jQuery('#product_archive').removeAttr('disabled');
    }
    
    if( jQuery('#material_type').val() != '0' && jQuery('#product_area').val() != '0' ) {
        
        jQuery("#download-menu").empty();
        jQuery("#download").empty().removeClass('warning').addClass('download-container');
        
        jQuery.jGrowl( MEVS.getText('material') +' ...');

        jQuery.ajax({
            url: '/procs/getMaterial.asp',
            data: 'product_area='+ jQuery('#product_area').val() +'&material_type='+ jQuery('#material_type').val() +'&archive='+ jQuery('#product_archive').val() +'&lang='+ MEVS.getLang() +'',
            success: function(j){
        
                if( j.error_code == 0 ) {
                    var strContent  = "<ul id=\"downloads\" class=\"pages\">";
                    var itemsOnPage = 9;
                    var itemsName   = '';

                    if( j.material.length > 0 ) {
  
                        for (var i = 0; i < j.material.length; i++) {
                        
                            if ( (i % itemsOnPage) == 0  ) {
                                strContent += "<li>";
                            }
                            
                            strContent += '<p class="'+ j.material[i].icon +' download-item"><a href="'+ j.material[i].file +'" target="_blank" class="download-link" onfocus="if(this.blur)this.blur();" onmousedown="ET_Event.download(\''+ j.material[i].type +'\', \'\');">'+ j.material[i].product +'</a> <span class="download-filesize">'+ j.material[i].filesize +'</span> <span class="download-icon"><a href="javascript:void(0);" onclick="toggleBasket('+ j.material[i].id +');"><img src="/img/icons/basket_'+ j.material[i].basket +'.gif" alt="" width="16" height="16" border="0" id="basket_'+ j.material[i].id +'"></a></span></p>';
                            strContent += "";

                            if ( (i % itemsOnPage) == itemsOnPage-1 ) {
                                strContent += "</li>";
                            }
                        }
                        
                        if ( (i % itemsOnPage) > 0 && (i % itemsOnPage) < itemsOnPage ) {
                            strContent += "</li>";
                        }
                        strContent += "</ul>";
                        jQuery("#download").html(strContent);

                        jQuery("#downloads").wslide({
                        	width: 307,
                        	height: 279,
                        	duration: 2000,
                            autolink: 'download-menu'
                        });
                        
                        if( j.material.length < itemsOnPage+1 ) {
                            jQuery("#download-menu").empty();
                        }
                        
                    } else {
                        jQuery('#download').addClass('warning').html(j.downloads_default);
                    }
                                        
                } else {
                    jQuery('#download').addClass('warning').html(j.error_msg);
                }
                
                jQuery.jGrowl('close');
                jQuery("#download").removeClass('download-container');
            },
            error: function(o,e,k){
                jQuery('#download').removeClass('download-container').addClass('warning').html(MEVS.getText('error_form'));
                jQuery.jGrowl('close');
            }
        });
    }
}


function getMaterialByProduct(section) {

    if( jQuery('#product_area_'+ section +'').val() != '0' ) {
        jQuery('#product_id_'+ section +'').removeAttr('disabled');
    }
    
    if( jQuery('#product_id_'+ section +'').val() != '0' && jQuery('#product_area_'+ section +'').val() != '0' ) {
        
        jQuery("#download-menu").empty();
        jQuery("#download").empty().removeClass('warning').addClass('download-container');
        
        jQuery.jGrowl( MEVS.getText('material') +' ...');

        jQuery.ajax({
            url: '/procs/getMaterialByProduct.asp',
            data: 'product_area='+ jQuery('#product_area_'+ section +'').val() +'&product_id='+ jQuery('#product_id_'+ section +'').val() +'&lang='+ MEVS.getLang() +'',
            success: function(j){
        
                if( j.error_code == 0 ) {
                    var strContent  = "<ul id=\"downloads\" class=\"pages\">\n";
                    var itemsOnPage = 11;
                    var itemsName   = '';

                    if( j.material.length > 0 ) {
  
                        if( j.product.length > 0 ) {
                            if( MEVS.getLang() == 'de' ) {
                                updateBreadcrumb('p', j.product[0].area + '/'+ j.product[0].href, j.product[0].name, MEVS.get('base_href'));
                                updatePageLink(MEVS.get('treelevel')+1, j.product[1].href, j.product[1].name);
                            } else {
                                updateBreadcrumb('p', j.product[0].area + '/'+ j.product[1].href, j.product[1].name, MEVS.get('base_href'));
                                updatePageLink(MEVS.get('treelevel')+1, j.product[0].href, j.product[0].name);
                            }
                        }
                        
                        for (var i = 0; i < j.material.length; i++) {
                        
                            if ( (i % itemsOnPage) == 0  ) {
                                strContent += "<li>\n";
                            }
                            
                            strContent += '<p class="'+ j.material[i].icon +' download-item"><a href="'+ j.material[i].file +'" target="_blank" class="download-link" onfocus="if(this.blur)this.blur();" onmousedown="ET_Event.download(\''+ j.material[i].type +'\', \'\');">'+ j.material[i].type +'</a> <span class="download-filesize">'+ j.material[i].filesize +'</span> <span class="download-icon"><a href="javascript:void(0);" onclick="toggleBasket('+ j.material[i].id +');"><img src="/img/icons/basket_'+ j.material[i].basket +'.gif" alt="" width="16" height="16" border="0" id="basket_'+ j.material[i].id +'"></a></span></p>';
                            strContent += "\n";

                            if ( (i % itemsOnPage) == itemsOnPage-1 ) {
                                strContent += "</li>";
                            }
                        }
                        
                        if ( (i % itemsOnPage) > 0 && (i % itemsOnPage) < itemsOnPage ) {
                            strContent += "</li>";
                        }
                        strContent += "\n</ul>";
                        jQuery("#download").html(strContent);
                                                
                        jQuery("#downloads").wslide({
                        	width: 307,
                        	height: 341,
                        	duration: 2000,
                            autolink: 'download-menu'
                        });

                        if( j.material.length < itemsOnPage+1 ) {
                            jQuery("#download-menu").empty();
                        }
                    
                    } else {
                        jQuery('#download').addClass('warning').html(j.downloads_default);
                    }
                                        
                } else {
                    jQuery('#download').addClass('warning').html(j.error_msg);
                }
                
                jQuery.jGrowl('close');
                jQuery("#download").removeClass('download-container');
            },
            error: function(o,e,k){
                jQuery('#download').removeClass('download-container').addClass('warning').html(MEVS.getText('error_form'));
                jQuery.jGrowl('close');
            }
        });
    } else {
        jQuery('#product_id_'+ section +'').attr('selectedIndex',0);
    }
}

function getPressMaterial(section) {

    if( jQuery('#product_area_'+ section +'').val() != '0' ) {
        jQuery('#product_id_'+ section +'').removeAttr('disabled');
    }
    
    if( jQuery('#product_id_'+ section +'').val() != '0' && jQuery('#product_area_'+ section +'').val() != '0' ) {
        
        jQuery("#download-menu").empty();
        jQuery("#downloads").empty().removeClass('warning');
        
        jQuery.jGrowl( MEVS.getText('press') +' ...');

        jQuery.ajax({
            url: '/procs/getPressMaterial.asp',
            data: 'product_area='+ jQuery('#product_area_'+ section +'').val() +'&product_id='+ jQuery('#product_id_'+ section +'').val() +'&lang='+ MEVS.getLang() +'',
            success: function(j){
        
                if( j.error_code == 0 ) {
                    var strContent  = '';
                    var strHeadline = '';
                    
                    if( j.downloads.length > 0 ) {
                    
                        if( j.product.length > 0 ) {
                            
                            if( MEVS.getLang() == 'de' ) {
                                updateBreadcrumb('p', j.product[0].area + '/'+ j.product[0].href, j.product[0].name, MEVS.get('base_href'));
                                updatePageLink(MEVS.get('treelevel')+1, j.product[1].href, j.product[1].name);
                            } else {
                                updateBreadcrumb('p', j.product[0].area + '/'+ j.product[1].href, j.product[1].name, MEVS.get('base_href'));
                                updatePageLink(MEVS.get('treelevel')+1, j.product[0].href, j.product[0].name);
                            }
                        }

                        strContent = '<ul>';
                                                
                        for (var i = 0; i < j.downloads.length; i++) {
                        
                            if( strHeadline == '' ) {
                                strHeadline = '<p><b>'+ j.download_title +'</b></p>';
                                strContent += strHeadline;
                            }
                            strContent += '<li class="'+ j.downloads[i].icon +' download-item"><a href="'+ j.downloads[i].file +'" class="download-link" target="_blank" onFocus="if(this.blur)this.blur();">'+ j.downloads[i].type +'</a> <span class="download-filesize-general">'+ j.downloads[i].filesize +'</span></li>';
                        }
                        strContent += '</ul>';

                        jQuery("#downloads").html(strContent);
                                              
                    } else {
                        jQuery("#downloads").addClass('warning').html(j.downloads_default); 
                    }
                    
                } else {
                    jQuery('#downloads').addClass('warning').html(j.error_msg);
                }
                
                jQuery.jGrowl('close');
            },
            error: function(o,e,k){
                jQuery('#downloads').addClass('warning').html(MEVS.getText('error_form'));
                jQuery.jGrowl('close');
            }
        });
    } else {
        jQuery('#product_id_'+ section +'').attr('selectedIndex',0);
    }
}


function getSalesSupportMaterial() {

    var options = '<option value="0">&raquo; '+ MEVS.getText('select_default') +'</option>';

    if( jQuery('#sales_lang').val() != '0' ) {

        jQuery("#download-menu").empty();
        jQuery("#download").empty().removeClass('warning').addClass('download-container');

        jQuery.jGrowl( MEVS.getText('sales_material') +' ...');

        jQuery.ajax({
            url: '/procs/getSalesSupportMaterial.asp',
            data: 'sales_lang='+ jQuery('#sales_lang').val() +'&lang='+ MEVS.getLang() +'',
            success: function(j){

                if( j.error_code == 0 ) {

                    if( j.sales.length > 0 ) {

                        for (var i = 0; i < j.sales.length; i++) {
                            options += '<option value="'+ j.sales[i].id +'">'+ j.sales[i].name +'</option>';
                        }

                        jQuery("#sales_material_id").html(options);

                        jQuery('#sales_material_id').removeAttr('disabled');

                    } else {
                        jQuery('#download').addClass('warning').html(j.downloads_default);
                    }

                } else {
                    jQuery('#download').addClass('warning').html(j.error_msg);
                }

                jQuery.jGrowl('close');
                jQuery("#download").removeClass('download-container');
            },
            error: function(o,e,k){
                jQuery('#download').removeClass('download-container').addClass('warning').html(MEVS.getText('error_form'));
                jQuery.jGrowl('close');
            }
        });

    }

    jQuery("#product_id").html(options);
    jQuery('#product_list').hide();
}


function getSalesSupportProducts() {

    var options = '<option value="0">&raquo; '+ MEVS.getText('select_default') +'</option>';

    if( jQuery('#sales_material_id').val() != 4 && jQuery('#sales_material_id').val() != 5 && jQuery('#sales_material_id').val() != 6 ) {

        jQuery("#download-menu").empty();
        jQuery("#download").empty().removeClass('warning').addClass('download-container');

        jQuery.jGrowl( MEVS.getText('sales_products') +' ...');

        jQuery.ajax({
            url: '/procs/getSalesSupportProducts.asp',
            data: 'material_id='+ jQuery('#sales_material_id').val() +'&sales_lang='+ jQuery('#sales_lang').val() +'&lang='+ MEVS.getLang() +'',
            success: function(j){

                if( j.error_code == 0 ) {

                    if( j.products.length > 0 ) {

                        for (var i = 0; i < j.products.length; i++) {
                            options += '<option value="'+ j.products[i].id +'">'+ j.products[i].name +'</option>';
                        }

                        jQuery("#product_id").html(options);
                        jQuery('#product_list').show();

                    } else {

                        jQuery('#download').addClass('warning').html(j.downloads_default);
                    }

                } else {

                    jQuery("#product_id").html(options);

                    jQuery('#download').addClass('warning').html(j.error_msg);
                }

                jQuery.jGrowl('close');
                jQuery("#download").removeClass('download-container');
            },
            error: function(o,e,k){
                jQuery('#download').removeClass('download-container').addClass('warning').html(MEVS.getText('error_form'));
                jQuery.jGrowl('close');
            }
        });

    } else {
        jQuery("#product_id").html(options);
        jQuery('#product_list').hide();

        getSalesSupportFiles();
    }

}

function getSalesSupportFiles() {

    if( jQuery('#sales_material_id').val() != '0' ) {

        jQuery("#download-menu").empty();
        jQuery("#download").empty().removeClass('warning').addClass('download-container');

        jQuery.jGrowl( MEVS.getText('sales_files') +' ...');

        jQuery.ajax({
            url: '/procs/getSalesSupportFiles.asp',
            data: 'product_id='+ jQuery('#product_id').val() +'&material_id='+ jQuery('#sales_material_id').val() +'&sales_lang='+ jQuery('#sales_lang').val() +'&lang='+ MEVS.getLang() +'',
            success: function(j){

                if( j.error_code == 0 ) {
                    var strContent  = "<ul id=\"downloads\" class=\"pages\">";
                    var itemsOnPage = 10;
                    var itemsName   = '';

                    if( j.material.length > 0 ) {

                        for (var i = 0; i < j.material.length; i++) {

                            if ( (i % itemsOnPage) == 0  ) {
                                strContent += "<li>";
                            }

                            if( jQuery('#product_id').val() > 0 ) {
                                strContent += '<p class="'+ j.material[i].icon +' download-item"><a href="'+ j.material[i].file +'" target="_blank" class="download-link" style="width: 160px;" onfocus="if(this.blur)this.blur();" onmousedown="ET_Event.download(\''+ j.material[i].type +'\', \'\');">'+ j.material[i].type +'</a> <span class="download-filesize">'+ j.material[i].filesize +'</span> <span class="download-icon"><a href="/getfile/vertrieb/'+ j.material[i].id +'.html" onmousedown="ET_Event.download(\''+ j.material[i].type +'\', \'\');"><img src="/img/icons/download.gif" width="16" height="16" alt="" style="padding-right: 4px;" /></a><a href="javascript:void(0);" onclick="toggleBasket('+ j.material[i].id +');"><img src="/img/icons/basket_'+ j.material[i].basket +'.gif" alt="" width="16" height="16" border="0" id="basket_'+ j.material[i].id +'"></a></span></p>';
                            } else {
                                strContent += '<p class="'+ j.material[i].icon +' download-item"><a href="'+ j.material[i].file +'" target="_blank" class="download-link" style="width: 160px;" onfocus="if(this.blur)this.blur();" onmousedown="ET_Event.download(\''+ j.material[i].type +'\', \'\');">'+ j.material[i].type +'</a> <span class="download-filesize">'+ j.material[i].filesize +'</span> <span class="download-icon"><a href="/getfile/vertrieb/'+ j.material[i].id +'.html" onmousedown="ET_Event.download(\''+ j.material[i].type +'\', \'\');"><img src="/img/icons/download.gif" width="16" height="16" alt="" style="padding-right: 4px;" /></a><a href="javascript:void(0);" onclick="toggleBasket('+ j.material[i].id +');"><img src="/img/icons/basket_'+ j.material[i].basket +'.gif" alt="" width="16" height="16" border="0" id="basket_'+ j.material[i].id +'"></a></span></p>';
                            }
                            strContent += "";

                            if ( (i % itemsOnPage) == itemsOnPage-1 ) {
                                strContent += "</li>";
                            }
                        }

                        if ( (i % itemsOnPage) > 0 && (i % itemsOnPage) < itemsOnPage ) {
                            strContent += "</li>";
                        }
                        strContent += "</ul>";
                        jQuery("#download").html(strContent);

                        jQuery("#downloads").wslide({
                        	width: 307,
                        	height: 301,
                        	duration: 2000,
                            autolink: 'download-menu'
                        });

                        if( j.material.length < itemsOnPage+1 ) {
                            jQuery("#download-menu").empty();
                        }

                    } else {
                        var options = '<option value="0">&raquo; '+ MEVS.getText('select_default') +'</option>';
                        jQuery("#product_id").html(options);
                        if( jQuery('#product_id').val() == 0 ) {
                            jQuery('#product_list').hide();
                        } else {
                            jQuery('#product_list').show();
                        }

                        jQuery('#download').addClass('warning').html(j.downloads_default);
                    }

                } else {
                    jQuery('#download').addClass('warning').html(j.error_msg);
                }

                jQuery.jGrowl('close');
                jQuery("#download").removeClass('download-container');
            },
            error: function(o,e,k){
                jQuery('#download').removeClass('download-container').addClass('warning').html(MEVS.getText('error_form'));
                jQuery.jGrowl('close');
            }
        });
    }
}


//----------------------------------------------------------------
// misc functions
//----------------------------------------------------------------

//function alert(msg) {
//  jQuery('#alertDialog').jqmShow().find('div.dialogContent').html(msg);
//}

function redirectPage(page) {
    if( page != '') {
        window.location.href = page;
    } else {
        if( MEVS.get('redirect_url') && MEVS.get('redirect_url') != '' ) {
            window.location.href = MEVS.get('redirect_url');
        }
    }
}

function openSitemap(sitemap_url) {
    intWidth 	= 450;
	intHeight 	= 500;
  	intX 		= (screen.width/2)-(intWidth/2);
	intY 		= (screen.height/2)-(intHeight/2);
  	
	popUp = window.open(sitemap_url,'sitemap','scrollbars=yes,width='+intWidth+',height='+intHeight+',left='+intX+',top='+intY);
    popUp.focus();
}

function printPage(page_url) {
    intWidth 	= 450;
	intHeight 	= 600;
  	intX 		= (screen.width/2)-(intWidth/2);
	intY 		= (screen.height/2)-(intHeight/2);
  	
	popUp = window.open(page_url,'print','scrollbars=yes,width='+intWidth+',height='+intHeight+',left='+intX+',top='+intY);
    popUp.focus();
}

function openWebpage(strURL) {
    if(window.opener && !window.opener.closed) {
        window.opener.location.href = strURL;
    } else {
        window.open(strURL, '_blank');
    }
}

function getValue(value_id) {
    text = jQuery('#'+ value_id +'').val();
    text = escape(text);
    text = nl2br(text);
    
    return text;
}

function formatValue(str) {
    str = str.replace(/<br\/>/g, "\n");
    str = str.replace(/&quot;/g, '"');
    return str;
}

function nl2br(text){
    var re_nlchar = '';
    
	if(text.indexOf('%0D%0A') > -1) {
		re_nlchar = /%0D%0A/g;
	} else if(text.indexOf('%0A') > -1) {
		re_nlchar = /%0A/g;
	} else if(text.indexOf('%0D') > -1) {
		re_nlchar = /%0D/g;
	}
    if( re_nlchar != '' ) {
        return text.replace(re_nlchar,'<br />');
    } else {
        return text;
    }
}

function toggleCell(cell_name) {
    jQuery("#"+ cell_name +"").toggle();
}

function toggleNavi(navi_id, navi_status, navi_lang) {
    if( navi_status == 'active' ) {
        jQuery("#n"+ navi_id +"").attr({ 
            src: '/img/navi/'+ navi_lang +'_0'+ navi_id +'_h.gif'
        });
    } else {
        jQuery("#n"+ navi_id +"").attr({ 
            src: '/img/navi/'+ navi_lang +'_0'+ navi_id +'.gif'
        });
    }
}

function fadeInElement(element,tab_id) {
    if (jQuery.browser.msie) {
        jQuery('#'+ element + '').css('display', 'block');
    } else {
        jQuery('#'+ element + '').fadeIn(800);
    }
    jQuery('#tablink'+ tab_id + '').addClass('active');
}

function fadeOutElement(element,tab_id) {
    if (jQuery.browser.msie) {
        jQuery('#'+ element + '').css('display', 'none');
        fadeInElement('content'+ tab_id +'',tab_id);
    } else {
        jQuery('#'+ element + '').fadeOut(800, function () {
            fadeInElement('content'+ tab_id +'',tab_id);
        });
    }
    jQuery('#tablink'+ contentID + '').removeClass('active');
}

function slideToggle(element) {
	jQuery('#'+ element + '').slideToggle('fast');
}

function updateBreadcrumb(type,href,text,url) {
    var pageURL     = url;
    var isUpdated   = false;

    if(pageURL.indexOf(href) < 0) {
        pageURL = pageURL.replace(/.html/g, '');
        if(href.indexOf('.html') < 0) {
            pageURL = pageURL + '/'+ href + '.html';
        } else {
            pageURL = pageURL + '/'+ href + '';
        }
    }
    jQuery('#breadcrumb ul li').each(function(i){
        if(this.id == 'bread_'+ type +'') {
            jQuery(this).html('<a href="' + pageURL +'" onFocus="if(this.blur)this.blur();" >'+ text +'</a>');
            isUpdated = true;
        }
    });
    
    if( isUpdated == false ) {
        jQuery("#breadcrumb ul li:last a").removeClass('highlight');
        jQuery("#breadcrumb ul li:last a").removeClass('highlight');
        
        jQuery("#breadcrumb ul").append('<li>&raquo;</li>');
        jQuery("#breadcrumb ul").append('<li id="bread_'+ type +'"><a href="' + pageURL +'" onFocus="if(this.blur)this.blur();" >'+ text +'</a></li>');
    }

    jQuery("#breadcrumb ul li:last a").addClass('highlight');
}

function updatePageLink(index,href,text) {
    var pageURL     = jQuery("#switchlang").attr('href');
    var isUpdated   = false;
    var urlFolders  = pageURL.split('/');

    if(urlFolders[index]) {
        urlFolders[index] = href;
        pageURL = urlFolders.join("/");
    } else {  
        if(pageURL.indexOf(href) < 0) {
            pageURL = pageURL.replace(/.html/g, '');
            pageURL = pageURL + '/'+ href + '';
        }
    }
    if(pageURL.indexOf('.html') < 0) {
        pageURL = pageURL + '.html';
    }
    
    jQuery("#switchlang").attr({ 
        href: pageURL
    });
}