var xmlHttp;
/*
function showindex()
{
	//Make the AJAX connection for the content
	xmlHttp=GetXmlHttpObject();
	
	//If we cant do the request error out
	if (xmlHttp==null) {
	 	alert ("Browser does not support HTTP Request");
	 	return;
	}
	
	//First build the navigation panel
	var url="indexdata.php";
	url=url+"?t=con";
	
	//return false;
	//Once the page finished loading put it into the div
	xmlHttp.onreadystatechange=indexdata;

	//Get the php page
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}


function indexdata() { 
	//IF this is getting called when the page is done loading then fill the pagination div
	var content;
	content	=	'';
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { 
	 	//Update the Div tag with the outputted text
	 	content	=	"<table width=\"96%\">"+xmlHttp.responseText+"</table>";
	 	document.getElementById("indexcontent").innerHTML=content;
	} 
}*/
function GetXmlHttpObject() {
	//Determine what browser we are on and make a httprequest connection for ajax
	var xmlHttp=null;

	try {
	 	// Firefox, Opera 8.0+, Safari
	 	xmlHttp=new XMLHttpRequest();
	}
	catch (e) {
	 	//Internet Explorer
	 	try {
	  		xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
	  	}
	 	catch (e) {
	  		xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
	  	}
	}
	
	return xmlHttp;
}
function showtop()
{
	var cur_url = self.location.href;
	var s	=	cur_url.indexOf('#pagetop');
	if(s == -1)
	{
		location.replace(cur_url +'#pagetop');
	}
	else
	{
		location.href = cur_url;
	}
}

var xmlHttp3;
var xmlHttp4;
var Retailer_ID=0;

function checkretailervaluebrands(str, cats, textname, malefemale, compid, denmanid, usuk, configid,retailerid)
{
	if(retailerid)
	{
		Retailer_ID	= retailerid;
	}
	showSpecificBrand(str,cats, textname, malefemale, compid, denmanid, usuk, configid);
	//alert(Retailer_ID);
}
function showSpecificBrandPage(str, cats, textname, malefemale, compid, denmanid, usuk, configid) { 
	//Function that gets called
	//Currently we only call one other sub, but this could change
	showSpecificBrand(str,cats, textname, malefemale, compid, denmanid, usuk, configid);
}


function showSpecificBrand(str,cats, textname, malefemale, compid, denmanid, usuk, configid) { 
	//This sub will populate a table with all the states and get the 
	//pagination built
	
	//Make the AJAX connection for both the navigation and content
	xmlHttp4=GetXmlHttpObject();
	
	//If we cant do the request error out
	if (xmlHttp4==null ) {
	 	alert ("Browser does not support HTTP Request");
	 	return;
	}
		
	
	
	//Build the url to call
	//Pass variables through the url
	var url="ajax_brand.php";
	url=url+"?p="+str;
	url=url+"&t=con";
	url=url+"&catsid="+cats;
	url=url+"&textname="+encodeURIComponent(textname);
	url=url+"&MF="+malefemale;
	url=url+"&compid="+compid;
	url=url+"&manid="+denmanid;
	url=url+"&USUK="+usuk;
	url=url+"&CONFID="+configid;
	url=url+"&RETAILERID="+Retailer_ID;
	url=url+"&sid="+Math.random();
	
	//Once the page finished loading put it into the div
	xmlHttp4.onreadystatechange=brandslist ;
	
	//Get the php page
	xmlHttp4.open("GET",url,true);
	xmlHttp4.send(null);
	if(str > 1)
	{
		showtop();
	}
}

function brandslist() { 
	//IF this is getting called when the page is done loading the states then output the div
	var loader = "<div style=\"position: absolute; z-index: 99; width: 116px; height: 38px; margin-left: -59px; margin-top: 99px; left: 45%;\" id=\"loader\" style=\"z-index: 999;\">";
	loader	=	loader+"<table cellspacing=\"0\" cellpadding=\"0\"><tr><td style=\"background: url(images/lbl.gif) top right no-repeat; width: 17px; height: 46px;\"></td>";
	loader	=	loader+"<td style=\"background: url(images/lbc.gif) top left repeat-x;\"><div style=\"display: inline;\" class=\"lT\">";
	loader	=	loader+"<img class=\"m\" alt=\"\" src=\"images/ls.gif\"/><span id=\"loaderText\">Loading...</span>";
	loader	=	loader+"</div></td><td style=\"background: url(images/lbr.gif) top right no-repeat; width: 17px; height: 46px;\"></td></tr></table></div>";
	document.getElementById("pgContent").innerHTML=loader;
	
	if (xmlHttp4.readyState==4 || xmlHttp4.readyState=="complete") { 
	 	//Update the Div tag with the outputted text
	 	//alert(xmlHttp.responseText);
	 	document.getElementById("pgContent").innerHTML=xmlHttp4.responseText;
	}
}

