/**
 * @author dberhane
 */
var headlines = 10;
var headline = 0;
var all_sections = /RESEARCH|NEWS|EDUCATION|FEATURE|PRACTICE|EDITORIAL|VIEWS|CLINICAL REVIEW|ANALYSIS|OBSERVATIONS|LETTERS|EDITOR\'S CHOICE/;
var research_channel = /NEWS|EDUCATION|CLINICAL REVIEW|PRACTICE|FEATURE|VIEWS|ANALYSIS|OBSERVATIONS|LETTERS|EDITORIAL|EDITOR\'S CHOICE/;
var news_channel = /EDUCATION|CLINICAL REVIEW|PRACTICE|FEATURE|VIEWS|ANALYSIS|OBSERVATIONS|LETTERS|EDITORIAL|RESEARCH|EDITOR\'S CHOICE/;
var education_channel = /NEWS|RESEARCH|FEATURE|VIEWS|ANALYSIS|OBSERVATIONS|LETTERS|EDITORIAL|EDITOR\'S CHOICE/;
var comment_channel = /RESEARCH|EDUCATION|CLINICAL REVIEW|PRACTICE|NEWS/;

var $jQuery = jQuery.noConflict();

$jQuery(function() {

popUp();

careerswidget = new widget(
{
	'widget'	:	"careers-widget",
	'url'	:	"http://careers.bmj.com/careers/articles-rss.html", 
	'track'	:	"w_bmj",
	'widget_title'	:	"Latest from BMJ careers",	
	'style'	:	"bmj",	
	'num_items':	"5"
})


bmjplayer1 = new mediaplayer (
{	
   'player': "#bmjplayer",
   'media': "audio",
//   'simage': "http://www.bmj.com/channels/icons/podcast2.jpg",
   'simage': "http://group.bmj.com/media/flowplayer/example/bmj-podcast3.jpg",
   'mdisplay': true,
   'mauto': false	
}
)


bmjplayer12 = new mediaplayer (
{	
   'player': "#bmjplayer2",
   'media': "audio",
   'simage': "http://group.bmj.com/media/flowplayer/example/bmjaudio3.jpg",
   'mdisplay': true,
   'mauto': false	
}
)


var bmjpanel1 = new widget(  /* Online First feed and relevant widget parameters */

{

	'widget'	:	"bmjpanel1",

	'url'	:	"http://www.bmj.com/rss/recent.xml",

	'widget_title'	:	"Latest",

	'style'	:	"bmj",

	'num_items':	"10"

})



var bmjpaneld = new widget(   /* TOC feed and relevant widget parameters */

{
	'widget'	:	"bmjpaneld",
	'url'	:	"http://sitelife.bmj.com/ver1.0/CommunityGroups/Rss?slGroupKey=32da9f1b-d97b-4c32-8ca2-bd6305018693",
	'widget_title'	:	"Latest doc2doc",
	'style'	:	"bmj",
	'num_items':	"10"
})

var bmjpanel2 = new widget(   /* TOC feed and relevant widget parameters */

{
	'widget'	:	"bmjpanel2",
	'jurl'	:	"http://group.bmj.com/xml/ga/jsonp/bmj-pages-7ex-jsonp.php",
	'widget_title'	:	"Most read",
	'style'	:	"bmj",
	'num_items':	"10"
})



var bmjpanel3 = new widget(   /* Top article feed and relevant widget parameters */

{
	'widget'	:	"bmjpanel33",
	'jurl'	:	"http://group.bmj.com/xml/ga/jsonp/bmj-searches-7-jsonp.php",
	'widget_title'	:	"Most searched",
	'style'	:	"bmj",
	'num_items':	"10"

})


var bmjpanel4 = new widget(   /* Top article feed and relevant widget parameters */

{
	'widget'	:	"bmjpanel32",
	'jurl'	:	"http://group.bmj.com/xml/ga/jsonp/bmj-pages-etoc7-jsonp.php",
	'widget_title'	:	"Most seachred",
	'style'	:	"bmjjournals",
	'num_items':	"10"
})



//$jQuery("#bmjcomwidget ul.tabs").tabs("#bmjcomwidget div.panes >  div");
$jQuery("#bmjcomwidget").tabs();


//mediaplayer("audio", "#bmjplayer", "autoplay");                    

/* Latest from BMJ.com widget displaying drug related headlines */
var widget1 = new widget(
{

	'widget'	:	"bmjusa",
	'url'	:	"http://group.bmj.com/xml/bmjusa-feed.xml", 
	'track'	:	"w_bmjusa",
	'widget_title'	:	"Latest BMJUSA headlines",	
	'style'	:	"bmj",	
	'num_items':	"15"


})
})



