$(document).ready(function () {

    // Logo effect
    $('a#logo, #lang a').hover(function () {
        $(this).stop().fadeTo(200, 0.8);
    }, function () {
        $(this).stop().fadeTo(200, 1.0);
    });
    
    $('.error,.success').click(function() {
        $(this).remove();
    });
    
    $('#newssletterSubmit').click(function(){
        alert('df')
        $('#newsForm').submit();
    });
    
    $('#polldetail').submit(function() {
        
        var err=0;
        $('#polldetail input[type=radio]').each(function(){ 
            if (!$("input[name='"+this.name+"']:checked").val()) {                
                err=1;
            }
        });
        $('#polldetail input[type=checkbox]').each(function(){ 
            if (!$("input[name='"+this.name+"']:checked").val()) {                
                err=1;
            }
        });
        
        if(err==0){
            return true;
        }else{            
            $('#poll_err').attr("style", "display:block");
            return false;
        }
    });    
    
    equalHeight($("p.info-title"));
    
    var leftHeight=$('#page-cont').height()-74;
    var newsHeight=$('#content-right div.box-cont').height();
    if(newsHeight<leftHeight)$('#content-right div.box-cont').height(leftHeight);
    
    var lang=$("#language").val();
    if(lang==1){
        $( "#marketDateFrom,#marketDateTo" ).datepicker({        
            monthNames: ['Януари','Февруари','Март','Април','Май','Юни','Юли','Август','Сепрември','Октомври','Ноември','Декември'],
            dayNamesMin: ['Н','П', 'В', 'С', 'Ч', 'П', 'С'],
            firstDay: 1,
            dateFormat: 'dd/mm/yy'
        });    
    }else{
        $( "#marketDateFrom,#marketDateTo" ).datepicker({        
            dateFormat: 'dd/mm/yy'
        });            
    }
    

    
//    $( "#marketDateFrom,#marketDateTo" ).datepicker({
//        
//        var lang=$("#lang").val();
//        
//        if(lang==1){
//            monthNames: ['Януари','Февруари','Март','Април','Май','Юни','Юли','Август','Сепрември','Октомври','Ноември','Декември'],
//            dayNamesMin: ['Н','П', 'В', 'С', 'Ч', 'П', 'С'],
//            firstDay: 1,
//        }
//        dateFormat: 'dd/mm/yy',
//    });    
    
});

function equalHeight(group) {
    var tallest = 0;
    group.each(function() {
        var thisHeight = $(this).height();
        if(thisHeight > tallest) {
            tallest = thisHeight;
        }
    });
    group.height(tallest);
}
