//Global variables
var xmlHttp;
//These are used in the viewGallery function
var iGlobalGalleryCount;
var sElementID;
var iTotalGallery
//These are used in the searchOptions function
var iCategoryID
var iTypeID
var iOptionID
var iBrandID

function GetXmlHttpObject()
{ 
	var objXMLHttp=null

	if (window.XMLHttpRequest)
	{
		objXMLHttp=new XMLHttpRequest()
	}
	else if (window.ActiveXObject)
	{
		objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
	}

	return objXMLHttp
}

//-----------------------------------------------------------------------------------------------------
//These function controlls the Gallery (shows the images for the gallery that is being click on)
function viewGallery(iGalleryID, iGalleryCount)
{
	//setting global variables
	iGlobalGalleryCount	= iGalleryCount //used to define which gallery to show
	sElementID				= 'gallery-display' + iGlobalGalleryCount // the full galleryID we are showing
	iTotalGallery			= document.getElementById("galleryamount").value //the total amount of gallerys used to loop through and hide them all
		
	//copy the contents of our local var to our global var for later use
	var url = "ajaxGrabGallery.asp?iGalleryID=" + iGalleryID;
	
	//Hiding all the Gallerys
	for (i=1;i<=iTotalGallery;i++) {
		document.getElementById("gallery-display" + i).style.display	= 'none'
	}

	xmlHttp=GetXmlHttpObject()

	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	}

	document.getElementById(sElementID).innerHTML						= ""
	document.getElementById(sElementID).style.display					= "none";
	document.getElementById("ajaxLoading").style.display				= "inline";

	xmlHttp.onreadystatechange=stateChanged_viewGallery
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function stateChanged_viewGallery() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		document.getElementById(sElementID).innerHTML			= xmlHttp.responseText;
		document.getElementById(sElementID).style.display		= "inline";
		document.getElementById("ajaxLoading").style.display	= "none";

		loadobjs('css/thickbox.css', 'js/thickbox.js', 'js/jquery.js');
	} 
} 



//-----------------------------------------------------------------------------------------------------
//These function controlls the product search area
function searchOptions(sShowType,iValue)
{
	//copy the contents of our local var to our global var for later use
	if (sShowType == 'ALL'){
		var url = "http://localhost/ajaxSearch.asp?sShowType=" + sShowType;
	} else {
		if (sShowType == 'SPORT'){
			document.getElementById('TYPEselect').value		= '0'
			document.getElementById('BRANDselect').value		= '0'
			document.getElementById('OPTIONselect').value	= '0'
		}
		if (sShowType == 'BRAND'){
			document.getElementById('TYPEselect').value		= '0'
			document.getElementById('OPTIONselect').value	= '0'
		}
		if (sShowType == 'TYPE'){
			document.getElementById('OPTIONselect').value	= '0'
		}
	}

	document.getElementById(sShowType + 'select').value	= iValue;
	document.forms.searching.submit();
}