﻿var i=0,j,k=0,l;
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 fnLeft1()
{   
	if(i==0)
    {
        i=imgArr.length;
    }  
    i--;   
    var obj = document.getElementById('obj1');
    if(obj != null)
    {
        document.getElementById(clientId+'divFlash1').removeChild(obj);   
    }
    CreateBookBindingZoomifyObject(clientId+'divFlash1');      
    return false;    
}

function fnRight1()
{ 
	if(j==imgArr.length)
    {   
        i=-1;
    }
    i++;   
    var obj = document.getElementById('obj1');
    if(obj != null)
    {
        document.getElementById(clientId+'divFlash1').removeChild(obj);   
    }
    CreateBookBindingZoomifyObject(clientId+'divFlash1');
    return false;
}
function CreateBookBindingZoomifyObject(divId)
{
    if(imgArr.length == 0)
    {
        document.getElementById(clientId+'divImageContent1').style.display = "none";        
    }
    else
    {
       document.getElementById(clientId+'divImageContent1').style.display = "inline";  
       document.getElementById(clientId+'lblImageHeadline1').innerHTML = titleArr[i]; 
	   document.getElementById(clientId+'lblImageCaption1').innerHTML = descArr[i];
       j=parseInt(i,10) + 1;
       document.getElementById(clientId+'lblCount1').innerHTML = j + ' (' + titleArr.length + ')';        
        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="obj1"><param name="FlashVars" value="zoomifyImagePath=http://images.harpercollins.co.uk/TAWebImages/'+escape(encodeURIComponent(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(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="obj1"></embed></object>';      
        }
        else
        {               
            document.getElementById(divId).innerHTML = '<img width="471" id="obj1" src="http://images.harpercollins.co.uk/TAWebImages/'+imgArr[i]+'" alt="'+altTextArr[i]+'" title="'+altTextArr[i]+'"/>';      
        }
    }

}
function fnLeft2()
{   
	if(k==0)
    {
        k=imgArr2.length;
    } 
    k--;   
    var obj = document.getElementById('obj2');
    if(obj != null)
    {
        document.getElementById(clientId+'divFlash2').removeChild(obj);   
    }
    CreateSamplePageZoomify(clientId+'divFlash2');   
    return false;
}

function fnRight2()
{ 
	if(l==imgArr2.length)
    {   
        k=-1;
    }
    k++;   
    var obj = document.getElementById('obj2');
    if(obj != null)
    {
        document.getElementById(clientId+'divFlash2').removeChild(obj);   
    }
    CreateSamplePageZoomify(clientId+'divFlash2');
    return false;
}
function CreateSamplePageZoomify(divId)
{
    if(imgArr2.length == 0)
    {
        document.getElementById(clientId+'divImageContent2').style.display = "none";        
    }
    else
    {
       document.getElementById(clientId+'divImageContent2').style.display = "inline";  
       document.getElementById(clientId+'lblImageHeadline2').innerHTML = titleArr2[k]; 
	   document.getElementById(clientId+'lblImageCaption2').innerHTML = descArr2[k];
       l=parseInt(k,10) + 1;
       document.getElementById(clientId+'lblCount2').innerHTML = l + ' (' + titleArr2.length + ')';        
       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="obj2"><param name="FlashVars" value="zoomifyImagePath=http://images.harpercollins.co.uk/TAWebImages/'+escape(encodeURIComponent(folderArr2[k]))+'/&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(folderArr2[k]))+'/&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="obj2"></embed></object>';      
        }
        else
        {               
            document.getElementById(divId).innerHTML = '<img width="471" id="obj2" src="http://images.harpercollins.co.uk/TAWebImages/'+imgArr2[k]+'" alt="'+altTextArr2[k]+'" title="'+altTextArr2[k]+'"/>';      
        }         
    }

}
