//***** Homepage Random image rotator *****//

var theImages = new Array();
theImages[0] = 'static/images/splash_Adidas_Samba_Nua.jpg';

var theUrls = new Array();
theUrls[0] = 'Adidas-Indoor-Soccer-Shoes-c311/';

var theTags = new Array();
theTags[0] = 'Adidas Indoor Soccer Shoes';

function rotator() {
	var whichImage = Math.round(Math.random()*(theImages.length-1));

	document.write('<a href="'+theUrls[whichImage]+'" ><img src="'+theImages[whichImage]+'" alt="'+theTags[whichImage]+'" border="0" width="575" height="141" /></a>');
}

var subImages = new Array();  //array = alt, image, link
subImages[0] = new Array('Nike Soccer Footwear','static/images/subLeft_NikeShoes_thin.jpg','Nike-Soccer-Shoes-c265/');
subImages[1] = new Array('Adidas Soccer Shoes','static/images/subLeft_AdidasShoe_thin.jpg','Adidas-Soccer-Shoes-c256/');


function subRotator() {
	var whichImage = Math.round(Math.random()*(subImages.length-1));

	document.write('<a href="'+subImages[whichImage][2]+'" ><img src="'+subImages[whichImage][1]+'" alt="'+subImages[whichImage][0]+'" border="0" width="210" height="100" /></a>');
}


//***** QueryString processor *****//

function PageQuery(q) {
	if(q.length > 1) this.q = q.substring(1, q.length);
	else this.q = null;
	this.keyValuePairs = new Array();
	if(q) {
		for(var i=0; i < this.q.split("&").length; i++) {
		this.keyValuePairs[i] = this.q.split("&")[i];
		}
	}
	this.getKeyValuePairs = function() { return this.keyValuePairs; }
	this.getValue = function(s) {
		for(var j=0; j < this.keyValuePairs.length; j++) {
			if(this.keyValuePairs[j].split("=")[0] == s)
			return this.keyValuePairs[j].split("=")[1];
		}
		return false;
	}
	this.getParameters = function() {
		var a = new Array(this.getLength());
		for(var j=0; j < this.keyValuePairs.length; j++) {
			a[j] = this.keyValuePairs[j].split("=")[0];
		}
		return a;
	}
	this.getLength = function() { return this.keyValuePairs.length; } 
}
function queryString(key){
	var page = new PageQuery(window.location.search); 
	return unescape(page.getValue(key)); 
}

//***** TopSubBanner ad rotator *****//

var AD = new Array();  //array = title, image, link
AD[0] = new Array('Free Shipping On Orders $50 Or More - Click For Details','static/images/top_free_upsshipping_50.gif','index/page/static/subpage/store_policies/#shipping');
AD[1] = new Array('Free Shipping On Orders $50 Or More - Click For Details','static/images/top_free_upsshipping_50.gif','index/page/static/subpage/store_policies/#shipping');
AD[2] = new Array('Free Shipping On Orders $50 Or More - Click For Details','static/images/top_free_upsshipping_50.gif','index/page/static/subpage/store_policies/#shipping');
AD[3] = new Array('Free Shipping On Orders $50 Or More - Click For Details','static/images/top_free_upsshipping_50.gif','index/page/static/subpage/store_policies/#shipping');
AD[4] = new Array('Free Shipping On Orders $50 Or More - Click For Details','static/images/top_free_upsshipping_50.gif','index/page/static/subpage/store_policies/#shipping');

function ADrotator(AD) {
	var whichAd;
	if (queryString('RCtest')!='false'){
		whichAd = queryString('RCtest');
	} else {
		whichAd = Math.round(Math.random()*(AD.length-1));
	}

	document.write('<a href="'+AD[whichAd][2]+'"><img src="'+AD[whichAd][1]+'" width="220" height="72" border="0" alt="'+AD[whichAd][0]+'"></a>');
}
