// JavaScript Document
var www = "http://www.";
var ajaxurl = document.URL;
var checkwww = ajaxurl.substring(7,10);
if (checkwww != "www") {www = "http://";}

function displayError(message) {
	throw("Error: " + message);
	}

function toolOn(toolid)
{
	var onn = document.getElementById(toolid)
	onn.style.display="block";
	var yelling = document.getElementById("yel" + toolid)
	yelling.style.backgroundPosition="0 -24px";
}

function toolOff(toolid)
{
	var offf = document.getElementById(toolid)
	offf.style.display="none";
	var shutup = document.getElementById("yel" + toolid)
	shutup.style.backgroundPosition="0 0";
}


function alphaLoad(cat)
{
	var serverParams = "mode=RTK&PTNS=1&cat=" + cat + "&subcat=NL";
	if (xmlHttp)
	{
		try
		{	
			xmlHttp.open("GET", www + "rusticaspenfurniture.com/Javascript/GalleryProcess.php?" + serverParams, true);
			xmlHttp.onreadystatechange = alphaReturn;
			xmlHttp.send("null");
		}
		catch(e)
		{
			throw("Error: " + e.toString());
		}
	}
}

function alphaReturn()
{
	if (xmlHttp.readyState == 4) 
	{
	if (xmlHttp.status == 200)
		{ 
		try 
		{
			
	var xmlResponse = xmlHttp.responseXML;
	if (!xmlResponse || !xmlResponse.documentElement)
		throw("Invalid XML Structure:\n" + xmlHttp.responseText);
	var rootNodeName = xmlResponse.documentElement.nodeName;
	if (rootNodeName == "parseerror")
		throw("Invalid XML Structure:\n" + xmlHttp.responseText);
	var xmlRoot = xmlResponse.documentElement;
	if (rootNodeName != "response" || !xmlRoot.firstChild)
		throw("Invalid XML Structure:\n" + xmlHttp.responseText);
			 
	var rts = xmlRoot.getElementsByTagName("rts")[0].firstChild.data;
	var ovf = xmlRoot.getElementsByTagName("overflow")[0].firstChild.data;
		if (ovf != "NA") {rts = rts + ovf;}
	var fiurl = xmlRoot.getElementsByTagName("firstimage")[0].firstChild.data;
	var fit = xmlRoot.getElementsByTagName("firstimageinfo")[0].firstChild.data;
	var fis = xmlRoot.getElementsByTagName("firstimagesku")[0].firstChild.data;
	var fip = xmlRoot.getElementsByTagName("firstimageprice")[0].firstChild.data;
	
	

	var writeImgA = document.getElementById("AJAX_loadimgA");
		writeImgA.innerHTML = "<img src='" + fiurl + "' />";
	var writeImgInfoA = document.getElementById("AJAX_miiA");
		writeImgInfoA.innerHTML = "<h3>" + fit + "</h3>";
	var tnarray = document.getElementById("imgtns");
		tnarray.innerHTML = rts;
	var writeSKU = document.getElementById("sku");
		writeSKU.innerHTML = "SKU: " + fis + ", " + fip;
	
	var hiliteOne = document.getElementById("pageone");
		hiliteOne.style.background="url('" + www + "rusticaspenfurniture.com/IM/Nav/PageNumBak.jpg')";
	var hiliteTwo = document.getElementById("pagetwo");
		hiliteTwo.style.background="";
	var hiliteThree = document.getElementById("pagethree");
		hiliteThree.style.background="";
	var hiliteFour = document.getElementById("pagefour");
		hiliteFour.style.background="";
	var hiliteFive = document.getElementById("pagefive");
		hiliteFive.style.background="";
	var hiliteSix = document.getElementById("pagesix");
		hiliteSix.style.background="";
	var hiliteSeven = document.getElementById("pageseven");
		hiliteSeven.style.background="";
	var hiliteEight = document.getElementById("pageeight");
		hiliteEight.style.background="";
	var hiliteNine = document.getElementById("pagenine");
		hiliteNine.style.background="";
	var hiliteTen = document.getElementById("pageten");
		hiliteTen.style.background="";
	var hiliteEleven = document.getElementById("pageeleven");
		hiliteEleven.style.background="";
	

} catch(e) {displayError(e.toString());}	// END Try Statement
} else {displayError(xmlHttp.statusText);}	// END Status200
} 											// END ReadyState4
} 											// END Function



