function get_json_data(act,vars)
{
	if(_nc=='1')
	{
		var p	=	{'act': act, 'vars': vars,'_no_cache':1};
	}
	else
	{
		var p	=	{'act': act, 'vars': vars};
	}
	var jsonRequest = new Request.JSON({url: "http://www.mso.com.cn/index/ajax.php",async:false}).get(p);//同步
	//var jsonRequest = new Request.JSON({url: "http://keno.mso.com.cn/index/ajax.php"}).get({'act': act, 'vars': vars});//异步
	if(jsonRequest.isSuccess())
	{
		return jsonRequest.response.json;
	}
	return false;

}
function str_charcode(str)
{
	var outStr	=	"";
	for(var i=0;i<str.length;i++)
	{
		outStr	+=	str.charCodeAt(i);
	}
	return outStr;
}
var old_wait_img_html	=	"";
function show_wait_img(objName)
{
	var obj	=	$(objName);
	
	//保存下旧数据
	old_wait_img_html	=	obj.innerHTML;
	
	var height		=	obj.getStyle('height');
	obj.innerHTML	=	"<div style='line-height:"+height+";text-align:center;'>正在加载数据...</div>";
	return true;
}
function revert_wait_img_html(objName)
{
	var obj	=	$(objName);
	if(old_wait_img_html!="")
	{
		obj.innerHTML	=	old_wait_img_html;
	}
	return true;
}
function getCurShowMc()
{
	return $('showMcName').innerHTML;
}
function change_football_odds(vs_id,odds_type)
{
	if(vs_id==last_vs_id && odds_type==last_odds_type)return false;
	
	show_wait_img('football_odds');

	if(vs_id!=last_vs_id)
	{
		$('vs_'+last_vs_id).className		='play_mosout';
		$('vs_'+last_vs_id+'_td').className	='';
		$('vs_'+vs_id).className			='play_mosover';
		$('vs_'+vs_id+'_td').className		='f12_2';
		
		last_vs_id		=	vs_id;
		
	}
	
	if(odds_type!=last_odds_type)
	{
		$('odds_type_'+last_odds_type).className	='right-content';
		$('odds_type_'+odds_type).className			='right-litle';

		last_odds_type	=	odds_type;
	}
	
	
	if(odds_type=='standard')
	{
		var lota_pic	=	'MC_ABL';
		var title_l		=	'主';
		var title_m		=	'平';
		var title_r		=	'客';
	}
	else if (odds_type=='asian')
	{
		var lota_pic	=	'MC_KChart';
		var title_l		=	'主';
		var title_m		=	'盘';
		var title_r		=	'客';
	}
	else if (odds_type=='goal')
	{
		var lota_pic	=	'MC_LOTA';
		var title_l		=	'大';
		var title_m		=	'盘';
		var title_r		=	'小';
	}
	else
	{
		return false;
	}

	if(all_football_odds==false||all_football_odds=="")
	{
		all_football_odds		=	get_json_data('get_all_football_odds',vs_ids_str);
	}
	dataArr	=	all_football_odds[vs_id][odds_type];

	//var dataArr = get_json_data('get_football_odds',vs_id+'|'+odds_type+'|28');
	if(dataArr==false)return false;
	
	
	var	htmlString	=	'<table width="182" border="0" cellpadding="0" cellspacing="0"><tr><td height="1" colspan="4"></td></tr><tr><td width="42%" align="center" valign="middle" bgcolor="#71777C" class="table-1">百家指数</td><td width="18%" align="center" valign="middle" bgcolor="#787878" class="table-1">'+title_l+'</td><td width="18%" align="center" valign="middle" bgcolor="#787878" class="table-1">'+title_m+'</td><td width="18%" align="center" valign="middle" bgcolor="#787878" class="table-11" >'+title_r+'</td></tr><tr><td height="6" colspan="4" align="center" valign="middle" bgcolor="#FFFFFF" ></td></tr>';
	dataArr.each(function(data)
	{ 
    	htmlString	+=	'<tr><td align="center" valign="middle" class="table-2"><a href="http://www.mso.com.cn/odds/index_simple.asp" target="_blank" style="color:#6F6F6F;">'+data['tcn']+'</a></td><td align="center" valign="middle" class="engish">'+data['l']+'</td><td align="center" valign="middle" class="engish">'+data['m']+'</td><td align="center" valign="middle" class="engish">'+data['r']+'</td></tr>';
	}); 
	//htmlString	+=	'<tr><td colspan="4" align="center" valign="middle" height="118"><div id="odds_lota_pic"><font id="showMcName" style="display:none">'+lota_pic+'</font><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="182" height="113" id="lota4hp" align="middle"><param name="allowScriptAccess" value="always" /><param name="movie" value="http://lota.mso.com.cn/lota4hp.swf?vsid='+vs_id+'" /><param name="quality" value="high" /><embed src="http://lota.mso.com.cn/lota4hp.swf?vsid='+vs_id+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="182" height="113"></embed></object></div></td></tr></table>';
	htmlString	+=	'<tr><td colspan="4" align="center" valign="middle" height="12"></td></tr></table>';
	
	$('football_odds').innerHTML	=	htmlString;
	return true;
}


