// JavaScript Document


function getShowObjFromID(ShowID)
{
	for (i=0;i<MyShowList.length;i++)
	{
		if(ShowID==MyShowList[i].ShowID)
			return MyShowList[i];
	}
	return null;
}
function getClipObjFromID(ClipID)
{
	for (var i=0;i<MyShowList.length;i++)
	{
		var o_show=MyShowList[i];
			
			for (var j=0;j<o_show.ClipList.length;j++)
			{
				var o_clip=o_show.ClipList[j];
				if (o_clip.ID==ClipID)
				{
					return o_clip;
				}
			}
			
	}
	return null;
}
function getPlayingTextOfShow(ShowID)
{
	o_show=getShowObjFromID(ShowID);
	
	len=o_show.Length;
	pattern=len.split(":");
	total_vote=pattern[pattern.length-1];
	len="";
	for(i=0;i<pattern.length-2;i++)
	{
		len+=pattern[i]+":"
	}
	len+=pattern[pattern.length-2];
	
	playing_status=(current_showid==ShowID)?"Playing":"Waiting";
	
	var show_link="<a href=\"javascript:show_show_clip('"+o_show.ShowID+"')\"><font color=#212E4C>Expand</font></a>";
	if(ShowID==current_expanded_showid)
		show_link="<a href=\"javascript:hide_show_clip('"+o_show.ShowID+"')\"><font color=#212E4C>Collapse</font></a>";
		
	show_add_fav_link="<a href=\"javascript:add_show_to_fav('"+o_show.ShowID+"');\"><font color=#212E4C>Favorite</font></a>";
	
	show_link=show_link +" | " + show_add_fav_link + "&nbsp;&#8226;&nbsp; <a href='javascript:top.load_iframe(\"sections/show_comment.php?ShowID="+ o_show.ShowID +"\")'><font color=#212E4C>Comments("+total_vote+")</font></a>";
	
	show_link=""+playing_status+"<span class=\"Grey11Normal\">&nbsp;                           Length: "+len+" &nbsp;&#8226;&nbsp; Clips: "+TotalClip+" &nbsp;&#8226;&nbsp; "+show_link+" </span>";
	
		return show_link;
}
function getPlayingTextOfShowClip	(ShowID,ClipID)
{
	
	var playing_status=(ClipID==current_clipid && current_showid==ShowID)?"Playing":"Waiting";
	var oclip=getClipObjFromID(ClipID);
	if (oclip==null)
	{
		
	}
	var add_status=(oclip.ShowID==-1000)?"<a href=\"javascript:remove_fav('"+oclip.ID+"')\"><font color=#212E4C>-Favorite</font></a>":"<a href=\"javascript:add_clip_to_fav('"+oclip.ID+"')\"><font color=#212E4C>+Favorite</font></a>";

	var s=playing_status+"<span class=\"Grey11Normal\"><strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Length: "+oclip.Length+" &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; " + add_status + "</strong></span>";
	
	return s;
}

//----------------------------------------------------------------------------------------------------

function write_player_info(currentClip,nextClip)
{
   
	
	len=currentClip.Length;
	title=currentClip.Title.substr(0,46);
	
	next_len=nextClip.Length;
	next_title=nextClip.Title.substr(0,46);
	
	
	str="<table width=\"100%\" height=\"37\" border=\"0\" valign=\"top\" cellpadding=\"0\" cellspacing=\"0\">            <tr>              <td width=\"100%\" align=\"left\" valign=\"middle\" class=\"ElectronicGuide_Title\">&nbsp;&nbsp;PLAYING:<span class=\"ElectronicGuide_Text\">&nbsp;"+title+" ("+len+")</span>&nbsp;&nbsp;&nbsp;<span class=\"ElectronicGuide_Title\">COMING UP:</span><span class=\"ElectronicGuide_Text\">&nbsp;"+next_title+" ("+next_len+")</span></td><td valign=\"middle\"></td></tr></table>";







	writeLayer(str,"player_info");
	
}

