xInclude('lib/x/x_core.js', 'lib/x/x_event.js', 'lib/x/x_drag.js', 'lib/x/x_slide.js');

pages = 58;  

cpage = 0;

linktextStack = '';

function setLinktext(t) {
	linktextStack = 	document.getElementById('barlinkstext').innerHTML;
	document.getElementById('barlinkstext').innerHTML = t;
}

function restoreLinktext() {
	document.getElementById('barlinkstext').innerHTML = linktextStack;
	linktextStack = '';
}                         


function showPage(x){

	 if (x<=pages) {	
	
    if (x==1) {
        xSlideTo(xGetElementById('cover'),-415*1.5,0,2000);
        setTimeout("xSlideTo(xGetElementById('leftpage'),40,20,2000);",2000*0.375);
        setTimeout("xSlideTo(xGetElementById('leftshadow'),41,557,2000);",2000*0.375);  
		  
		  document.getElementById('p1hand').src = 'img/handleft1.png'; 
		  setTimeout("document.getElementById('p1hand').src = 'img/handleftblank.gif';",2000*1.375);
		  
        document.getElementById('p3').innerHTML = '<a href="#" onclick="showPage(4); this.blur(); return false"><img src="img/3.jpg" width="415" height="538" alt="page 3" border="0" /><img src="img/handblank.png" width="51" height="23" alt="&lt;" class="arrowleft" id="p3hand" /></a>';
        document.getElementById('p4').innerHTML = '<a href="#" onclick="showPage(5); this.blur(); return false"><img src="img/4.jpg" width="415" height="538" alt="page 4" border="0" /><img src="img/handblank.png" width="51" height="23" alt="&gt;" class="arrowright" id="p4hand" /></a>';
		  document.getElementById('barlinkstext').innerHTML = '<a href="http://www.amazon.com/exec/obidos/tg/detail/-/1580930972/qid=1108143698/sr=8-1/ref=sr_8_xs_ap_i1_xgl14/102-1457986-3499327?v=glance&amp;s=books&amp;n=507846">Order Emotion as Promotion now</a>';
    }
    if (x==2) {                                          	
        document.getElementById('coverhand').src = 'img/handright1.png'; 
		  setTimeout("document.getElementById('coverhand').src = 'img/handblank.png';",2000*1.65); 
		  
		  document.getElementById('barlinkstext').innerHTML = 'Online now: <a href="#" onclick="showPage(888888); this.blur(); return false" style="text-decoration: none; color:#F00; font-weight: bold;">The chapter our lawyer insisted we not publish</a></span>';
		  document.getElementById('rightpage').style.zIndex = 800;
		  document.getElementById('leftpage').style.zIndex = 200;
		  setTimeout("xSlideTo(xGetElementById('cover'),0,0,2000);",2000*0.375);
        xSlideTo(xGetElementById('leftpage'),454,20,2000*0.6);
        xSlideTo(xGetElementById('leftshadow'),454,557,2000*0.6);
    }
    if (x==3) {
        document.getElementById('p3hand').src = 'img/handleft1.png'; 
		  setTimeout("document.getElementById('p3hand').src = 'img/handblank.png';",2000*1.3);   
        
        setTimeout("xSlideTo(xGetElementById('p3'),0,0,2000);",2000*0.375);
        xSlideTo(xGetElementById('p2'),-415*1.5,0,2000);
        xMoveTo(xGetElementById('p4'),0,0);
        document.getElementById('p5').innerHTML = '<a href="#" onclick="showPage(6); this.blur(); return false"><img src="img/5.jpg" width="415" height="538" alt="page 5" border="0" /><img src="img/handblank.png" width="51" height="23" alt="&lt;" class="arrowleft" id="p5hand" /></a>';
        document.getElementById('p6').innerHTML = '<a href="#" onclick="showPage(7); this.blur(); return false"><img src="img/6.jpg" width="415" height="538" alt="page 6" border="0" /><img src="img/handblank.png" width="51" height="23" alt="&gt;" class="arrowright" id="p6hand" /></a>';
        document.getElementById('coverright').innerHTML = '<a href="#" onclick="showPage(99999); this.blur(); return false"><img src="img/backcover.jpg" width="415" height="538" alt="back cover" border="0" /><img src="img/handrightblank.gif" width="51" height="23" alt="&lt;" class="arrowleft" id="backcoverhand" /></a>';  

    }
    if (x==4) {
	     xMoveTo(xGetElementById('p1'),0,0);
        setTimeout("xSlideTo(xGetElementById('p2'),0,0,2000);",2000*0.25);
        xSlideTo(xGetElementById('p3'),415*1.5,0,2000); 
  
        setTimeout("document.getElementById('p2hand').src = 'img/handright1.png';",2000*0.25);
		  setTimeout("document.getElementById('p2hand').src = 'img/handblank.png.png';",2000*(1.5+0.25));      
    }

    if ((x>4) && (x%2==1)) {
 		  document.getElementById('p'+x+'hand').src = 'img/handleft1.png'; 
		  setTimeout("document.getElementById('p"+x+"hand').src = 'img/handblank.png';",2000*1.6); 

		  xSlideTo(xGetElementById('p'+(x-1)),-415*1.5,0,2000);
        setTimeout("xSlideTo(xGetElementById('p"+x+"'),0,0,2000);",2000*0.5);
        xMoveTo(xGetElementById('p'+(x+1)),0,0);
        document.getElementById('p'+(x+2)).innerHTML = '<a href="#" onclick="showPage('+(x+3)+'); this.blur(); return false"><img src="img/'+(x+2)+'.jpg" width="415" height="538" alt="page '+(x+2)+'" border="0" /><img src="img/handblank.png" width="51" height="23" alt="&lt;" class="arrowleft" id="p'+(x+2)+'hand" /></a>';
        document.getElementById('p'+(x+3)).innerHTML = '<a href="#" onclick="showPage('+(x+4)+'); this.blur(); return false"><img src="img/'+(x+3)+'.jpg" width="415" height="538" alt="page '+(x+3)+'" border="0" /><img src="img/handblank.png" width="51" height="23" alt="&gt;" class="arrowright" id="p'+(x+3)+'hand" /></a>';    
	 }
    if ((x>4) && (x%2==0)) {
		   //even 
		  xMoveTo(xGetElementById('p'+(x-3)),0,0); 

        document.getElementById('p'+(x-2)+'hand').src = 'img/handright1.png'; 
		  setTimeout("document.getElementById('p"+(x-2)+"hand').src = 'img/handblank.png';",2000*1.6); 
        
        setTimeout("xSlideTo(xGetElementById('p"+(x-2)+"'),0,0,2000);",2000*0.25);
        xSlideTo(xGetElementById('p'+(x-1)),415*1.5,0,2000);
        document.getElementById('p'+(x-4)).innerHTML = '<a href="#" onclick="showPage('+(x-3)+'); this.blur(); return false"><img src="img/'+(x-4)+'.jpg" width="415" height="538" alt="page '+(x-4)+'" border="0" /><img src="img/handblank.png" width="51" height="23" alt="&gt;" class="arrowright" id="p'+(x-4)+'hand" /></a>';
        document.getElementById('p'+(x-5)).innerHTML = '<a href="#" onclick="showPage('+(x-4)+'); this.blur(); return false"><img src="img/'+(x-5)+'.jpg" width="415" height="538" alt="page '+(x-5)+'" border="0" /><img src="img/handblank.png" width="51" height="23" alt="&lt;" class="arrowleft" id="p'+(x-5)+'hand" /></a>';

    }
	}
	else {
	
		if (x==99999) {                                            
         setTimeout("xHide(xGetElementById('coverrighttext'));",4000);
			xSlideTo(xGetElementById('coverright'),415,0,2000);
			setTimeout("xSlideTo(xGetElementById('rightpage'),454,20,2000);",2000*0.875);
   		setTimeout("xSlideTo(xGetElementById('rightshadow'),869,20,2000);",2000*0.875);
   		setTimeout("xSlideTo(xGetElementById('bottomrightshadow'),454,557,2000);",2000*0.875);    
   		
   	  document.getElementById('p'+pages+'hand').src = 'img/handright1.png'; 
   	  setTimeout("document.getElementById('p"+pages+"hand').src = 'img/handblank.png';",2000*1.875);

			document.getElementById('barlinkstext').innerHTML = '<a href="http://www.amazon.com/exec/obidos/tg/detail/-/1580930972/qid=1108143698/sr=8-1/ref=sr_8_xs_ap_i1_xgl14/102-1457986-3499327?v=glance&amp;s=books&amp;n=507846">Order Emotion as Promotion now</a>';
		}
		else if (x==888888) {  
	     xSlideTo(xGetElementById('cover'),-415*1.5,0,2000);
        document.getElementById('p43').innerHTML = '<a href="#" onclick="showPage(44); this.blur(); return false"><img src="img/43.jpg" width="415" height="538" alt="page 43" border="0" /><img src="img/handblank.png" width="51" height="23" alt="&lt;" class="arrowleft" id="p43hand" /></a>';    
        setTimeout("xSlideTo(xGetElementById('leftpage'),40,20,2000);",2000*0.375);
        setTimeout("xSlideTo(xGetElementById('leftshadow'),41,557,2000);",2000*0.375);     
        
        document.getElementById('p43hand').src = 'img/handleft1.png'; 
   	  setTimeout("document.getElementById('p43hand').src = 'img/handblank.png';",2000*1.6);
        
        xMoveTo(xGetElementById('p43'),0,0);
        xMoveTo(xGetElementById('p44'),0,0);
        document.getElementById('p45').innerHTML = '<a href="#" onclick="showPage(46); this.blur(); return false"><img src="img/45.jpg" width="415" height="538" alt="page 45" border="0" /><img src="img/handblank.png" width="51" height="23" alt="&lt;" class="arrowleft" id="p45hand" /></a>';    
        document.getElementById('p46').innerHTML = '<a href="#" onclick="showPage(47); this.blur(); return false"><img src="img/46.jpg" width="415" height="538" alt="page 46" border="0" /><img src="img/handblank.png" width="51" height="23" alt="&gt;" class="arrowright" id="p46hand" /></a>';    
        document.getElementById('p47').innerHTML = '<a href="#" onclick="showPage(48); this.blur(); return false"><img src="img/47.jpg" width="415" height="538" alt="page 47" border="0" /<img src="img/handblank.png" width="51" height="23" alt="&lt;" class="arrowleft" id="p47hand" /></a>';    
        document.getElementById('p48').innerHTML = '<a href="#" onclick="showPage(49); this.blur(); return false"><img src="img/48.jpg" width="415" height="538" alt="page 48" border="0" /><img src="img/handblank.png" width="51" height="23" alt="&gt;" class="arrowright" id="p48hand" /></a>';    
        document.getElementById('p42').innerHTML = '<a href="#" onclick="showPage(43); this.blur(); return false"><img src="img/42.jpg" width="415" height="538" alt="page 42" border="0" /><img src="img/handblank.png" width="51" height="23" alt="&gt;" class="arrowright" id="p42hand" /></a>';    
        document.getElementById('p41').innerHTML = '<a href="#" onclick="showPage(42); this.blur(); return false"><img src="img/41.jpg" width="415" height="538" alt="page 41" border="0" /><img src="img/handblank.png" width="51" height="23" alt="&lt;" class="arrowleft" id="p41hand" /></a>';    

			document.getElementById('barlinkstext').innerHTML = '<a href="http://www.amazon.com/exec/obidos/tg/detail/-/1580930972/qid=1108143698/sr=8-1/ref=sr_8_xs_ap_i1_xgl14/102-1457986-3499327?v=glance&amp;s=books&amp;n=507846">Order Emotion as Promotion now</a>';

         for(zz=1;zz<43;zz++) {
				 xMoveTo(xGetElementById('p'+zz),-415*1.5,0);
        }

        document.getElementById('coverright').innerHTML = '<a href="#" onclick="showPage(99999); this.blur(); return false"><img src="img/backcover.jpg" width="415" height="538" alt="back cover" border="0" /><img src="img/handrightblank.gif" width="51" height="23" alt="&lt;" class="arrowleft" id="backcoverhand" /></a>';
		}
		else {
   		xSlideTo(xGetElementById('rightpage'),40,20,2000*0.875);
   		setTimeout("xSlideTo(xGetElementById('coverright'),0,0,2000);",2000*0.875);
   		document.getElementById('barlinkstext').innerHTML = '';
			document.getElementById('rightpage').style.zIndex = 2;
      	xSlideTo(xGetElementById('rightshadow'),41,20,2000*0.875);
      	xSlideTo(xGetElementById('bottomrightshadow'),41,557,2000*0.875);              
        
        document.getElementById('backcoverhand').src = 'img/handleft1.png'; 
   	  setTimeout("document.getElementById('backcoverhand').src = 'img/handrightblank.gif';",2000*2);
    	   xShow(xGetElementById('coverrighttext'));
		}
		cpage = x;
	}
}