var last_commended_news_type	=	'all';
function change_commended_news(news_type)
{
	if(last_commended_news_type==news_type)return false;
	
	show_wait_img('commended_news');
	
	$('commended_news_'+news_type).className					='f13';
	$('commended_news_'+last_commended_news_type).className		='f13_1';
	last_commended_news_type	=	news_type;
	
	
	var parent_ids;
	var channel_id;
	switch(news_type)
	{
		case 'all':
			parent_ids	=	'all';
			channel_id	=	'18';
			break;
		case 'football':
			parent_ids	=	'9';
			channel_id	=	'19';
			break;
		case 'basketball':
			parent_ids	=	'94';
			channel_id	=	'20';
			break;
		case 'sports':
			parent_ids	=	'13,58,67,72';
			channel_id	=	'23';
			break;
		default:
			return false;
	}
	
	var dataArr = get_json_data('get_best_board_by_channel',channel_id+'|1');
	if(dataArr==false)return false;
	
	var	htmlString	=	' <div class="f16" id="main_litle_1"><a href="'+dataArr[0]['board_url']+'" target="_blank">'+dataArr[0]['board_title']+'</a></div><div class="f13red"><a href="'+dataArr[0]['board_url']+'" target="_blank">'+dataArr[0]['board_content']+'</a></div><div class="new"><ul>';
	
	
	var dataArr = get_json_data('get_news',parent_ids+'||6|18');
	if(dataArr==false)return false;
	
	dataArr.each(function(data)
	{ 
		if(news_type=='basketball')
		{
			htmlString	+=	'<li class="f13black"><a href="http://nba.mso.com.cn/news/news.php?id='+data['news_id']+'" target="_blank" title="'+data['news_title']+'">·[NBA]'+data['news_title_short']+'</a></li>';
		}
		else
		{
			htmlString	+=	'<li class="f13black"><a href="http://news.mso.com.cn/html/'+data['news_column_path']+'/'+data['news_id']+'.shtml" target="_blank" title="'+data['news_title']+'">·['+data['news_column_name']+']'+data['news_title_short']+'</a></li>';
		}
	}); 
	htmlString	+=	'</ul></div><div class="clear" style="border:1px solid #FFFFFF;"></div>';

	$('commended_news').innerHTML	=	htmlString;
	
	return true;
	
}


var last_nba_standings_area	=	"1";
function change_nba_standings(area)
{
	
	if(area==last_nba_standings_area)return false;
	
	show_wait_img('nba_standings');
	
	var another_area	=	area=='1'?'2':'1';
	$('nba_standings_'+area).className			='basketball_litle';
	$('nba_standings_'+another_area).className	='basketball_right_litle';
	last_nba_standings_area	=	area;

	var dataArr = get_json_data('get_nba_standings',area);
	if(dataArr==false)return false;
	
	
	var	htmlString	=	'<table width="100%" border="0" cellspacing="0" cellpadding="0">';
	dataArr.each(function(data)
	{ 
		var team_name	=	data['color']==""?data['team_name']:'<span style="color:'+data['color']+';">'+data['team_name']+'</span>'
    	htmlString	+=	'<tr><td width="12%" height="24" align="center" valign="middle">'+data['no']+'</td><td height="24" colspan="4" align="center" valign="middle" class="f12_bule"><a href="http://nba.mso.com.cn/database/team.php?id='+data['team_id']+'_/" target="_blank">'+team_name+'</a></td><td width="25%" height="24" align="center" valign="middle">'+data['tw']+'/'+data['tl']+'</td><td width="14%" height="24" align="center" valign="middle">'+data['gb']+'</td></tr>';
	}); 
	htmlString	+=	'</table>';
	
	$('nba_standings').innerHTML	=	htmlString;
	return true;
}

