$(document).ready(function(){

	
	
	// Check for minimum height
	if($('#content').height()<400) {
		$('#content').height(400);
	}


	// Activate print icon
	$('#links ul li.printicon').click(function(){
		window.print();
	});

	// Make the top-search form quick-jump to product
	$('#top-search-form').submit(function(){
		var sword = $('#tx_indexedsearch_sword').val();
	
		// Test if search value is integer
		if(sword.length>0 && sword.split(" ").length==1) {
			
			// Value is int, so find out if product exists on current language, and
			// change action of form to new URL and remove the form elements
			$.ajax({
				async: false,
				type: "GET",
				url: "/",
				data: "type=733&itemno="+sword,
				dataType: "json",
				cache: false,
				beforeSend: function() {
					$('#tx_indexedsearch_submit').hide();
					$('#tx_indexedsearch_sword').hide();
					$('#top-search-form-loading').show();	

				},
				success: function(data) {
					if(typeof data == 'object') {
						// Change action
						$('#top-search-form').attr('action',data.action);
						
						// Remove elements from form
						$('#tx_indexedsearch_submit').remove();
						$('#tx_indexedsearch_sword').remove();
						
//						$(this).submit();
//						console.log('Action should be changed');


					}
					
				}
			});
			
		} else {
			// Do nothing - just search like normal
		}	
		
//						return false;		
	});
	
	
	/**
	* Category browser - equal height
	**/
	if($('.category-list-and-content').length>0) {
		// Find max height
		var height = parseInt($('.category-list-and-content-list-1').height());
		
		var newHeight = parseInt($('.category-list-and-content-list-2').height());
		if(newHeight > height) {
			height = newHeight;
		}
		
		newHeight = parseInt($('.category-list-and-content-list-3').height());
		if(newHeight > height) {
			height = newHeight;
		}
		
		newHeight = parseInt($('.category-list-and-content-content').height());
		if(newHeight > height) {
			height = newHeight;
		}
		
		// Set all to max height
		$('.category-list-and-content-list-1').height(height);
		$('.category-list-and-content-list-2').height(height);
		$('.category-list-and-content-list-3').height(height);
		$('.category-list-and-content-content').height(height);

	}






});
