var durtVideoR2L = 1500;
var durtT2B = 2000;
/*window.addEvent('domready', function(){
// START
// used in: Stanford_SoE_AJAX/imagine_the_future.html
// for: sliding in the you tube video from Right to Left 
// used in: Stanford_SoE_AJAX/imagine_the_future.html
// for: sliding in the you tube video from Right to Left 
// END
}); // DOM
*/

//setUpVideo();
urViewing=0;
function setUpVideo(){
	urViewing=0;
	/*var vd; 
	var vCount = 0;
	for(vd=0; vd<document.getElementById("allVideo").childNodes.length; vd++ ){
					var kid= document.getElementById("allVideo").childNodes[vd];
					
					if(kid.tagName=="DIV"){
						//alert(kid.id + " current Id " );
						if(kid.id.substring(0, 12)=="videoWrapper"){
							vCount++;
							 $('videoWrapper'+vCount).setStyle('width','0px');
							 $('videoWrapper'+vCount).setStyle('visibility','visible');

						}
					}
		}*/
		
		 $('allVideo').setStyle('height','0px');

	}
	
	
function showUtubeVideo(elem) {
	videoWrapper = 'videoWrapper'+elem;
	block = '.block'+elem;
	media = 'media_player_'+elem;

	// close the streaming of the previous vide which user had been viewing

/**************/
		if(urViewing){
			getFlashMovie("media_player_"+urViewing).closeVideoStream();
	 	}
/**************/

	if(urViewing==elem) {
		urViewing = 0;	
		$('allVideo').set('tween',{duration:durtT2B}).tween('height','0px');
		$(videoWrapper).set('tween',{}).tween('width','0px');
		$$(block).setStyle('color','black');
	} else {
		
		resetAll();
		
		$$(block).setStyle('color','#900');
		urViewing = elem;	
		$(videoWrapper).setStyle('visibility','visible');
		$('allVideo').set('tween',{}).tween('height','345px');
		$(videoWrapper).set('tween', {
			duration: durtVideoR2L,
			transition: Fx.Transitions.Quad.easeOut
		}).tween('width', '490px');
	}
}

function resetAll() {
	urViewing=0;
	
	
	var d; 
	var vW=0;
	for(d=0; d<document.getElementById("allVideo").childNodes.length; d++ ){
					var kid= document.getElementById("allVideo").childNodes[d];
					
					if(kid.tagName=="DIV"){
						//alert(kid.id + " current Id " );
						if(kid.id.substring(0, 12)=="videoWrapper"){
							vW++;
							 $('videoWrapper'+vW).set('tween',{}).tween('width','0px');
							 $$('.block'+vW).setStyle('color','black');
		
						}
					}
		}
		
}

 function getFlashMovie(movieName) {
  var isIE = navigator.appName.indexOf("Microsoft") != -1;
  return (isIE) ? window[movieName] : document[movieName];
 }