function write_show_info(o_show,show_clip,show_to_fav)
{
	/*
	len=o_show.Length;
	pattern=len.split(":");
	total_vote=pattern[pattern.length-1];
	len="";
	for(i=0;i<pattern.length-2;i++)
	{
		len+=pattern[i]+":"
	}
	len+=pattern[pattern.length-2];

	
	
	
	showid=o_show.ShowID;	
	title=o_show.Title;
	desc=o_show.Description;
	thumb=o_show.Thumbnail;
	bigthumb=0;
	
	if(showid==-999)
	{
	    show_clip=1
		bigthumb=1;
		if(o_show.ClipList.length==0)
		{
			str="<span class=White12Bold>Sorry, we couldn't find clips matched your keyword. Enter a different keyword</span>";
			return str;
		}
	}
	if(showid==-1000)
	{
	    show_clip=1
		bigthumb=1;
		if(o_show.ClipList.length==0)
		{
			str="<span class=White12Bold>You haven't got any clips in your favorites</span>";
			return str;
		}
	}
	
	TotalClip=o_show.ClipList.length;

	playing_status=(current_showid==showid)?"Playing":"Waiting";
	index=0;
	if(o_show.ClipList.length==0)
		return "";
	
	var clip_list="";
	
	
	var show_link="<a href=\"javascript:show_show_clip('"+o_show.ShowID+"')\"><font color=#212E4C>Expand</font></a>";
	//if(show_clip)
	{
		//show_link="<a href=\"javascript:hide_show_clip('"+o_show.ShowID+"')\"><font color=#212E4C>Collapse</font></a>";
		clip_list="<div id='clipshow_"+showid+"' style=\"display:none\">";
		for( var i=0;i<o_show.ClipList.length;i++)
		{
			clip_list+=write_clip(o_show.ClipList[i],bigthumb);
		}
		clip_list+="</div>";
	}

	show_add_fav_link="<a href=\"javascript:add_show_to_fav('"+o_show.ShowID+"');\"><font color=#212E4C>Favorite</font></a>";
	if(!show_to_fav)
	{
		show_add_fav_link="<a href=\"javascript:remove_show_from_fav('"+o_show.ShowID+"')\"><font color=#212E4C>-Favorite</font></a>";
	}
	show_link=show_link +" | " + show_add_fav_link + " &nbsp;&#8226;&nbsp; <a href='javascript:top.load_iframe(\"sections/show_comment.php?ShowID="+ o_show.ShowID +"\")'><font color=#212E4C>Comments("+total_vote+")</font></a>";

	
		var str="<table width=\"485\" height=\"86\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">  <tr>    <td width=\"112\" align=\"left\" valign=\"top\" bgcolor=\"13182d\">";
	
	
				if (navigator.appName.indexOf('Microsoft') != -1) {
                         str+="<a href=\"javascript:play_show('"+showid+"')\"><img src=\""+thumb+"\" width=\"112\" height=\"86\" alt=\"\" border=0></a>";
                }
                else {
                        
						 str+="<a href=\"javascript:play_show('"+showid+"')\"><img src=\""+thumb+"\" width=\"112\" height=\"86\" alt=\"\" border=0></a>";
                }

	str+=" <div id=\"add_img_show_"+showid+"\" style=\"width:20px;margin-top:-90px;margin-left:90px;height:20px\">						 <a href=\"#\" onClick=\"clicked_add_icon('ACVQ2J3tp-4', 0);return false;\"  OnMouseOver=\"change_img('add_button_show_"+showid+"','images/icn_add_over_20x20.gif');return false;\" OnMouseOut=\"change_img('add_button_show_"+showid+"','images/icn_add_20x20.gif');return false;\" title=\"Add Video to QuickList\"> <img id=\"add_button_show_"+showid+"\" border=\"0\"  src=\"images/icn_add_20x20.gif\" alt=\"Add Video to QuickList\" >															</a>																	 </div>	 	    </td>    <td width=\"375\" align=\"left\" valign=\"top\" bgcolor=\"#13182d\"><table width=\"100%\" height=\"86\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">      <tr>        <td height=\"19\" bgcolor=\"#496678\"><span class=\"White11Bold\">&nbsp;</span><span class=\"White11Bold\">&nbsp;" + title +"</span>.     </tr>      <tr>        <td height=\"44\" cellpadding=\"5\" align=\"left\" valign=\"top\" bgcolor=\"#EFEFEF\" class=\"Black11Text\" onmouseover=\"hilight(this)\" onmouseout=\"no_hilight(this)\" style='cursor:pointer' onclick=\"play_show('"+showid+"')\"\">"+desc+"</td>      </tr>      <tr>        <td height=\"19\" align=\"left\" valign=\"bottom\" bgcolor=\"#C6D5D9\" class=\"RedTitle\"> <div id=\"playing_text"+showid+"\" style=\"position:relative\">&nbsp;&nbsp;"+playing_status+"<span class=\"Grey11Normal\">&nbsp;                           Length: "+len+" &nbsp;&#8226;&nbsp; Clips: "+TotalClip+" &nbsp;&#8226;&nbsp; "+show_link+" </span></div></td>      </tr>    </table></td>  </tr></table>";
		
	
	if(showid>-999)	 
		str=str+clip_list;
	else
	{
		str=clip_list;
		
	}
	return str;
	*/
}

