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 = "4px";
			    isUp = true;
			    clearTimeout(t);
		    }
        } else {
            thePosition = -630;
            document.getElementById('scroller').style.top = "4px";
            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] = -253;
positions[3] = -506;
positions[4] = -759;
positions[5] = -1012;
positions[6] = -1268;
positions[7] = -1524;
positions[8] = -1778;
positions[9] = -2033;
positions[10] = -2285;
positions[11] = -2536;
positions[12] = -2792;
positions[13] = -3045;

}
else {
var positions = new Array();
positions[0] = 0;
positions[1] = 0;
positions[2] = -250;
positions[3] = -500;
positions[4] = -750;
positions[5] = -1000;
positions[6] = -1250;
positions[7] = -1500;
positions[8] = -1750;
positions[9] = -2000;
positions[10] = -2250;
positions[11] = -2500;
positions[12] = -2750;
positions[13] = -3000;
}
/*
Uncomment these as images are needed to be added
*/

var dater = new Date();
var numImages = 13; // 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()",4000);


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 = "/images/button.gif";
	var thePastButton = "image" + imageOn;
	document.getElementById(thePastButton).src = "/images/buttonSelected.gif";
	document.getElementById(thePastButton+'Text').style.display = "block";
}


function autoScroll(){
	counter=setTimeout("autoScroll()",4000);
	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 = "images/button.gif";
	document.getElementById(thePresentButton).src = "images/buttonSelected.gif";
	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()",4000);
		clearTimeout(timer);
		theLocation = positions[imageOn];
		document.getElementById('thePics').style.top = theLocation + 'px';
	}
}

//function for button mouseOver
function swapImages(theOne){
	document.getElementById(theOne).style.border = '2px solid #FFBD33';
	//document.body.style.cursor = 'pointer';
}
//function for button mouseOut
function swapBack(theOne){
	//document.body.style.cursor = 'none';
	document.getElementById(theOne).style.border = '2px solid #FFBD33';
}





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";
}