var last_five_league_rank_lmc	=	'EP';
function change_five_league_rank(lmc)
{
	if(lmc==last_five_league_rank_lmc)return false;
	
	show_wait_img('five_league_rank');
	
	$('five_league_rank_'+lmc).className						='content_litle';
	$('five_league_rank_'+last_five_league_rank_lmc).className	='content_content_litle_1';
	last_five_league_rank_lmc	=	lmc;

	var dataArr = get_json_data('get_five_league_rank',lmc);
	if(dataArr==false)return false;
	
	
	var	htmlString	=	'<table width="100%" border="0" cellspacing="0" cellpadding="0">';
	dataArr.each(function(data)
	{ 
		var team_name	=	data['color']==""?data['team_name']:'<span style="color:'+data['color']+';">'+data['team_name']+'</span>'
    	htmlString	+=	'<tr><td width="9%" height="18" align="center" valign="middle">'+data['rank']+'</td><td width="28%" height="18" align="center" valign="middle" class="f12_bule"><a href="http://www.mso.com.cn/html/database/team/'+data['team_code']+'_/" target="_blank">'+team_name+'</a></td><td width="13%" height="18" align="center" valign="middle">'+data['win_count']+'</td><td width="11%" height="18" align="center" valign="middle">'+data['draw_count']+'</td><td width="12%" height="18" align="center" valign="middle">'+data['lose_count']+'</td><td width="14%" height="18" align="center" valign="middle">'+data['goal_lost_compare']+'</td><td width="13%" height="18" align="center" valign="middle">'+data['points']+'</td></tr>';
	}); 
	htmlString	+=	'</table>';

	$('five_league_rank').innerHTML	=	htmlString;
	
	return true;
}
var last_tennisball_news_type	=	'tennisball';
function change_tennisball_news(news_type)
{
	if(last_tennisball_news_type==news_type)return false;
	
	show_wait_img('tennisball_news');
	
	$('tennisball_news_'+news_type).className					='fottball_litle_1';
	$('tennisball_news_'+last_tennisball_news_type).className	='fottball_litle_2';
	last_tennisball_news_type	=	news_type;
	
	
	var parent_ids	=	news_type=='tennisball'?'58':'67';
	var dataArr = get_json_data('get_news',parent_ids+'||9|24');
	if(dataArr==false)return false;
	
	var	htmlString	=	'<ul>';
	dataArr.each(function(data)
	{ 
    	htmlString	+=	'<li class="f13hei_2"><a href="http://news.mso.com.cn/html/'+data['news_column_path']+'/'+data['news_id']+'.shtml" target="_blank" title="'+data['news_title']+'">·'+data['news_title_short']+'('+data['d']+'日)</a></li>';
	}); 
	htmlString	+=	'</ul><div class="clear"></div>';

	$('tennisball_news').innerHTML	=	htmlString;
	
	return true;
	
}
var last_golf_news_type	=	'golf';
function change_golf_news(news_type)
{
	if(last_golf_news_type==news_type)return false;
	
	show_wait_img('golf_news');
	
	$('golf_news_'+news_type).className				='fottball_litle_1';
	$('golf_news_'+last_golf_news_type).className	='fottball_litle_2';
	last_golf_news_type	=	news_type;
	
	if(news_type=='golf')
	{
		$('golf_news_more').innerHTML	=	'<a href="http://news.mso.com.cn/golf.shtml" target="_blank">更多&gt;&gt;</a>';
	}
	else
	{
		$('golf_news_more').innerHTML	=	'<a href="http://news.mso.com.cn/moto.shtml" target="_blank">更多&gt;&gt;</a>';
	}
	
	
	var parent_ids	=	news_type=='golf'?'67':'72';
	var dataArr = get_json_data('get_news',parent_ids+'||9|24');
	if(dataArr==false)return false;
	
	var	htmlString	=	'<ul>';
	dataArr.each(function(data)
	{ 
    	htmlString	+=	'<li class="f13hei_2"><a href="http://news.mso.com.cn/html/'+data['news_column_path']+'/'+data['news_id']+'.shtml" target="_blank" title="'+data['news_title']+'">·'+data['news_title_short']+'('+data['d']+'日)</a></li>';
	}); 
	htmlString	+=	'</ul><div class="clear"></div>';

	$('golf_news').innerHTML	=	htmlString;
	
	return true;
}
var last_bbs_commended_type	=	"all";
function get_bbs_commended_threads(bbs_type)
{
	if(last_bbs_commended_type==bbs_type)return false;
	
	
	var type_str;
	switch(bbs_type)
	{
		case 'all':
			type_str	=	'www_digest';break;
		case 'football':
			type_str	=	'www_football';break;
		case 'basketball':
			type_str	=	'www_basketball';break;
		case 'other':
			type_str	=	'www_other';break;
		default:
			return false;
	}
	
	
	
	show_wait_img('bbs_commended');
	
	$('bbs_commended_'+bbs_type).className					='f13';
	$('bbs_commended_'+last_bbs_commended_type).className	='f13_1';
	last_bbs_commended_type=bbs_type;
	
	
	var dataArr = get_json_data('get_bbs_threads',type_str+'|6|25');
	if(dataArr==false)return false;
	
	var	htmlString	=	'<ul>';
	dataArr.each(function(data)
	{ 
    	htmlString	+=	'<li class="f13black"><a href="http://club.mso.com.cn/viewthread.php?tid='+data['tid']+'&extra=page%3D1" target="_blank" title="'+data['subject']+'【'+data['author']+'】">· '+data['subject_short']+'</a></li>';
	}); 
	htmlString	+=	'</ul><div class="clear"></div>';

	$('bbs_commended').innerHTML	=	htmlString;
	
	return true;
	
}