function write_clip(oclip,bigthumbnail)
{
	/*
	var playing_status=(oclip.ID==current_clipid && current_showid==oclip.ShowID)?"Playing":"Waiting";
	thumb_w=100
	thumb_h=76;
	table_h=67;
	add_status=(oclip.ShowID==-1000)?"<a href=\"javascript:remove_fav('"+oclip.ID+"')\"><font color=#212E4C>-Favorite</font></a>":"<a href=\"javascript:add_clip_to_fav('"+oclip.ID+"')\"><font color=#212E4C>+Favorite</font></a>";
	
	if(bigthumbnail)
	{
		var str="<table width=\"489\" height=\"86\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">  <tr>    <td width=\"112\" align=\"left\" valign=\"top\" bgcolor=\"13182d\"><a href=\"javascript:play_clipid('"+oclip.ID+"','"+oclip.ShowID+"')\"><img src=\""+oclip.Thumbnail+"\" width=\""+112+"\" height=\""+86+"\" alt=\"\" border=0></a><div id=\"add_img_ACVQ2J3tp-4\" style=\"width:20px;margin-top:-90px;margin-left:0px;\">						 <a href=\"#\" onClick=\"clicked_add_icon('ACVQ2J3tp-4', 0);return false;\"  OnMouseOver=\"change_img('add_button_clip_"+oclip.ID+"','images/icn_add_over_20x20.gif');return false;\" OnMouseOut=\"change_img('add_button_clip_"+oclip.ID+"','images/icn_add_20x20.gif');return false;\" title=\"Add Video to QuickList\"><img id=\"add_button_clip_"+oclip.ID+"\" border=\"0\"  src=\"images/icn_add_20x20.gif\" alt=\"Add Video to QuickList\">														</a>																				    </div> </td>    <td width=\"375\" align=\"left\" valign=\"top\" bgcolor=\"13182d\"><table width=\"100%\" height=\"86\" border=\"0\" cellpadding=\"2\" cellspacing=\"1\">      <tr>        <td height=\"19\" bgcolor=\"#2B3660\" class=\"Yellow11Bold\">&nbsp;"+oclip.Title+"</td>      </tr>      <tr>        <td height=\"44\" align=\"left\" valign=\"top\" bgcolor=\"#EFEFEF\" class=\"Black11Text\">"+oclip.Description+"</td>      </tr>      <tr>        <td height=\"19\" align=\"left\" valign=\"bottom\" bgcolor=\"#C6D5D9\" class=\"RedTitle\"><div id=\"showclip"+oclip.ShowID+"_"+oclip.ID+"test\">"+playing_status+"<span class=\"Grey11Normal\"><strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Length: "+oclip.Length+" &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; " + add_status + "</strong></span></div>></td>      </tr>    </table></td>  </tr></table>";
		
	return str;
		
	}else
	{
	
	var str="<table width=\"485\" height=\"86\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">  <tr>    <td width=\"112\" align=\"left\" valign=\"top\" bgcolor=\"13182d\"><a href=\"javascript:play_clipid('"+oclip.ID+"','"+oclip.ShowID+"')\"><img src=\""+oclip.Thumbnail+"\" width=\""+thumb_w+"\" height=\""+thumb_h+"\" alt=\"\" border=0></a><div id=\"add_img_ACVQ2J3tp-4\" style=\"width:20px;margin-top:-80px;margin-left:0px;\">						 <a href=\"#\" onClick=\"clicked_add_icon('ACVQ2J3tp-4', 0);return false;\"  OnMouseOver=\"change_img('add_button_clip_"+oclip.ID+"','images/icn_add_over_20x20.gif');return false;\" OnMouseOut=\"change_img('add_button_clip_"+oclip.ID+"','images/icn_add_20x20.gif');return false;\" title=\"Add Video to QuickList\"><img id=\"add_button_clip_"+oclip.ID+"\" border=\"0\"  src=\"images/icn_add_20x20.gif\" alt=\"Add Video to QuickList\">														</a>																				    </div> </td>    <td width=\"375\" align=\"left\" valign=\"top\" bgcolor=\"13182d\"><table width=\"100%\" height=\"86\" border=\"0\" cellpadding=\"2\" cellspacing=\"1\">      <tr>        <td height=\"19\" bgcolor=\"#2B3660\" class=\"Yellow11Bold\">&nbsp;"+oclip.Title+"</td>      </tr>      <tr>        <td height=\"44\" align=\"left\" valign=\"top\" bgcolor=\"#EFEFEF\" class=\"Black11Text\">"+oclip.Description+"</td>      </tr>      <tr>        <td height=\"19\" align=\"left\" valign=\"bottom\" bgcolor=\"#C6D5D9\" class=\"RedTitle\"><div id=\"showclip"+oclip.ShowID+"_"+oclip.ID+"test\">"+playing_status+"<span class=\"Grey11Normal\"><strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Length: "+oclip.Length+" &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; " + add_status + "</strong></span></div></td>      </tr>    </table></td>  </tr></table>";
	return str;
	}
	*/
	
}
//---------------------------------------------------------------------------------------
function write_showlist()
{
	//var str=" <table width=\"100\"  border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
	return;	
}
//---------------------------------------------------------------------------------------
function show_show_clip(showid)
{
	return;
	current_expanded_showid=showid;
	
	writeLayer(getPlayingTextOfShow(showid),"playing_text"+showid);
	showTreeLayer("clipshow_"+showid);
	//write_showlist(show_id);
	
}
//---------------------------------------------------------------------------------------
function hide_show_clip(showid)
{
	return;
	current_expanded_showid="";
	//write_showlist(-1);
	writeLayer(getPlayingTextOfShow(showid),"playing_text"+showid);
	hideTreeLayer("clipshow_"+showid);
}
//---------------------------------------------------------------------------------------
function writeShowPlayingStatus(showid,status)
{
	
	if(!top.win_content.writeShowStatus)
	{
		//alert("iframe win_content not found");
	}else
	top.win_content.writeShowStatus(showid,status);
}
//---------------------------------------------------------------------------------------
function writeClipStatus(ShowID,ClipID,status)
{
	top.win_content.writeClipStatus(ShowID,ClipID,status);
}
//---------------------------------------------------------------------------------------
function update_PlayingStatus()
{
	isTheSameShowList=true;
	writeShowPlayingStatus(current_showid,"Playing");
	writeClipStatus(current_showid,current_clipid,"Playing");

}
//---------------------------------------------------------------------------------------
function play_show(showid)
{
	//current_showid=showid;	
	
	
		/*
	
	if(showid!=current_showid)
	{
		lastshowid=current_showid;
		current_showid=showid
		if(lastshowid!="")
			writeLayer(getPlayingTextOfShow(lastshowid),"playing_text"+lastshowid);
		
		writeLayer(getPlayingTextOfShow(current_showid),"playing_text"+current_showid);	
		*/
		//alert(top.win_content.writeShowStatus);
		
		writeShowPlayingStatus(showid,"Playing");
		
		
		//top.win_content.writeLayer("Playing","showStatus"+showid);
		for(var i=0;i<MyShowList.length;i++)
		{
			//alert(MyShowList);

			oshow=MyShowList[i];
			
			if(oshow.ShowID==showid)
			{
				lastshowid=current_showid;
				lastclipid=current_clipid;
				
				writeShowPlayingStatus(lastshowid,"Played");
				writeClipStatus(lastshowid,lastclipid,"Played");
		
				current_showid=showid;	
				current_clipid=oshow.ClipList[0].ID;
				
			}
		}
	
	
	play_clipid(current_clipid,showid);
	
	
}
//---------------------------------------------------------------------------------------
function call_js()
{

	
	
	var message=fc.getVariable("JSText");	
	
	
	eval(message);
	
}
//-------------------------------------------------------------------
//when flash finish loading xml file, it will call this function
function load_playlist_from_flash(show_list)
{
	
	
	
	PlayList=show_list; //this is the object from flash
	MyShowList=show_list.MyShowList;	
	if(isTheSameShowList)
	{
		update_PlayingStatus();
	}
	//
	//alert(xmlFileName);
	//alert(xmlFilename);
	//alert("After:"+xmlFileName);
	//alert(xmlFileName.indexOf("memberPlaylist"));
	//alert(xmlFileName.indexOf("playlist_uservideo"));
	if(xmlFileName.indexOf("playlist_uservideo")==0)
		return false;
	if(xmlFileName.indexOf("playlist_usergallery")==0)
		return false;
	if(xmlFileName.indexOf("memberPlaylist")==-1)
		load_iframe(xmlFileName);
	else
	{
		//member list

	}
	//write_showlist();
	
}
//-------------------------------------------------------------------
//when the flv player play a video,it will send this message to js
function flash_play_movie(oclip,nextClip)
{
	//if(current_showid!="")
	{
		lastshowid=current_showid;
		lastclipid=current_clipid;
		current_clipid=oclip.ID;
		current_showid=oclip.ShowID;
		
		if(lastshowid!="" && lastclipid!="")
		{
			//alert(lastclipid);
			writeShowPlayingStatus(lastshowid,"Played");
			writeClipStatus(lastshowid,lastclipid,"Played");
			//PlayingTextOfShowClip(lastshowid,lastclipid),"showclip"+lastshowid +"_"+lastclipid+"test");
			//writeLayer(getPlayingTextOfShow(lastshowid),"playing_text"+lastshowid);
			
		}
	}
	//alert(getPlayingTextOfShowClip(current_showid,current_clipid));
	//writeLayer(getPlayingTextOfShowClip(current_showid,current_clipid),"showclip"+current_showid+"_"+current_clipid+"test");
	write_player_info(oclip,nextClip);

	if(isTheSameShowList)
	{
		//Thao
		//write_showlist();
		
		//writeLayer(getPlayingTextOfShow(current_showid),"playing_text"+current_showid);
		writeShowPlayingStatus(current_showid,"Playing");
		writeClipStatus(current_showid,current_clipid,"Playing");
	}
	url="showclip_stat.php?ShowID="+current_showid+"&ClipID="+current_clipid
	top.win_controller.location=url;
	

}
//-------------------------------------------------------------------
function getPlayListFromShowList()
{
	MyPlayList=new Array();
	for(i=0;i<MyShowList.length;i++)
		{			
			o_show=MyShowList[i];
			
			for (j=0;j<o_show.ClipList.length;j++)
			{
				o_clip=o_show.ClipList[j];
				MyPlayList.push(o_clip);
			}
		}
	
	
		
}
function add_to_slideshow(id)
{
	for (i=0;i<slide_arr.length;i++)
	{
		if( slide_arr[i]==id)
			return false;
	}
  

	slide_arr.push(id);
	return true;
}
//------------------------------------------------------------------------------------------------
function write_slideshow()
{

	
}
var slide_arr=new Array();
//------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------
function load_playlist(xml_file,start)
{
	//current_showid="";
	//current_expanded_showid="";
	
	if(isTheSameShowList)
	{
		isTheSameShowList=false;
		MyOnNowShow=MyShowList;
	}
	if(start>0)
		fc.callFunction("_level0","load_xml_file",[xml_file,start]	);
	else
		fc.callFunction("_level0","load_xml_file",[xml_file,0]	);
	//str=STR_LOADING;

	//writeLayer(str,"content");
	if(xml_file.indexOf("memberPlaylist")==-1)
		xml_file=xml_file.replace("playlist.php","indextv_playlist_html.php");
	xmlFileName=xml_file;
	//alert("Before:"+xmlFileName);
		
	
}
//------------------------------------------------------------------------------------------------