function populateTNS(direction, cat, subcat)
{
	var checksubcats = document.SubCategorySelection.subcategory.value;
		if (checksubcats != "NL") {subcat = checksubcats;}
	var serverParams = "mode=TNS&PTNS=" + direction + "&cat=" + cat + "&subcat=" + subcat;
	if (xmlHttp)
	{
		try
		{	
			xmlHttp.open("GET", www + "rusticaspenfurniture.com/Javascript/GalleryProcess.php?" + serverParams, true);
			xmlHttp.onreadystatechange = returnTNS;
			xmlHttp.send("null");
		}
		catch(e)
		{
			throw("Error: " + e.toString());
		}
	}
}

function returnTNS()
{
	if (xmlHttp.readyState == 4) 
	{
	if (xmlHttp.status == 200)
		{ 
		try 
		{
			
	var xmlResponse = xmlHttp.responseXML;
	if (!xmlResponse || !xmlResponse.documentElement)
		throw("Invalid XML Structure:\n" + xmlHttp.responseText);
	var rootNodeName = xmlResponse.documentElement.nodeName;
	if (rootNodeName == "parseerror")
		throw("Invalid XML Structure:\n" + xmlHttp.responseText);
	var xmlRoot = xmlResponse.documentElement;
	if (rootNodeName != "response" || !xmlRoot.firstChild)
		throw("Invalid XML Structure:\n" + xmlHttp.responseText);
			 
	var rts = xmlRoot.getElementsByTagName("rts")[0].firstChild.data;
	var ovf = xmlRoot.getElementsByTagName("overflow")[0].firstChild.data;
		if (ovf != "NA") {rts = rts + ovf;}
	var chngdir = xmlRoot.getElementsByTagName("chngdir")[0].firstChild.data;
	var cat = xmlRoot.getElementsByTagName("category")[0].firstChild.data;
	var catpass = xmlRoot.getElementsByTagName("subcatpass")[0].firstChild.data;
	var sublevel = xmlRoot.getElementsByTagName("sublevel")[0].firstChild.data;
		var pageinnards = document.getElementById("PageDiv");
		if (sublevel == 1) {pageinnards.innerHTML = "<p id='pageone' onmouseover=this.style.cursor='pointer' onclick=\"populateTNS('1','" + cat + "','" + catpass + "')\">1</p>" +
			"<p id='pagetwo' class='inactivecolor'>2</p>" + "<p id='pagethree' class='inactivecolor'>3</p>" + "<p id='pagefour' class='inactivecolor'>4</p>" +
			"<p id='pagefive' class='inactivecolor'>5</p>" + "<p id='pagesix' class='inactivecolor'>6</p>" + "<p id='pageseven' class='inactivecolor'>7</p>" + 
			"<p id='pageeight' class='inactivecolor'>8</p>" + "<p id='pagenine' class='inactivecolor'>9</p>" + "<p id='pageten' class='inactivecolor'>10</p>" + 
			"<p id='pageeleven' class='inactivecolor'>11</p>";}
		else if (sublevel == 2) {pageinnards.innerHTML = "<p id='pageone' onmouseover=this.style.cursor='pointer' onclick=\"populateTNS('1','" + cat + "','" + catpass + "')\">1</p>" +
			"<p id='pagetwo' onmouseover=this.style.cursor='pointer' onclick=\"populateTNS('2','" + cat + "','" + catpass + "')\">2</p>" + "<p id='pagethree' class='inactivecolor'>3</p>" + 
			"<p id='pagefour' class='inactivecolor'>4</p>" + "<p id='pagefive' class='inactivecolor'>5</p>" + "<p id='pagesix' class='inactivecolor'>6</p>" + 
			"<p id='pageseven' class='inactivecolor'>7</p>" + "<p id='pageeight' class='inactivecolor'>8</p>" + "<p id='pagenine' class='inactivecolor'>9</p>" + 
			"<p id='pageten' class='inactivecolor'>10</p>" + 
			"<p id='pageeleven' class='inactivecolor'>11</p>";}
		else if (sublevel == 3) {pageinnards.innerHTML = "<p id='pageone' onmouseover=this.style.cursor='pointer' onclick=\"populateTNS('1','" + cat + "','" + catpass + "')\">1</p>" +
			"<p id='pagetwo' onmouseover=this.style.cursor='pointer' onclick=\"populateTNS('2','" + cat + "','" + catpass + "')\">2</p>" + 
			"<p id='pagethree' onmouseover=this.style.cursor='pointer' onclick=\"populateTNS('3','" + cat + "','" + catpass + "')\">3</p>" + 
			"<p id='pagefour' class='inactivecolor'>4</p>" + "<p id='pagefive' class='inactivecolor'>5</p>" + "<p id='pagesix' class='inactivecolor'>6</p>" + 
			"<p id='pageseven' class='inactivecolor'>7</p>" + "<p id='pageeight' class='inactivecolor'>8</p>" + "<p id='pagenine' class='inactivecolor'>9</p>" + 
			"<p id='pageten' class='inactivecolor'>10</p>" + 
			"<p id='pageeleven' class='inactivecolor'>11</p>";}
		else if(sublevel == 4) {pageinnards.innerHTML = "<p id='pageone' onmouseover=this.style.cursor='pointer' onclick=\"populateTNS('1','" + cat + "','" + catpass + "')\">1</p>" +
			"<p id='pagetwo' onmouseover=this.style.cursor='pointer' onclick=\"populateTNS('2','" + cat + "','" + catpass + "')\">2</p>" + 
			"<p id='pagethree' onmouseover=this.style.cursor='pointer' onclick=\"populateTNS('3','" + cat + "','" + catpass + "')\">3</p>" + 
			"<p id='pagefour' onmouseover=this.style.cursor='pointer' onclick=\"populateTNS('4','" + cat + "','" + catpass + "')\">4</p>" + "<p id='pagefive' class='inactivecolor'>5</p>" +
			"<p id='pagesix' class='inactivecolor'>6</p>" + "<p id='pageseven' class='inactivecolor'>7</p>" + "<p id='pageeight' class='inactivecolor'>8</p>" + 
			"<p id='pagenine' class='inactivecolor'>9</p>" + "<p id='pageten' class='inactivecolor'>10</p>" + 
			"<p id='pageeleven' class='inactivecolor'>11</p>";}
		else if(sublevel == 5) {pageinnards.innerHTML = "<p id='pageone' onmouseover=this.style.cursor='pointer' onclick=\"populateTNS('1','" + cat + "','" + catpass + "')\">1</p>" +
			"<p id='pagetwo' onmouseover=this.style.cursor='pointer' onclick=\"populateTNS('2','" + cat + "','" + catpass + "')\">2</p>" + 
			"<p id='pagethree' onmouseover=this.style.cursor='pointer' onclick=\"populateTNS('3','" + cat + "','" + catpass + "')\">3</p>" + 
			"<p id='pagefour' onmouseover=this.style.cursor='pointer' onclick=\"populateTNS('4','" + cat + "','" + catpass + "')\">4</p>" + 
			"<p id='pagefive' onmouseover=this.style.cursor='pointer' onclick=\"populateTNS('5','" + cat + "','" + catpass + "')\">5</p>" + "<p id='pagesix' class='inactivecolor'>6</p>" + 
			"<p id='pageseven' class='inactivecolor'>7</p>" + "<p id='pageeight' class='inactivecolor'>8</p>" + "<p id='pagenine' class='inactivecolor'>9</p>" + 
			"<p id='pageten' class='inactivecolor'>10</p>" + 
			"<p id='pageeleven' class='inactivecolor'>11</p>";}
		else if(sublevel == 6) {pageinnards.innerHTML = "<p id='pageone' onmouseover=this.style.cursor='pointer' onclick=\"populateTNS('1','" + cat + "','" + catpass + "')\">1</p>" +
			"<p id='pagetwo' onmouseover=this.style.cursor='pointer' onclick=\"populateTNS('2','" + cat + "','" + catpass + "')\">2</p>" + 
			"<p id='pagethree' onmouseover=this.style.cursor='pointer' onclick=\"populateTNS('3','" + cat + "','" + catpass + "')\">3</p>" + 
			"<p id='pagefour' onmouseover=this.style.cursor='pointer' onclick=\"populateTNS('4','" + cat + "','" + catpass + "')\">4</p>" + 
			"<p id='pagefive' onmouseover=this.style.cursor='pointer' onclick=\"populateTNS('5','" + cat + "','" + catpass + "')\">5</p>" +
			"<p id='pagesix' onmouseover=this.style.cursor='pointer' onclick=\"populateTNS('6','" + cat + "','" + catpass + "')\">6</p>" + 
			"<p id='pageseven' class='inactivecolor'>7</p>" + "<p id='pageeight' class='inactivecolor'>8</p>" + "<p id='pagenine' class='inactivecolor'>9</p>" + 
			"<p id='pageten' class='inactivecolor'>10</p>" + 
			"<p id='pageeleven' class='inactivecolor'>11</p>";}
		else if(sublevel == 7) {pageinnards.innerHTML = "<p id='pageone' onmouseover=this.style.cursor='pointer' onclick=\"populateTNS('1','" + cat + "','" + catpass + "')\">1</p>" +
			"<p id='pagetwo' onmouseover=this.style.cursor='pointer' onclick=\"populateTNS('2','" + cat + "','" + catpass + "')\">2</p>" + 
			"<p id='pagethree' onmouseover=this.style.cursor='pointer' onclick=\"populateTNS('3','" + cat + "','" + catpass + "')\">3</p>" + 
			"<p id='pagefour' onmouseover=this.style.cursor='pointer' onclick=\"populateTNS('4','" + cat + "','" + catpass + "')\">4</p>" + 
			"<p id='pagefive' onmouseover=this.style.cursor='pointer' onclick=\"populateTNS('5','" + cat + "','" + catpass + "')\">5</p>" +
			"<p id='pagesix' onmouseover=this.style.cursor='pointer' onclick=\"populateTNS('6','" + cat + "','" + catpass + "')\">6</p>" +
			"<p id='pageseven' onmouseover=this.style.cursor='pointer' onclick=\"populateTNS('7','" + cat + "','" + catpass + "')\">7</p>" + 
			"<p id='pageeight' class='inactivecolor'>8</p>" + "<p id='pagenine' class='inactivecolor'>9</p>" + "<p id='pageten' class='inactivecolor'>10</p>" + 
			"<p id='pageeleven' class='inactivecolor'>11</p>";}
		else if(sublevel == 8) {pageinnards.innerHTML = "<p id='pageone' onmouseover=this.style.cursor='pointer' onclick=\"populateTNS('1','" + cat + "','" + catpass + "')\">1</p>" +
			"<p id='pagetwo' onmouseover=this.style.cursor='pointer' onclick=\"populateTNS('2','" + cat + "','" + catpass + "')\">2</p>" + 
			"<p id='pagethree' onmouseover=this.style.cursor='pointer' onclick=\"populateTNS('3','" + cat + "','" + catpass + "')\">3</p>" + 
			"<p id='pagefour' onmouseover=this.style.cursor='pointer' onclick=\"populateTNS('4','" + cat + "','" + catpass + "')\">4</p>" + 
			"<p id='pagefive' onmouseover=this.style.cursor='pointer' onclick=\"populateTNS('5','" + cat + "','" + catpass + "')\">5</p>" +
			"<p id='pagesix' onmouseover=this.style.cursor='pointer' onclick=\"populateTNS('6','" + cat + "','" + catpass + "')\">6</p>" +
			"<p id='pageseven' onmouseover=this.style.cursor='pointer' onclick=\"populateTNS('7','" + cat + "','" + catpass + "')\">7</p>" +
			"<p id='pageeight' onmouseover=this.style.cursor='pointer' onclick=\"populateTNS('8','" + cat + "','" + catpass + "')\">8</p>" + 
			"<p id='pagenine' class='inactivecolor'>9</p>" + "<p id='pageten' class='inactivecolor'>10</p>" + 
			"<p id='pageeleven' class='inactivecolor'>11</p>";}
		else if(sublevel == 9) {pageinnards.innerHTML = "<p id='pageone' onmouseover=this.style.cursor='pointer' onclick=\"populateTNS('1','" + cat + "','" + catpass + "')\">1</p>" +
			"<p id='pagetwo' onmouseover=this.style.cursor='pointer' onclick=\"populateTNS('2','" + cat + "','" + catpass + "')\">2</p>" + 
			"<p id='pagethree' onmouseover=this.style.cursor='pointer' onclick=\"populateTNS('3','" + cat + "','" + catpass + "')\">3</p>" + 
			"<p id='pagefour' onmouseover=this.style.cursor='pointer' onclick=\"populateTNS('4','" + cat + "','" + catpass + "')\">4</p>" + 
			"<p id='pagefive' onmouseover=this.style.cursor='pointer' onclick=\"populateTNS('5','" + cat + "','" + catpass + "')\">5</p>" +
			"<p id='pagesix' onmouseover=this.style.cursor='pointer' onclick=\"populateTNS('6','" + cat + "','" + catpass + "')\">6</p>" +
			"<p id='pageseven' onmouseover=this.style.cursor='pointer' onclick=\"populateTNS('7','" + cat + "','" + catpass + "')\">7</p>" +
			"<p id='pageeight' onmouseover=this.style.cursor='pointer' onclick=\"populateTNS('8','" + cat + "','" + catpass + "')\">8</p>" +
			"<p id='pagenine' onmouseover=this.style.cursor='pointer' onclick=\"populateTNS('9','" + cat + "','" + catpass + "')\">9</p>" + 
			"<p id='pageten' class='inactivecolor'>10</p>" + 
			"<p id='pageeleven' class='inactivecolor'>11</p>";}
		else if(sublevel == 10) {pageinnards.innerHTML = "<p id='pageone' onmouseover=this.style.cursor='pointer' onclick=\"populateTNS('1','" + cat + "','" + catpass + "')\">1</p>" +
			"<p id='pagetwo' onmouseover=this.style.cursor='pointer' onclick=\"populateTNS('2','" + cat + "','" + catpass + "')\">2</p>" + 
			"<p id='pagethree' onmouseover=this.style.cursor='pointer' onclick=\"populateTNS('3','" + cat + "','" + catpass + "')\">3</p>" + 
			"<p id='pagefour' onmouseover=this.style.cursor='pointer' onclick=\"populateTNS('4','" + cat + "','" + catpass + "')\">4</p>" + 
			"<p id='pagefive' onmouseover=this.style.cursor='pointer' onclick=\"populateTNS('5','" + cat + "','" + catpass + "')\">5</p>" +
			"<p id='pagesix' onmouseover=this.style.cursor='pointer' onclick=\"populateTNS('6','" + cat + "','" + catpass + "')\">6</p>" +
			"<p id='pageseven' onmouseover=this.style.cursor='pointer' onclick=\"populateTNS('7','" + cat + "','" + catpass + "')\">7</p>" +
			"<p id='pageeight' onmouseover=this.style.cursor='pointer' onclick=\"populateTNS('8','" + cat + "','" + catpass + "')\">8</p>" +
			"<p id='pagenine' onmouseover=this.style.cursor='pointer' onclick=\"populateTNS('9','" + cat + "','" + catpass + "')\">9</p>" + 
			"<p id='pageten' onmouseover=this.style.cursor='pointer' onclick=\"populateTNS('10','" + cat + "','" + catpass + "')\">10</p>" + 
			"<p id='pageeleven' class='inactivecolor'>11</p>";}
		else if(sublevel == 11) {pageinnards.innerHTML = "<p id='pageone' onmouseover=this.style.cursor='pointer' onclick=\"populateTNS('1','" + cat + "','" + catpass + "')\">1</p>" +
			"<p id='pagetwo' onmouseover=this.style.cursor='pointer' onclick=\"populateTNS('2','" + cat + "','" + catpass + "')\">2</p>" + 
			"<p id='pagethree' onmouseover=this.style.cursor='pointer' onclick=\"populateTNS('3','" + cat + "','" + catpass + "')\">3</p>" + 
			"<p id='pagefour' onmouseover=this.style.cursor='pointer' onclick=\"populateTNS('4','" + cat + "','" + catpass + "')\">4</p>" + 
			"<p id='pagefive' onmouseover=this.style.cursor='pointer' onclick=\"populateTNS('5','" + cat + "','" + catpass + "')\">5</p>" +
			"<p id='pagesix' onmouseover=this.style.cursor='pointer' onclick=\"populateTNS('6','" + cat + "','" + catpass + "')\">6</p>" +
			"<p id='pageseven' onmouseover=this.style.cursor='pointer' onclick=\"populateTNS('7','" + cat + "','" + catpass + "')\">7</p>" +
			"<p id='pageeight' onmouseover=this.style.cursor='pointer' onclick=\"populateTNS('8','" + cat + "','" + catpass + "')\">8</p>" +
			"<p id='pagenine' onmouseover=this.style.cursor='pointer' onclick=\"populateTNS('9','" + cat + "','" + catpass + "')\">9</p>" + 
			"<p id='pageten' onmouseover=this.style.cursor='pointer' onclick=\"populateTNS('10','" + cat + "','" + catpass + "')\">10</p>" + 
			"<p id='pageeleven' onmouseover=this.style.cursor='pointer' onclick=\"populateTNS('11','" + cat + "','" + catpass + "')\">11</p>";}

	var tnarray = document.getElementById("imgtns");
	tnarray.innerHTML = rts;
	
	var hiliteOne = document.getElementById("pageone");
	var hiliteTwo = document.getElementById("pagetwo");
	var hiliteThree = document.getElementById("pagethree");
	var hiliteFour = document.getElementById("pagefour");
	var hiliteFive = document.getElementById("pagefive");
	var hiliteSix = document.getElementById("pagesix");
	var hiliteSeven = document.getElementById("pageseven");
	var hiliteEight = document.getElementById("pageeight");
	var hiliteNine = document.getElementById("pagenine");
	var hiliteTen = document.getElementById("pageten");
	var hiliteEleven = document.getElementById("pageeleven");
	
	if (chngdir == "PageOne") {
		hiliteOne.style.background="url('" + www + "rusticaspenfurniture.com/IM/Nav/PageNumBak.jpg')";
		hiliteTwo.style.background="";
		hiliteThree.style.background="";
		hiliteFour.style.background="";
		hiliteFive.style.background="";
		hiliteSix.style.background="";
		hiliteSeven.style.background="";
		hiliteEight.style.background="";
		hiliteNine.style.background="";
		hiliteTen.style.background="";
		hiliteEleven.style.background="";
	}
	else if (chngdir == "PageTwo") {
		hiliteOne.style.background="";
		hiliteTwo.style.background="url('" + www + "rusticaspenfurniture.com/IM/Nav/PageNumBak.jpg')";
		hiliteThree.style.background="";
		hiliteFour.style.background="";
		hiliteFive.style.background="";
		hiliteSix.style.background="";
		hiliteSeven.style.background="";
		hiliteEight.style.background="";
		hiliteNine.style.background="";
		hiliteTen.style.background="";
		hiliteEleven.style.background="";
	}
	else if (chngdir == "PageThree") {
		hiliteOne.style.background="";
		hiliteTwo.style.background="";
		hiliteThree.style.background="url('" + www + "rusticaspenfurniture.com/IM/Nav/PageNumBak.jpg')";
		hiliteFour.style.background="";
		hiliteFive.style.background="";
		hiliteSix.style.background="";
		hiliteSeven.style.background="";
		hiliteEight.style.background="";
		hiliteNine.style.background="";
		hiliteTen.style.background="";
		hiliteEleven.style.background="";
	}
	else if (chngdir == "PageFour") {
		hiliteOne.style.background="";
		hiliteTwo.style.background="";
		hiliteThree.style.background="";
		hiliteFour.style.background="url('" + www + "rusticaspenfurniture.com/IM/Nav/PageNumBak.jpg')";
		hiliteFive.style.background="";
		hiliteSix.style.background="";
		hiliteSeven.style.background="";
		hiliteEight.style.background="";
		hiliteNine.style.background="";
		hiliteTen.style.background="";
		hiliteEleven.style.background="";
	}
	else if (chngdir == "PageFive") {
		hiliteOne.style.background="";
		hiliteTwo.style.background="";
		hiliteThree.style.background="";
		hiliteFour.style.background="";
		hiliteFive.style.background="url('" + www + "rusticaspenfurniture.com/IM/Nav/PageNumBak.jpg')";
		hiliteSix.style.background="";
		hiliteSeven.style.background="";
		hiliteEight.style.background="";
		hiliteNine.style.background="";
		hiliteTen.style.background="";
		hiliteEleven.style.background="";
	}
	else if (chngdir == "PageSix") {
		hiliteOne.style.background="";
		hiliteTwo.style.background="";
		hiliteThree.style.background="";
		hiliteFour.style.background="";
		hiliteFive.style.background="";
		hiliteSix.style.background="url('" + www + "rusticaspenfurniture.com/IM/Nav/PageNumBak.jpg')";
		hiliteSeven.style.background="";
		hiliteEight.style.background="";
		hiliteNine.style.background="";
		hiliteTen.style.background="";
		hiliteEleven.style.background="";
	}
	else if (chngdir == "PageSeven") {
		hiliteOne.style.background="";
		hiliteTwo.style.background="";
		hiliteThree.style.background="";
		hiliteFour.style.background="";
		hiliteFive.style.background="";
		hiliteSix.style.background="";
		hiliteSeven.style.background="url('" + www + "rusticaspenfurniture.com/IM/Nav/PageNumBak.jpg')";
		hiliteEight.style.background="";
		hiliteNine.style.background="";
		hiliteTen.style.background="";
		hiliteEleven.style.background="";
	}
	else if (chngdir == "PageEight") {
		hiliteOne.style.background="";
		hiliteTwo.style.background="";
		hiliteThree.style.background="";
		hiliteFour.style.background="";
		hiliteFive.style.background="";
		hiliteSix.style.background="";
		hiliteSeven.style.background="";
		hiliteEight.style.background="url('" + www + "rusticaspenfurniture.com/IM/Nav/PageNumBak.jpg')";
		hiliteNine.style.background="";
		hiliteTen.style.background="";
		hiliteEleven.style.background="";
	}
	else if (chngdir == "PageNine") {
		hiliteOne.style.background="";
		hiliteTwo.style.background="";
		hiliteThree.style.background="";
		hiliteFour.style.background="";
		hiliteFive.style.background="";
		hiliteSix.style.background="";
		hiliteSeven.style.background="";
		hiliteEight.style.background="";
		hiliteNine.style.background="url('" + www + "rusticaspenfurniture.com/IM/Nav/PageNumBak.jpg')";
		hiliteTen.style.background="";
		hiliteEleven.style.background="";
	}
	else if (chngdir == "PageTen") {
		hiliteOne.style.background="";
		hiliteTwo.style.background="";
		hiliteThree.style.background="";
		hiliteFour.style.background="";
		hiliteFive.style.background="";
		hiliteSix.style.background="";
		hiliteSeven.style.background="";
		hiliteEight.style.background="";
		hiliteNine.style.background="";
		hiliteTen.style.background="url('" + www + "rusticaspenfurniture.com/IM/Nav/PageNumBak.jpg')";
		hiliteEleven.style.background="";
	}
	else if (chngdir == "PageEleven") {
		hiliteOne.style.background="";
		hiliteTwo.style.background="";
		hiliteThree.style.background="";
		hiliteFour.style.background="";
		hiliteFive.style.background="";
		hiliteSix.style.background="";
		hiliteSeven.style.background="";
		hiliteEight.style.background="";
		hiliteNine.style.background="";
		hiliteTen.style.background="";
		hiliteEleven.style.background="url('" + www + "rusticaspenfurniture.com/IM/Nav/PageNumBak.jpg')";
	}
} catch(e) {displayError(e.toString());}	// END Try Statement
} else {displayError(xmlHttp.statusText);}	// END Status200
} 											// END ReadyState4
} 											// END Function