var last_lottery_class_id	=	10;
function change_lottery_class(lottery_class_id)
{
	
	if(lottery_class_id==last_lottery_class_id)return false;
	
	var lottery_desc_count	=	get_lottery_desc_count(lottery_class_id);
	if(lottery_desc_count==0)return false;
	
	show_wait_img('lottery_box');
	

	$('lottery_btn_'+lottery_class_id).className			='fottball_litle_1';
	$('lottery_btn_'+last_lottery_class_id).className		='fottball_litle_2';
	last_lottery_class_id	=	lottery_class_id;

	var dataArr = get_json_data('get_current_lottery_desc_list',lottery_class_id+'|'+lottery_desc_count);
	if(dataArr==false)return false;
	
	change_lottery_box_html(lottery_class_id,dataArr);
	return true;
}
function last_next_lottery(last_next)
{
	var lottery_class_id	=	last_lottery_class_id*1;
	var lottery_name		=	last_lottery_name;
	
	var lottery_desc_count	=	get_lottery_desc_count(lottery_class_id);
	if(lottery_desc_count==0)return false;
	
	show_wait_img('lottery_box');

	var dataArr = get_json_data('get_last_next_lottery_desc_list',lottery_class_id+'|'+lottery_name+'|'+last_next);
	if(dataArr==false)
	{
		revert_wait_img_html('lottery_box');
		return false;
	}
	
	var rs	=	change_lottery_box_html(lottery_class_id,dataArr);
	return true;
}