function play_clipid(clipid,showID)
{
	/*current_showid=showID;
	if( lastshowid!=showID)
	{		
		if (lastshowid!="" )
			writeLayer(getPlayingTextOfShow(lastshowid),"playing_text"+lastshowid);
			
		//writeLayer(getPlayingTextOfShow(current_showid),"playing_text"+current_showid);
	}	
	lastclipid=current_clipid;
	current_clipid=clipid;
	if(lastclipid!="")
	{
			writeLayer(getPlayingTextOfShowClip(lastshowid,lastclipid),"showclip"+lastshowid +"_"+lastclipid+"test");
			//writeLayer(getPlayingTextOfShow(lastshowid),"playing_text"+lastshowid);
			
		
	}
	
	//alert(getPlayingTextOfShowClip(current_showid,current_clipid));
		writeLayer(getPlayingTextOfShowClip(current_showid,current_clipid),"showclip"+current_showid +"_"+lastclipid+"test");
		
	writeLayer(getPlayingTextOfShowClip(current_showid,current_clipid),"showclip"+current_showid+"_"+current_clipid+"test");*/
	
	isTheSameShowList=true;
	lastshowid=current_showid;
	lastclipid=current_clipid;
		
	writeShowPlayingStatus(lastshowid,"Played");
	writeClipStatus(lastshowid,lastclipid,"Played");
		
	current_showid=showID;	
	current_clipid=clipid;
	writeShowPlayingStatus(current_showid,"Playing");
	writeClipStatus(current_showid,current_clipid,"Playing");
	
				
	//alert(clipid + ":"+ showID);
	fc.callFunction("_level0","play_movie_by_clipid", [clipid,showID]);
}
//------------------------------------------------------------------------------------------------

