videoCurrent = "";

videoDiv = "";

function videoSwap(swf,width,height)
{	
	if(videoCurrent == swf)
	{
		
		if(!$('videoPlayerContainer').visible())
		{ new Effect.Grow('videoPlayerContainer', {direction: 'top-left', duration: '.5', queue: { position: 'end', scope: 'menuxscope' },
						  beforeStart: function (){  },
						  afterFinish: function(){ 	videoEmbed(swf,width,height); 
						  							DisableEnableVideoLinks(false,$('videoList').getElementsByTagName("a")); 
													$('videoClose').show();
													}});
		}
		else
		{ new Effect.Shrink('videoPlayerContainer', {direction: 'top-left', duration: '.5', queue: { position: 'end', scope: 'menuxscope' },
						  beforeStart: function (){	$('videoPlayer').hide();
						  							DisableEnableVideoLinks(true,$('videoList').getElementsByTagName("a")); 
													$('videoClose').hide();
													},
						  afterFinish: function(){	
						  swfobject.removeSWF("videoPlayer"); 
						  DisableEnableVideoLinks(false,$('videoList').getElementsByTagName("a"));}});
		  	videoCurrent = "";
		  	videoWidth = 0;
			videoHeight = 0;
		}		
	}
	else
	{
		
		videoCurrent = swf;
	
		if(!$('videoPlayerContainer').visible())
		{ new Effect.Grow('videoPlayerContainer', {direction: 'top-left', duration: '.5', queue: { position: 'end', scope: 'menuxscope' }, 
						  beforeStart: function (){DisableEnableVideoLinks(true,$('videoList').getElementsByTagName("a")); }, 
						  afterFinish: function(){	videoEmbed(swf,width,height);
						  							DisableEnableVideoLinks(false,$('videoList').getElementsByTagName("a")); 
													$('videoClose').show();
													}});
		}
		else
		{ 	
			new Effect.Shrink('videoPlayerContainer', {direction: 'top-left', duration: '.5', queue: { position: 'end', scope: 'menuxscope' }, 
							beforeStart: function(){$('videoPlayer').hide();
														DisableEnableVideoLinks(true,$('videoList').getElementsByTagName("a"));	
														
							  							$('videoClose').hide();
														} , 
							afterFinish: function (){swfobject.removeSWF("videoPlayer"); videoSwap(swf,width,height); }});
		} 
	}
}

function videoEmbed(swf,Xwidth,Xheight)
{ 
 	// check if SWF hasn't been removed, if this is the case, create a new alternative content container
 	if (!swfExists()) {
  		var d = document.createElement("div");
  		d.setAttribute("id", "videoPlayer");
  		$('videoPlayerContainer').appendChild(d);
 	}
 
 	if(Xwidth > 0)
 		$('videoPlayer').setStyle({width: Xwidth, height: Xheight});
 	
	flashvars = {};
 
 	params = {};
 
 	params.allowFullScreen = true;
 
 	attributes = {};
 
 	if(Xwidth > 0)
  		swfobject.embedSWF(swf, "videoPlayer", Xwidth, Xheight, "9.0.0","expressInstall.swf", flashvars, params, attributes); 
 	else {
		
		$('videoPlayer').innerHTML = '';
 
  		d1 = document.createElement("a");
  		if(swf == 'structure/videoslider/weather-alerts.jpg')
   			d1.setAttribute("href", "http://www.lonestar.edu/12803.htm");
  		else if(swf == 'structure/videoslider/UP-center.jpg') {
   			d1.setAttribute("href", "http://www.lonestar.edu/12801.htm");
  		}
  
  		var d2 = document.createElement("img");
  		d2.setAttribute("id", "bigSliderImage");
  		d2.setAttribute('border',0);
		$(d2).setStyle({width: 320, marginTop:8});
  		d2.setAttribute('src',swf);
 
  		$(d1).appendChild(d2);
  
  		$('videoPlayer').appendChild(d1);
  		$('videoPlayer').show();
 
 	}
}


function setDiv(whichDiv)
{
	videoDiv = whichDiv;
}

function videoClose()
{
	if(swfExists() && videoCurrent != '')	videoSwap(videoCurrent);
	return;
}

function swfExists()
{
	if ($('videoPlayer')) return true;
	else return false;
}

function DisableEnableVideoLinks(xHow,xWhat)
{
	$$('.overLayers').each(function(item){$(item).toggle();});
	
	if(navigator.userAgent.toLowerCase().indexOf('chrome') > -1)
		{ return; }
	else { return DisableEnableLinks(xHow,xWhat);	}
}