function get_lottery_desc_count(lottery_class_id)
{
	switch(lottery_class_id)
	{
		case 10:
			var count	=	14;
			break;
		case 15:
			var count	=	6;
			break;
		case 17:
			var count	=	4;
			break;
		default:
			return 0;
	}
	return count;
}
function change_lottery_box_html(lottery_class_id,dataArr)
{
	if(dataArr.lenght==0)		return false;
	if(lottery_class_id==0)	lottery_class_id	=	last_lottery_class_id;
	
	switch(lottery_class_id)
	{
		case 10:
			var tdHeight	=	'23';
			break;
		case 15:
			var tdHeight	=	'60';
			break;
		case 17:
			var tdHeight	=	'90';
			break;
		default:
			return false;
	}
	
	show_wait_img('lottery_box');
	
	var rsTitle	=	dataArr['lottery_desc_list'][0]['vs_status']==4?'结果':'在线缩水';
	if(lottery_class_id!=10 && rsTitle!='结果')rsTitle='结果';
	
	$('lottery_name').innerHTML	=	'<strong>'+dataArr['lottery_name']+'</strong>';
	last_lottery_name	=	dataArr['lottery_name'];
	lottery_class_id	=	dataArr['lottery_class_id'];
	

	var	htmlString	=	'<table width="100%" border="0" cellspacing="1" cellpadding="0"> <tr> <td width="6%" height="19" align="center" bgcolor="#D9DBDD">场次</td><td width="14%" align="center" bgcolor="#D9DBDD">主队</td><td width="12%" align="center" bgcolor="#D9DBDD">亚指</td><td width="14%" align="center" bgcolor="#D9DBDD">客队</td><td width="12%" align="center" bgcolor="#D9DBDD">时间</td><td width="16%" align="center" bgcolor="#D9DBDD">标盘</td><td width="16%" align="center" bgcolor="#D9DBDD"><span id="lottery_result_title">'+rsTitle+'</span></td></tr> <tr> <td height="8" colspan="7">&nbsp;</td></tr>';
	dataArr['lottery_desc_list'].each(function(data)
	{ 
		
		if(data['vs_status']==4)
		{
			//$('lottery_result_title').innerHTML='结果';
			data['lottery_result']	=	data['lottery_result'].replace('|',' ');
			var scoreStr	=	data['team_to_versus_homescore']+'-'+data['team_to_versus_awayscore'];
			var resultHtml	=	'<p align="center" style="color:#CB0100; font-size:18px; font-weight:bold;font-family:Arial, Helvetica, sans-serif;">'+data['lottery_result']+'</p>'
		}
		else if (lottery_class_id==10 && dataArr['lottery_name']>=current_lottery_name)
		{
			
			$('lottery_id').value	=	dataArr['lottery_id'];
			$('lottery_name').value	=	dataArr['lottery_name'];
			$('bCanZip').value		=	dataArr['lottery_desc_list'][0]['b_can_zip'];
			
			var scoreStr	=	data['team_to_versus_handicap'];
			var resultHtml	=	'<table width="100%" height="23" border="0" cellpadding="0" cellspacing="1">  <tr><td width="40" align="center" valign="middle" id="td'+data['no3']+'"><input name="chk'+data['no3']+'"  type="checkbox" id="chk'+data['no3']+'" onclick="calculate('+data['no3']+');" value="1" />3<br /><span style="display:none;"><INPUT id="evg'+data['no3']+'" type="hidden" value="'+data['std_water_home']+'"><FONT id="u'+data['no3']+'">0</FONT>%</span></td><td width="40" align="center" valign="middle" id="td'+data['no1']+'"><input name="chk'+data['no1']+'"  type="checkbox" id="chk'+data['no1']+'" onclick="calculate('+data['no1']+');" value="1" />1<br /><span style="display:none;"><INPUT id="evg'+data['no1']+'" type="hidden" value="'+data['std_water_draw']+'"><FONT id="u'+data['no1']+'">0</FONT>%</span></td><td width="40" align="center" valign="middle" id="td'+data['no0']+'"><input name="chk'+data['no0']+'"  type="checkbox" id="chk'+data['no0']+'" onclick="calculate('+data['no0']+');" value="1" />0<br /><span style="display:none;"><INPUT id="evg'+data['no0']+'" type="hidden" value="'+data['std_water_away']+'"><FONT id="u'+data['no0']+'">0</FONT>%</span></td></tr></table>';
		}
		else
		{
			var scoreStr	=	data['team_to_versus_handicap'];
			var resultHtml	=	'<p align="center" style="color:#CB0100; font-size:12px; font-weight:bold;font-family:Arial, Helvetica, sans-serif;">暂无结果</p>';
		}
		
		
		if(scoreStr=="")
		{
			scoreStr	=	'-';
		}
		
		
		
    	htmlString	+=	'<tr><td align="center"><span class="rr1">'+data['sort']+'</span></td><td height="'+tdHeight+'" align="center"><span class="f13back_b">'+data['home_team_name_cn']+'</span></td><td height="'+tdHeight+'" align="center" class="rr1">'+scoreStr+'</td><td height="'+tdHeight+'" align="center"><span class="f13back_b">'+data['away_team_name_cn']+'</span></td><td height="'+tdHeight+'" align="center" class="m">'+data['md']+' '+data['hi']+' </td><td height="'+tdHeight+'" align="center" class="m"><table width="90%" border="0" align="center" cellpadding="0" cellspacing="0" style="text-align:center;"><tr><td>'+data['std_home']+'</td><td>'+data['std_drow']+'</td><td>'+data['std_away']+'</td></tr></table></td><td height="'+tdHeight+'">'+resultHtml+'</td></tr>';
	}); 
	htmlString	+=	'<tr bgcolor="#EAEAEA"> <td height="10" colspan="7" align="center" bgcolor="#FFFFFF"></td></tr>            </table>';
	
	if(lottery_class_id==10 && dataArr['lottery_name']>=current_lottery_name)
	{
		htmlString	+=	'            <table width="100%" height="26" border="0" cellpadding="0" cellspacing="0"><tr><td width="16" height="26">&nbsp;</td><td width="530"><span class="f12back_b">注数: <span id="control__nodeNumber">0</span>注  ￥<span id="control__nodeMoney">0.00</span>元 截止日期:</span> '+dataArr['end_date']+' 开奖日期: '+dataArr['start_date']+' </td><td width="132" align="center" valign="middle" class="td_bg"><input name="缩水" type="submit" value="缩水" style="background-image:url(http://www.mso.com.cn/index/images/football_bn.gif); width:80px; height:26px; border:0px; font-weight:bold; color:#FFFFFF;" /></td><td width="10">&nbsp;</td><td width="82" align="center" valign="middle" class="td_bg"><input name="缩水" type="button" value="清空" style="background-image:url(http://www.mso.com.cn/index/images/football_bn.gif); width:80px; height:26px; border:0px; font-weight:bold; color:#FFFFFF;"  onclick="reset_lottery_box();" /></td></tr></table>';
	}
	
	$('lottery_box').innerHTML	=	htmlString;
	return true;
}
function reset_lottery_box()
{
	for(var i=1;i<43;i++)
	{
		$('td'+i).style.backgroundColor='';
		$('chk'+i).checked=false;
		$('u'+i).innerHTML='0';
	}
}
function change_notice(notice_type)
{
	if(notice_type==last_notice_type)return false;
	
	$('notice_s_'+last_notice_type).innerHTML					=	"";
	if(last_notice_type=='odds'||last_notice_type=='lota'||last_notice_type=='tips')
	{
		$('notice_'+last_notice_type).className			='f12white_3';
	}
	else
	{
		$('notice_'+last_notice_type).className			='litle_5';
	}
	if(notice_type=='odds'||notice_type=='lota'||notice_type=='tips')
	{
		$('notice_'+notice_type).className				='f12b';
		$('notice_s_'+notice_type).innerHTML			=	'<img src="http://www.mso.com.cn/index/images/redarrow1.gif" height="5" width="9"  border="0" />';
	}
	else
	{
		$('notice_'+notice_type).className				='litle_4';
		$('notice_s_'+notice_type).innerHTML			=	'<img src="http://www.mso.com.cn/index/images/redarrow2.gif" height="5" width="9"  border="0" />';
	}
	
	$('notice_title_'+last_notice_type).style.display			=	"none";
	$('notice_title_'+notice_type).style.display				=	"";
	$('notice_content_'+last_notice_type).style.display			=	"none";
	$('notice_content_'+notice_type).style.display				=	"";
	
	
	
	
	
	
	last_notice_type	=	notice_type;
	
	return true;
}
function change_renowned_league(league)
{
	if(last_renowned_league==league)return false;
	$('renowned_league_title_'+last_renowned_league).className	='litle_7';
	$('renowned_league_title_'+league).className				='litle_6';
	$('renowned_league_'+last_renowned_league).style.display			=	"none";
	$('renowned_league_'+league).style.display							=	"";
	
	//var myHorizontalSlide = new Fx.Slide('horizontal_slide', {mode: 'horizontal'});
	
	last_renowned_league=league;
	return true;
	
}