window.onload = function() {
    xMoveTo(xGetElementById('cover'),0,0);
    xMoveTo(xGetElementById('coverright'),415,0);
    xMoveTo(xGetElementById('leftpage'),454,20);
    xMoveTo(xGetElementById('leftshadow'),454,557);
    xMoveTo(xGetElementById('rightpage'),454,20);
    xMoveTo(xGetElementById('rightshadow'),869,20);
    xMoveTo(xGetElementById('bottomrightshadow'),454,557);
    xMoveTo(xGetElementById('p1'),0,0);
    document.getElementById('p43').innerHTML = '<a href="#" onclick="showPage(44); this.blur(); return false"><img src="img/43.jpg" width="415" height="538" alt="page 43" border="0" /><img src="img/handblank.png" width="51" height="23" alt="&lt;" class="arrowleft" id="p43hand" /></a>';    
    document.getElementById('p44').innerHTML = '<a href="#" onclick="showPage(45); this.blur(); return false"><img src="img/44.jpg" width="415" height="538" alt="page 44" border="0" /><img src="img/handblank.png" width="51" height="23" alt="&gt;" class="arrowright" id="p44hand" /></a>';    

	 for(i=3;i<60;i++) {
		 xMoveTo(xGetElementById('p'+i),415,0);
	 }
 }