// General Javascript/jQuery for Quick Order Portal 'Freestyle'
//--------------------------------------------------------------
$(document).ready(function() {
	// Category Nav
	//---------------
	// Change category-nav position
//	$('#category-nav').css('position', 'absolute');
//	$('#category-nav').css('top', '180px');

	$('#category-nav').prepend("<h3>Categories</h3>"); // Add a category-nav header
//	$('#category-nav').append("<img alt='Buckets of Products' src='static/Image/buckets.png' />"); // Add a category-nav footer

	// Search
	//---------------
//	$('#top-search .desc').html('Search');
	$('#top-search').prepend("<h3>Search</h3>"); // Add a category-nav header
//	$('#top-search input#keywords').attr('value', 'Search'); // Search box default text
//	$("#keywords").focus(function(event) { $(this).attr('value', ''); }); // Remove search text on focus
	$('#top-search input.submit').attr('value', 'Search'); // Login button text

	// Login box
	//---------------
	$('#secondary #login li.text input#usr').attr('value', 'username'); // Username input field default text
	$('#secondary #login li.text input#pwd').attr('value', 'password'); // Password input field default text
	$("#secondary #login li.text input#usr").focus(function(event) { $(this).attr('value', ''); }); // Remove username text on focus
	$("#secondary #login li.text input#pwd").focus(function(event) { $(this).attr('value', ''); }); // Remove password text on focus
	
	// Stock title
	$('p.stock').append('<span> in stock</span>');

	// Append an externally loaded page
	$.get('/static/bestSellers.htm', function(data) {
		$('#secondary').append(data);

	});

	// Adjust footer height
	//----------------------
	var heights = new Array(3);
	heights[0] = $('#primary').height();
	heights[1] = $('#secondary').height();
	heights[2] = $('#tertiary').height();

	function sortNumber(a,b) {
		return a - b;

	}

	heights.sort(sortNumber);
	
	// Set all heights to maximum
	$('#primary').height(heights[2]);
	$('#secondary').height(heights[2]);
	$('#tertiary').height(heights[2]);

	// Set footer position
	$('#footer').css('position', 'absolute');
	$('#footer').css('top', (heights[2] + 168) + 'px');

});