$(document).ready(function() {

	if (getCookie('footer') == "show")
	{
		$("#footerHidden").hide();
		$("#footerBottomHidden").hide();
		$("#footerShowButton").hide();
	}
	else
	{
		$("#footerShowButton").hide();
		$("#footerColumn1").hide();	
		$("#footerColumn2").hide();
		$("#footerColumn3").hide();
		$("#footerColumn4").hide();
		$("#footerColumn5").hide();
 		$("#footerHideButton").hide();
 		$("#footerVisible").hide();
 		$("#footerBottomVisible").hide();
 		$("#footerShowButton").show();
	}

	$("#footerHideButton").click(function() {

		$("#footerShowButton").hide();
		$("#footerColumn1").fadeOut("slow");	
		$("#footerColumn2").fadeOut("slow");
		$("#footerColumn3").fadeOut("slow");
		$("#footerColumn4").fadeOut("slow");
		$("#footerColumn5").fadeOut("slow");
 		$(this).hide();
 		$("#footerVisible").hide();
 		$("#footerBottomVisible").hide();
 		$("#footerBottomHidden").show();
 		$("#footerHidden").show();
 		$("#footerShowButton").fadeIn("slow");
 		setCookie('footer','hide','1000');
 	});

	$("#footerShowButton").click(function() {

		$("#footerHidden").hide();
		$("#footerBottomHidden").hide();
		$("#footerBottomVisible").show();
		$("#footerVisible").show();
		$("#footerColumn1").fadeIn("slow");	
		$("#footerColumn2").fadeIn("slow");
		$("#footerColumn3").fadeIn("slow");
		$("#footerColumn4").fadeIn("slow");
		$("#footerColumn5").fadeIn("slow");
 		$("#footerHideButton").fadeIn("slow");
 		setCookie('footer','show','1000');
 	});
 	
	$("#widthSlider").slider({ min: 12, max:104, range: true, change: function(e,ui) { 
	
		lowValue = $("#widthSlider").slider('value', 0);
		highValue = $("#widthSlider").slider('value', 1);
		
		//Step to values 30, 54, 64, 74, 104
		
		
		if (lowValue > 74)
		{
			lowValue = 74;
			$("#widthSlider").slider('moveTo', lowValue, 0);
		}
		else if (lowValue > 69  && lowValue < 74 && highValue > 74)
		{
			lowValue = 74;
			$("#widthSlider").slider('moveTo', lowValue, 0);
		}
		else if (lowValue > 64 && lowValue < 74 && highValue > 64)
		{
			lowValue = 64;
			$("#widthSlider").slider('moveTo', lowValue, 0);
		}
		else if (lowValue > 59 && lowValue < 64 && highValue > 64)
		{
			lowValue = 64;
			$("#widthSlider").slider('moveTo', lowValue, 0);
		}
		else if (lowValue > 54 && lowValue < 64 && highValue > 54)
		{
			lowValue = 54;
			$("#widthSlider").slider('moveTo', lowValue, 0);
		}
		else if (lowValue > 42 && lowValue < 54 && highValue > 54)
		{
			lowValue = 54;
			$("#widthSlider").slider('moveTo', lowValue, 0);
		}
		else if (lowValue > 30 && lowValue < 54 && highValue > 30)
		{
			lowValue = 30;
			$("#widthSlider").slider('moveTo', lowValue, 0);
		}
		
		else if (lowValue > 20 && lowValue < 30 && highValue > 20)
		{
			lowValue = 20;
			$("#widthSlider").slider('moveTo', lowValue, 0);
		}		


		else if (lowValue > 12 && lowValue < 20 && highValue > 12)
		{
			lowValue = 12;
			$("#widthSlider").slider('moveTo', lowValue, 0);
		}	

		
//		if (lowValue > 30 && lowValue <= 42)
//		{
//			lowValue = 30;
//			$("#widthSlider").slider('moveTo', lowValue, 0);
//		}
//		else if (lowValue > 42 && lowValue < 54)
//		{
//			lowValue = 54;
//			$("#widthSlider").slider('moveTo', lowValue, 0);
//		}
//		else if (lowValue > 54 && lowValue <= 59)
//		{
//			lowValue = 54;
//			$("#widthSlider").slider('moveTo', lowValue, 0);
//		}
//		else if (lowValue > 59 && lowValue < 64)
//		{
//			lowValue = 64;
//			$("#widthSlider").slider('moveTo', lowValue, 0);
//		}
//		else if (lowValue > 64 && lowValue <= 69)
//		{
//			lowValue = 64;
//			$("#widthSlider").slider('moveTo', lowValue, 0);
//		}
//		else if (lowValue > 69 && lowValue < 74)
//		{
//			lowValue = 74;
//			$("#widthSlider").slider('moveTo', lowValue, 0);
//		}
//		else if (lowValue > 74)
//		{
//			lowValue = 74;
//			$("#widthSlider").slider('moveTo', lowValue, 0);
//		}
		
		if (highValue < 20)
		{
			
			
			
			highValue = 20;
			$("#widthSlider").slider('moveTo', highValue, 1);
		}

		else if (highValue > 20 && highValue <= 25 && lowValue < 20)
		{
			highValue = 20;
			$("#widthSlider").slider('moveTo', highValue, 1);
		}
		else if (highValue > 20 && highValue < 32 && lowValue < 32)
		{


			highValue = 32;
			$("#widthSlider").slider('moveTo', highValue, 1);
		}
		else if (highValue > 32 && highValue <= 37 && lowValue < 32)
		{
			highValue = 32;
			$("#widthSlider").slider('moveTo', highValue, 1);
		}
		else if (highValue > 32 && highValue < 54 && lowValue < 54)
		{
			
			highValue = 54;
			$("#widthSlider").slider('moveTo', highValue, 1);
		}
		else if (highValue > 54 && highValue <= 59 && lowValue < 54)
		{
			highValue = 54;
			$("#widthSlider").slider('moveTo', highValue, 1);
		}
		else if (highValue > 54 && highValue < 64 && lowValue < 64)
		{

			highValue = 64;
			$("#widthSlider").slider('moveTo', highValue, 1);
		}
		else if (highValue > 64 && highValue <= 69 && lowValue < 64)
		{
			highValue = 64;
			$("#widthSlider").slider('moveTo', highValue, 1);
		}
		else if (highValue > 64 && highValue < 74 && lowValue < 74)
		{
			highValue = 74;
			$("#widthSlider").slider('moveTo', highValue, 1);
		}
		else if (highValue > 74 && highValue <= 89 && lowValue < 74)
		{
			highValue = 74;
			$("#widthSlider").slider('moveTo', highValue, 1);
		}
		else if (highValue > 74 && highValue < 104)
		{
			highValue = 104;
			$("#widthSlider").slider('moveTo', highValue, 1);
		}
		
		
			//High Node change
			document.getElementById('widthHigh').value = highValue;
			document.getElementById('widthHighText').innerHTML = highValue + '"';

			//Low Node Change
			document.getElementById('widthLow').value = lowValue;
			document.getElementById('widthLowText').innerHTML = lowValue + '"';

			getPrinters();
	} });
	
	$("#priceSlider").slider({ min: 7, max:70, range: true, change: function(e,ui) { 
	
		lowValue = $("#priceSlider").slider('value', 0);
		highValue = $("#priceSlider").slider('value', 1);
		
			//High Node change
			document.getElementById('priceHigh').value = highValue;
			document.getElementById('priceHighText').innerHTML = '$' + highValue + 'K';

			//Low Node Change
			document.getElementById('priceLow').value = lowValue;
			document.getElementById('priceLowText').innerHTML = '$' + lowValue + 'K';

			getPrinters();
	} });
	
	$("#speedSlider").slider({ min: 7, max:1000, range: true, stepping: 5, change: function(e,ui) { 
	
		lowValue = $("#speedSlider").slider('value', 0);
		highValue = $("#speedSlider").slider('value', 1);
		
			//High Node change
			document.getElementById('speedHigh').value = highValue;
			document.getElementById('speedHighText').innerHTML = highValue;

			//Low Node Change
			document.getElementById('speedLow').value = lowValue;
			document.getElementById('speedLowText').innerHTML = lowValue;

			getPrinters();
	} });


});

function setCookie(name,value,nDays)
{
	var today = new Date();
	var expire = new Date();
	if (nDays==null || nDays==0) nDays=1;
 	expire.setTime(today.getTime() + 3600000*24*nDays);
 	document.cookie = name+"="+escape(value)
                 + ";expires="+expire.toGMTString()
                 + ";path=/";
}

function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
    {
    c_start=c_start + c_name.length+1;
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));
    }
  }
return "";
}
