// JavaScript Document
gSlideshowInterval = 5;
gNumberOfImages = 9;

gImages = new Array(gNumberOfImages);
gImages[0] = "/content/images/sponsor1.jpg";
gImages[1] = "/content/images/sponsor2.jpg";
gImages[2] = "/content/images/sponsor3.jpg";
gImages[3] = "/content/images/sponsor5.jpg";
gImages[4] = "/content/images/sponsor6.jpg";
gImages[5] = "/content/images/sponsor9.jpg";
gImages[6] = "/content/images/sponsor10.jpg";
gImages[7] = "/content/images/sponsor11.jpg";
gImages[8] = "/content/images/sponsor13.jpg";

function canManipulateImages() {
	if (document.images)
		return true;
	else
		return false;
}
function loadSlide(imageURL) {
	if (gImageCapableBrowser) {
		document.sponsorImages.src = imageURL;
		return false;
	}
	else {
		return true;
	}
}
function nextSlide() {
	gCurrentImage = (gCurrentImage + 1) % gNumberOfImages;
	loadSlide(gImages[gCurrentImage]);
}
gImageCapableBrowser = canManipulateImages();
gCurrentImage = 0;
setInterval("nextSlide()",gSlideshowInterval * 1000);

function submitSearchFormFromDropdown(type){

	var catid = document.getElementById('categoryid').value;
	var groupid = document.getElementById('groupid').value;
	var vendorid = document.getElementById('vendorid').value;
	var sizeid = document.getElementById('sizeid').value;
	var selecttype = type


	var qs = new Querystring();
	var ps = qs.get("productSearch")
	var join = qs.get("joining")
	var sub = qs.get("submit")

	var location = "index.asp?select=" + selecttype + "&categoryid=" + catid + "&vendorid=" + vendorid + "&groupid=" + groupid + "&sizeid=" + sizeid;

	if (ps == null)
		location = location + "&productSearch=";
	else
		location = location + "&productSearch=" + ps;


	if (join != '') {
		if (join != 'null' && join != null)
			location = location + "&joining=" + join;
		else
			location = location + "&joining=";
	}

	if (sub != '') {
		if (sub != 'null' && sub != null)
			location = location + "&submit=" + sub;
		else
			location = location + "&submit=";

	}

	document.getElementById('hdnProgessMsg').style.visibility='visible';
	window.location=location;
}

/* Client-side access to querystring name=value pairs
	Version 1.2.3
	22 Jun 2005
	Adam Vandenberg
*/
function Querystring(qs) { // optionally pass a querystring to parse
	this.params = new Object()
	this.get=Querystring_get
	
	if (qs == null)
		qs=location.search.substring(1,location.search.length)

	if (qs.length == 0) return

// Turn <plus> back to <space>
// See: http://www.w3.org/TR/REC-html40/interact/forms.html#h-17.13.4.1
	qs = qs.replace(/\+/g, ' ')
	var args = qs.split('&') // parse out name/value pairs separated via &
	
// split out each name=value pair
	for (var i=0;i<args.length;i++) {
		var value;
		var pair = args[i].split('=')
		var name = unescape(pair[0])

		if (pair.length == 2)
			value = unescape(pair[1])
		else
			value = name
		
		this.params[name] = value
	}
}

function Querystring_get(key, default_) {
	// This silly looking line changes UNDEFINED to NULL
	if (default_ == null) default_ = null;
	
	var value=this.params[key]
	if (value==null) value=default_;
	
	return value
}