﻿// IWM v1.5.1 cookie enabled displaylinks auto fill blank columns and calendar

// FUNCTION DISPLAY DETAILS IN A DIV: ajaxpage(gotoURL, 'contentarea')
/***********************************************
* Dynamic Ajax Content- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

var bustcachevar=1 //bust potential caching of external pages after initial request? (1=yes, 0=no)
var loadedobjects=""
var rootdomain="http://"+window.location.hostname
var bustcacheparameter=""

if (!profilerCookieValue) var profilerCookieValue = "END";

function ajaxpage2(url, containerid){
var page_request = false
var tempArray = url.split("|")
url = tempArray[0]
var product = tempArray[1]
if (window.XMLHttpRequest) // if Mozilla, Safari etc
page_request = new XMLHttpRequest()
else if (window.ActiveXObject){ // if IE
try {
page_request = new ActiveXObject("Msxml2.XMLHTTP")
} 
catch (e){
try{
page_request = new ActiveXObject("Microsoft.XMLHTTP")
}
catch (e){}
}
}
else
return false
page_request.onreadystatechange=function(){
loadpage3(page_request, url, product, containerid)
}
page_request.open('GET', url, true)
page_request.send(null)
}


function loadpage3(page_request, url, product, containerid){
if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1)){
      if (page_request.responseText.match("cannot be found")) {
      getNextID(containerid)
      }
      else {
	var finalContent = getContent(url, product, "")
      document.getElementById(containerid).innerHTML= finalContent
      }
}
}

function getNextID(containerid)
{
if(ContentCount < ContentList.length-1)
	{
	if(ContentCount < 3) ContentCount = 3;
	var contentnum = ContentCount;
	ContentCount++;
	var target3 = "http://profilertracking3.com/iwm/update_prod.asp?HREF=" + url + "&prodprice=0";
	loadobjs(target3);
	if(ContentList[contentnum]) ajaxpage2(ContentList[contentnum], containerid);
	}
}


function getContent(page_url, product_details, response_text)
{

product_details = product_details.replace("undefined", " ");
product_details = product_details.replace("<prodname>", "");	// 0 = name
product_details = product_details.replace("<prodprice>", "|");	// 1 = price
product_details = product_details.replace("<prodimage>", "|");	// 2 = image

var prodArray = product_details.split("|");


// delete product id

prodArray[0] = prodArray[0].replace(/-.+/, "");
if(page_url.match(/\?/)) page_url = page_url + "&CT=1";
else page_url = page_url + "?CT=1";

var innerContent = '<table width="100" border="0" cellspacing="0" cellpadding="0"><tr bgcolor="#CCCCCC"><td width="100"><A href="' +  page_url + '" style="font-size: 10px;color: #CCCCCC;" onClick="profilerLink()"><IMG title="' +  prodArray[0] + '" alt="' +  prodArray[0] + '" src="' +  prodArray[2] + '" border=0 width="100"></A></td></tr><tr bgcolor="#CCCCCC"><td width="100" height="10" bgcolor="#FFFFFF" ></td></tr><tr bgcolor="#CCCCCC"><td width="100" bgcolor="#FFFFFF" style="font-family: Arial, Helvetica, sans-serif;font-size: 11px;font-style: normal;font-weight: bold;color: #000;text-align: center;"><A href="' +  page_url + '" onClick="profilerLink()">' +  prodArray[0] + '</A></td></tr><tr bgcolor="#CCCCCC"><td width="100" height="10" bgcolor="#FFFFFF" ></td></table>';
return innerContent;
}


function loadpage(page_request, containerid){
if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1))
document.getElementById(containerid).innerHTML=page_request.responseText
}

function loadobjs(){
if (!document.getElementById)
return
for (i=0; i<arguments.length; i++){
var file=arguments[i]
var fileref=""
if (loadedobjects.indexOf(file)==-1){ //Check to see if this object has not already been added to page before proceeding
if (file.indexOf(".asp")!=-1){ //If object is a js file
fileref=document.createElement('script')
fileref.setAttribute("type","text/javascript");
fileref.setAttribute("src", file);
}
else if (file.indexOf(".css")!=-1){ //If object is a css file
fileref=document.createElement("link")
fileref.setAttribute("rel", "stylesheet");
fileref.setAttribute("type", "text/css");
fileref.setAttribute("href", file);
}
}
if (fileref!=""){
document.getElementsByTagName("head").item(0).appendChild(fileref)
loadedobjects+=file+" " //Remember this object as being already added to page
}
}
}

function writeDivs()
{
var content = '<!-- start profiler table --><table width="160" border="0" cellspacing="0" cellpadding="0"><tr><td height="22" colspan="3" bgcolor="#999999" style="font-family: Arial, Helvetica, sans-serif;font-size: 12px;font-style: normal;font-weight: bold;color: #000;text-align: center;">Shop online</td></tr><tr bgcolor="#CCCCCC"><td width="30" height="10" bgcolor="#FFFFFF" ></td><td width="100" height="10" bgcolor="#FFFFFF" ></td><td width="30" height="10" bgcolor="#FFFFFF" ></td></tr><tr bgcolor="#CCCCCC"><td width="30" bgcolor="#FFFFFF" ></td><td width="100" bgcolor="#FFFFFF" ><DIV id="Profiler1"></DIV></td><td width="30" bgcolor="#FFFFFF" ></td></tr><tr bgcolor="#CCCCCC"><td width="30" height="1" bgcolor="#FFFFFF" ></td><td width="100" height="1" bgcolor="#FFFFFF"></td><td width="30" height="1" bgcolor="#FFFFFF" ></td></tr><tr bgcolor="#CCCCCC"><td width="30" height="10" bgcolor="#FFFFFF" ></td><td width="100" height="10" bgcolor="#FFFFFF" ></td><td width="30" height="10" bgcolor="#FFFFFF" ></td></tr><tr bgcolor="#CCCCCC"><td width="30" bgcolor="#FFFFFF"></td><td width="100" bgcolor="#FFFFFF"><DIV id="Profiler2"></DIV></td><td width="30" bgcolor="#FFFFFF"></td></tr><tr bgcolor="#CCCCCC"><td width="30" bgcolor="#FFFFFF">&nbsp;</td><td width="100" bgcolor="#FFFFFF"></td><td width="30" bgcolor="#FFFFFF"></td></tr></table><!-- end profiler table -->';
document.getElementById("whole").innerHTML=content;
}

if (document.getElementById('whole')) {

if (!document.location.href.match("https:")) {
var target = "http://profilertracking3.com/iwm/suggestPages_inside_iwm.asp?HREF=" + document.location.href + "&TITLE=" + document.title + "&PLINK=" + profilerCookieValue;
} else {
var target = "https://profilertracking3.com/iwm/suggestPages_inside_iwm.asp?HREF=" + document.location.href + "&TITLE=" + document.title + "&PLINK=" + profilerCookieValue;
}
loadobjs(target);
}

if(!document.getElementById("whole")) // if no display div 
{
// check if section OK
if((document.title.match(/What.+?On/) || document.title.match(/Exhibitions/) || document.title.match(/Outbreak.+?Poster Gallery/) || document.title.match(/Outbreak.+?Photo Gallery/)) && (!document.title.match(/Holocaust/) && !document.title.match(/Press/) && !document.title.match(/News/))) 
{
var rightcontent = "" + document.getElementById("rightColumn").innerHTML;
rightcontent=rightcontent.replace(/<div.+?calendarContaine.+?>/i, "");

 if(!rightcontent.match(/<div.+?class+?>/i, "")) // if right hand column empty or only calendar
 {
document.getElementById("rightColumn").innerHTML=document.getElementById("rightColumn").innerHTML + '<div id="whole"></div>';

if (!document.location.href.match("https:")) {
var target = "http://profilertracking3.com/iwm/suggestPages_inside_iwm.asp?HREF=" + document.location.href + "&TITLE=" + document.title + "&PLINK=" + profilerCookieValue;
} else {
var target = "https://profilertracking3.com/iwm/suggestPages_inside_iwm.asp?HREF=" + document.location.href + "&TITLE=" + document.title + "&PLINK=" + profilerCookieValue;
}
loadobjs(target);
}

 }
}


