﻿// JScript File

// variables to control behavior
	var Book_Image_LeftOffSet=0;
	var Book_Image_Width=200;
	var Book_Image_Height=400;
	var Book_Speed=15;

	var BookPage_LeftImage,BookPage_MovingImage,BookPage_RightImage,EndImage,B_Angle=0,B_CrImg=6,B_MaxW,B_Direction=1;
	var B_MSz,WhenDone,FlipToLeft;

	function ImageBookFlip(StartLeftImage,StartRightImage,EndLeftImage,EndRightImage,URLWhenDone,RightToLeft,Width,Height,Speed,LeftOffSet){
		    Book_Image_LeftOffSet=LeftOffSet;
		    Book_Image_Width=Width;
	        Book_Image_Height=Height;
	        Book_Speed=Speed;

		    WhenDone=URLWhenDone;
		    if (RightToLeft){EndImage=EndLeftImage;} else {EndImage=EndRightImage;}
		    B_Direction=RightToLeft;
		    FlipToLeft=RightToLeft;
			Book_Div=document.getElementById('BookDiv');
			BookPage_LeftImage=document.createElement("img");Book_Div.appendChild(BookPage_LeftImage);	
			BookPage_RightImage=document.createElement("img");Book_Div.appendChild(BookPage_RightImage);
			BookPage_MovingImage=document.createElement("img");Book_Div.appendChild(BookPage_MovingImage);	
			
			BookPage_LeftImage.style.position=BookPage_MovingImage.style.position=BookPage_RightImage.style.position="absolute";
			
			BookPage_LeftImage.style.zIndex=BookPage_RightImage.style.zIndex=0;
			BookPage_MovingImage.style.zIndex=1;
			
			BookPage_LeftImage.style.top="0px";
			BookPage_LeftImage.style.left=Book_Image_LeftOffSet+"px";
			BookPage_MovingImage.style.top=0+"px";
			BookPage_MovingImage.style.left=(Book_Image_Width+1+Book_Image_LeftOffSet)+"px";
			BookPage_RightImage.style.top=0+"px";
			BookPage_RightImage.style.left=(Book_Image_Width+Book_Image_LeftOffSet)+"px";
			BookPage_LeftImage.style.height=Book_Image_Height+"px";
			BookPage_MovingImage.style.height=Book_Image_Height+"px";
			BookPage_RightImage.style.height=Book_Image_Height+"px";
			BookPage_LeftImage.style.width=Book_Image_Width+"px";
			BookPage_MovingImage.style.width=Book_Image_Width+"px";
			BookPage_RightImage.style.width=Book_Image_Width+"px";
			document.getElementById('BookImg').style.width="0px";

			BookPage_LeftImage.src=StartLeftImage;
			if (RightToLeft) {BookPage_MovingImage.src=StartRightImage} else BookPage_MovingImage.src=StartLeftImage;
			BookPage_RightImage.src=EndRightImage;

			BookImages()
			}

	function BookImages(){
            var Book_DoneImage;
        	B_MSz=Math.abs(Math.round(Math.cos(B_Angle)*Book_Image_Width));
			MidOffset=B_Direction?Book_Image_Width+1:Book_Image_Width-B_MSz;
			BookPage_MovingImage.style.left=Book_Image_LeftOffSet+MidOffset+"px";
			BookPage_MovingImage.style.width=B_MSz+"px";
			
		    B_Angle+=Book_Speed/720*Math.PI;
			    
			if(B_Angle>=Math.PI/2&&B_Direction&&FlipToLeft){
				B_Direction=0;
				BookPage_MovingImage.src=EndImage;
				B_CrImg+=2}
			if(B_Angle>=Math.PI/2&&!B_Direction&&!FlipToLeft){
				B_Direction=1;
				BookPage_MovingImage.src=EndImage;
				B_CrImg+=2}
			if(B_Angle>=Math.PI){
			    Book_DoneImage=document.createElement("img");Book_Div.appendChild(Book_DoneImage);
			    Book_DoneImage.style.position="absolute";
			    Book_DoneImage.style.zIndex=2;
			    Book_DoneImage.style.top=BookPage_LeftImage.style.top;
			    Book_DoneImage.style.left=Book_Image_LeftOffSet*2 +"px";
			    Book_DoneImage.style.height="100%";
			    Book_DoneImage.src="images/Book/OpenBook.gif";
			    
			    BookPage_LeftImage.style.width="0px";
			    BookPage_MovingImage.style.width="0px";
			    BookPage_RightImage.style.width="0px";
			    
				window.open(WhenDone,'_top')
				}
			else setTimeout("BookImages()",50)
			}

	var ExpandDiv_EndLeft=0;
	var ExpandDiv_EndTop=20;
	var ExpandDiv_EndHeight=0;

	function ExpandDiv(EndLeft,EndTop,EndHeight){
	    document.images.FireImg.style.visibility="hidden";
	    ExpandDiv_EndHeight = document.images[0].height -(ExpandDiv_EndTop*2)
	    var BackImgWidth = document.images[0].width
	    ExpandDiv_EndLeft=BackImgWidth*.01;

        ExpandDiv_Do()
    }
    
    var bFinished = false;
    
	function ExpandDiv_Do(){
        var ExpandDiv=document.getElementById('BookDiv');
 	    var ExpandDiv_Left=parseInt(ExpandDiv.style.left.substring(0,ExpandDiv.style.left.indexOf("p")));
	    var ExpandDiv_Top=parseInt(ExpandDiv.style.top.substring(0,ExpandDiv.style.top.indexOf("p")));
	    var ExpandDiv_Height=parseInt(ExpandDiv.style.height.substring(0,ExpandDiv.style.height.indexOf("p")));
              
			if(ExpandDiv_Left > ExpandDiv_EndLeft){
				ExpandDiv.style.left=ExpandDiv_Left-10}
			//if( ExpandDiv_Left < ExpandDiv_EndLeft){
			//	ExpandDiv.style.left=ExpandDiv_Left+10}
			
			if( ExpandDiv_Top > ExpandDiv_EndTop){
				ExpandDiv.style.top=ExpandDiv_Top-10}
			//if( ExpandDiv_Top < ExpandDiv_EndTop){
			//	ExpandDiv.style.top=ExpandDiv_Top+10}
			
			//if( ExpandDiv_Height > ExpandDiv_EndHeight){
			//	ExpandDiv.style.height=ExpandDiv_Height-15}
			if( ExpandDiv_Height < ExpandDiv_EndHeight){
				ExpandDiv.style.height=ExpandDiv_Height+15}
				

			if( ExpandDiv_Height<ExpandDiv_EndHeight-14 || ExpandDiv_Height > ExpandDiv_EndHeight+14){ setTimeout("ExpandDiv_Do()",40);}
			else{bFinished=true;MoveImgRight();}
			}
			
			
	function MoveImgRight(){
        var ExpandBook=document.getElementById('BookImg');
 	    var ExpandBook_Width=ExpandBook.width;
 	    var ExpandBook_Height=ExpandBook.height;
        var ExpandBook_EndLeft=ExpandDiv_EndLeft + ExpandBook_Width;
 	    var ExpandBook_Left=parseInt(ExpandBook.style.left.substring(0,ExpandBook.style.left.indexOf("p")));

			if(ExpandBook_Left > ExpandBook_EndLeft){
				ExpandBook.style.left=ExpandBook_Left-25+"px"}
			if( ExpandBook_Left < ExpandBook_EndLeft){
				ExpandBook.style.left=ExpandBook_Left+25+"px"}
				
			if( ExpandBook_Left < ExpandBook_EndLeft-24 || ExpandBook_Left > ExpandBook_EndLeft+24){ setTimeout("MoveImgRight()",10);}
			else {ImageBookFlip('images/spacer.gif','Images/Book/Leather_book_Phoenix.gif','images/Book/BookLeft.gif','images/book/BookRight.gif','Home.aspx',true,ExpandBook_Width,ExpandBook_Height,50,ExpandDiv_EndLeft*1.5);}
  
			}
			
	function PositionExpandDiv(){
        var ExpandDiv=document.getElementById('BookDiv');
	    
	    if (bFinished==false) {
        ExpandDiv.style.left = document.images[0].width * 0.40;
        ExpandDiv.style.top = document.images[0].height * 0.53;
        ExpandDiv.style.height = document.images[0].height * 0.10;
        }
        else
        {
        ExpandDiv.style.height = document.images[0].height -(ExpandDiv_EndTop*2);
        }
        
        document.images.Banner.style.height=document.images[0].height * 0.30;
        document.images.Banner.style.top=document.images[0].height * 0.15;
        document.images.Banner.style.left=document.images[0].width * 0.10;
        
        document.images.Shield.style.height=document.images[0].height * 0.20;
        document.images.Shield.style.top=document.images[0].height * 0.80;
        document.images.Shield.style.left=document.images[0].width * 0.91;
        }