// JavaScript Document
function createajaxrequest()
{
	var obj;
	if(window.XMLHttpRequest)
	{
		obj = new XMLHttpRequest();
	}
	else if(window.ActiveXObject)
	{
		obj = new ActiveXObject("MSXML2.XMLHTTP");
	}
	return obj;
}

function getAllProducts(vCategoryId)
{
	var serverpage="getAllProducts.php?action=viewall&catid=" + vCategoryId;
	xmlhttp = createajaxrequest();
	xmlhttp.open("post",serverpage,true);
	xmlhttp.onreadystatechange = function() {
	  if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
		document.getElementById('divAllProds').innerHTML = xmlhttp.responseText;
		document.getElementById('top_bar').style.display = "none";
		document.getElementById('top_bar_alternate').style.display="block";
		document.getElementById('bottom_bar').innerHTML = '<a href="javascript:goBack();" class="pageResults"><< Back</a>';
	  }
	  else
	  {
		  document.getElementById('divAllProds').innerHTML = '<img src="images/loading.gif" border="0" alt="">';
	  }
	}
	xmlhttp.send(serverpage);
}

function getProducts(vCategoryId,vSortfield)
{
	
	var serverpage="getProducts.php?sortby=" + vSortfield + "&catid=" + vCategoryId + "&price=" + document.price_sort.prod_sort_alternate.value + "&width=" + document.price_sort.prod_width_sort_alternate.value + "&size=" + document.price_sort.prod_size_sort_alternate.value;
	xmlhttp = createajaxrequest();
	xmlhttp.open("post",serverpage,true);
	xmlhttp.onreadystatechange = function() {
	  if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
		document.getElementById('divAllProds').innerHTML = xmlhttp.responseText;
	  }
	  else
	  {
		  document.getElementById('divAllProds').innerHTML = '<img src="images/loading.gif" border="0" alt="">';
	  }
	}
	xmlhttp.send(serverpage);
}