function play_clipobj(objclip)
{
	
	fc.callFunction("_level0","play_movie_by_clipobj", [objclip.ID,objclip.Title,objclip.ShowID,objclip.FileLocation]);
}
//------------------------------------------------------------------------------------------------
function play_clip_in_slide(clipid)
{
	var i=0;
	for(i=0;i<SlideList.length;i++)
	{
		if (SlideList[i].ID==clipid)
			play_clipobj(SlideList[i]);
	}	
}
//------------------------------------------------------------------------------------------------
function show_on_now()
{
	if(!isTheSameShowList)
		MyShowList=MyOnNowShow;
	write_showlist();
}
//------------------------------------------------------------------------------------------------
function add_to_slidelist(oclip)
{
	for(i=0;i<SlideList.length;i++)
	{
		if (SlideList[i].ID==oclip.ID)
		return false;
	}
	SlideList.push(oclip);
	return true;
	
}
//------------------------------------------------------------------------------------------------
function do_fullscreen() {
		
		isFullScreen=true
		hide_preload();
		return;
		p_w=document.body.clientWidth;
		p_h=document.body.clientHeight
		
		if(document.all && !document.getElementById) {
			document.all['videoDiv'].style.pixelWidth = p_w;
			document.all['videoDiv'].style.pixelHeight = p_h;
			document.all['videoDiv'].style.top = 0;
			document.all['videoDiv'].style.left = 0;
			
		} else {
			
			document.getElementById('videoDiv').style.top = 0;
			document.getElementById('videoDiv').style.left = 0;
			document.getElementById('videoDiv').style.width = p_w;
			document.getElementById('videoDiv').style.height = p_h;
		}
		
		//fc.callFunction("_level0","do_fullscreen",[]);
	}
////------------------------------------------------------------------------------------------------
function show_preload() {		

		p_w=document.body.clientWidth;
		p_h=document.body.clientHeight
		document.write("		<div id=\"preloadDiv\" style=\"position:absolute;width:437px;height:549;display:block;z-index:100\"><table width=100% height=100% bgcolor=white><tr><td align=center class=\"Bold11\">Loading...please wait. <a href=\"javascript:hide_preload()\">Show now</a></td></tr></table></div>");
		hideLayer('videoDiv');
		if(document.all && !document.getElementById) {
			document.all['preloadDiv'].style.pixelWidth = p_w;
			document.all['preloadDiv'].style.pixelHeight = p_h;
			document.all['preloadDiv'].style.top = 0;
			document.all['preloadDiv'].style.left = 0;
			
		} else {
			
			document.getElementById('preloadDiv').style.top = 0;
			document.getElementById('preloadDiv').style.left = 0;
			document.getElementById('preloadDiv').style.width = p_w;
			document.getElementById('preloadDiv').style.height = p_h;
		}
		
		//fc.callFunction("_level0","do_fullscreen",[]);
	}
//------------------------------------------------------------------------------------------------
function hide_preload()
{
	hideLayer('preloadDiv');
	no_fullscreen();
}

//------------------------------------------------------------------------------------------------
function no_fullscreen() {
		p_w=461;
		p_h=358;
		isFullScreen=false
		
		if(document.all && !document.getElementById) {
			document.all['videoDiv'].style.pixelWidth = p_w;
			document.all['videoDiv'].style.pixelHeight = p_h;
		} else {
			
			document.getElementById('videoDiv').style.top = "";
			document.getElementById('videoDiv').style.left = "";
			document.getElementById('videoDiv').style.width = p_w;
			document.getElementById('videoDiv').style.height = p_h;
		}
		
	}
//------------------------------------------------------------------------------------------------
function do_resize()
{
	if(isFullScreen)
	{
		do_fullscreen();
	}
}
isFullScreen=false
//------------------------------------------------------------------------------------------------
function do_search()
{
	var frm=document.form1;
	keyword=frm.keyword.value;
	search_type=frm.search_type.options[frm.search_type.selectedIndex].value
	if(keyword=="")
	{
		alert("Please enter keyword to search");
		frm.keyword.focus();
		return;
	}
	if(search_type=="Members")
		url="userlist_all.php?view=search&keyword="+keyword;
	else
		url="playlist.php?view=search&keyword="+keyword;
	if(frm.anyword.checked)
		url+="&anyword=1";
	
		url+="&search_type="+search_type
	
	load_playlist(url);
	//writeLayer(STR_LOADING,"content");
}
//------------------------------------------------------------------------------------------------
function add_clip_to_fav(clipID)
{
	if(is_logged_in==undefined || is_logged_in==false)
	{
		alert("Please login to add to your favorites.");
		return;
	}
	var frm=document.form1;
	url="sections/member/add_to_fav.php?id="+clipID;
	top.win_controller.location=url;

}
//------------------------------------------------------------------------------------------------
function add_show_to_fav(ShowID)
{
	if(is_logged_in==undefined || is_logged_in==false)
	{
		alert("Please login to add to your favorites.");
		return;
	}
	var frm=document.form1;
	url="sections/member/add_show_to_fav.php?id="+ShowID;
	top.win_controller.location=url;

}
//------------------------------------------------------------------------------------------------
function remove_show_from_fav(ShowID)
{
	
	var frm=document.form1;
	url="sections/member/add_show_to_fav.php?task=remove&id="+ShowID;
	top.win_controller.location=url;

}



