// javascript for GenBuy image timer
window.onload = initPage;
var c=0;
var t;
var timer_is_on=1;


// javascript for GenBuy image timer to animate newspaper page switching with blur
// by John Kraus -- October 15, 2009 -- john@johnfkraus.com
//window.onload = initPageNewspage;
d=0;
var modulus = 4;
var longCount = 4600;
var shortCount = 300;
var q;
var timer_is_on2=1;



function initPage() {
	timedCount();

	paper1 = new Image();
  paper1.src = "images/paper1.jpg";
	paper2 = new Image();
	paper2.src = "images/paper2.jpg";
	paper3 = new Image();
	paper3.src = "images/paper3.jpg";
	paper4 = new Image();
	paper4.src = "images/paper4.jpg";
	timedCountNumbered();




}

// Preload the images for the rollover        
if (document.images) {
	smBookOn = new Image();
	smBookOn.src = "images/bookcover_smOn.jpg";
	smBookOff = new Image();
	smBookOff.src = "images/bookcover_smOff.jpg";

	usatOn = new Image();
  usatOn.src = "images/usat_logo2bOn.gif";
  usatOff = new Image();
  usatOff.src = "images/usat_logo2bOff.gif";
}

// Function to replace the off images with on images.        
function activate(image_name) {
	if (document.images) {
  	document[image_name].src = eval(image_name + "On.src");
  }
}

function deactivate(image_name) {
  if (document.images) {
  document[image_name].src = eval(image_name + "Off.src");
  }
}

function timedCount() {
	if ((c%2)==1) {
    activate('smBook');
    activate('usat');
	} else {
		deactivate('smBook');
		deactivate('usat');
	}         
	c=c+1;
	t=setTimeout("timedCount()",3000);
}


function initPageNewspage() {

}

// Preload the images for the rollover        
if (document.images) {

	paper1 = new Image();
  paper1.src = "images/paper1.jpg";
	paper2 = new Image();
	paper2.src = "images/paper2.jpg";
	paper3 = new Image();
	paper3.src = "images/paper3.jpg";
	paper4 = new Image();
	paper4.src = "images/paper4.jpg";

}

// Function to replace the off images with on images.        
function activate1(image_name) {
	if (document.images) {
  	document[image_name].src = eval(image_name + "1.src");
  }
}

function activate2(image_name) {
	if (document.images) {
  	document[image_name].src = eval(image_name + "2.src");
  }
}
function activate3(image_name) {
	if (document.images) {
  	document[image_name].src = eval(image_name + "3.src");
  }
}
function activate4(image_name) {
	if (document.images) {
  	document[image_name].src = eval(image_name + "4.src");
  }
}

function timedCountNumbered() {
	if (d%modulus == 1) {
		//printD(d);
    activate2('paper');
		d=d+1;
		q=setTimeout("timedCountNumbered()",shortCount);		
	} else if (d%modulus == 2) {
		//printD(d);
		activate3('paper');
		d=d+1;
		q=setTimeout("timedCountNumbered()",longCount);		
    //deactivate('blur');
	} else if (d%modulus == 3) {
		//printD(c);
		activate4('paper');
		d=d+1;
		q=setTimeout("timedCountNumbered()",shortCount);		

	} else if (d%modulus == 0) {
		//printC(c);
		activate1('paper');
		d=d+1;
		q=setTimeout("timedCountNumbered()",longCount);		
	}
}

/*function printD(d) {
		var numberDiv = document.getElementById("number");
		numberDiv.innerHTML = d;
}*/
