// Read a page's GET URL variables and return them as an associative array.
function getRecoUrlVars()
{   var vars = [], hash;
    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
    for(var i = 0; i < hashes.length; i++)
    { hash = hashes[i].split('=');
      vars.push(hash[0]);
      vars[hash[0]] = hash[1];
    }
    return vars;
}


RecoURLVars = getRecoUrlVars();

//Shopping-Cart Recommendations
//---------------------------------------------------------------
if (typeof(CM_PageID) != 'undefined' && typeof(cmRecRequest) == 'function' && CM_PageID == "Warenkorb")
{ //Check ob Aufruf aus Masthead (Wenn 'search' equals 'cm_re=70_Toolbox-_-70_6_Warenkorb-_-70_6_Warenkorb')
  //if(!RecoURLVars["cm_re"])
  //{ //document.write('<scr' + 'ipt type="text/javascript" src="/dehtml/javascript/wk_a_zpfs.js">' + '<\/script>');
   //var arr_FindElements = document.getElementsByTagName("table");
   //var obj_CartIOTable  = arr_FindElements[arr_FindElements.length-5]; //5
     
   var int_LastProductID = CM_ProductID[CM_ProductID.length-1];
   //Check ob Artikel im WK sind
    if (typeof(int_LastProductID) != 'undefined')
	{ obj_CartIOTable = document.getElementsByName("KeepShopping").item(0).parentNode.parentNode.parentNode.parentNode;
      document.write('<style type="text/css">#reccomendations{ visibility: visible;}</style>');  
	  var str_newCartContent = '<div style="width:809px;position:relative;right:21px;text-align:center;" id="reccomendations"><br><table cellspacing="0" cellpadding="0" border="0" width="100%"><tr><td colspan="4" class="blau_00384A_12" bgcolor="d6e3f7" height="23">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<strong> Andere Kunden kauften auch</strong></td></tr><tr><td height="1" colspan="4"></td></tr><tr><td><div style="width:807px;border: 1px #e2e2e2 solid;text-align:center;"><img src="/degif/recoloader.gif" width="250"></div></td></tr></table><br></div>';
	  var tablerow  = obj_CartIOTable.insertRow(0);
	  var tablecell = tablerow.insertCell(0);
 	  tablecell.colSpan = "9";
      tablecell.align   = "right";	
	  tablecell.innerHTML = str_newCartContent;
	  //Request IO Output and Parse into site
	  cmRecRequest('wk_a',int_LastProductID,'');
	  cmDisplayRecs();
	 }
}






//Prod-Detail No-Hit Recommendations
//---------------------------------------------------------------
if (typeof(CM_PageID) == 'undefined')
 var str_TestPageID = "empty";
else
 var str_TestPageID = CM_PageID;

if ((typeof(cmRecRequest) == 'function') && (typeof(CM_ProdViewTag) == "undefined") && (window.location.href.search("app.detail/params.item") > 10) && str_TestPageID != "Warenkorb")
{ var arr_tmparray = window.location.href.split("item.");
  var int_LastProductID = arr_tmparray[1].charAt(0)+""+arr_tmparray[1].charAt(1)+""+arr_tmparray[1].charAt(2)+""+arr_tmparray[1].charAt(3)+""+arr_tmparray[1].charAt(4)+""+arr_tmparray[1].charAt(5);
 
  var arr_FindElements     = document.getElementsByTagName("td");
  var obj_CartIOTableCell  = arr_FindElements[arr_FindElements.length-15];
 
  var str_newCartContent = '<BR><BR><div style="width:809px;position:relative;left:15px;text-align:center;" id="reccomendations"><br><table cellspacing="0" cellpadding="0" border="0" width="100%"><tr><td colspan="4" class="blau_00384A_12" bgcolor="d6e3f7" height="23">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<strong> Andere Kunden kauften auch</strong></td></tr><tr><td height="1" colspan="4"></td></tr><tr><td><div style="width:807px;border: 1px #e2e2e2 solid;text-align:center;"><img src="/degif/recoloader.gif" width="250"></div></td></tr></table><br></div><BR><BR>';
  obj_CartIOTableCell.innerHTML = str_newCartContent;
  document.write('<style type="text/css">#reccomendations{ visibility: visible;}</style>');  

  //Request IO Output and Parse into site
  cmRecRequest('prod_a',int_LastProductID,'');
  cmDisplayRecs();
}