//------------------------------------------------------------------------------------------------
function remove_fav(clipID)
{	
	url="sections/member/add_to_fav.php?task=remove&id="+clipID;
	top.win_controller.location=url;

}

//------------------------------------------------------------------------------------------------
function set_logged_in()
{
	
	is_logged_in=true;
}
//------------------------------------------------------------------------------------------------
function load_favorites()
{
	isTheSameShowList=false;
	MyOnNowShow=MyShowList;
	MyOnNowPlayList=PlayList;
	load_playlist("playlist.php?view=favorites");
}
//------------------------------------------------------------------------------------------------
function load_saved_show()
{
	isTheSameShowList=false;
	MyOnNowShow=MyShowList;
	MyOnNowPlayList=PlayList;
	load_playlist("playlist.php?view=saved_show");
}
//------------------------------------------------------------------------------------------------
var isNN = (navigator.appName.indexOf("Netscape")!=-1);
function search_keyup(obj,e)
			{
				var keyCode = (isNN) ? e.which : e.keyCode; 
				if(keyCode==13)
					do_search();
			}
//------------------------------------------------------------------------------------------------
			function login_keyup(obj,e)
			{
				var keyCode = (isNN) ? e.which : e.keyCode; 
				if(keyCode==13)
					do_login();
			}

function thisMovie(movieName) {
  // IE and Netscape refer to the movie object differently.
  // This function returns the appropriate syntax depending on the browser.
  var isIE = navigator.appName.indexOf("Microsoft") != -1;
 if(isIE && (window[movieName] )== "undefined")
 {
	window.location.reload();
 }
        return (isIE) ? window[movieName] : document[movieName];
		
	 if (window.document[movieName]) 
  {
    return window.document[movieName];
  }
  if (navigator.appName.indexOf("Microsoft Internet")==-1)
  {
    if (document.embeds && document.embeds[movieName])
      return document.embeds[movieName]; 
  }
  else // if (navigator.appName.indexOf("Microsoft Internet")!=-1)
  {
    return document.getElementById(movieName);
  }
}


function createJSFCommunicatorObject(playerObj)
{
		//create an instance of JSFCommunicator, pass the flashMovie's reference
		//make sure flash object is loaded when you create this object with parameter otherwise
		//you can JSFCommunicator.setMovie(flashMovie) once flash object is loaded
		
	//	fc = new JSFCommunicator(playerObj);
}
//------------------------------------------------------------------------------
//load external pages in content window on right
function load_iframe(url)
{
	url=ROOT_URL+url
	

	isTheSameShowList=false;
	MyOnNowShow=MyShowList;
	
	if(top.win_content==undefined)
	{
		str="<iframe src=\""+url+"\" width=\"361px\" height=\"519px\" frameborder=\"no\" scrolling=\"auto\" name='win_content' id='win_content'></iframe>";

		writeLayer(str,"content");
	}
		
	else
	  top.win_content.location.href=url;
	  
	
	
	
}
//-----------------------------------------------------------------------------------

//------------------------------------------------------------------------------
//load external pages in content window on right
function load_iframe_talent(url)
{
	url=ROOT_URL+"Talent/member/"+url
	

	//isTheSameShowList=false;
	//MyOnNowShow=MyShowList;
	
	//if(top.win_content==undefined)
	//{
	//	str="<iframe src=\""+url+"\" width=\"609\" height=\"664\" frameborder=\"no\" scrolling=\"auto\" name='win_content' id='win_content'></iframe>";
		str="<iframe  src=\""+url+"\" name=\"content\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"Auto\" frameborder=\"0\" id=\"main\" style=\"width:609px;height:664px;\"></iframe>";
		writeLayer(str,"content");
	//}
		
	//else
	//  top.win_content.location.href=url;
	  
	
	
	
}
//-----------------------------------------------------------------------------------
function do_login()
{
	//var login_box_wait="{login_box_wait}";
	var frm=document.form1;
	if(frm.loginname.value==''||frm.password.value=='' )
	{	alert('Please input your username and password within the login boxes and click GO, click FORGOT if you lost your login information.');
		return false;
	}
	url="/check_login.php?loginname="+frm.loginname.value+"&password="+frm.password.value;
	top.win_controller.location=url;
	writeLayer(login_box_wait,"login_area");
	
	//window.location=url;






}
function show_logged_in_popup()
{
	writeLayer("<center><img src='/images/loading.gif'  border='0' /></center>","boxlogin_content");	
	var url="/login_requiredpopup.html";
	var myAjax = new Ajax.Updater('boxlogin_content', url, {method: 'get',evalScripts: true	});
	
}

