function swtichFlagshipIndexToSchedule() {
	var options = {asynchronous:true,
				   evalScripts:true};
	switchTab('scheduleTab');
	//alert(tabSelected);
	new Ajax.Updater('flagship_index_schedule','/ajax/flagship_to_schedule',options);
}

function swtichScheduleToFlagshipIndex() {
	var options = {asynchronous:true,
				   evalScripts:true};
	switchTab('flagshipTab');
	//alert(tabSelected);
	new Ajax.Updater('flagship_index_schedule','/ajax/schedule_to_flagship',options);
}

function fullScheduleSwitchDay(viewingDate,station) {
	var options = {asynchronous:true,
				   evalScripts:true};
	
	new Ajax.Updater('schedule','/ajax/update_full_schedule/'+viewingDate+'/'+station,options);
}

function switchProgrammeContent(peid,ceid,ptype,theme,archivePage) {
	rtfUpdated = false;
	var options = {asynchronous:true,
				   evalScripts:true,
				   onComplete:function(){switchProgramContentArchive(archivePage,peid,ceid,ptype,theme);}};

   new Ajax.Updater('programme_content','/ajax/update_programme_content/'+peid+'/'+ceid+'/'+ptype+'/'+theme,options);	
}

function switchProgramContentArchive(page,peid,ceid,ptype,theme) {
	var options = {asynchronous:true,
				   evalScripts:true};
	
	new Ajax.Updater('programme_content_archive','/ajax/update_programme_content_archive/'+page+'/'+peid+'/'+ceid+'/'+ptype+'/'+theme,options);
}

function switchTrendsProgrammeContent(ceid,ptype,theme,archivePage) {
	rtfUpdated = false;
	var options = {asynchronous:true,
				   evalScripts:true,
				   onComplete:function(){switchTrendsProgrammeContentArchive(archivePage,ceid,ptype,theme);}};
	//alert('a');
   new Ajax.Updater('programme_content','/ajax/update_trends_programme_content/'+ceid+'/'+ptype+'/'+theme,options);	
}

function switchTrendsProgrammeContentArchive(page,ceid,ptype,theme) {
	var options = {asynchronous:true,
				   evalScripts:true};
	
	new Ajax.Updater('programme_content_archive','/ajax/update_trends_programme_content_archive/'+page+'/'+ceid+'/'+ptype+'/'+theme,options);
}

function switchMiniprogramme(page,peid) {
	var options = {asynchronous:true,
				   evalScripts:true};
	
	new Ajax.Updater('miniprogramme','/ajax/update_miniprogramme/'+page+'/'+peid,options);
}

function playMiniprogramme(url) {
	flashProxy.call('playInsertVideo',url);
	document.location.href ="#richMediaVideo";
}

function switchEssence(ajax_prog, cid, targetPage, entryPerPage, theme, textColor, contentArea, barArea, index) {
	var options = {	asynchronous:true,
					evalScripts:true,
					onComplete:	function(){
									for ($i=0; $i < entryPerPage; $i++) {
										if ($i != index && document.getElementById(contentArea + $i) != null) {
											// already included the bar area.
											document.getElementById(contentArea + $i).innerHTML = "";
										}
									}
								}};				   
	var keys = ajax_prog+'/'+cid+'/'+targetPage+'/'+entryPerPage+'/'+theme+'/'+textColor+'/'+contentArea+'/'+barArea+'/'+index;
	new Ajax.Updater(contentArea + index,'/ajax/' + ajax_prog + '/'+ keys ,options);
}

function switchEssencePage(ajax_prog, cid, targetPage, entryPerPage, totalPage, theme, textColor, contentArea, barArea, index) {
	var options = {asynchronous:true,
				   evalScripts:true};
	var keys = ajax_prog+'/'+cid+'/'+targetPage+'/'+entryPerPage+'/'+totalPage+'/'+theme+'/'+textColor+'/'+contentArea+'/'+barArea+'/'+index;
	new Ajax.Updater(barArea + index,'/ajax/reset_prev_next_bar/'+keys, options);
	//document.getElementById(barArea + index).innerHTML = '<table border="0" cellpadding="0" cellspacing="0"><tbody><tr bgcolor="white"><td colspan="3" height="1" width="158"></td></tr></tbody></table><table border="0" cellpadding="0" cellspacing="0"><tbody><tr colspan="3" valign="baseline"> <td class="videoarchive_orange_d" width="44"></td><td class="videoarchive_orange_d" align="center" valign="baseline" width="66"><font face="Webdings" size="-1">&nbsp;</font>1/2?<font face="Webdings" size="-1">&nbsp;</font></td><td class="videoarchive_orange_d" width="48"><span class="videoarchive_orange_c_link"><a href="javascript:;" onclick="switchEssence("get_miniprogram_next_category_video",1860,1,3,"orange","black","miniProgrammeVideoArea_","miniProgrammeVideoBarArea_",0)" ?="">¦^?</a></span><font face="Webdings" size="-1">4</font></td></tr></tbody></table>';
}


/*
function checkClosestProgramme(peid,ptype ,theme){
	var options = {asynchronous:true,
				   evalScripts:true};
	new Ajax.Updater('checkingDiv','/ajax/check_closest_programme/'+peid+'/'+ptype+'/'+theme,options);
}*/