$(function()
{
	var ticker = function()
	{
		setTimeout(function(){
			$('#ticker li:first').animate( {marginTop: '-40px'}, 800, function()
			{
				$(this).detach().appendTo('ul#ticker').removeAttr('style');	
			});
			ticker();
		}, 4000);
	};
	ticker();
});

		$(document).ready(function() {
			//ARTICLE IMAGE CAROUSELS
           if(!getParam('css')== 'print' || getParam('css') == undefined)
            {
               $('#article-carousel .mycarousel').jcarousel({scroll: 1, auto:3, visible: 1, wrap:'last', initCallback: configSlideShow});
            }           
    
            $('.article-carousel .mycarousel').jcarousel({scroll: 1}); 
            
             activeMenu= $(".first-level li a.active").parent();
            $(".first-level li").not(activeMenu).mouseover(function(){
                $(this).find(".sec-level").show();
               // console.log(this);
            });
            
             $(".first-level li").not(activeMenu).mouseout(function(){
                $(this).find(".sec-level").hide();
                 //$(activeMenu).find(".sec-level").show();
                //console.log($(this).filter(this).find(".sec-level"));
            });
			
			//ARTICLE VIDEO CAROUSELS
		$('#videoart-carousel .myVideoCarousel').jcarousel(
			{
				scroll: 1,
				visible: 1
			}
		);
		
		$("#nextVideoBtn").click(
			function()
			{
				var index = BL_VideoPlayer.currentIndex;
				try {
				var isPlaying = flowplayer(index-1).isPlaying();}
				catch(e){
					var isPlaying=false;
				}
				
					if(isPlaying)
					{
						flowplayer(index-1).stop();
					}
				
				BL_VideoPlayer.currentIndex++;
				//alert(BL_VideoPlayer.currentIndex);
				
			}
		);
		
		$("#prevVideoBtn").click(
			function()
			{
				var index = BL_VideoPlayer.currentIndex;
				try {
				var isPlaying = flowplayer(index-1).isPlaying();}
				catch(e){
					var isPlaying=false;
				}
				
				if(isPlaying)
				{
					flowplayer(index-1).stop();
				}
				BL_VideoPlayer.currentIndex--;
				if(BL_VideoPlayer.currentIndex < 1)
				{
					BL_VideoPlayer.currentIndex = 1;
				}
				//alert(BL_VideoPlayer.currentIndex);
				
			}
		);
		//CSS HELP
        $(".columnists-listing-left a:even").css("padding-right", "25px");
        $(".columnists-listing-left a:odd:not(:last)").after("<div class='line two10'></div>");
        $("#getting-around-links a:even").css("padding-right", "20px");
        $(".life-right .pick:last-child").css({border:"none", margin:"0", padding:"0"});
	});
		
		function configSlideShow(carousel)
		{
			 $('#article-carousel .mycarousel').mouseover(function(e)
			  {
				  e.preventDefault();
				  carousel.stopAuto();
			  });
			
			 $('#article-carousel .mycarousel').mouseout(function(e)
			  {
				  e.preventDefault();
				  carousel.startAuto();
			  });
		}
		var BL_VideoPlayer = {currentIndex:1};
// Vuukle comment 
function commentcount(curl,sec){
if ($.browser.msie && parseInt($.browser.version, 10) <= 9) {
   $.getJSON(curl +"&callback=?" , function(data){countlist(data,sec); });
}
else if ('XDomainRequest' in window && window.XDomainRequest !== null) {  
    var xdr = new XDomainRequest();
    xdr.open("get", curl);
    xdr.onload = function () {
        var dom  = new ActiveXObject("Microsoft.XMLDOM"),
            JSON = $.parseJSON(xdr.responseText);
        dom.async = false;
        if (JSON == null || typeof (JSON) == 'undefined') {
            JSON = $.parseJSON(data.firstChild.textContent);
        }
        countlist(JSON,sec); 
    };

    xdr.onerror = function() {
        _result = false;  
    };
    xdr.send();
}      
else if(!$.browser.msie ){
    $.ajax({
    type:"GET",
    url: curl  ,
    data: "" ,
	dataType: "json" ,
    async: false,
	success: function(data){ countlist(data,sec); }
    });
}
}

function countlist(data,sec){  
if (sec){
	for (var obj in data){
		var cname = "comments";	
		if (data[obj] == 1 || data[obj] == 0){cname = "comment";}		
			$(".count"+ obj).html("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" + data[obj] + "&nbsp;" + cname);
		}
}else{
	for (var obj in data){
	if (data[obj] < 10){$(".count"+ obj).html("&nbsp;" + data[obj]);}
	else {$(".count"+ obj).html(data[obj]);}
			
	}
 }
}

function getParam(sParam){    var sPageURL = window.location.search.substring(1);    if(sPageURL)    {        var sURLVariables = sPageURL.split('&');        for (var i = 0; i < sURLVariables.length; i++)         {            var sParameterName = sURLVariables[i].split('=');            if (sParameterName[0] == sParam)             {                return sParameterName[1];            }            else            {                return undefined;            }        }    }    return undefined;}  var activeMenu;
//Vuukle comment