
// MN Flag user clicked on swatch or not
var userClickSwatch = false;
var userClickVideo = false;

function SelectThumb(swatchID, newImage, isZoom)
{
	
  //alert('swatchID = ' + swatchID + ', newImage = ' + newImage + ', isZoom = ' + isZoom);

  if(isZoom == "Y")
  {
	  //Hide the static image and show the zoom image
	  document.getElementById('staticImage').style.display = "none";
	  document.getElementById('zoomImage').style.display = "";
	
	  //Hide the "no zoom" message and show the zoom controls
	  document.getElementById('noZoomMessage').style.display = "none";
	  document.getElementById('zoomControls').style.display = "";
	
	  //Load the new swatch into the zoom image
	  tsz15042.setImage(newImage,true);
  }
  else
  {
	  //Hide the zoom image and show the static image
	  document.getElementById('zoomImage').style.display = "none";
	  document.getElementById('staticImage').style.display = "";
	
	  //Hide the zoom controls and show the "no zoom" message
	  document.getElementById('zoomControls').style.display = "none";
	  document.getElementById('noZoomMessage').style.display = "";
	
	  //Load the new swatch into the static image
	  document.LargeImg.src = newImage;
  }

  //Reset the borders on all swatches
  ResetBorders();
  
  //Highlight the selected swatch
  document.images[swatchID].border = 1;
  document.images[swatchID].className = "highlightSwatch";

}

function ResetBorders()
{
  var i, imageCount;
  var strName = "";
  imageCount = document.images.length;
  
  for (i=0;i < imageCount; i++){
	  strName = document.images[i].name;

	  if(strName.indexOf("Thumb_") != -1){
		  document.images[i].border = 1;
		  document.images[i].className = "swatchBorder";
	  }
  }
}

function ChangeTab(form, selectedViewOption)
{
  form.viewOption.value = selectedViewOption;

  if(form.cont)
  {
		form.cont.value = selectedViewOption;
  }
 
  form.submit();
}

var video;

function StopVideo(selectedViewOption){
	if(!userClickVideo){
		if(selectedViewOption != "WATCHVIDEO"){
			if(document.getElementById("medPlayer") && document.getElementById("divVideo")){
				if (window.ActiveXObject && (navigator.userAgent.indexOf('Windows') != -1)){
					objMediaPlayer = document.getElementById("medPlayer");
					objMediaPlayer.stop();
				}else{
					objMediaPlayer = document.getElementById("divVideo");
					objMediaPlayer.innerHTML = '<embed type="application/x-mplayer2" src="" name="medPlayer" id="medPlayer" autostart="0" showcontrols="1" showstatusbar="1" width="352" height="333" displaysize="0" border="0" autosize="0" volume="1" pluginspage="http:\/\/www.microsoft.com\/Windows\/Downloads\/Contents\/Products\/MediaPlayer\/"><\/embed>';
				}
			}
		}
		userClickVideo = true;
	}
}

function queryStringForDE(val){var q = unescape(window.top.location.search.substr(1)).split('&');for(var i=0; i<q.length; i++){var t=q[i].split('=');if(t[0].toLowerCase()==val.toLowerCase()) return t[1];}return '';}

function writeVideo(){
	var product = queryStringForDE('item');
		video = "mms://wms.0D89.edgecastcdn.net/000D89/wm/" + product.substr(0,1) + "/" + product.substr(product.length-2,2) + "/" + product + ".wmv";
	
	document.write('<div id="divVideo">');		
		document.write('<embed type="application/x-mplayer2" src="'+video+'" name="medPlayer" id="medPlayer" autostart="1" showcontrols="1" showstatusbar="1" width="352" height="333" displaysize="0" border="0" autosize="0" volume="1" pluginspage="http:\/\/www.microsoft.com\/Windows\/Downloads\/Contents\/Products\/MediaPlayer\/"><\/embed>');
		document.write('<noembed>This browser appears to be unable to display clips inline the player.<br /><a href="'+video+'">&gt;Play the clip in Windows Media Player<\/a><\/noembed>');
	document.write('<\/div>');
}

function writePackShotVideo(){
	var product = queryStringForDE('item');
		video = "mms://wms.0D89.edgecastcdn.net/000D89/wm/" + product.substr(0,1) + "/" + product.substr(product.length-2,2) + "/p" + product + ".wmv";
	
	document.write('<div id="divVideo">');		
		document.write('<embed type="application/x-mplayer2" src="'+video+'" name="medPlayer" id="medPlayer" autostart="1" showcontrols="1" showstatusbar="1" width="352" height="333" displaysize="0" border="0" autosize="0" volume="1" pluginspage="http:\/\/www.microsoft.com\/Windows\/Downloads\/Contents\/Products\/MediaPlayer\/"><\/embed>');
		document.write('<noembed>This browser appears to be unable to display clips inline the player.<br /><a href="'+video+'">&gt;Play the clip in Windows Media Player<\/a><\/noembed>');
	document.write('<\/div>');
}

function writeVideoASX(videoFileName){
	
	video = "/asx/" + videoFileName;
	
	document.write('<div id="divVideo">');		
		document.write('<embed type="application/x-mplayer2" src="'+video+'" name="medPlayer" id="medPlayer" autostart="1" showcontrols="1" showstatusbar="1" width="352" height="333" displaysize="0" border="0" autosize="0" volume="1" pluginspage="http:\/\/www.microsoft.com\/Windows\/Downloads\/Contents\/Products\/MediaPlayer\/"><\/embed>');
		document.write('<noembed>This browser appears to be unable to display clips inline the player.<br /><a href="'+video+'">&gt;Play the clip in Windows Media Player<\/a><\/noembed>');
	document.write('<\/div>');
}

function writeBrandVideo(videoFileName){
	
	video = "/degif/moreinfo/" + videoFileName;
	
	document.write('<div id="divVideo">');		
		document.write('<embed type="application/x-mplayer2" src="'+video+'" name="medPlayer" id="medPlayer" autostart="1" showcontrols="1" showstatusbar="1" width="352" height="333" displaysize="0" border="0" autosize="0" volume="1" pluginspage="http:\/\/www.microsoft.com\/Windows\/Downloads\/Contents\/Products\/MediaPlayer\/"><\/embed>');
		document.write('<noembed>This browser appears to be unable to display clips inline the player.<br /><a href="'+video+'">&gt;Play the clip in Windows Media Player<\/a><\/noembed>');
	document.write('<\/div>');
}

function SelectThumbFrames(img_id,filename)
{
  parent.leftFrame.document.LargeImg.src=filename;
  ResetBorders();
  document.images[img_id].border = 1;
  document.images[img_id].className = "highlightSwatch";
}

function CheckBrowserType()
{
  var OP=(window.opera)?true:false; 
  var NS=(navigator.appName=="Netscape"&&!OP)?true:false; 
  var IE=(document.all &&!OP)?true:false; 

	if(NS)
	{
		document.forms[0].ShiptoFirstName.value = document.forms[0].eval(nick).getAttribute('adname');

	}
	if(IE)
	{

		document.all.item('ShiptoABNickName').value = nick;

	}
	if(OP)
	{

		document.all.item('ShiptoFirstName').value = document.all.item(nick).getAttribute('adname');

	}
}

function open_video_help(url){
      var new_win = window.open(url, "new_win", "Height=500,Width=640,scrollbars=1");
	new_win.focus();
}

function goToDetail(itemNumber){
	opener.location.href = "http://www.qvc.de/deqic/qvcapp.aspx?app=detail&params=item^"+itemNumber+",frames^y,from^se";
	self.close();
}
