var pWidth;var pHeight;var isMoving=false;var myBook,isHidden=false,AF;var leftStart=0,rightStart=1;var hideDiv,revealDiv,revealHtmlDiv,hideHtmlDiv,hasPlayed=false,pSound,tempSound,soundManager;var myBook,myBinder,counter=0;var numPixels=20;var allowNavigation=false;var tempPixelsToMove,tempSpeed;var allowPageClick=false;var doIncrementalAutoFlip=false;function flipSoundIni(){if(pSound){if(!soundManager){pSound=false;return false}soundManager.url="soundmanager/soundmanager2.swf";soundManager.debugMode=false;soundManager.consoleOnly=false;soundManager.waitForWindowLoad=true;soundManager.onload=function(){soundManager.createSound({id:"flip",url:"flip.mp3",autoLoad:true})}}}function ini(){if(pSound){flipSoundIni()}if(!document.getElementById("myBook")){return}allowNavigation=selectNavigation;numPixels=numPixelsToMove;if(numPixels>100){numPixels=100}pWidth=myPageW+(pageBorderWidth*2);pHeight=myPageH+(pageBorderWidth*2);myBook=document.getElementById("myBook");myBook.style.width=(pWidth*2)+"px";myBook.style.height=pHeight+"px";myBook.style.position="relative";myBook.style.zIndex="0";for(var f=0;f<myBook.childNodes.length;f++){if(myBook.childNodes[f].nodeType==1){var e=myBook.childNodes[f];var c=document.createElement("div");c.style.position="absolute";c.style.left=pWidth+"px";c.style.top="0px";c.style.width=pWidth+"px";c.style.height=pHeight+"px";c.style.backgroundColor="#000000";c.style.overflow="hidden";c.style.zIndex=myBook.childNodes.length-counter;c.setAttribute("id","flipPage"+counter);e.parentNode.replaceChild(c,e);e.setAttribute("id","flipHtml"+counter);e.style.position="absolute";e.style.width=myPageW+"px";e.style.height=myPageH+"px";e.style.top="0px";e.style.left="0px";e.style.overflow="hidden";e.style.borderWidth=pageBorderWidth+"px";e.style.borderColor=pageBorderColor;e.style.borderStyle=pageBorderStyle;if(!number_check(counter)){if(document.all){e.style.filter="progid:DXImageTransform.Microsoft.Alpha(Opacity=100, FinishOpacity=30, Style=1, StartX=80, FinishX=100, StartY=0, FinishY=0)"}else{var b=document.createElement("div");b.style.position="absolute";b.style.left=(pWidth-80)+"px";b.style.top="0px";b.style.width=80+"px";b.style.height=pHeight+"px";b.style.background="transparent url(black_gradient.png) top right repeat-y";e.appendChild(b)}}if(allowPageClick){if(number_check(counter)){e.onclick=function(h){whichElement(h,true)}}else{e.onclick=function(h){whichElement(h,false)}}}c.appendChild(e);if(allowNavigation&&document.getElementById("flipSelect")){var g=document.createElement("option");if(counter==0){if(e.getAttribute("name")){g.text=e.getAttribute("name")}else{g.text="Cover "}}else{if(e.getAttribute("name")){g.text=e.getAttribute("name")}else{g.text=counter}}g.value=counter;var a=document.getElementById("flipSelect");a.style.display="";a.onchange=function(){this.blur();document.body.focus();autoFlip(this.value)};try{a.add(g,null)}catch(d){a.add(g)}}counter++}}if(showBinder){myBinder=document.createElement("div");myBinder.style.width=binderWidth+"px";myBinder.style.height=pHeight+"px";myBinder.style.position="absolute";myBinder.style.top="0px";myBinder.style.left=pWidth-(binderWidth/2)+"px";myBinder.style.background="transparent url('"+binderImage+"') top left repeat-y";myBinder.style.zIndex="200";myBook.appendChild(myBinder)}myBook.style.display=""}function number_check(a){return(1-(a%2))}function autoFlip(a){currentLeft=leftStart-1;if(a>(currentLeft+1)){cycles=a-currentLeft;if(number_check(cycles)){cycles=cycles/2}else{cycles=(cycles-1)/2}if(doIncrementalAutoFlip){tempSound=pSound;pSound=false;tempPixelsToMove=numPixels;tempSpeed=pSpeed;pSpeed=0;numPixels=(pWidth/4);doAutoFlip(cycles,true)}else{rightDirectFlip(cycles)}}else{if(a==currentLeft||a==currentLeft+1){return false}else{cycles=currentLeft-a;if(number_check(cycles)){cycles=cycles/2}else{cycles=(cycles+1)/2}if(doIncrementalAutoFlip){tempSound=pSound;pSound=false;tempPixelsToMove=numPixels;tempSpeed=pSpeed;pSpeed=0;numPixels=(pWidth/4);doAutoFlip(cycles,false)}else{leftDirectFlip(cycles)}}}}function doAutoFlip(b,a){if(b==0){AF=window.clearTimeout(AF);numPixels=tempPixelsToMove;pSpeed=tempSpeed;pSound=tempSound;return}if(a){gonext()}else{goprev()}b--;AF=window.setTimeout("doAutoFlip("+b+","+a+")",100)}function rightDirectFlip(a){for(var b=0;b<a;b++){if(!document.getElementById("flipPage"+rightStart)){return}hideDiv=document.getElementById("flipPage"+leftStart);hideHtmlDiv=document.getElementById("flipHtml"+leftStart);revealDiv=document.getElementById("flipPage"+rightStart);revealHtmlDiv=document.getElementById("flipHtml"+rightStart);revealDiv.style.left=0+"px";revealDiv.style.width=pWidth+"px";revealDiv.style.zIndex=0;hideDiv.style.left="";hideDiv.style.right="0px";hideDiv.style.width="0px";hideHtmlDiv.style.left="";hideHtmlDiv.style.right="0px";revealHtmlDiv.style.left="";revealHtmlDiv.style.right="0px";leftStart=leftStart+2;rightStart=rightStart+2}}function leftDirectFlip(a){for(var b=0;b<a;b++){if(!document.getElementById("flipPage"+(leftStart-2))){return false}leftStart=leftStart-2;rightStart=rightStart-2;hideDiv=document.getElementById("flipPage"+rightStart);hideHtmlDiv=document.getElementById("flipHtml"+rightStart);revealDiv=document.getElementById("flipPage"+leftStart);revealHtmlDiv=document.getElementById("flipHtml"+leftStart);hideDiv.style.left="";hideDiv.style.right=pWidth+"px";hideDiv.style.width=0+"px";revealDiv.style.left=pWidth+"px";revealDiv.style.width=pWidth+"px";revealHtmlDiv.style.left="0px";hideHtmlDiv.style.left="0px"}}function gonext(){if(isMoving){return}if(!document.getElementById("flipPage"+rightStart)){return}isMoving=true;hideDiv=document.getElementById("flipPage"+leftStart);hideHtmlDiv=document.getElementById("flipHtml"+leftStart);revealDiv=document.getElementById("flipPage"+rightStart);revealHtmlDiv=document.getElementById("flipHtml"+rightStart);revealDiv.style.width="0px";revealDiv.style.left=pWidth*2+"px";revealDiv.style.zIndex=99;goright(pWidth*2,0)}function goright(b,a){if(b<=numPixels*2){window.clearTimeout(ID);revealDiv.style.left=0+"px";revealDiv.style.width=pWidth+"px";revealDiv.style.zIndex=revealDiv.style.zIndex-99;hideHtmlDiv.style.left="";hideHtmlDiv.style.right="0px";revealHtmlDiv.style.left="";revealHtmlDiv.style.right="0px";leftStart=leftStart+2;rightStart=rightStart+2;isHidden=false;isMoving=false;if(showBinder){myBinder.style.zIndex="100"}if(allowNavigation&&document.getElementById("flipSelect")){document.getElementById("flipSelect").selectedIndex=leftStart-1}hasPlayed=false;return}b=b-(numPixels*2);a=a+numPixels;revealDiv.style.left=b+"px";revealDiv.style.width=a+"px";hideWidth=b-pWidth;if(hideWidth>0){hideDiv.style.width=hideWidth+"px"}else{if(!isHidden){hideDiv.style.width=0+"px";isHidden=true}}if(b<(pWidth+binderWidth+numPixels)&&!hasPlayed){if(showBinder){myBinder.style.zIndex="0"}if(pSound){soundManager.play("flip")}hasPlayed=true}ID=window.setTimeout("goright("+b+","+a+")",pSpeed)}function goprev(){if(isMoving){return}if(!document.getElementById("flipPage"+(leftStart-2))){return false}isMoving=true;leftStart=leftStart-2;rightStart=rightStart-2;hideDiv=document.getElementById("flipPage"+rightStart);hideHtmlDiv=document.getElementById("flipHtml"+rightStart);revealDiv=document.getElementById("flipPage"+leftStart);revealHtmlDiv=document.getElementById("flipHtml"+leftStart);revealDiv.style.left="0px";revealDiv.style.width="0px";hideDiv.style.left="";hideDiv.style.right=pWidth+"px";goleft(0,0)}function goleft(b,a){if(b>=(pWidth-(numPixels*2))){window.clearTimeout(ID);revealDiv.style.left=pWidth+"px";revealDiv.style.width=pWidth+"px";revealHtmlDiv.style.left="0px";hideHtmlDiv.style.left="0px";isHidden=false;isMoving=false;if(showBinder){myBinder.style.zIndex="100"}if(allowNavigation&&document.getElementById("flipSelect")){if(leftStart-1>0){document.getElementById("flipSelect").selectedIndex=leftStart-1}else{document.getElementById("flipSelect").selectedIndex=leftStart}}hasPlayed=false;return}b=b+numPixels;a=a+numPixels;revealDiv.style.width=a+"px";revealDiv.style.left=b+"px";hideWidth=pWidth-a;if(hideWidth>(pWidth/2)){hideDiv.style.width=hideWidth-numPixels+"px"}else{if(!isHidden){hideDiv.style.width=0+"px";isHidden=true}}if(b>((pWidth/2)-numPixels)&&!hasPlayed){if(showBinder){myBinder.style.zIndex="0"}if(pSound){soundManager.play("flip")}hasPlayed=true}ID=window.setTimeout("goleft("+b+","+a+")",pSpeed)}function whichElement(c,a){var b;if(!c){var c=window.event}if(c.target){b=c.target}else{if(c.srcElement){b=c.srcElement}}if(b.nodeType==3){b=b.parentNode}pname=b.parentNode.tagName;tname=b.tagName;if(tname=="A"||tname=="INPUT"||pname=="A"||pname=="INPUT"){return false}else{if(a){return gonext()}else{return goprev()}}}function toggleBinder(){showBinder=(showBinder!=false?false:true);if(showBinder){myBinder.style.display=""}else{myBinder.style.display="none"}}function toggleSound(){pSound=(pSound!=false?false:true)};
