// Fix layout
function fixLayout() {
	var containerWidth = 980;
	var horizontalBoxWidth = ($(document.body).width() / 2) - (containerWidth / 2);

	// Set box width
	if(horizontalBoxWidth >= 0) {
		$("#horz_box").css('width',horizontalBoxWidth + 'px');
	}
	else {
		$("#horz_box").css('width',0);
	}

	// Set box height
	newHeight = $("#col_a").attr('offsetHeight') + "px";
	$("#horz_box").css('height',newHeight); 
}
// Hide search box for drop down effect
function enableSearch() {
	keywordsValue = $('#keywords').attr('value');
	actionAddress = $('#site_search').attr('action');
	$('#drop_down').html('<form id="site_search" class="search" action="'+actionAddress+'" method="get"><input type="text" maxlength="64" id="keywords" name="keywords" class="keywords" value="'+keywordsValue+'" /><a href="#" title="Go" class="submit_button" onclick="submitSearchForm()">Go</a></form>');
	$('#drop_down').css('display','none');
	$('#search').css('height','30px');
}
// Allow the toggling of the search drop down up or down.
var searchDropDownToggle = false;
function toggleSearchDropDown() {
	if(!searchDropDownToggle) {
		$('#drop_down').css('display','block');		
		$('#drop_down').css('height','35px');				
		$('#search').css('height','70px');		
		searchDropDownToggle = true;
	}
	else {
		$('#drop_down').css('display','none');	
		$('#search').css('height','30px');
	
		searchDropDownToggle = false;
	}
}
function submitSearchForm() {
	$('#site_search').submit();	
	/*
	if($('#keywords').attr('value') == "") {
		$('#keywords').before('<p class="warning">You must enter keywords before searching.</p>');	
	}
	else {
	}*/
}
// Randam number generator for random background image
function rand( min, max ) {
	// http://kevin.vanzonneveld.net
	// +   original by: Leslie Hoare
	// *     example 1: rand(1, 1);
	// *     returns 1: 1
	if( max ) {
		return Math.floor(Math.random() * (max - min + 1)) + min;
	} else {
		return Math.floor(Math.random() * (min + 1));
	}
}
// Highlight search results
function highlight(searchObj, keywords) {
	
}
// Allow a new background to be set
// function setPageBackground(url) {
//  $(document.body).css('background','#000000 url('+url+')');
//  $(document.body).css('backgroundPosition','top center');  
//  $(document.body).css('backgroundAttachment','fixed');   
// }
// When document is loaded
$(document).ready(function () {				
	fixLayout();
	enableSearch();
});
// When document is resized
$(window).resize(function () {
	fixLayout();						 
});