/**			顶部焦点图flash			**/
/**---------------------------------------------------------**/

/**
 * SWFObject v1.5: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
 *
 * SWFObject is (c) 2007 Geoff Stearns and is released under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 */
if(typeof deconcept == "undefined") var deconcept = new Object();
if(typeof deconcept.util == "undefined") deconcept.util = new Object();
if(typeof deconcept.SWFObjectUtil == "undefined") deconcept.SWFObjectUtil = new Object();
deconcept.SWFObject = function(swf, id, w, h, ver, c, quality, xiRedirectUrl, redirectUrl, detectKey) {
	if (!document.getElementById) { return; }
	this.DETECT_KEY = detectKey ? detectKey : 'detectflash';
	this.skipDetect = deconcept.util.getRequestParameter(this.DETECT_KEY);
	this.params = new Object();
	this.variables = new Object();
	this.attributes = new Array();
	if(swf) { this.setAttribute('swf', swf); }
	if(id) { this.setAttribute('id', id); }
	if(w) { this.setAttribute('width', w); }
	if(h) { this.setAttribute('height', h); }
	if(ver) { this.setAttribute('version', new deconcept.PlayerVersion(ver.toString().split("."))); }
	this.installedVer = deconcept.SWFObjectUtil.getPlayerVersion();
	if (!window.opera && document.all && this.installedVer.major > 7) {
		// only add the onunload cleanup if the Flash Player version supports External Interface and we are in IE
		deconcept.SWFObject.doPrepUnload = true;
	}
	if(c) { this.addParam('bgcolor', c); }
	var q = quality ? quality : 'high';
	this.addParam('quality', q);
	this.setAttribute('useExpressInstall', false);
	this.setAttribute('doExpressInstall', false);
	var xir = (xiRedirectUrl) ? xiRedirectUrl : window.location;
	this.setAttribute('xiRedirectUrl', xir);
	this.setAttribute('redirectUrl', '');
	if(redirectUrl) { this.setAttribute('redirectUrl', redirectUrl); }
}
deconcept.SWFObject.prototype = {
	useExpressInstall: function(path) {
		this.xiSWFPath = !path ? "expressinstall.swf" : path;
		this.setAttribute('useExpressInstall', true);
	},
	setAttribute: function(name, value){
		this.attributes[name] = value;
	},
	getAttribute: function(name){
		return this.attributes[name];
	},
	addParam: function(name, value){
		this.params[name] = value;
	},
	getParams: function(){
		return this.params;
	},
	addVariable: function(name, value){
		this.variables[name] = value;
	},
	getVariable: function(name){
		return this.variables[name];
	},
	getVariables: function(){
		return this.variables;
	},
	getVariablePairs: function(){
		var variablePairs = new Array();
		var key;
		var variables = this.getVariables();
		for(key in variables){
			variablePairs[variablePairs.length] = key +"="+ variables[key];
		}
		return variablePairs;
	},
	getSWFHTML: function() {
		var swfNode = "";
		if (navigator.plugins && navigator.mimeTypes && navigator.mimeTypes.length) { // netscape plugin architecture
			if (this.getAttribute("doExpressInstall")) {
				this.addVariable("MMplayerType", "PlugIn");
				this.setAttribute('swf', this.xiSWFPath);
			}
			swfNode = '<embed pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" src="'+ this.getAttribute('swf') +'" width="'+ this.getAttribute('width') +'" height="'+ this.getAttribute('height') +'" style="'+ this.getAttribute('style') +'"';
			swfNode += ' id="'+ this.getAttribute('id') +'" name="'+ this.getAttribute('id') +'" ';
			var params = this.getParams();
			 for(var key in params){ swfNode += [key] +'="'+ params[key] +'" '; }
			var pairs = this.getVariablePairs().join("&");
			
			 if (pairs.length > 0){ swfNode += 'flashvars='+ pairs +'&realfull=1&moz=1"'; }
			swfNode += '/>';
		} else { // PC IE
			if (this.getAttribute("doExpressInstall")) {
				this.addVariable("MMplayerType", "ActiveX");
				this.setAttribute('swf', this.xiSWFPath);
			}
			swfNode = '<object id="'+ this.getAttribute('id') +'" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="'+ this.getAttribute('width') +'" height="'+ this.getAttribute('height') +'" style="'+ this.getAttribute('style') +'">';
			swfNode += '<param name="movie" value="'+ this.getAttribute('swf') +'" />';
			var params = this.getParams();
			for(var key in params) {
			 swfNode += '<param name="'+ key +'" value="'+ params[key] +'" />';
			}
			var pairs = this.getVariablePairs().join("&");

			if(pairs.length > 0) {swfNode += '<param name="flashvars" value="'+ pairs +'" />';}
			swfNode += "</object>";
		}
		return swfNode;
	},
	write: function(elementId){
		if(this.getAttribute('useExpressInstall')) {
			// check to see if we need to do an express install
			var expressInstallReqVer = new deconcept.PlayerVersion([6,0,65]);
			if (this.installedVer.versionIsValid(expressInstallReqVer) && !this.installedVer.versionIsValid(this.getAttribute('version'))) {
				this.setAttribute('doExpressInstall', true);
				this.addVariable("MMredirectURL", escape(this.getAttribute('xiRedirectUrl')));
				document.title = document.title.slice(0, 47) + " - Flash Player Installation";
				this.addVariable("MMdoctitle", document.title);
			}
		}
		if(this.skipDetect || this.getAttribute('doExpressInstall') || this.installedVer.versionIsValid(this.getAttribute('version'))){
			
		}else{
			if(this.getAttribute('redirectUrl') != "") {
				document.location.replace(this.getAttribute('redirectUrl'));
			}
			
		}
		var n = (typeof elementId == 'string') ? document.getElementById(elementId) : elementId;
		n.innerHTML = this.getSWFHTML();
		return true;
	}
}