function imgload(tn, channel, cat, subcat)
{
	var serverParams = "imgNum=" + tn + "&mode=" + channel + "&cat=" + cat + "&subcat=" + subcat;
	if (xmlHttp)
	{
		try
		{	
			xmlHttp.open("GET", www + "rusticaspenfurniture.com/Javascript/GalleryProcess.php?" + serverParams, true);
			xmlHttp.onreadystatechange = returnMain;
			xmlHttp.send("null");
		}
		catch(e)
		{
			throw("Error: " + e.toString());
		}
	}
}


function returnMain()
{
	if (xmlHttp.readyState == 4) 
	{
	if (xmlHttp.status == 200)
		{ 
		try 
		{
			
	var xmlResponse = xmlHttp.responseXML;
	if (!xmlResponse || !xmlResponse.documentElement)
		throw("Invalid XML Structure:\n" + xmlHttp.responseText);
	var rootNodeName = xmlResponse.documentElement.nodeName;
	if (rootNodeName == "parseerror")
		throw("Invalid XML Structure:\n" + xmlHttp.responseText);
	var xmlRoot = xmlResponse.documentElement;
	if (rootNodeName != "response" || !xmlRoot.firstChild)
		throw("Invalid XML Structure:\n" + xmlHttp.responseText);
		
	var url = xmlRoot.getElementsByTagName("url")[0].firstChild.data;
	var imginfo = xmlRoot.getElementsByTagName("imginfo")[0].firstChild.data;
	var imgsku = xmlRoot.getElementsByTagName("imgsku")[0].firstChild.data;
	var imgprice = xmlRoot.getElementsByTagName("imgprice")[0].firstChild.data;
	
	var Mimg = "<img src='" + www + "rusticaspenfurniture.com/IM/Gallery/" + url + ".jpg' />";
	writeImg = document.getElementById("AJAX_loadimgA");
		writeImg.innerHTML = "<img src='" + url +  "' />";
	writeImgInfo = document.getElementById("AJAX_miiA");
		writeImgInfo.innerHTML = "<h3>" + imginfo + "</h3>";
	writeSKU = document.getElementById("sku");
		writeSKU.innerHTML = imgsku + ", " + imgprice;

} catch(e) {displayError(e.toString());}	// END Try Statement
} else {displayError(xmlHttp.statusText);}	// END Status200
} 											// END ReadyState4
} 											// END Function