/*
//Prod-Detail Recommendations
//---------------------------------------------------------------
if ((typeof(cmRecRequest) == 'function') && (typeof(CM_ProdViewTag) != "undefined") && (document.getElementById("reccomendations") != null))
{ if(CM_ProdViewTag)
  { //Save manual recos
    str_ManualReco = document.getElementById("reccomendations").innerHTML; 

	var str_LoaderContent = "";
	var str_RecoHeader    = "";
	
	//Check if Manual Reco was set - if not put own header
	if(str_ManualReco.length < 100)
	{ str_RecoHeader = '<div style="top:0px;margin-top:-52px;left:0px;margin-left:-4px;"><div style="position:absolute;z-index:999"><img height="52" width="160" src="/degif/pd_tabre_oben_reco.gif"></div></div><br><br><br>';
	}
	
	//Display Recommendationloader
    str_LoaderContent += str_RecoHeader;
	str_LoaderContent += '<table cellspacing="0" cellpadding="0" border="0" width="156"><tbody><tr>';
	str_LoaderContent += '<td bgcolor="#e2e2e2" width="1"><img height="10" width="1" src="http://www.qvc.de/degif/abstandhalter.gif"></td>';
	str_LoaderContent +='<td width="13"><img height="11" width="13" src="http://www.qvc.de/degif/pd_tabeoben_1.gif"></td>';
	str_LoaderContent +='<td width="137"><img height="11" width="137" src="http://www.qvc.de/degif/pd_tabeoben_2.gif"></td>';
	str_LoaderContent +='<td colspan="2"><img height="11" width="5" src="http://www.qvc.de/degif/pd_tabecke_reob.gif"></td>';
	str_LoaderContent +='</tr><tr><td bgcolor="#e2e2e2" width="1" rowspan="22"><img height="10" width="1" src="http://www.qvc.de/degif/abstandhalter.gif"></td>';

	str_LoaderContent +='<td align="center" colspan="2">';
	str_LoaderContent +='<br><br><br><br><img src="/degif/recoloader2.gif" width="96" height="104"><br><br><br><br><br><br><br><br><br>';
	str_LoaderContent +='</td>';
	str_LoaderContent +='<td width="4">&nbsp;</td><td bgcolor="#e2e2e2" width="1" rowspan="22"><img height="10" width="1" src="http://www.qvc.de/degif/abstandhalter.gif"></td>';
	str_LoaderContent +='</tr><tr><td colspan="3"><img height="7" width="10" src="http://www.qvc.de/degif/abstandhalter.gif"></td>';
	str_LoaderContent +='</tr><tr><td>&nbsp;</td><td class="grau_73797B_12">&nbsp;</td><td>&nbsp;</td>';
	str_LoaderContent +='</tr><tr><td colspan="3"><img height="7" width="10" src="http://www.qvc.de/degif/abstandhalter.gif"></td>';
	str_LoaderContent +='</tr><tr><td bgcolor="#e2e2e2" colspan="5"><img height="1" width="10" src="http://www.qvc.de/degif/abstandhalter.gif"></td></tr></tbody></table>';

    document.getElementById("reccomendations").innerHTML = str_LoaderContent;
    document.write('<style type="text/css">#reccomendations{ visibility: visible;}</style>');  

    //Request IO Output and Parse into site
    cmRecRequest('prod_a',CM_ProductID,'');
    cmDisplayRecs();	
  }
}
*/

//Prod-Detail Recommendations (do not show if manual recos were set)
//---------------------------------------------------------------
if ((typeof(cmRecRequest) == 'function') && (typeof(CM_ProdViewTag) != "undefined") && (document.getElementById("reccomendations") != null))
{ if(CM_ProdViewTag)
  { //Save manual recos
    str_ManualReco = document.getElementById("reccomendations").innerHTML; 

	var str_LoaderContent = "";
	var str_RecoHeader    = "";
	
	//Check if Manual Reco was set - if not show dynamic recommendations
	if(str_ManualReco.length < 100)
	{ str_RecoHeader = '<div style="top:0px;margin-top:-52px;left:0px;margin-left:-4px;"><div style="position:absolute;z-index:999"><img height="52" width="160" src="/degif/pd_tabre_oben_reco.gif"></div></div><br><br><br>';
	  
	  //Display Recommendationloader
      str_LoaderContent += str_RecoHeader;
	  str_LoaderContent += '<table cellspacing="0" cellpadding="0" border="0" width="156"><tbody><tr>';
	  str_LoaderContent += '<td bgcolor="#e2e2e2" width="1"><img height="10" width="1" src="http://www.qvc.de/degif/abstandhalter.gif"></td>';
	  str_LoaderContent +='<td width="13"><img height="11" width="13" src="http://www.qvc.de/degif/pd_tabeoben_1.gif"></td>';
	  str_LoaderContent +='<td width="137"><img height="11" width="137" src="http://www.qvc.de/degif/pd_tabeoben_2.gif"></td>';
	  str_LoaderContent +='<td colspan="2"><img height="11" width="5" src="http://www.qvc.de/degif/pd_tabecke_reob.gif"></td>';
	  str_LoaderContent +='</tr><tr><td bgcolor="#e2e2e2" width="1" rowspan="22"><img height="10" width="1" src="http://www.qvc.de/degif/abstandhalter.gif"></td>';

	  str_LoaderContent +='<td align="center" colspan="2">';
	  str_LoaderContent +='<br><br><br><br><img src="/degif/recoloader2.gif" width="96" height="104"><br><br><br><br><br><br><br><br><br>';
	  str_LoaderContent +='</td>';
	  str_LoaderContent +='<td width="4">&nbsp;</td><td bgcolor="#e2e2e2" width="1" rowspan="22"><img height="10" width="1" src="http://www.qvc.de/degif/abstandhalter.gif"></td>';
	  str_LoaderContent +='</tr><tr><td colspan="3"><img height="7" width="10" src="http://www.qvc.de/degif/abstandhalter.gif"></td>';
	  str_LoaderContent +='</tr><tr><td>&nbsp;</td><td class="grau_73797B_12">&nbsp;</td><td>&nbsp;</td>';
	  str_LoaderContent +='</tr><tr><td colspan="3"><img height="7" width="10" src="http://www.qvc.de/degif/abstandhalter.gif"></td>';
	  str_LoaderContent +='</tr><tr><td bgcolor="#e2e2e2" colspan="5"><img height="1" width="10" src="http://www.qvc.de/degif/abstandhalter.gif"></td></tr></tbody></table>';

      document.getElementById("reccomendations").innerHTML = str_LoaderContent;
      document.write('<style type="text/css">#reccomendations{ visibility: visible;}</style>');  

      //Request IO Output and Parse into site
      cmRecRequest('prod_a',CM_ProductID,'');
      cmDisplayRecs();
    }
	else
	{ document.write('<style type="text/css">#reccomendations{ visibility: visible;}</style>');  
	}
  }
}

