/* IMPORTANT: COREMETRICS LIBRARY HAS TO BE LOADED FIRST  <------------------------------------------ 
*********************************************************
*********************************************************/

/****************** Configuration **********************
// Debug-Mode true||false > prevent Cookies from beeing set
// Distribution {in int_Variance / 100 = %   [4 = 25%] [3 = 33%] [2 = 50%]}
// Cookie Lifetime in Days
*******************************************************/
int_Debug          = false;
int_Variance       = 2;  
int_CookieDuration = 1;   
/***************** Variant Definition ******************
[0] = always Default Variant
*******************************************************/


//TAG Artikelnummer ermitteln und Content entsprechend setzen
var tdElement = document.getElementById("tagImageLeft");
var imgElement = tdElement.getElementsByTagName("IMG");
var artNr = imgElement[0].alt.slice(0, 6);
 
		   
/***************** Tracking Definition ******************
same indexes as Variant Definitions
[0] = always Default Variant
str_VariantTracking[] = CM Site Promotion Parameter
***************************************************/
var str_VariantTracking = new Array(); 
str_VariantTracking[0] = 'HP_TAG_AB_Test-_-Version_A-_-'; //Artikelnummer wird im Javascript angehängt!!!!!!!!
str_VariantTracking[1] = 'HP_TAG_AB_Test-_-Version_B-_-'; //





/****************** ETC Functions **********************
#
*******************************************************/
function setCookie(c_name,value,expiredays)
{ var exdate=new Date();
  //Cookie auf den nächsten Tag 0:00 Uhr setzen
  exdate.setDate(exdate.getDate()+expiredays);
  exdate.setHours(0);
  exdate.setMinutes(0);
  exdate.setSeconds(0);
 
  document.cookie=c_name+ "=" +escape(value)+  ((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}
function getCookie(c_name)
{ if (document.cookie.length>0)
  { c_start=document.cookie.indexOf(c_name + "=");
    if (c_start!=-1)
    { c_start=c_start + c_name.length+1;
      c_end=document.cookie.indexOf(";",c_start);
      if (c_end==-1) c_end=document.cookie.length;
       return unescape(document.cookie.substring(c_start,c_end));
    }
  }
return "";
}
var isFunction = function(o) {
return typeof(o) == 'function' && (!Function.prototype.call ||
typeof(o.call) == 'function');
};

function showSWF(artID)
{
// Flash-Film einbetten
	AC_FL_RunContent(
		'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,124,0',
		'width', '240',
		'height', '133',
		'src', 'http://www.qvc.de/dehtml/flash/file_'+artID,
		'quality', 'high',
		'pluginspage', 'http://www.adobe.com/go/getflashplayer',
		'align', 'middle',
		'play', 'true',
		'loop', 'true',
		'scale', 'showall',
		'wmode', 'transparent',
		'devicefont', 'false',
		'id', '/dehtml/flash/file_'+artID,
		'bgcolor', '#ffffff',
		'name', '/dehtml/flash/file_'+artID,
		'menu', 'true',
		'allowFullScreen', 'false',
		'allowScriptAccess','sameDomain',
		'movie', 'http://www.qvc.de/dehtml/flash/file_'+artID,
		'salign', ''
		); //end AC code

}

	 
/******************* Define Variant ********************
#
*******************************************************/
//Check for Variant Cookie & define Variant if not set
qvc_abvariant = getCookie('qvc_abvariant');
if (qvc_abvariant!=null && qvc_abvariant!="" && !int_Debug)
{ int_VarSwitchtest = qvc_abvariant;
}
else
{ int_randomseed = Math.random();
  int_VarSwitchtest = Math.floor(int_randomseed*int_Variance);
  //Flash check:
  var hasRightVersion = DetectFlashVer("9", "0", "124");
  //Falls kein Flash, Variante 0.
  if(!hasRightVersion) int_VarSwitchtest=0; 
    
  setCookie('qvc_abvariant',int_VarSwitchtest,int_CookieDuration); 
}

// zum testen!!!!!!!!
//int_VarSwitchtest = 1;

/******************** View Variant *********************
#
*******************************************************/
//Check ob Produkt eine Message erhalten soll      
if(artNr=="872472" || artNr=="467210" || artNr=="830750" || artNr=="872426")
{ var str_TrackingOutput = str_VariantTracking[int_VarSwitchtest];
  // Show SWF?
  //alert(document.getElementById("newnamemessage").style.zIndex = '-100');
  if (int_VarSwitchtest == 1) showSWF(artNr); else document.getElementById("newnamemessage").style.zIndex = '-100';	
  //Call Tracking Request
  cmCreateManualLinkClickTag('http://www.qvc.de/?cm_sp=' + str_TrackingOutput + artNr);
}
else
{ //div ausblenden, falls nicht das richtige TAG
	document.getElementById("newnamemessage").style.zIndex = '-100'
}