/**
 * @author swannc
 */

var ccmb_show = typeof(ccmb_show) != 'undefined' ? ccmb_show : 50;
var ccmb_cat = typeof(ccmb_cat) != 'undefined' ? ccmb_cat : 'all';
var ccmb_hours = typeof(ccmb_hours) != 'undefined' ? ccmb_hours : 24;
var ccmb_search_type = typeof(ccmb_search_type) != 'undefined' ? ccmb_search_type : null;
var ccmb_search_text = typeof(ccmb_search_text) != 'undefined' ? ccmb_search_text : null;
var ccmb_forbid_document_write = typeof(ccmb_forbid_document_write) != 'undefined' ? ccmb_forbid_document_write : false;
var ccmb_search_param = '';
var ccmb_search_index = '1';

function ccmb_parse_search_index()
{
	var index_matches = location.href.match(/ccmb_search_index=([^\s|&]+)/)
	
	try{ ccmb_search_index = index_matches[1]; } catch(e){}
}

function ccmb_parse_url()
{
	var type_matches = location.href.match(/ccmb_search_type=(\w+)/)
	var text_matches = location.href.match(/ccmb_search_text=([^\s|&]+)/)
	
	try{ ccmb_search_type = type_matches[1]; } catch(e){}
	try{ ccmb_search_text = text_matches[1]; } catch(e){}
}

if(location.href.indexOf('ccmb_search_text') > -1 && location.href.indexOf('ccmb_search_type') > -1)
{
	ccmb_parse_url();
}

if(location.href.indexOf('ccmb_search_index') > -1)
{
	ccmb_parse_search_index();
}

if(ccmb_search_text && ccmb_search_type == 'user')
{
	ccmb_search_param = '&screenNameList=' + ccmb_search_text;
	ccmb_show = 500;
}


if(!ccmb_forbid_document_write)
{
	if(ccmb_search_type != 'keyword')
	{
		document.write('<scr'+'ipt type="text/javascript" src="http://mb.espn.go.com/dir-app/acx/activeContent.aspx?mappedOnly=false&webtag=espnmb&type=messagelist&activityHours=' + ccmb_hours + '&fmt=json&timeout=1&catList=' + ccmb_cat + '&count=' + ccmb_show + '&scriptKey=_ccmb' + ccmb_search_param + '"></scr'+'ipt>');
	}
	else
	{
		document.write('<scr'+'ipt type="text/javascript" src="http://mb.espn.go.com/n/pfx/forum.aspx?sType=mbsearch&q=' + ccmb_search_text + '&nav=json&webtag=espnmb&startIndex=' + ccmb_search_index + '&activityHours=100000"></scr'+'ipt>');
	}
	document.write('<scr'+'ipt type="text/javascript" src="http://mb.espn.go.com/dir-app/acx/activeContent.aspx?mappedOnly=false&webtag=espnmb&type=discussions&activityHours=' + ccmb_hours + '&fmt=json&timeout=1&catList=Conversations&count=25&scriptKey=_ccmb_popular_convesations"></scr'+'ipt>');
	document.write('<scr'+'ipt type="text/javascript" src="http://mb.espn.go.com/dir-app/acx/activeContent.aspx?mappedOnly=false&webtag=espnmb&type=talkback&activityHours=' + ccmb_hours + '&fmt=json&timeout=1&catList=general&count=25&scriptKey=_ccmb_popular_message_board"></scr'+'ipt>');
	document.write('<scr'+'ipt type="text/javascript" src="http://mb.espn.go.com/dir-app/acx/activeContent.aspx?mappedOnly=false&webtag=espnmb&type=discussions&activityHours=' + ccmb_hours + '&fmt=json&timeout=1&catList=Blogs&count=25&scriptKey=_ccmb_popular_blog_comments"></scr'+'ipt>');
}

if(typeof(Scriptaculous) == "undefined")
{
	document.write('<scr'+'ipt type="text/javascript" src="http://assets.espn.go.com/profile/lib/protoculous-packer.js"></scr'+'ipt>');
}

document.write('<scr'+'ipt type="text/javascript" src="http://assets.espn.go.com/profile/lib/domready.js"></scr'+'ipt>');
document.write('<scr'+'ipt type="text/javascript" src="http://assets.espn.go.com/profile/lib/date-1.3.js"></scr'+'ipt>');

if( typeof( conversation_url ) == 'undefined' )
{
	document.write('<scr'+'ipt type="text/javascript" src="http://assets.espn.go.com/profile/lib/compressed/conversation_utils_6.js"></scr'+'ipt>');
}