var t=setTimeout("moveIt()",4000)

var thePosition = 0;

var isUp = false;



function moveIt(){

	clearTimeout(t);

	if(isUp == true){

		document.getElementById('cover').style.display = "block";

		thePosition += 6;

		t=setTimeout("moveIt()",15)

		document.getElementById('scroller').style.top = thePosition + "px";

		if(thePosition >= -4){

			isUp = false;

			clearTimeout(t);

		}

	}else{

	    if(document.getElementById('cover').style.display != "none"){

		    thePosition -= 6;

		    document.getElementById('scroller').style.top = thePosition + "px";

		    t=setTimeout("moveIt()",15)

		    if(thePosition <= -630){

			    document.getElementById('cover').style.display ="none";

			    document.getElementById('scroller').style.top = "0px";

			    isUp = true;

			    clearTimeout(t);

		    }

        } else {

            thePosition = -630;

            document.getElementById('scroller').style.top = "0px";

            isUp = true;

			clearTimeout(t);

        }

	}

}







//an array of the top relative position of the div in order to display the correct picture



      function getBrowser() {



      var sBrowser = navigator.userAgent;



      if (sBrowser.toLowerCase().indexOf('msie 7.0') > 0)



      return 'ie7';



      if (sBrowser.toLowerCase().indexOf('msie 6.0') > 0)



      return 'ie6';



      if (sBrowser.toLowerCase().indexOf('firefox') > 0)



      return 'ff2';



      else



      return;



      }

if(getBrowser()=='ie7' || getBrowser()=='ie6'){

var positions = new Array();

positions[0] = 0;

positions[1] = 0;

positions[2] = -292;

positions[3] = -585;

positions[4] = -880;

positions[5] = -1170;

positions[6] = -1465;

positions[7] = -1756;

positions[8] = -2049;

positions[9] = -2341;

positions[10] = -2636;

positions[11] = -2927;

positions[12] = -3220;

positions[13] = -3513;

positions[14] = -3800;

positions[15] = -4092;

positions[16] = -4380;

}

else

{

var positions = new Array();

positions[0] = 0;

positions[1] = 0;

positions[2] = -290;

positions[3] = -580;

positions[4] = -870;

positions[5] = -1160;

positions[6] = -1450;

positions[7] = -1740;

positions[8] = -2030;

positions[9] = -2320;

positions[10] = -2610;

positions[11] = -2900;

positions[12] = -3200;

positions[13] = -3500;

positions[14] = -3790;

positions[15] = -4080;

positions[16] = -4360;

}

/*

Uncomment these as images are needed to be added

*/



var dater = new Date();

var numImages = 10; // the max number of images to be displayed

var scrollAmount = 0;  // a number that will be used to determine the distance between two slides

var toScroll = 0;  // a number that will determine the amount of scroll for each iteration through the function

var timer;

var counter=setTimeout("autoScroll()",8000);





var theImage = 1;



if(theImage == 0){

	theImage = numImages;

}

var theLocation = positions[theImage];  // the location top relative position of the div

var imageOn = theImage;  // the image displayed, starts on the 1st image





function setUpImage(){

	document.getElementById('thePics').style.top = theLocation + 'px';

	/*document.getElementById('image1').src = "none";*/

	var thePastButton = "image" + imageOn;

	/*document.getElementById(thePastButton).src = "none";*/

	document.getElementById(thePastButton+'Text').style.display = "block";

}





function autoScroll(){

	counter=setTimeout("autoScroll()",8000);

	if(imageOn <= numImages - 1){

		calculateScroll(imageOn + 1);

	}else{

		calculateScroll(1);

	}	

}





function calculateScroll(theOne){

	clearTimeout(counter);

	var thePastButton = "image" + imageOn;

	var thePresentButton = "image" + theOne;

	/*document.getElementById(thePastButton).src = "none";*/

	/*document.getElementById(thePresentButton).src = "none";*/

	document.getElementById(thePastButton+'Text').style.display = "none";

	document.getElementById(thePresentButton+'Text').style.display = "block";

	scrollAmount = (theLocation - positions[theOne]);

	clearTimeout(timer);

	scroller();

	imageOn = theOne;

}





function scroller(){

	toScroll = scrollAmount/5;

	theLocation -= toScroll;

	scrollAmount -= toScroll;

	document.getElementById('thePics').style.top = theLocation + 'px';

	timer = setTimeout("scroller()",50);

	if(scrollAmount <= .5 && scrollAmount >= -.5){

		counter=setTimeout("autoScroll()",8000);

		clearTimeout(timer);

		theLocation = positions[imageOn];

		document.getElementById('thePics').style.top = theLocation + 'px';

	}

}



//function for button mouseOver

function swapImages(theOne){

	document.getElementById(theOne).style.border = 'none';

	//document.body.style.cursor = 'pointer';

}

//function for button mouseOut

function swapBack(theOne){

	//document.body.style.cursor = 'none';

	document.getElementById(theOne).style.border = 'none';

}











function coverWin2(){

    coverWindow2 = window.open ("C:\Documents and Settings\nshelton\Desktop\pageFlip\main.html", "mywindow2","resizable=0,location=0,status=0,scrollbars=0,menubar=0,toolbar=0,directories=0,width=900,height=580");

    coverWindow.moveTo(100,100);

}





function coverWin(){

    coverWindow = window.open ("covergallery/covers.html", "mywindow","resizable=0,location=0,status=0,scrollbars=0,menubar=0,toolbar=0,directories=0,width=800,height=600");

    coverWindow.moveTo(100,100);

}



function showComments(){

    document.getElementById("commentText").style.display = "block";

    document.getElementById("closeCoupons").innerHTML = "X";  

    document.getElementById("closeCoupons").style.borderColor = "#DDDDDD";  

}



function closeComments(){

    document.getElementById("commentText").style.display = "none";

    document.getElementById("closeCoupons").innerHTML = "";

    document.getElementById("closeCoupons").style.borderColor = "#EEEEEE";

    }



function closeCommentBorder(){

    document.getElementById("closeCoupons").style.borderColor = "#EEEEEE";

}