function changeSize(boxid,weighs,howtall){
		//Div id's for the output
		var boxletter = "#" + boxid;
		//Current weight
		var weight = weighs;
		var measure = howtall;
		//Weight limits
		var lowweight = 155;
		var midweight = 170;
		var highweight = 200;
		var xhighweight = 210;
		//Height limits
		var shortheight = 68;
		var midheight = 71;
		var tallheight = 74;
		var xllimit = 75;

		//Determine the Size first by height, then weight
		function findLimits(height){
			var measure = height;
			if(measure == 65) {
				var weightlimits = ["135","155","170","185"];
			}
			else if(measure == 66) {
				var weightlimits = ["135","160","175","185"];
			}
			else if(measure == 67) {
				var weightlimits = ["140","160","175","190"];
			}
			else if(measure == 68) {
				var weightlimits = ["140","165","180","195"];
			}
			else if(measure == 69) {
				var weightlimits = ["145","160","180","190"];
			}
			else if(measure == 70) {
				var weightlimits = ["150","165","180","195"];
			}
			else if(measure == 71) {
				var weightlimits = ["155","170","185","195"];
			}
			else if(measure == 72) {
				var weightlimits = ["150","170","185","205"];
			}
			else if(measure == 73) {
				var weightlimits = ["100","170","195","205"];
			}
			else if(measure == 74) {
				var weightlimits = ["100","170","195","205"];
			}
			else if(measure == 75) {
				var weightlimits = ["100","110","200","205"];
			}
			else if(measure == 76) {
				var weightlimits = ["100","110","200","210"];
			}
			else{
				var weightlimits = ["100","110","115","210"];
			}
			
			return weightlimits;
		}
		weightlimits =new Array();
		weightlimits = findLimits(measure);
		
		//Weight limits
		lowweight = weightlimits[0];
		midweight = weightlimits[1];
		highweight = weightlimits[2];
		xhighweight = weightlimits[3];
		
		if(measure){
			if(weight <= lowweight){
			$(boxletter).html( "<p>S</p>" );
			}
			else if((weight > lowweight) && (weight <= midweight)){
			$(boxletter).html( "<p>M</p>" );
			}
			else if((weight > midweight) && (weight <= highweight)){
				$(boxletter).html( "<p>L</p>" );
			}
			else if((weight > highweight) && (weight <= xhighweight)){
				$(boxletter).html( "<p>XL</p>" );
			}
			else if(weight > xhighweight){
			$(boxletter).html( "<p>XXL</p>" );
			}
			else{
				$(boxletter).html( "<p>XXL</p>" );
			}
		}
	}
	
	$(function() {
		var url = window.location.pathname;
		if (url != ('/finishorder.php'))
		{
			//Weight slider
			var weight = 165;
			$( "#sliderW" ).slider({
				value:165,
				min: 120,
				max: 220,
				step: 5,
				slide: function( event, ui ) {
					var weight = ui.value;
					var height = $( "#amountH" ).val(); //Collect the current height from div
					var measureArray = height.split(' '); //Turn div value into array
					var num1 = parseInt(measureArray[0]); //Take the 'feet' value from array
					var num2 = parseInt(measureArray[2]); //Take the 'inches' value from array
					var measure = (((num1)*12)+num2); //Get total inches
					$( "#amountW" ).val( weight + " lbs");
					//Change Size Shown
					this.changeSize = changeSize("sizeBox",weight, measure);
				}
			});
			$("#amountW").val(weight + " lbs");
			//Height Slider
			var measure = 68;
			var feet = Math.floor((measure)/12);
			var inches = (measure)-(feet*12);
			$( "#sliderH" ).slider({
				value:68,
				min: 65,
				max: 76,
				step: 1,
				slide: function( event, ui ) {
					var measure = ui.value;
					var heavy = $( "#amountW" ).val(); //Collect the current weight from div
					var heavyArray = heavy.split(' '); //Turn div value into array
					var weight = heavyArray[0]; //Take only the number from array
					var feet = Math.floor((measure)/12); //For User Readability
					var inches = (measure)-(feet*12); //For User Readability
					$( "#amountH" ).val( feet + " ft, " + inches + " inches" );
					//Change Size Shown
					this.changeSize = changeSize("sizeBox",weight, measure);
				}
			});
			$("#amountH").val( feet + " ft, " + inches + " inches" );
			
			//hover states on the static widgets
				$('#dialog_link, ul#icons li').hover(
					function() { $(this).addClass('ui-state-hover'); }, 
					function() { $(this).removeClass('ui-state-hover'); }
			);
		

			// Dialog	
			$('#dialog').dialog({
				autoOpen: false,
				width: 555,
				centered: true,
				modal: true
				/*buttons: {
					"Ok": function() { 
						$(this).dialog("close"); 
					}, 
				}*/
			});
			
			// Dialog Link
			$('.findsize').click(function(){
				$('#dialog').dialog('open');
				$('#amountH').blur();
				$('#sliderH').focus();
				return false;
			});
		
		}
	});
