
//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 isnumeric( theVal )
{
  var numericExpression = /^[0-9]+$/;

  if(theVal.match(numericExpression))
   return true;
   
  else 
   return false;
}

function isurl( theVal )
{
  if(theVal.match("http") )
   return true;
   
  else 
   return false;
}

function SFchangeAction( theVal )
{
	var newProdCount;
	var pageNum;
	var currPageNum;
	var currProdPerPageNum;
	var currUrlString;
	var pgString;

   // -- for dropdown menu -- //
   if(!isnumeric(theVal) && isurl(theVal) )
    top.location.href = theVal;
    
   // -- for filter form  -- // 
   else {
    
	   currPageNum = parseFloat(document.filterform.currPageNum.value);  

	   currProdPerPageNum = parseFloat(document.filterform.currProdPerPageNum.value);
	   currUrlString = top.location.href;
	   newProdCount = parseFloat(theVal);

	
	   if( newProdCount != currProdPerPageNum)
	   {
	   	if( currPageNum == 1 )
	   	{
	   		pageNum = 1;
	   	}
	   	else
	   	{
	   		
	   		
	   		pageNum = ((((currPageNum - 1) * currProdPerPageNum) + 1) / newProdCount);

	   	}
	   	pageNum = Math.ceil(pageNum);
	   	pgString='PG--' + currPageNum;
	   	

	   	currUrlString = currUrlString.replace(pgString,'PG--' + pageNum);

	   }

	
	   document.filterform.method = "post";
	   if (currUrlString.indexOf('isAdvanced--Y')<=0)
	   {

	   	document.filterform.action = currUrlString;
	   }
	
	   document.filterform.submit();
    }
}

function onCustomizeDisplay()
{
	document.filterform.action = top.location.href;
	document.filterform.submit();
}

function VC_expand(pElementID) {	
   if (document.getElementById){
      document.getElementById(pElementID).style.display = "";
   }
}
  
function VC_close(pElementID) {	
   if (document.getElementById){
      document.getElementById(pElementID).style.display = "none";
   }
} 
   