if (location.href == "http://www.bmj.com/preview_home/sample1.dtl" || location.href == "http://www.bmj.com/preview_home/sample2.dtl" || location.href == "http://www.bmj.com/preview_home/sample3.dtl" || location.href == "http://www.bmj.com/preview_home/sample3.dtl" || location.href == "http://www.bmj.com/preview_home/sample4.dtl" || location.href == "http://www.bmj.com/preview_home/sample5.dtl" || location.href == "http://www.bmj.com/preview_home/sample6.dtl" || location.href == "http://www.bmj.com/preview_home/sample7.dtl" || location.href == "http://www.bmj.com/" || location.href == "http://www.bmj.com/index.dtl" || location.href == "http://www.bmj.com/preview_home/index.dtl") {

    track_url = 'rss_home';
    top_html = 'Latest articles';
    
   $jQuery(function(){
    
        var widget1 = new widget({
        
            'widget': "update",
            'url': "www.bmj.com/rss/recent.xml",
            'track': "w_bmjhome",
            'widget_title': top_html,
            'style': "bmj",
            'num_items': "10"
        
        
        })
    })
    
    
}
else 
    if (location.href == "http://www.bmj.com/channels/news.dtl" || location.href == "http://www.bmj.com/preview_channels/news.dtl") {
        sections = 'nonews';
        track_url = 'rss_news';
        top_html = 'Latest comment, research, education';
        
       $jQuery(function(){
        
            var widget2 = new widget({
            
                'widget': "update",
                'url': "www.bmj.com/rss/recent.xml",
                'track': "w_bmjnews",
				'section': sections,
                'widget_title': top_html,
                'style': "bmj",
                'num_items': "10"
            
            
            })
        })
        
        
        
    }
    else 
        if (location.href == "http://www.bmj.com/channels/research.dtl" || location.href == "http://www.bmj.com/preview_channels/research.dtl") {
            sections = 'noresearch';
            track_url = 'rss_research';
            top_html = 'Latest education, comment, news';
            
           $jQuery(function(){
            
                var widget3 = new widget({
                
                    'widget': "update",
                    'url': "www.bmj.com/rss/recent.xml",
                    'track': "w_bmjresearch",
				    'section': sections,
                    'widget_title': top_html,
                    'style': "bmj",
                    'num_items': "5"
                
                
                })
            })
            
            
        }
        else 
            if (location.href == "http://www.bmj.com/channels/education.dtl" || location.href == "http://www.bmj.com/preview_channels/education.dtl") {
                sections = 'noeducation';
                track_url = 'rss_education';
                top_html = 'Latest news, research, comment';
                
               $jQuery(function(){
                
                    var widget4 = new widget({
                    
                        'widget': "update",
                        'url': "www.bmj.com/rss/recent.xml",
                        'track': "w_bmjeducation",
						'section': sections,
                        'widget_title': top_html,
                        'style': "bmj",
                        'num_items': "5"
                    
                    
                    })
                })
                
                
                
            }
            else 
                if (location.href == "http://www.bmj.com/channels/comment.dtl" || location.href == "http://www.bmj.com/preview_channels/comment.dtl") {
                    sections = 'nocomment';
                    track_url = 'rss_comment';
                    top_html = 'Latest research, education, and news';
                    
                   $jQuery(function(){
                    
                        var widget5 = new widget({
                        
                            'widget': "update",
                            'url': "www.bmj.com/rss/recent.xml",
                            'track': "w_bmjcomment",
							'section': sections,
                            'widget_title': top_html,
                            'style': "bmj",
                            'num_items': "5"
                        
                        
                        })
                    })
                    

                }

//flowplayer("bmjplayer", "http://group.bmj.com/media/flowplayer/flowplayer-3.1.0.swf");


// mediaplayer("video", "#player", "autoplay");

