
//filteroptions dropdown below the searchbox

function disablefilter()
{
	

	if (document.SearchForm.rbSearchOriginal.checked==false)
		{document.SearchForm.filteroptions.disabled=false;}
	else 
		{document.SearchForm.filteroptions.disabled=true;}
}

//banner popup window

function popOpen( url, name, attributes ) 
{ 
	windowHandle = window.open( url, name, attributes ); 
}
			

function HideDiv (divID)
{
	if (document.getElementById(divID))
		(document.getElementById(divID)).style.display = "none";
}

function ShowDiv (divID)
{
	if (document.getElementById(divID))
	  (document.getElementById(divID)).style.display = "";
}

function SwapDivs (outDivID, inDivID)
{
  HideDiv (outDivID);
  ShowDiv (inDivID);
}

function SizeRadioChanged ()
{

  sizeradio = document.filterform.size;
  
  if (sizeradio[0].checked)
  {
    ChangeSizeForm(false);
  }
  else if (sizeradio[1].checked)
  {
    ChangeSizeForm(false);
  }
  else if (sizeradio[2].checked)
  {
    ChangeSizeForm(false);
  }
  else if (sizeradio[3].checked)
  {
    ChangeSizeForm(true);
  }
}

function ChangeSizeForm(bEnabled)
{ 
  if (bEnabled)
  {
		document.filterform.width_from.disabled = false;
		document.filterform.width_to.disabled = false;
		document.filterform.height_from.disabled = false;
		document.filterform.height_to.disabled = false;
		
		document.getElementById("width_from").style.backgroundColor = "#ffffff";
		document.getElementById("width_to").style.backgroundColor = "#ffffff";
		document.getElementById("height_from").style.backgroundColor = "#ffffff";
		document.getElementById("height_to").style.backgroundColor = "#ffffff";
		
	}
	else
	{
		document.filterform.width_from.disabled = true;
		document.filterform.width_to.disabled = true;
		document.filterform.height_from.disabled = true;
		document.filterform.height_to.disabled = true;
		
		document.getElementById("width_from").style.backgroundColor = "#ededed";
		document.getElementById("width_to").style.backgroundColor = "#ededed";
		document.getElementById("height_from").style.backgroundColor = "#ededed";
		document.getElementById("height_to").style.backgroundColor = "#ededed";
	}
}

function PriceRadioChanged ()
{

  priceradio = document.filterform.price;
  
  if (priceradio[0].checked)
  {
    ChangePriceForm(false);
  }
  else if (priceradio[1].checked)
  {
    ChangePriceForm(true);
  }

}


function ChangePriceForm(bEnabled)
{ 
  if (bEnabled)
  {
		document.filterform.price_from.disabled = false;
		document.filterform.price_to.disabled = false;
		
		document.getElementById("price_from").style.backgroundColor = "#ffffff";
		document.getElementById("price_to").style.backgroundColor = "#ffffff";
	}
	else
	{
		document.getElementById("price_from").style.backgroundColor = "#ededed";
		document.getElementById("price_to").style.backgroundColor = "#ededed";
		
		document.filterform.price_from.disabled = true;
		document.filterform.price_to.disabled = true;
	}
}

function ClearFilters()
{
  document.filter.clrfilters.value = "Y";
  document.filter.action = top.location.href;
  document.filter.submit();
}

function ShowFilter()
{
	ShowDiv ('FilterFormPrice'); 
	HideDiv('applySort');
  SizeRadioChanged(); 
  PriceRadioChanged();
}

function pickerSelectWallColor( newColor ) 
{
	if(navigator.appName != "Netscape")
	{
		for ( var i = 0; i < bgItemArray.length; i ++ ) 
		{
		      
			var objColor = document.getElementById( eval( "\"" + bgItemArray[ i ] + "\"" ) );
			var objColorsub = document.getElementById( eval( "\"" + bgItemArray[ i ] + "sub"+ "\"" ) );
			objColor.style.backgroundColor = newColor;
			objColorsub.style.backgroundColor = newColor;
		}
   }
	document.displayform.gridWallColor.value = newColor;
	document.displayform.submit();
}

