
$(document).ready(function(){
    
    if($('.paper')){
        $('.paper').each(function(){
            $(this).after('<div class="papercontainer"><div class="paperhead"></div><div class="paper">'+$(this).html()+'</div><div class="paperfoot"></div></div>');
            $(this).remove();
        });
    }
    
    /*if title emtpy do not show h1*/
    if($('#fe_PreviewTitle').html() == "") {
        $('#fe_PreviewTitle').parent('h1').hide();
    }
    
    var mainWidth = $('#mainMenu').css('width');
    
    $('#mainMenuCenter').css('width' , mainWidth);
    $('#mainMenuCenter').css('margin' , 'auto');
    
    $('a.active').each(function(){
        var altName = $(this).children('img').attr("alt");
        $(this).children('img').attr('src', 'themes/boxingkings/images/button_'+altName+'_active.png');

    });
    
    $('a.starter_active').each(function(){
        var altName = $(this).children('img').attr("alt");
        $(this).children('img').attr('src', 'themes/boxingkings/images/button_'+altName+'_active.png');

    });
    
    $('a.showmorenews').click(function(){
        if($(this).attr('alt') == 'open') {
            $(this).prev('.longtext').slideUp();
            $(this).html('MEHR'); 
            $(this).attr('alt', 'close');       
        } else {
            $(this).prev('.longtext').slideDown();
            $(this).html('WENIGER'); 
            $(this).attr('alt', 'open');   
            
        }
    });
    
    // Hovereffect for the hover class
    $(".hover").hover(function(){

        var elementName =  $(this).attr('alt');
        var arrPath = $(this).attr('src').split('/');
        var arrLen = arrPath.length -1;
        var path = '';
        $(arrPath).each(function(index, value){
            if(index != arrLen) {
                path = path+value+'/';    
            }   
        }); 
        $(this).attr('src', path+elementName+'_active.png')
        },
        function(){
            var elementName =  $(this).attr('alt');
            var arrPath = $(this).attr('src').split('/');
            var arrLen = arrPath.length -1;
            var path = '';
            $(arrPath).each(function(index, value){
                if(index != arrLen) {
                    path = path+value+'/';    
                }
            }); 
            var elementName =  $(this).attr('alt');
            $(this).attr('src', path+elementName+'.png');
    });
    
    // Hovereffect for the metanavigation
    
    $("#metanavigation img.hover").hover(function(){
        var elementName =  $(this).attr('alt');  
        $(this).attr('src', 'themes/boxingkings/images/'+elementName+'_active.png')
        },
        function(){
            var elementName =  $(this).attr('alt');
            $(this).attr('src', 'themes/boxingkings/images/'+elementName+'.png')
    }); 
    
    // Hovereffect for the Facebook Icon
    $("#facebook img").hover(function(){
        var elementName =  $(this).attr('alt');  
        $(this).attr('src', 'themes/boxingkings/images/'+elementName+'_active.png')
        },
        function(){
            var elementName =  $(this).attr('alt');
            $(this).attr('src', 'themes/boxingkings/images/'+elementName+'.png')
    });     
                  
    // Hovereffect for the navigation
    $("#navigation ul li a img").hover(function(){ 
        var cName = $(this).parent('a').attr('class');
        if(cName != 'active') { 
            var elementName =  $(this).attr('alt');  
            $(this).attr('src', 'themes/boxingkings/images/button_'+elementName+'_active.png')  
        }          
        },
        function(){
            var cName = $(this).parent('a').attr('class');
            if(cName != 'active') {  
                var elementName =  $(this).attr('alt');
                $(this).attr('src', 'themes/boxingkings/images/button_'+elementName+'.png') 
            } 
    });
        

    // Hovereffect for the navigation in the footer
    $("#mainMenu img").hover(function(){
        var elementName =  $(this).attr('alt');  
        var cName = $(this).parent('a').attr('class');
        if(cName != 'starter_active' && cName != 'active') { 
            $(this).attr('src', 'themes/boxingkings/images/button_'+elementName+'_active.png')
        }
        },
        function(){
            var cName = $(this).parent('a').attr('class');
            if(cName != 'starter_active' && cName != 'active') { 
                var elementName =  $(this).attr('alt');
                $(this).attr('src', 'themes/boxingkings/images/button_'+elementName+'.png')
            }
    });  
    
    // Hovereffect for the arrow buttons
    $("#arrowleft img").hover(function(){
        var elementName =  $(this).attr('alt');  
        $(this).attr('src', 'themes/boxingkings/images/'+elementName+'_active.png')
        },
        function(){
            var elementName =  $(this).attr('alt');
            $(this).attr('src', 'themes/boxingkings/images/'+elementName+'.png')
    }); 
    $("#arrowright img").hover(function(){
        var elementName =  $(this).attr('alt');  
        $(this).attr('src', 'themes/boxingkings/images/'+elementName+'_active.png')
        },
        function(){
            var elementName =  $(this).attr('alt');
            $(this).attr('src', 'themes/boxingkings/images/'+elementName+'.png')
    }); 

});

function newsletterValidate() {
    
    var err = 0;
    var errmsg;

    if($("select[name=title]").val() == 0) {
        err = 1;
        $("select[name=title]").css('border', '1px solid red');
    } else {
        $("select[name=title]").css('border', '');
    }
    if($("input[name=firstname]").val() == '') {
        err = 1;
        $("input[name=firstname]").css('border', '1px solid red');
    } else {
        $("input[name=firstname]").css('border', '');
    }
    if($("input[name=lastname]").val() == '') {
        err = 1;
        $("input[name=lastname]").css('border', '1px solid red');
    } else {
        $("input[name=lastname]").css('border', '');
    }
    if($("input[name=email]").val() == '') {
        err = 1;
        $("input[name=email]").css('border', '1px solid red');
    } else {
        $("input[name=email]").css('border', '');
    }
    
    if(err == 0){
        return true;

    } else {
        return false;
    }

    
}
