// Custom js 

// loading calender for archiving


function jcalender(year,month){
    $(document).ready(function(){
        $.get(path+"news/calender/"+year+"/"+month,function(data){
            $('#jCalender').html(data);
        })
    }); 
}


$(document).ready(function(){
    $.get(path+"news/calender",function(data){
        $('#jCalender').html(data);
    })
    
    $('.showpoll').click(function(e){
        e.preventDefault()
        $('.oldpoll').slideDown(200);
        $(this).hide()
    })
    
    $('.stockDse').cycle({ 
        fx:     'scrollHorz', 
        delay: -1000,
        timeout: 5000, 
        next:   '.dseNext', 
        prev:   '.dsePrev',
        pause:true         
    });
    
    $('.stockCse').cycle({ 
        fx:     'scrollHorz', 
        delay: -1000,
        timeout: 5000,  
        next:   '.cseNext', 
        prev:   '.csePrev',
        pause:true
    });
    
    
    $('.writerCycle').cycle();
    
    
    $('#banglaInpTool a').tooltip()
    
    $('.gallery_title').tooltip({showURL:false})
    
    
    $('a.mailto').fancybox({
        'width' :580,
        'titleShow'     : false,
        'transitionIn'  : 'elastic',
        'transitionOut' : 'elastic',
        'type'          : 'iframe'
    });
    
    $('a.mailtopublic').fancybox({
        'width' :580,
        'titleShow'     : false,
        'transitionIn'  : 'elastic',
        'transitionOut' : 'elastic',
        'type'          : 'iframe'
    });
    
    
    
    $('a.showmore').click(function(e){
        var link=$(this)
        e.preventDefault()
        $('.linklist .hidden').slideDown(200,function(){
            link.hide()
        })
        
    })
    
    
}); 



$(function() {
    $(".j_tabs").tabs();
});

var j_lock=false;

$(document).ready(function(){
    
    Shadowbox.init();        
    
    $('.j_slider').jSlider({
            nextClass:'j_next',
            prevClass:'j_prev',
            container:'ul',
            item:'li',
            showItems:1,
            slideSpeed:250,
            circular:true,
            autoTransition:5000
    });
    
    
    $('.gallery_image').fancybox();
    
    $('.j_gal li a').click(function(e){
        e.preventDefault()
        
        $('.j_gal .bigimg img').attr({
                src:$(this).find('img').attr('src'),
                rel:$(this).find('img').attr('rel')
        })
    })
    
    
    $('.j_gal .bigimg img').css({cursor:'pointer'}).click(function(e){
        
        $('.j_gal a.item_thumb img[rel='+$(this).attr('rel')+']').parent().parent().find('.gallery_image').trigger('click')
        
        
        
        
        
    })
    
    
    
    $('.cartoon_image').fancybox();
    
    $('.cartoon_gallery b a').click(function(e){
        e.preventDefault()
        $('.cartoon_gallery .bigimg img').attr({
                src:$(this).find('img').attr('src'),
                rel:$(this).find('img').attr('rel')
        })
    })
    
    $('.cartoon_gallery .bigimg img').css({cursor:'pointer'}).click(function(e){
        
        $('.cartoon_gallery b a.item_thumb img[rel='+$(this).attr('rel')+']').parent().parent().find('.cartoon_image').trigger('click')
        
        
    })
    
    
    
    
    $("#cycle-pane").cycle({
      before: function() { $(this).find('a').jTypeWriter(); },
      timeout:         7000,
      pause:true
    });
    $(".j_bulletin").cycle({
      fx:           'fade',
      timeout:         7000
    });
    
   
   
    
    $(".sub-list").hover(function(e){
        e.preventDefault()
        if(!j_lock){
            j_lock=true;
            if($(this).hasClass('active')){
                $(this).find('ul').slideUp(200,function(){
                    j_lock=false;                        
                })
                
                $(this).removeClass('active')
            }
            else{
                $(this).find('ul').slideDown(200,function(){
                    j_lock=false;                        
                })
                
                $(this).addClass('active')
            }
        }
    });

    /*
    $(".featured").click(function(e){
        e.preventDefault()
        if(!j_lock){
            j_lock=true;
            if($(this).hasClass('active')){
                $(this).parent().find('ul').slideUp(200,function(){
                    j_lock=false;                        
                })
                
                $(this).removeClass('active')
            }
            else{
                $(this).parent().find('ul').slideDown(200,function(){
                    j_lock=false;                        
                })
                
                $(this).addClass('active')
            }
        }
    });

     */
     
     // flashing the msg
    if($('.flash_box p').text()!=''){
        $.fancybox({content:$('.flash_box').show()})
    }
    
    
    $(".do_comment").click(function(e){
            e.preventDefault()
            $(".respond").slideDown(200)
    })
    
    
    if(window.location.hash=="#comment"){
        $(".respond").slideDown(200)
        $(document).scrollTo('.respond',500)
        
    }
    
    
    
    $('a[rel=newsmedia]').fancybox();
        
    
})


