function preparePreview(src,widget_folder,flg,sId)
{
	var src = src+'/widgets';
	var innerpreview = 'innerpreview';
    switch (widget_folder) {
        case 'team':   {set_widget_team_options(src,innerpreview,flg); break;}
        case 'competition': {
				set_widget_competition_options(src,innerpreview,sId); break;
				}
        case 'matches': {set_widget_competition_match_options(src,innerpreview,flg); break;}
    }
}

function set_widget_team_options(src,innerpreview,flg)
{
	if(document.frmwidget.selTeamList.value=='') 
		return false;	
	else 	
		var team_id      = document.frmwidget.selTeamList.value;		
	
    if (document.frmwidget.teamType[0].checked == true) {
		src = src+'/team/index.php?id='+team_id+'&type=stat&flg='+flg;
	}else {
		src = src+'/team/index.php?id='+team_id+'&type=match&flg='+flg;
	}
	ajaxWidgetPreview(src,innerpreview);	
}

function set_widget_competition_options(src,innerpreview,roundId)
{
	// optition type full/half competition table
	if(document.frmwidget.selSeason.value=='') 
	{
		return false;	
	}
	else 	
	{
		var competition_id = document.frmwidget.selCompetition.value;
		var season_id      = document.frmwidget.selSeason.value;		
	}
	
	if(document.frmwidget.competitionType[0])
		{
			if (document.frmwidget.competitionType[0].checked == true) {
				src = src+'/competition/index.php?id='+season_id+'&rId='+roundId+'&type=half';
			}else {
				src = src+'/competition/index.php?id='+season_id+'&rId='+roundId+'&type=full';
			}
		}
	else
		{
			if (document.frmwidget.competitionType.checked == true)	
			{
				src = src+'/competition/index.php?id='+season_id+'&rId='+roundId+'&type=full';	
			}
			else
			{
				return false;	
			}
		}
	ajaxWidgetPreview(src,innerpreview);
}

function set_widget_competition_match_options(src,innerpreview,flg)
{
	if((document.frmteam.selTeamListOne.value=='') || (document.frmteam.selTeamListTwo.value==''))
		return false;	
	else 	
		var team1_id      = document.frmteam.selTeamListOne.value;
		var team2_id      = document.frmteam.selTeamListTwo.value;
	
    if (document.frmteam.teamType[0].checked == true) {
		src = src+'/matches/index.php?id1='+team1_id+'&id2='+team2_id+'&type=stat&flg='+flg;
	}else {
		src = src+'/matches/index.php?id1='+team1_id+'&id2='+team2_id+'&type=match&flg='+flg;
	}
	ajaxWidgetPreview(src,innerpreview);		
}

function widget_select_options(block,url,rootUrl)
{
	block_code  = document.getElementById(block);
	block_code.innerHTML ='Loading...';
	rootUrl 	  = decodeURIComponent(rootUrl);
	var urlstring = url + "?siteURL="+ rootUrl;
	ajax(block_code,urlstring);
}

//Function for display Table Match/Fixture
function displayMatch(flg)
{
	if(flg=="Y")	
		{
			document.getElementById("matchType").style.display="block";
		}
	else
		{
			document.getElementById("matchType").style.display="none";
		}
}
//End Functio for display Table Match/Fixture

//Function for display Table Match/Fixture
function displayRound(flg)
{
	if(flg=="Y")	
		{
			document.getElementById("Displayround").style.display="block";
		}
	else
		{
			document.getElementById("Displayround").style.display="none";
		}
}
//End Functio for display Table Match/Fixture

//Function for display Table Match/Fixture
function displayComp(val,url)
{
	if(val=="N")
	{
	 	 document.getElementById("displayComp").innerHTML="<input name='competitionType' id='competitionType' value='H' type='radio' checked='checked' onclick=\"displayRound('N'),preparePreview('"+url+"','competition','','a')\"><span class='bug_message'>Half Competition</span><input name='competitionType' id='competitionType' value='F' type='radio' onclick=\"displayRound('Y'),getRoundList('"+url+"')\"><span class='bug_message'>Full Competition</span>";	
	}
	else
	{
		document.getElementById("displayComp").innerHTML="<input name='competitionType' id='competitionType' value='F' type='radio' onclick=\"displayRound('Y'),getRoundList('"+url+"')\"><span class='bug_message'>Full Competition</span>";
	}
	/*
	if(flg=="Y")	
		{
			document.getElementById("Displayround").style.display="block";
		}
	else
		{
			document.getElementById("Displayround").style.display="none";
		}
	*/	
}
//End Functio for display Table Match/Fixture

//Code for display Round list
function getRoundList(src)
 {
	var seasonId  = document.frmwidget.selSeason.value;	
	block_content = document.getElementById("Displayround");
	src = src+'/page_include/getRoundList.php?sId='+seasonId;
	ajaxRequest(block_content,src);
 }
//End code for display Round list