function getvideofromurl(defpid)
{
	//http://link.brightcove.com/services/player/bcpid5725652001?bclid=14644269001&bctid=14730276001
	//http://link.brightcove.com/services/link/bcpid1842754338/bclid1847335360/bctid2266283001

	var qs=location.search
	
	var pid=''
	var lid=''
	var tid=''
	var vid=''
	var x=''
	//alert(qs)
	
	if(pid=qs.match(/(?=pid).+?\d+/))
	{
		pid=pid[0].match(/\d+/)
	}
	
	if(lid=qs.match(/(?=lid).+?\d+/))
	{
		lid=lid[0].match(/\d+/)
	}
	
	if(tid=qs.match(/(?=tid).+?\d+/))
	{
		tid=tid[0].match(/\d+/)
		vid=tid
	}

	var newhtml=''
	if((pid=='')|| (pid==null) || (qs==''))
	{
		newhtml='<embed src="http://services.brightcove.com/services/viewer/federated/'+defpid+'" bgcolor="#FFFFFF" flashVars="playerId='+defpid+'&viewerSecureGatewayURL=https://services.brightcove.com/services/amfgateway&servicesURL=http://services.brightcove.com/services&cdnURL=http://admin.brightcove.com&domain=embed&autoStart=false&" base="http://admin.brightcove.com" name="flashObj" width="790" height="620" seamlesstabbing="false" type="application/x-shockwave-flash" wmode="transparent" swLiveConnect="true" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></embed>'
	}
	else if((pid != null) && (lid != null) && (tid != null))
	{
		//this works with this style:
		//http://link.brightcove.com/services/player/bcpid1137883267?bclid=1155224533&bctid=40741777001
		newhtml+='<embed src="http://services.brightcove.com/services/viewer/federated/'+pid+'" bgcolor="#FFFFFF" flashVars="playerId='+pid+'&lineupId='+lid+'&videoId='+vid+'&viewerSecureGatewayURL=https://services.brightcove.com/services/amfgateway&servicesURL=http://services.brightcove.com/services&cdnURL=http://admin.brightcove.com&domain=embed&autoStart=false&" base="http://admin.brightcove.com" name="flashObj" width="790" height="620" seamlesstabbing="false" type="application/x-shockwave-flash" wmode="transparent" swLiveConnect="true" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></embed>'
	}
	else if((pid != null) && (tid != null))
	{
		//this works with this style:
		//http://link.brightcove.com/services/player/bcpid52525620001?bctid=54262510001
		newhtml+='<object id="myExperience" class="BrightcoveExperience">\n'
		newhtml+='\t<param name="bgcolor" value="#FFFFFF" />\n'
		newhtml+='\t<param name="width" value="486" />\n'
		newhtml+='\t<param name="height" value="412" />\n'
		newhtml+='\t<param name="playerID" value="'+pid+'" />\n'
		newhtml+='\t<param name="publisherID" value="1138077113"/>\n'
		newhtml+='\t<param name="isVid" value="true" />\n'
		newhtml+='\t<param name="wmode" value="transparent" />\n'
		newhtml+='</object>\n'
	}
	else if((pid!=null))
	{
		//http://link.brightcove.com/services/player/bcpid1244679431	
		var config = new Array();

		config["videoId"] = null; //the default video loaded into the player
		config["videoRef"] = null; //the default video loaded into the player by ref id specified in console
		config["lineupId"] = null; //the default lineup loaded into the player
		config["playerTag"] = null; //player tag used for identifying this page in brightcove reporting
		config["autoStart"] = false; //tells the player to start playing video on load
		config["preloadBackColor"] = "#FFFFFF"; //background color while loading the player
		
		config["playerId"] = parseInt(pid);
		config["width"] = 790;
		config["height"] = 620;
		
		createExperience(config, 8);
	}
	return newhtml
}