function show_login_box()
{
	//var login_box="{login_box}";
	writeLayer(login_box,"login_area");	
}
function show_logged_in(str)
{
	
	writeLayer(str,"login_area");	
	
}
function log_out(call_hidden)
{
	
	show_login_box();
	//show_on_now();
	is_logged_in=false;
	url="/log_out.php";	
	if(call_hidden!="no")
	{
		
		window.location = url;
		//top.win_controller.location=url;
		//win_controller.location=url;
	}
	
	top.loadmenu('/mainmenu.html');
	
}
function showLayer(id) {
  var lyr = getElemRefs(id);
  if (lyr && lyr.css) lyr.css.display = "visible";
}

function hideLayer(id) {
  var lyr = getElemRefs(id);
  if (lyr && lyr.css) lyr.css.visibility = "hidden";
}
function getElemRefs(id) {
	var el = (document.getElementById)? document.getElementById(id): (document.all)? document.all[id]: (document.layers)? document.layers[id]: null;
	if (el) el.css = (el.style)? el.style: el;
	return el;
}

function earse_me(obj,evt,defaultText)

{
	var s=obj.value
	if((s.indexOf("Enter Keywords") + 1))
	{
			obj.value="";
	}
	if(defaultText!="undefined" && (s.indexOf(defaultText) + 1))
	{
			obj.value="";
	}

}
var is_logged_in;
function isLoggedIn()
{

	if(is_logged_in==undefined || is_logged_in==false)
	{
		return false;
	}
	return true;

}
//---------------------------------------------
function addToQuickList(ShowID)
{
	
	url="indextv_quickListManage.php?task=addShow&ShowID="+ShowID;
	
	top.win_controller.location=url;
}
//---------------------------------------------
function removeFromQuickList(ShowID)
{
	url="indextv_quickListManage.php?task=removeShow&ShowID="+ShowID;
	top.win_controller.location=url;
}
//---------------------------------------------
function clearQuickList()
{
	url="indextv_quickListManage.php?task=clear";
	top.win_controller.location=url;
}

//---------------------------------------------
function PlaySlideShow(xmlFile)
{
	fc.callFunction("_level0","startSlideShow", [xmlFile]);
}
//---------------------------------------------
function play_by_url(url)
{
	if(url=="")
	{
		alert("The video is not available");
		return;
	}
	fc.callFunction("_level0","play_by_url",[url]);
}

//---------------------------------------------
function showPhoto(url)
{
		fc.callFunction("_level0","loadPhoto",[url]);
}
//-CHAT WITH PERSON-------------------------------
function  chat_to(UserName)
{
	if(!isLoggedIn())
	{
		alert("Please become a Registered Member to access this feature. Signup or Login.");
		return "";
	}
	if(UserName=="")
		return "";
		var url="/sections/chat/chat.php?ToUserName="+UserName
		popwin=window.open(url,"win_" + UserName,"toolbar=no,location=no,directories=no,status=no,menub ar=no,scrollbar=no,resizable=no,width=550,height=280,left=100, top=100,screenX=100,screenY=100")
	popwin.focus()
}
//--ADD FRIEND -------------------------------------------
function addToFriendList(FriendID,FriendUserName,FriendType)
{
	
	if(!isLoggedIn())
	
	{
		alert("Please become a Registered Member to access this feature. Signup or Login. ");
		return "";
	}
	if(FriendID=="")
		return "";

	if(typemember==2)//employer member
	{
		url="/Employer/member/friend_list_f.php?task=add&FriendID="+FriendID+"&FriendUserName="+FriendUserName+"&FriendType="+FriendType;
		top.win_controller.location=url;
	}
	else
	{
		url="/Talent/member/friend_list_f.php?task=add&FriendID="+FriendID+"&FriendUserName="+FriendUserName+"&FriendType="+FriendType;
		top.win_controller.location=url;
	}

	
}
//---BLOCK MEMBER------------------------------------------

function BlockFriend(UserID,UserName,FriendType)
{
	
	if(!isLoggedIn())
	{
		alert("Please become a Registered Member to access this feature. Signup or Login. ");
		return "";
	}
	if(UserID=="")
		return "";

	if(typemember==2)//employer member
	{
		url="/Employer/member/blocked_f.php?task=add&UserName="+UserName+"&id="+UserID+"&UserType="+FriendType;
		top.win_controller.location=url;
	}
	else
	{
		url="/Talent/member/blocked_f.php?task=add&UserName="+UserName+"&id="+UserID+"&UserType="+FriendType;
		top.win_controller.location=url;
	}

	
}

//-LOAD GALLERY ALBUM SLIDESHOW--------------------------------------------
function loadGallery(xmlFile,ID)
{
		fc.callFunction("_level0","loadPhotoSlideShow",[xmlFile,ID]);
}
//---------------------------------------------
function preview_link_byemp(url) //khai bao var typemember trong main html, da~ set ja tri typemember khi check_login
{
	
	if(!top.isLoggedIn())
	{
		alert("Please become a Registered Member to access this feature. Signup or Login. ");
		return "";
	}
	if(typemember==1)//talent member
	{
		alert("Unfortunately this Feature is available for Verified Employers only.");
				
		return "";
	}
	if(url=="")
	{	
		//url=" target=\"_blank\" "	;
		alert("No Resume Attached by This Member");
		return "";
	}
	if(typemember==2)//employer member
	{
		window.open(url,"_blank");
	}
}