/* ---- detection functions ---- */
deconcept.SWFObjectUtil.getPlayerVersion = function(){
	var PlayerVersion = new deconcept.PlayerVersion([0,0,0]);
	if(navigator.plugins && navigator.mimeTypes.length){
		var x = navigator.plugins["Shockwave Flash"];
		if(x && x.description) {
			PlayerVersion = new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/, "").replace(/(\s+r|\s+b[0-9]+)/, ".").split("."));
		}
	}else if (navigator.userAgent && navigator.userAgent.indexOf("Windows CE") >= 0){ // if Windows CE
		var axo = 1;
		var counter = 3;
		while(axo) {
			try {
				counter++;
				axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+ counter);
//				document.write("player v: "+ counter);
				PlayerVersion = new deconcept.PlayerVersion([counter,0,0]);
			} catch (e) {
				axo = null;
			}
		}
	} else { // Win IE (non mobile)
		// do minor version lookup in IE, but avoid fp6 crashing issues
		// see http://blog.deconcept.com/2006/01/11/getvariable-setvariable-crash-internet-explorer-flash-6/
		try{
			var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
		}catch(e){
			try {
				var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
				PlayerVersion = new deconcept.PlayerVersion([6,0,21]);
				axo.AllowScriptAccess = "always"; // error if player version < 6.0.47 (thanks to Michael Williams @ Adobe for this code)
			} catch(e) {
				if (PlayerVersion.major == 6) {
					return PlayerVersion;
				}
			}
			try {
				axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
			} catch(e) {}
		}
		if (axo != null) {
			PlayerVersion = new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));
		}
	}
	return PlayerVersion;
}
deconcept.PlayerVersion = function(arrVersion){
	this.major = arrVersion[0] != null ? parseInt(arrVersion[0]) : 0;
	this.minor = arrVersion[1] != null ? parseInt(arrVersion[1]) : 0;
	this.rev = arrVersion[2] != null ? parseInt(arrVersion[2]) : 0;
}
deconcept.PlayerVersion.prototype.versionIsValid = function(fv){
	if(this.major < fv.major) return false;
	if(this.major > fv.major) return true;
	if(this.minor < fv.minor) return false;
	if(this.minor > fv.minor) return true;
	if(this.rev < fv.rev) return false;
	return true;
}
/* ---- get value of query string param ---- */
deconcept.util = {
	getRequestParameter: function(param) {
		var q = document.location.search || document.location.hash;
		if (param == null) { return q; }
		if(q) {
			var pairs = q.substring(1).split("&");
			for (var i=0; i < pairs.length; i++) {
				if (pairs[i].substring(0, pairs[i].indexOf("=")) == param) {
					return pairs[i].substring((pairs[i].indexOf("=")+1));
				}
			}
		}
		return "";
	}
}
/* fix for video streaming bug */
deconcept.SWFObjectUtil.cleanupSWFs = function() {
	var objects = document.getElementsByTagName("OBJECT");
	for (var i = objects.length - 1; i >= 0; i--) {
		objects[i].style.display = 'none';
		for (var x in objects[i]) {
			if (typeof objects[i][x] == 'function') {
				objects[i][x] = function(){};
			}
		}
	}
}
// fixes bug in some fp9 versions see http://blog.deconcept.com/2006/07/28/swfobject-143-released/
if (deconcept.SWFObject.doPrepUnload) {
	if (!deconcept.unloadSet) {
		deconcept.SWFObjectUtil.prepUnload = function() {
			__flash_unloadHandler = function(){};
			__flash_savedUnloadHandler = function(){};
			window.attachEvent("onunload", deconcept.SWFObjectUtil.cleanupSWFs);
		}
		window.attachEvent("onbeforeunload", deconcept.SWFObjectUtil.prepUnload);
		deconcept.unloadSet = true;
	}
}
/* add document.getElementById if needed (mobile IE < 5) */
if (!document.getElementById && document.all) { document.getElementById = function(id) { return document.all[id]; }}

/* add some aliases for ease of use/backwards compatibility */
var getQueryParamValue = deconcept.util.getRequestParameter;
var FlashObject = deconcept.SWFObject; // for legacy support
var SWFObject = deconcept.SWFObject;
/*  |xGv00|12f3bac2d2a43155a8555a3c07859656 */