//get twitter
var twits=3
function getTwitter(which)
{
	createRequest()
	var sel=''
	var url='/includes/gettwitter.asp'
	sel+='twits='+twits
	sel+='&feed='+which
	
	
	request.open("POST",url,true)

	request.onreadystatechange = updatetwitter
	request.setRequestHeader("Content-Type","application/x-www-form-urlencoded")
	request.send(sel)
}
var XMLdoc
var twarr= []
function updatetwitter()
{
	if(request.readyState==4)
	{

		//alert(request.responseText)
		if (request.status==200)
		{
			//var resp=request.responseText
			//alert(request.responseText)
			//parse response
			XMLdoc=request.responseXML
			var twarr= []
			var curdate=''
			var curtxt=''
			
			var stats=XMLdoc.getElementsByTagName('status')
			for(var x=0;x<twits;x++)
			{
				curdate=stats[x].getElementsByTagName('created_at')[0].firstChild.nodeValue
				curtxt=stats[x].getElementsByTagName('text')[0].firstChild.nodeValue
				curtxt=curtxt.replace(/\'/g,'&rsquo;')

				twarr.push(eval('[\''+curdate+'\',\''+curtxt+'\']'))
			}

			var twit=''
			for(var x=0;x<twits;x++)
			{
				curdate=twarr[x][0].split(' ')
				//fix time
				var curtime=curdate[3].split(':')
				var newtime
				if(curtime[0]<=12)
				{
					if(curtime[0]=='00')
					{
						newtime='12:'+curtime[1]
					}
					else
					{
						newtime=curtime[0]+':'+curtime[1]
					}
					newtime+=' AM'
				}
				else
				{
					newtime=(parseInt(curtime[0])-12)+':'+curtime[1]+' PM'
				}
				curdate=curdate[0]+' '+curdate[1]+' '+curdate[2]+' '+newtime
				
				var notopm=''
				if(x==0)
				{
					notopm='margin-top:0px;'
				}
				else
				{
					notopm=''
				}
				twit+='<div style="margin-bottom:10px;'+notopm+'"><div class="twittime">'+curdate+"</div>"
				curtxt=twarr[x][1]
				var findURL=curtxt.indexOf('http://')
				
				if(findURL > -1)
				{
					//extract the URL
					//find the next space
					var endspace=curtxt.indexOf(' ',findURL)
					if(endspace==-1)
					{
						endspace=curtxt.length
					}

					var curURL=curtxt.substring(findURL,endspace)
					//alert(curURL+' '+findURL+' '+endspace)
					//alert('findURL = '+findURL+'\nendspace = '+endspace+'\ncurURL = '+curURL+'\ncurtxt = '+curtxt)
					curtxt=curtxt.substring(0,findURL)+' <a href="'+curURL+'">'+curURL+'</a>'+curtxt.substring(endspace)
					//alert(curtxt)
				}
				twit+='<div class="twittxt">'+curtxt+'</div></div>\n'
			}

			twit+='<div style="margin-top:10px;"><a href="http://twitter.com/bgeaprayerteam">Follow Prayer Team on Twitter »</a></div>'
			document.getElementById('twitterbox').innerHTML=twit
		}
		else
		{
			//alert("The server said: "+request.status+'\n'+resp)
			document.getElementById('twitterbox').innerHTML='<span style="color:#FF0000">There was an error retrieving the Twitter updates</span>'
		}
	}
}

function addimgtitles()
{
	for(var x=0;x<document.images.length;x++)
	{
		document.images[x].title=document.images[x].alt
	}
}

/*==============================================================================================*/
function showpopup(idx)
{
	createmask()
	changedisplay(idx,'table')
	centerelement(idx)
}

function hidepopup(idx)
{
	removebox('bgeapagemask')
	
	if(gebid('flashObj') && (isie()))
	{
		if(isvisible('embedcontents'))
		{
			gebid('embedcontents').innerHTML=''
			/*var experienceID='flashObj'
			var bcExp = brightcove.getExperience(experienceID);
			if(bcExp != null)
			{
				modVP = bcExp.getModule(APIModules.VIDEO_PLAYER);
				modVP.stop()
			}*/
		}
		else if(isvisible('flashObj'))
		{
			var experienceID='flashObj'
			var bcExp = brightcove.getExperience(experienceID);
			if(bcExp != null)
			{
				modVP = bcExp.getModule(APIModules.VIDEO_PLAYER);
				modVP.stop()
			}
		}
	}
	gebid(idx).style.display='none'
}

function loadvid(idxs,title)
{

/*	var experienceID='myExperience'
	var bcExp = brightcove.getExperience(experienceID);
    modVP = bcExp.getModule(APIModules.VIDEO_PLAYER);
	modVP.stop()
*/
	var idarr=idxs.split('&')
	var cur,pid,vid,lid
	
	cur=idarr[0].split('=')
	pid=cur[1]
	cur=idarr[1].split('=')
	if(cur[1]!='')
	{
		vid='videoId='+cur[1]+'&'
	}
	else
	{
		vid=''
	}
	cur=idarr[2].split('=')
	if(cur[1]!='')
	{
		lid='lineupId='+cur[1]+'&'
	}
	else
	{
		lid=''
	}

	
	var embed='<object id="flashObj" width="776" height="410" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"	codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,47,0">\n'+
	  '<param name="movie" value="http://c.brightcove.com/services/viewer/federated_f9/'+pid+'?isVid=1&isUI=1&publisherID=1138077113" />\n'+
	  '<param name="bgcolor"	value="#FFFFFF" />\n'+
	  '<param name="flashVars" value="playerID='+pid+'&'+vid+''+lid+'domain=embed&" />\n'+
	  '<param name="base" value="http://admin.brightcove.com" />\n'+
	  '<param name="seamlesstabbing" value="false" />\n'+
	  '<param name="allowFullScreen" value="true" />\n'+
	  '<param name="swLiveConnect" value="true" />\n'+
	  '<param name="allowScriptAccess" value="always" />\n'+
	  '<embed src="http://c.brightcove.com/services/viewer/federated_f9/'+pid+'?isVid=1&isUI=1&publisherID=1138077113" bgcolor="#FFFFFF" flashvars="playerID='+pid+'&'+vid+''+lid+'domain=embed&" base="http://admin.brightcove.com" name="flashObj" width="776" height="410" seamlesstabbing="false" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" swliveconnect="true"	pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></embed>\n'+
	'</object>'
	
	gebid('embedcontents').innerHTML=embed
	gebid('CTVPopUpTitle').innerHTML=unescape(title)
	centerelement('popup_featuredvideo')
}
/*==============================================================================================*/
function get_url_parse(name)
{
	name = name.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");
	var regex = new RegExp("[\?&]"+name+"=([^&#]*)");
	var results = regex.exec(window.location.href); return results == null ? "" : results[1];
}

function createpopupvid(ts,projectid,projectuuid,videouuid,swf,bgcol,w,h,headertext)
{
	if(gebid('popup_featuredvideo'))
	{
		removebox('popup_featuredvideo')
	}
	if(gebid('bgeapagemask'))
	{
		removebox('bgeapagemask')	
	}
	
	
	createmask()
	
	var evname='mediaSuitePlayer_embedcontents'
	
	if(headertext=='')
	{
		headertext='Featured Video'
	}
	
	var popupdiv=''
	//popupdiv+='<div class="CTVPopUp" style="width:776px;display:none;" id="popup_featuredvideo">'
	popupdiv+='<div style="display:table;width:100%;"><p class="subtitle" style="float:left;" id="EmbeddedVidPopUpTitle">'+headertext+'</p><span onclick="removebox(\'popup_featuredvideo\');removebox(\'bgeapagemask\')" class="EmbeddedVidPopUpClose">CLOSE X</span></div>'
	popupdiv+='<div id="'+evname+'"></div>'
	//popupdiv+='</div>'
	
	x=document.createElement('div')
	x.setAttribute('id','popup_featuredvideo')
	x.className='EmbeddedVidPopUp'
	if((w==undefined) || (w==null))
	{
		x.style.width='776px'		
	}
	else
	{
		x.style.width=w+'px'
	}
	x.innerHTML=popupdiv
	
	document.body.insertBefore(x,document.body.firstChild)

	var programid=''
	if((videouuid!='') && ((videouuid!=null) && (videouuid!=undefined)))
	{
		//try to get programid from var passed to function
		programid=videouuid
	}

	if(programid=='')
	{
		//try to get program id from url
		programid = get_url_parse('video_uuid');
	}
	
	
	var playerDiv = document.getElementById(evname).style;
	playerDiv.display = "inline";
	//playerDiv.style.backgroundColor="#FFFFFF"
	var so = new SWFObject(swf, "live_player", w, h, "9", bgcol);
	so.addVariable("ts", ts);
	so.addVariable("projectid", projectid);
	so.addVariable("projectuuid", projectuuid);
	so.addVariable("programid", programid); //video_uuid
	so.addVariable("programuuid", programid); //video_uuid
	
	so.addVariable("gfToken", "");
	so.addVariable("loadingdomain", "http://mediasuite.multicastmedia.com");
	so.addVariable("serviceURL", "http://mediasuite.multicastmedia.com/services/index.php");
	so.addVariable("doResize", "false");
	so.addParam("allowFullScreen", "false");
	so.addParam("allowScriptAccess", "always");
	so.addVariable("typePlayer", "vod");
	so.addVariable("wmode", "transparent");
	
	so.write(evname);
	
	changedisplay('popup_featuredvideo','table')
	centerelement('popup_featuredvideo')
}

function createembeddedvid(ts,projectid,projectuuid,videouuid,swf,bgcol,w,h)
{
	var programid=''
	
	if((videouuid!='') && ((videouuid!=null) && (videouuid!=undefined)))
	{
		//try to get programid from var passed to function
		programid=videouuid
	}
	

	if(programid=='')
	{
		//try to get program id from url
		programid = get_url_parse('video_uuid');
	}
	
	var newobj=''
	
	newobj+='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab" width="'+w+'" height="'+h+'" id="Media Player" align="middle">\n'
	newobj+='<param name="movie" value="'+swf+'?ts='+ts+'&projectid='+projectid+'&projectuuid='+projectuuid+'&programid='+programid+'&programuuid='+programid+'&loadingdomain=http://mediasuite.multicastmedia.com&pagetype=&typePlayer=vod"/>\n'
	newobj+='<param name="quality" value="high" />\n'
	newobj+='<param name="wmode" value="transparent" />\n'
	newobj+='<param name="bgcolor" value="'+bgcol+'" />\n'
	newobj+='<param name="allowFullScreen" value="true" />\n'
	newobj+='<embed src="'+swf+'?ts='+ts+'&projectid='+projectid+'&projectuuid='+projectuuid+'&programid='+programid+'&programuuid='+programid+'&loadingdomain=http://mediasuite.multicastmedia.com&pagetype=&typePlayer=vod" quality="high" bgcolor="'+bgcol+'" width="'+w+'" height="'+h+'" allowFullScreen="true" name="Media Suite Flash Media Player" align="middle" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer" />\n'
	newobj+='</object>\n'
	
/*	newobj+='<object id="MCM_'+projectid+'" class="" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab" width="'+w+'" height="'+h+'" id="Media Player" align="middle">\n'
	newobj+='<param name="bgcolor" value="'+bgcol+'" />\n'
//	newobj+='<param name="width" value="'+w+'" />\n'
//	newobj+='<param name="height" value="'+h+'" />\n'
	newobj+='<param name="ts" value="'+ts+'" />\n'
	newobj+='<param name="projectid" value="'+projectid+'"/>\n'
	newobj+='<param name="projectuuid" value="'+projectuuid+'" />\n'
	newobj+='<param name="projectid" value="'+programid+'"/>\n'
	newobj+='<param name="projectuuid" value="'+programid+'" />\n'

	newobj+='<param name="movie" value="'+swf+'" />\n'
	newobj+='<param name="quality" value="high" />\n'
	newobj+='<param name="wmode" value="transparent" />\n'
	newobj+='<param name="allowFullScreen" value="true" />\n'
	newobj+='<param name="loadingdomain" value="http://mediasuite.multicastmedia.com" />\n'
	newobj+='<param name="pagetype" value="transparent" />\n'
	newobj+='<param name="typePlayer" value="vod" />\n'

	newobj+='</object>\n'
	*/
	
	return newobj
	/*
	var playerDiv = document.getElementById(evname).style;
	playerDiv.display = "inline";
	//playerDiv.style.backgroundColor="#FFFFFF"
	var so = new SWFObject(swf, "live_player", w, h, "9", bgcol);
	so.addVariable("ts", ts);
	so.addVariable("projectid", projectid);
	so.addVariable("projectuuid", projectuuid);
	so.addVariable("programid", programid); //video_uuid
	so.addVariable("programuuid", programid); //video_uuid
	
	so.addVariable("gfToken", "");
	so.addVariable("loadingdomain", "http://mediasuite.multicastmedia.com");
	so.addVariable("serviceURL", "http://mediasuite.multicastmedia.com/services/index.php");
	so.addVariable("doResize", "false");
	so.addParam("allowFullScreen", "false");
	so.addParam("allowScriptAccess", "always");
	so.addVariable("typePlayer", "vod");
	so.addVariable("wmode", "transparent");
	
	so.write(evname);
	*/
}