$(document).ready(function(){

	var deviceBB = DetectBlackBerry( navigator.userAgent.toLowerCase() );
	if (deviceBB) {
		$('#blackberry_desktop_link').show();
	}

	var webKit = true;
	var ua = navigator.userAgent;
	if (ua.indexOf("BlackBerry") >= 0){
		//if (ua.indexOf("WebKit") >= 0) {
			var webKit = false;
			//}
		}

		//Begin progressive enhancements
		$('#container').removeClass('javascript_disabled');

		if (webKit)
		{

			$('.click_to_animate').click(function(){
				//var target = $(this).attr('data-target');
				var target = $(this).children('.target').html();
				if (target)
				{
					if ($(target).siblings().is(":visible"))
					{
						$(target).siblings().hide();
						$(target).show();
					}
					else
					{
						if ($(target).is(':visible'))
						{
							$(target).hide();
						}
						else
						{
							$(target).show();
						}
					}
				}
				return false;
			});

		}

		//Is there a story list on this page?
		// if ( $('.story_list, .photo_list').length != 0)
		//    {
		//      //Limit the story display to 3
		//      var initial_display = 4;
		//      var inremental_display = 6;
		//      $('.story_list, .photo_list').each(function(){
		//        var story_list = $(this);
		//        var button = $(this).siblings('.block-button');
		//        if (button.length != 0)
		//        {
		//          //Hide stories after first 3
		//          var count = 0;
		//          story_list.children('li').each(function(){
		//            if (count >= initial_display){
		//              $(this).hide();
		//            }
		//            count++;
		//          });
		//          //Clicking a story will display it
		//          button.click(function(){
		//            var count = 0;
		//            var hidden = 0;
		//            story_list.children('li').each(function(){
		//              if( ! $(this).is(':visible') ) {
		//                if (count < inremental_display){
		//                  $(this).show();
		//                  count++;
		//                }else{
		//                  hidden++;
		//                }
		//              }
		//            });
		// 
		//            if (hidden == 0){
		//              $(this).hide();
		//            }
		// 
		//            return false;
		//          });
		// 
		//        }
		//      });
		//    }
		// 
		//    //If there is an article on this page?
		//    var story_detail = '.story_detail';
		//    if ( $(story_detail).length != 0)
		//    {
		//      var story_height = $(story_detail + '>.maxwidth>.content').height();
		//      //Truncate the story content
		//      var condense = $(story_detail + '>.maxwidth>.content').condense({condensedLength: 400, appendButtons: false, ellipsis:''});
		//      if ($(story_detail + '>.maxwidth>.content.the_clone').length > 0){
		//        //elipsis
		//        $(story_detail + '>.maxwidth>.content.the_clone').children('p:last').append(' ...');
		//        //If the continue reading button is clicked display the rest of the copy
		//        $(story_detail + ' .block-button').click(function(){
		//          var condense_height = $(this).siblings('.maxwidth').children('.the_clone').height();
		//          $(this).siblings('.maxwidth').children('.the_clone').remove();
		//          var jcontent = $(this).siblings('.maxwidth').children('.content');
		//          jcontent.show();
		// 
		//          $(this).hide();
		// 
		//          return false;
		//        });
		//        }else
		//        {
		//          $(story_detail + ' .block-button').hide();
		//        }
		//      }
		// 
		//    });
		

		// Detects if the current browser is a BlackBerry of some sort.
		function DetectBlackBerry(target)
		{
		   if (target.search("blackberry") > -1)
		      return true;
		   else
		      return false;
		}