function resetColor( resetColor )
{
   for ( var i = 0; i < bgItemArray.length; i ++ )
   {
      var objColor = document.getElementById( eval( "\"" + bgItemArray[ i ] + "\"" ) );
      objColor.style.backgroundColor = resetColor;
   }
}

function SFchangeAction( theVal )
{
	var newProdCount;
	var pageNum;
	var currPageNum;
	var currProdPerPageNum;
	var currSearchString;
	var currCategory;
	var currOrder;
	var currUrlString;
	var pgString;

	currPageNum = parseFloat(document.filterform.currPageNum.value);  

	currProdPerPageNum = parseFloat(document.filterform.currProdPerPageNum.value);
	currCategory = document.filterform.Cat.value
	currSearchString = document.SearchForm.Search_String.value
	currOrder = document.sortform.Order.value
	currUrlString = "Gallery.asp"
	newProdCount = parseFloat(theVal);

	
	if( newProdCount != currProdPerPageNum)
	{
		if( currPageNum == 1 )
		{
			pageNum = 1;
		}
		else
		{
			
			
			pageNum = ((((currPageNum - 1) * currProdPerPageNum) + 1) / newProdCount);

		}
		pageNum = Math.ceil(pageNum);
		pgString='page=' + currPageNum;
		

		currUrlString = currUrlString + "?" + pgString;
	    document.filterform.action = currUrlString + "&rpp=" + newProdCount + "&search_string=" + currSearchString + "&cat=" + currCategory + "&order=" + currOrder;
	}
	else
	{
	    document.filterform.action = currUrlString + "?rpp=" + newProdCount + "&search_string=" + currSearchString + "&cat=" + currCategory + "&order=" + currOrder;	
	}

	document.filterform.method = "post";
	document.filterform.submit();
	
}


function SFchangeAction2( theVal )
{
	var newOrder;
	var currSearchString;
	var currUrlString;

	currSearchString = document.SearchForm.Search_String.value
	currUrlString = "Gallery.asp"
	newOrder = theVal;	
	
	currUrlString = currUrlString + "?";
    document.filterform.action = currUrlString + "order=" + newOrder;

	document.filterform.method = "post";
	document.filterform.submit();
	
}

function SFchangeAction3( theVal )
{
	var newProdCount;
	var pageNum;
	var currPageNum;
	var currProdPerPageNum;
	var currSearchString;
	var currCategory;
	var currOrder;
	var currUrlString;
	var pgString;

	currPageNum = parseFloat(document.filterform.currPageNum.value);  

	currProdPerPageNum = parseFloat(document.filterform.currProdPerPageNum.value);
	currCategory = document.filterform.Cat.value
	currSearchString = document.SearchForm.Search_String.value
	currOrder = document.sortform.Order.value
	currUrlString = "Gallery2.asp"
	newProdCount = parseFloat(theVal);

	
	if( newProdCount != currProdPerPageNum)
	{
		if( currPageNum == 1 )
		{
			pageNum = 1;
		}
		else
		{
			
			
			pageNum = ((((currPageNum - 1) * currProdPerPageNum) + 1) / newProdCount);

		}
		pageNum = Math.ceil(pageNum);
		pgString='page=' + currPageNum;
		

		currUrlString = currUrlString + "?" + pgString;
	    document.filterform.action = currUrlString + "&rpp=" + newProdCount + "&search_string=" + currSearchString + "&cat=" + currCategory + "&order=" + currOrder;
	}
	else
	{
	    document.filterform.action = currUrlString + "?rpp=" + newProdCount + "&search_string=" + currSearchString + "&cat=" + currCategory + "&order=" + currOrder;	
	}

	document.filterform.method = "post";
	document.filterform.submit();
	
}


function SFchangeAction4( theVal )
{
	var newOrder;
	var currSearchString;
	var currUrlString;

	currSearchString = document.SearchForm.Search_String.value
	currUrlString = "Gallery2.asp"
	newOrder = theVal;	
	
	currUrlString = currUrlString + "?";
    document.filterform.action = currUrlString + "order=" + newOrder;

	document.filterform.method = "post";
	document.filterform.submit();
	
}


function onCustomizeDisplay()
{
	document.filterform.action = top.location.href;
	document.filterform.submit();
}
