var bannerimgs = new Array("bannerimg1.jpg", "bannerimg2.jpg",  "bannerimg3.jpg", "bannerimg4.jpg");
var links = new Array("http://gem.compaq.com/gemstore/sites/federal/3115m_112/index.asp?jumpid=in_R3962_smaddox_3115m_112/promo_storeLOB|fed/placement|HomeTopLeft1","http://gem.compaq.com/gemstore/sites/federal/awards/index_7.asp?jumpid=in_R3962_smaddox_IPGawards/promo_storeLOB|fed/placement|HomeTopLeft1","http://gem.compaq.com/gemstore/sites/federal/microserver_1211/index.asp?jumpid=in_R3962_smaddox_microserver_1211/promo_storeLOB|fed/placement|HomeTopLeft1","http://gem.compaq.com/gemstore/sites/federal/slate2_212/index.asp?jumpid=in_R3962_smaddox_slate2_212/promo_storeLOB|fed/placement|HomeTopLeft1 ");

var currentframe = 1;
var currentdir = 1;
var last = 0;

var t = setTimeout("nextimage();",5000);


$(document).ready(function() {
						 
$('#bannerimage').css('cursor','pointer');

$('#bannerimage').click(function () { 
      window.location.href = links[currentframe-1];
    });


$('#control img:not(#control7)').hover(function () {

	var imgid = $(this).attr('id');
	var num = imgid.substring(7);
	num = parseInt(num);
	
	$(this).attr("src","http://gem.compaq.com/gemstore/images/yellow_0" + num + ".gif");
		}, function() {
		
	var imgid = $(this).attr('id');
	var num = imgid.substring(7);
	num = parseInt(num);	
	
	if ((currentframe != num) && (currentdir != num-7)) 
		
	$(this).attr("src","http://gem.compaq.com/gemstore/images/white_0" + num + ".gif");
	});

$('#control7').hover(function () {
	
	if (currentdir == 0)
	$(this).attr("src","http://gem.compaq.com/gemstore/images/yellow_07.gif");
	
	else
	$(this).attr("src","http://gem.compaq.com/gemstore/images/pause_yellow.gif");
		
		}, function() {
		
	if (currentdir == 0)
	$(this).attr("src","http://gem.compaq.com/gemstore/images/white_07.gif");
	else
	$(this).attr("src","http://gem.compaq.com/gemstore/images/pause_white.gif");
	});
	

$('#control img').click(function () {

	var imgid = $(this).attr('id');
	var num = imgid.substring(7);
	num = parseInt(num);
		
	if (num <= 4 && num != 5)
	{
		last = currentframe - 1;
		$('#control img:eq(' + last + ')').attr("src","http://gem.compaq.com/gemstore/images/white_0" + currentframe + ".gif");
		$(this).attr("src","http://gem.compaq.com/gemstore/images/yellow_0" + num + ".gif");
		$('#control img:eq(6)').attr("src","http://gem.compaq.com/gemstore/images/white_07.gif");
		$('#control img:eq(5)').attr("src","http://gem.compaq.com/gemstore/images/white_06.gif");
		$('#control img:eq(7)').attr("src","http://gem.compaq.com/gemstore/images/white_08.gif");
		currentframe = num;
		imageswap(currentframe);
		clearTimeout(t);
		currentdir = 0;
			
		
		
	}
	
	else if (num != 7 && num != 5)
	{
		last = currentdir + 6;
		dir = currentdir + 7;
		last3 = currentframe - 1;
		$('#control img:eq(' + last + ')').attr("src","http://gem.compaq.com/gemstore/images/white_0" + dir + ".gif");
		$('#control img:eq(' + last3 + ')').attr("src","http://gem.compaq.com/gemstore/images/white_0" + currentframe + ".gif");
		currentdir = num - 7;
		currentframe += currentdir;
		if (currentframe <= 0) currentframe = bannerimgs.length;
		else if (currentframe > bannerimgs.length) currentframe = 1;
		last2 = currentframe - 1;
		$(this).attr("src","http://gem.compaq.com/gemstore/images/yellow_0" + num + ".gif");
		$('#control img:eq(' + last2 + ')').attr("src","http://gem.compaq.com/gemstore/images/yellow_0" + currentframe + ".gif");
		$('#control img:eq(6)').attr("src","http://gem.compaq.com/gemstore/images/pause_white.gif");
		imageswap(currentframe);
		clearTimeout(t);
		t = setTimeout("nextimage();",5000);
	}
	
	else if (num == 7)
	{
		
		if (currentdir == 0)
		{
			currentdir = 1;
			$('#control img:eq(6)').attr("src","http://gem.compaq.com/gemstore/images/pause_white.gif");
			$('#control img:eq(5)').attr("src","http://gem.compaq.com/gemstore/images/white_06.gif");
			$('#control img:eq(7)').attr("src","http://gem.compaq.com/gemstore/images/yellow_08.gif");
			t = setTimeout("nextimage();",5000);
		}
		else
		{	
			currentdir = 0;
			$('#control img:eq(6)').attr("src","http://gem.compaq.com/gemstore/images/white_07.gif");
			$('#control img:eq(5)').attr("src","http://gem.compaq.com/gemstore/images/white_06.gif");
			$('#control img:eq(7)').attr("src","http://gem.compaq.com/gemstore/images/white_08.gif");
			clearTimeout(t);
		}
		
	}
	});
	
	
});

function imageswap(cf) {
	
		var image = "http://gem.compaq.com/gemstore/images/" + bannerimgs[cf-1];
		$("#scrollingbanner").fadeOut('slow',function() { 
		$("#scrollingbanner").css("display","none");
		$("#scrollingbanner").attr("src", image);
		$("#scrollingbanner:img").fadeIn('slow');
		
		});	
	}

function nextimage() {
	
		last = currentdir + 6;
		dir = currentdir + 7;
		last3 = currentframe - 1;
		//$('#control img:eq(' + last + ')').attr("src","images/white_0" + dir + ".gif");
		$('#control img:eq(' + last3 + ')').attr("src","http://gem.compaq.com/gemstore/images/white_0" + currentframe + ".gif");
		currentframe += currentdir;
		if (currentframe <= 0) currentframe = bannerimgs.length;
		else if (currentframe > bannerimgs.length) currentframe = 1;
		last2 = currentframe - 1;
		$('#control img:eq(' + last2 + ')').attr("src","http://gem.compaq.com/gemstore/images/yellow_0" + currentframe + ".gif");
		imageswap(currentframe);
		t = setTimeout("nextimage();",5000);
	
	}

