// JavaScript Document
openClose();

function openClose() {
    $(function() { 
    $('.open').each(function() {
        $(this).click(function() {
            var el = $(this);
            var id = $(this).attr('rel');
            //alert(id);
            openevents(id);
            $(this).next().show();
            $(this).addClass('close');
        })
    });
    $('.close').each(function() {
        $(this).click(function() {


            $(this).next().hide();
            $(this).removeClass('close');
        })
    });
})
}


function getallscript() {


    jQuery.noConflict();

    jQuery(document).ready(function() {
        jQuery(function() {           // <-- what's this doing here?
            jQuery("img.lazy").show().lazyload({
                //placeholder: "/images/blank.gif",
                effect: "fadeIn",
                failurelimit: 1,
                threshold: -20
            });
            
            jQuery(".picksWrapper img.lazy").show().lazyload({
                //placeholder: "/images/blank.gif",
                container: $(".picksWrapper"),
                effect: "fadeIn",
                failurelimit: 1,
                threshold: -20
                
            });
        });
    });   
        

    $(function() {

		//$('.base').find('iframe').attr('id', 'fb_login');
		//$("#fb_login").contents().find("#fbRegistrationWidgetTopmost").css("background-color","#BADA55");
		var relatedLT = $('.news-desc-rt');
		if (relatedLT.length == '0') {
			$('.desc').css({ padding: '15px 50px 15px 20px' });
		}

			$('ul.recent-o-story li').each(function(i) {
            if (!((i + 1) % 3)) {
                $(this).addClass("last");
                $(this).next().addClass('first')
            }

        });


		 $('ul.recent-oo-story li').each(function(el) {
        if (!((el + 1) % 3)) {
                $(this).addClass("last");
                $(this).next().addClass('first')
            }

        });

        

        /*----------- Serach box ---------*/
        $('#txtSearch').keydown(function(event) {
            //alert("search");
            if (event.keyCode === 13 && $('#txtSearch').val() != "") {

                Search();
            }
        })

        $('a[rel]').overlay({ top: 300, close: 'a.closeit', mask: {
            color: '#000',
            loadSpeed: 200,
            opacity: 0.4
}
        });


        /*----------- Stream list expand ---------*/
        
        $('.sub').each(function() {
            $(this).click(function() {
                $(this).toggleClass('active-link').parent().toggleClass('active-nav1').next().slideToggle('slow');
            });
        });

        $('.top-news-scroll').scrollable({ circular: true, mousewheel: false, size: 1 }).autoscroll(10000).navigator('ul.dots');

        $('.editorsPick').scrollable({ circular: true, mousewheel: false, size: 1, prev: '.prev_e', next: '.next_e'
        }).autoscroll(10000).navigator({ navi: 'ul.pick', naviItem: 'li' });


        $('.vartical_list').scrollable({ circular: false, vertical: true, mousewheel: false, size: 1, next: '.down', prev: '.up',
            onSeek: function(event, index) {
                var v_list = 10;
                if (this.getIndex() >= this.getSize() - v_list) {

                    $(".down").addClass("disabled");

                }
                else {
                    $(".down").removeClass("disabled");
                }

            },
            onBeforeSeek: function(event, index) {
                var v_list = 10;
                if (this.getIndex() >= this.getSize() - v_list) {
                    if (index > this.getIndex()) {

                        return false;
                    }
                }
            }
        });

        $('.review-mainImg').scrollable({ circular: true, mousewheel: true, size: 1, next: '.rt-arrow', prev: '.lt-arrow' }).autoscroll(8000);
        /*---------------- Plus - Minus ----------*/
        $('.plus').each(function() {
            $(this).click(function() {
                var el = $(this);
                $(this).parent().next().slideToggle('slow', function() { el.parent().toggleClass('collapse') });
                $(this).toggleClass('minus');
            })
        })

        /*--------------Go to Top ----------*/
        $('.btn_gototop').click(function() {
            $('html, body').animate({ scrollTop: 0 }, 1000);
        });

        /*---------Settings pop---------*/
        $('.settings').click(function() {
            //alert('click');
            $(this).children('.settings-List').slideDown('slow');
        })
        $('body').click(function(s) {
            $('.settings-List').hide();
        });
        $('.settings-List').click(function(event) {
            event.stopPropagation();
        });



        var ctHeight;
        var sitewt;

        function setHeight() {
            clearTimeout(ctHeight);
            ctHeight = setTimeout(rtheight, 20);
        }
        function rtheight() {
            var ht = $('#sect-right').height();
            var mht = $('#sect-mid').height();

            var ht2 = $('#main-container').height();
            var winht = $(window).height();
            var ftht = $('#mainFooter').height();
            var rht = (winht - ftht);
            $('#sect-mid').css({ minHeight: rht });
            if (ht2 <= winht || winht <= 1263) {
                $('#main-container').css({ minHeight: rht });
            }

            if (mht < ht) {
                //alert(ht + '@-----@' + mht);
                $('#sect-mid').css({ height: ht });
            }
            //alert(ftht);		
        }


        $('.active-nav').addClass('active-nav1').parent().find('.subnav').css({ display: 'block' });
        $('.active-nav').children(this).addClass('active-link');



        $('ul.mainNav li').each(function() {
            var listItems1 = $(this).find('ul.subnav').children();
            var count = listItems1.length;

            if (count >= 10) {
                //$(this).find('ul.subnav').addClass('scrY');
            }
        });


        //************************************************	
        // for changing width of scroller	
        $('ul.tabs').tabs('.strem-list');

        //Scroller
        
        /**/


        // Calender script
        $('.filter').click(function() {

            $(this).parent().next().slideToggle('fast');
            $(this).children('span:last-child').toggleClass('cl');
        })

        $('.sitelist-Wrapper').scrollable({ circular: false, vertical: true, mousewheel: false, size: 1, next: '.down2', prev: '.up2', onSeek: function(event, index) {
            sizebet = 5;
            if (this.getIndex() >= this.getSize() - sizebet) {

                $(".down2").addClass("disabled");

            }
            else {
                $(".down2").removeClass("disabled");
            }

        },
        onBeforeSeek: function(event, index) {
        sizebet = 5;
                if (this.getIndex() >= this.getSize() - sizebet) {
                    if (index > this.getIndex()) {

                        return false;
                    }
                }
            }
        });
        //var betscrl = $(".sitelist-Wrapper").data("scrollable");
        //betscrl.getConf().keyboard = false;
        

        //category scroll
        $('.catScroll').scrollable({ circular: false, vertical: false, mousewheel: false, size: 1, next: '.next_c', prev: '.prev_c' }).navigator('ul.dots_c');





        //tabs













        //************************************************
        //Category list
        //$('ul.allsports').hide();
        $('ul.allsports, .sub-cat-hold').each(function() {
            if ($(this).is(':visible')) {
                $(this).parent().find('.sub-title').addClass('upActive');
            }
            else {
                $(this).parent().find('.sub-title').removeClass('upActive');
            }
        });
        $('.sub-title').each(function() {
            $(this).click(function() {
                $(this).toggleClass('upActive').next().slideToggle('slow');
            });
        });

        // newsList

        $('.main-title-news').each(function() {
            $(this).find('.arrow-Lt').click(function() {
                $(this).parent().toggleClass('upActive').next().slideToggle('slow');
            });
        });



    });

//***********************************************
//news social


}






