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
	}

	if((pid=='')|| (pid==null) || (qs==''))
	{
		return ('<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
	{
		return ('<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>')
	}	
}


//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')
}
/*==============================================================================================*/