//---------------------------------------------
function get_resumefile(UserID,filename)
{
	if(!top.isLoggedIn())
	{
		alert("Please become a Registered Member to access this feature. Signup or Login. ");
		return "";
	}
	if(typemember==1)//talent member
	{
		alert("Unfortunately this Feature is available for Verified Employers only.");
				
		return "";
	}
	if(filename=="")
	{	
		//url=" target=\"_blank\" "	;
		alert("No Resume Attached by This Member");
		return "";
	}
	if(typemember==2)//employer member
	{	url="/uploads/1000/upload/users/"+UserID+"/"+filename;
		window.open(url,"_blank");
	}
}
//---------------------------------------------
function preview_link_bytal(url,typemember) //xem lai  preview_link_byemp(url) da~ bo~ typemember trong goi ham`//. de~ su~ dung nhu ham` tren => khai bao var typemember trong main html, da~ set ja tri typemember khi check_login
{
	if(!top.isLoggedIn())
	{
		alert("Please become a Registered Member to access this feature. Signup or Login. ");
		return "";
	}
	if(typemember==1)//talent member
	{
		window.open(url,"_blank");
	}
	if(typemember==2)//employer member
	{
		alert("This Option is for Talent members only.");
		return "";
		
	}
	if(url=="")
	{	
		//url=" target=\"_blank\" "	;
		alert("Could not find URL ");
		return "";
	}
	
}

//---------------------------------------------
function preview_link(url)
{
	if(!top.isLoggedIn())
	{
		alert("Please become a Registered Member to access this feature. Signup or Login. ");
		return "";
	}
	if(url=="")
	{	alert('There are no links');	
		return "";
	}
	
	self.location.href=url;
}
//---------------------------------------------


//---------------------------------------------
function applyjob(JobID,typemember)
{	
	var frm = document.form1;
	if(!top.isLoggedIn())
	{
		alert("Please become a Registered Member to access this feature. Signup or Login. ");
		return "";
	}
	if(typemember==2)//employer member
	{
		alert("This Feature is available for Talent Candidates only");
				
		return "";
	}

	self.location.href='/Talent/member/apply_job.php?task=add&JobID='+JobID;
}
//---------------------------------------------
function request(UserName,typemember)
{	
	var frm = document.form1;
	if(!top.isLoggedIn())
	{
		alert("Please become a Registered Member to access this feature. Signup or Login. ");
		return "";
	}
	if(typemember==2)//employer member
	{
		alert("This Feature is available for Talent Candidates only");
				
		return "";
	}

	self.location.href='Talent/member/sendrequest.php?ToUserField='+UserName;
}

//---------------------------------------------
function viewjob(JobID)
{
	var frm = document.form1;
	if(!top.isLoggedIn())
	{
		alert("Please become a Registered Member to access this feature. Signup or Login. ");
		return "";
	}

	self.location.href='public_profile_joblist.php?JobID='+JobID;
}
//---------------------------------------------
function viewprofile(UserID,typemember)
{
	
	if(UserID=="" || typemember=="")
	{
		alert("This Member is no longer active on the system.");
		return "";
	}
	
	if(!top.isLoggedIn())
	{
		alert("You will be redirected to this member`s public profile, however please Create an Account or Sign In to access additional Features on the site and remove these pesky messages. ");
	//	return "";
	}
	if(typemember==1)//talent member
	{
		self.location.href='public_profile_f.php?UserID='+UserID;
	}
	if(typemember==2)//emp member
	{
		self.location.href='public_profile_emp_f.php?UserID='+UserID;
	}
	if(typemember==11)//forum talent member
	{
		self.location.href='public_profile_f.php?UserID='+UserID;
	}
	if(typemember==22)//forum emp member
	{
		self.location.href='public_profile_emp_f.php?UserID='+UserID;
	}
}

function viewcalander(ID)
{
	
	if(ID=="" || !ID)
	{
		alert("This Member is no longer active on the system.");
		return "";
	}
	
	if(!top.isLoggedIn())
	{
		alert("You will be redirected to this Calendar Event, however please Create an Account or Sign In to access additional Features on the site and remove these pesky messages. ");
	self.location.href='event_calendar_details.php?ID='+ID;
	} else
		self.location.href='event_calendar_details.php?ID='+ID;
	
	
}


function loadPhoto(UserID,ID)
{
	
	top.loadGallery("playlist_usergallery.php?UserID="+UserID,ID);
}



//FOR FORUMS  ---------------------------------------------
function forumviewprofile(UserID,typemember)
{
	var frm = document.form1;
	if(!top.isLoggedIn())
	{
		alert("Please become a Registered Member to access this feature. Signup or Login. ");
		return "";
	}
	if(typemember==1)//talent member
	{
		self.location.href='public_profile_f.php?UserID='+UserID;
	}
	if(typemember==2)//talent member
	{
		self.location.href='public_profile_emp_f.php?UserID='+UserID;
	}
}
function forumloadPhoto(UserID,ID)
{
	
	top.loadGallery("forum_playlist_usergallery.php?UserID="+UserID,ID);
}
//FOR menu of member  ---------------------------------------------
function loadmenu(menu_url)
{	
	if(document.getElementById('navigation'))
	{	var pars = 'someParameter=ABC';
		var myAjax = new Ajax.Updater('navigation', menu_url, {method: 'get',parameters: pars,evalScripts: true	});
		writeLayer("<br><br><br><br><center><img src='/images/loading.gif'  border='0' /></center>","navigation");	
	}
		

	/*
	
	writeLayer("<br><br><br><br><center><img src='/images/loading.gif'  border='0' /></center>","navigation");	

	str="<iframe src=\""+menu_url+"\" width=\"100%\" height=\"100%\" frameborder=\"no\" scrolling=\"no\" name='navigation_menu' id='navigation_menu'></iframe>";
	writeLayer(str,"navigation");
	*/
	
	  
}

