window.addEvent("domready", function(){
	(function(){
	
		// no video player, eject
		if (!$E('#movieinline')) { return; }
	
		var replace_player=new window['video']['_v']("/swf/qvc_video_player.swf", 'video_1', 210, 225, "8", "#f5f5f5", function(video){
			video.addVariable("configuration", "home");
			video.addVariable("debug", "false");
			video.addVariable("controlY", 0);
			video.addVariable("progressY", 0);
			video.addVariable("videoHeight", 300);
			video.addVariable("videoWidth", 686);
			video.addVariable("hideProgress", "auto");
			video.addVariable("giantPlayButtonScale", "100");
			video.addVariable("leftControls", "playButton, backButton, volumeSlider, 4");
			video.addVariable("leftDistanceBetween", "-1, -1, 3, 3");
			video.addVariable("rightControls", "expandButton");
			video.addVariable("rightDistanceBetween", "[0]");
			video.addVariable("isPlaying", false);
			video.addVariable("shouldMute", false);
			video.addVariable("expandPulseTime", 5000);
			
			video.addParam("scale", "noscale");
			video.addParam("salign", "tl")
			video.addParam("wmode", "transparent");
			
			
		});
		 
			
		window['video']['replace_player']=replace_player;
		
		var movPath = $E('.moviepath a').getProperty('href');

		// check to see if we should be playing something other than the live stream		
		var movMoreDet=$E('.moviemoredet a').getProperty('href');
		var re = /changeMovie\s*\(\s*'([^']*?)'\s*,\s*'([^']*?)'/i;
		var myArray;
		myArray = movMoreDet.match( re );
		
		// check to see if moviepath had an href to display of if moviemoredet class exists
		if( (movPath=='') && (myArray.length == 3) )
		{
			// if it doesn't exist, then default to the live stream
			// an href was specified. just go with it.
			
			window['video']['replace_player'].write($E('#movieinline'),686, 377,
					[['videoURI', myArray[1]], ['videoHeight', 300], ['videoWidth', 686], ['imageName', myArray[2]]
					],
				[]
			);
		}
		else
		{
			// if it doesn't exist, then default to the live stream
			window['video']['replace_player'].write($E('#movieinline'),686, 377,
				[['videoURI', movPath], ['videoHeight', 300], ['videoWidth', 686]],
				[]
			);
		
		}
		
		$isPlaying = true;
	})();
});


function changeMovie(movPath, keyframe) {
//try{console.log(keyframe)}catch(e){}
	var listContainer = $E('#movielistcontainer');
	/* listContainer.setStyle('top',205);
	listContainer.setStyle('height',168); */
	expanded = false;
	//alert(movPath+','+ $isPlaying+',' + false+ ','+ keyframe);
	//TEST TO SEE IF START TIME IS THERE
	$('video_1_holder').changeContent(window['video']['replace_player'], movPath, true, false, keyframe);
	//$('video_1').changeContent(movPath, $isPlaying, false, keyframe);
	
	//.changeContent(url, autoPlay, mute, imageName)
}

function thisMovie(movieName) {
	if (navigator.appName.indexOf("Microsoft") != -1) {
		return window[movieName];
	}else {
		return document[movieName];
	}
}

var expanded=false;
var $isPlaying = false;


function expandButtonPress() {
	var listContainer = $E('#movielistcontainer');
	var listContainer2 = $E('#moviewrapouter');
	var listContainer3 = $E('#video_1');
	if (!expanded) {
		listContainer.setStyle('top',10);
		listContainer.setStyle('height',373);
		listContainer2.setStyle('z-index',110);
		listContainer3.setStyle('margin-top',0);
		expanded = true;
	} else {
		listContainer.setStyle('top',205);
		listContainer.setStyle('height',165);
		listContainer2.setStyle('z-index',1);
		listContainer3.setStyle('margin-top',5);
		expanded = false;
	}
}
