﻿var objCZoomifyCollection = new Array();
var i=0,j;
var MM_contentVersion = 6;
var MM_FlashCanPlay;
var plugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;
if ( plugin ) {
		var words = navigator.plugins["Shockwave Flash"].description.split(" ");
	    for (var count = 0; count < words.length; ++count)
	    {
		if (isNaN(parseInt(words[count])))
		continue;
		var MM_PluginVersion = words[count]; 
	    }
	MM_FlashCanPlay = MM_PluginVersion >= MM_contentVersion;
}
else if (navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0 
   && (navigator.appVersion.indexOf("Win") != -1)) {
	document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n'); //FS hide this from IE4.5 Mac by splitting the tag
	document.write('on error resume next \n');
	document.write('MM_FlashCanPlay = ( IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & MM_contentVersion)))\n');
	document.write('</SCR' + 'IPT\> \n');
}
function CZoomify(_imgArr, _titleArr, _descArr, _altTextArr, _folderArr)
{
	this.imgArr = _imgArr;
	this.titleArr= _titleArr;
	this.descArr= _descArr;
	this.altTextArr= _altTextArr;
	this.folderArr= _folderArr;
}
function disableAnchor(anchorId)
{
    var obj = document.getElementById(anchorId);
    var href = obj.getAttribute("href"); 
    var onclick = obj.getAttribute("onclick"); 
    //First we store previous value in a new attribute 
    if(href && href != "" && href != null) 
    { 
        obj.setAttribute('href_bak', href); 
    } 
    if(onclick != null) 
    { 
        obj.setAttribute('onclick_back', onclick); 
        obj.setAttribute('onclick', "void(0);"); 
    } 
    return false;
}
function enableAnchor(anchorId)
{
    var obj = document.getElementById(anchorId);
    var hrefBack = obj.getAttribute("href_bak"); 
    var onclickBack = obj.getAttribute("onclick_back"); 
    if(onclickBack !=null ) 
    { 
        obj.setAttribute('onclick', onclickBack); 
        obj.removeAttribute('onclick_back'); 
    } 
    if(hrefBack !=null ) 
    { 
        obj.setAttribute('href', hrefBack); 
        obj.removeAttribute('href_bak'); 
    } 
    return false;
}
function isAnchorDisabled(obj)
{        
    var href = obj.getAttribute("href");
    if(href && href != "" && href != null)
    {
        return false;
     }
    else
    {
        return true;
    }
}
function fnLeft()
{	
	if(i==0)
    {
        i=objCZoomifyCollection[currentYear - 1].imgArr.length;
    }       	
    i--; 
    var obj = document.getElementById('theMovie');
    if(obj != null)
    {
        document.getElementById(clientId+'divFlash').removeChild(obj);
    }
    CreateZoomifyObject(clientId+'divFlash');
    return false;
}
function fnRight()
{ 
    if(j==objCZoomifyCollection[currentYear - 1].imgArr.length)
    {   
        i=-1;
    }
    i++;   
    var obj = document.getElementById('theMovie');
    if(obj != null)
    {
        document.getElementById(clientId+'divFlash').removeChild(obj);   
    }
    CreateZoomifyObject(clientId+'divFlash');
    return false;
   
}
function CreateZoomifyObject(divId)
{
    if(objCZoomifyCollection[currentYear - 1].imgArr.length == 0)
    {
        document.getElementById(clientId+'divImageContent').style.display = "none";        
    }
    else
    {
       document.getElementById(clientId+'divImageContent').style.display = "inline";  
       document.getElementById(clientId+'lblImageHeadline').innerHTML = objCZoomifyCollection[currentYear - 1].titleArr[i]; 
	   document.getElementById(clientId+'lblImageCaption').innerHTML = objCZoomifyCollection[currentYear - 1].descArr[i];
       j=parseInt(i,10) + 1;
       document.getElementById(clientId+'lblCount').innerHTML = j + ' (' + objCZoomifyCollection[currentYear - 1].titleArr.length + ')';        
       /*	if(i==0)
	    {
	        disableAnchor('aleft');
	    }       
	    else
	    {
	        enableAnchor('aleft');
	    } 
	    if(j == objCZoomifyCollection[currentYear - 1].titleArr.length)
	    {
	    	disableAnchor('aright');
	    }       
	    else
	    {
	        enableAnchor('aright');
	    }*/  
	    if (MM_FlashCanPlay)
	    {
	        document.getElementById(divId).innerHTML = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" width="471" height="344" id="theMovie"><param name="FlashVars" value="zoomifyImagePath=http://images.harpercollins.co.uk/TAWebImages/'+escape(encodeURIComponent(objCZoomifyCollection[currentYear - 1].folderArr[i]))+'/&zoomifyX=0.0&zoomifyY=0.0&zoomifyZoom=-1&zoomifyToolbar=1&zoomifyNavWindow=0"><param name="src" value="/Style Library/zoomifyDynamicViewer.swf"><embed flashvars="zoomifyImagePath=http://images.harpercollins.co.uk/TAWebImages/'+escape(encodeURIComponent(objCZoomifyCollection[currentYear - 1].folderArr[i]))+'/&zoomifyX=0.0&zoomifyY=0.0&zoomifyZoom=-1&zoomifyToolbar=1&zoomifyNavWindow=0" src="/Style Library/zoomifyDynamicViewer.swf" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" width="471" height="344" name="theMovie"></embed></object>';      
	    }
	    else
	    {               
	        document.getElementById(divId).innerHTML = '<img width="471" id="theMovie" src="http://images.harpercollins.co.uk/TAWebImages/'+objCZoomifyCollection[currentYear - 1].imgArr[i]+'" alt="'+objCZoomifyCollection[currentYear - 1].titleArr[i]+'" title="'+objCZoomifyCollection[currentYear - 1].titleArr[i]+'" />';      
	    }
           
    }
}

