function submitSearch ()
{
	var form = document.getElementById('searchForm');
	var searchBox = (document.getElementById('searchBox').value).replace(/ /gi, '+');
	
	form.action = '/search/' + searchBox + '/';

	form.submit();
}
$(function(){ 
	$('a.normalTip').aToolTip();
	$('a.fixedTip').aToolTip({
		fixed: true
	});	
	$('a.clickTip').aToolTip({
		clickIt: true,
		tipContent: 'Hello I am a ToolTip with content from the "tipContent" param'
	});				
}); 

var RecaptchaOptions = {
	theme : 'custom'
};

$.easing.elasout = function(x, t, b, c, d)
{
	var s=1.70158;var p=0;var a=c;
	if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
	if (a < Math.abs(c)) { a=c; var s=p/4; }
	else var s = p/(2*Math.PI) * Math.asin (c/a);
	return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
};

// Just like PHP's strstr
function strstr (haystack, needle, bool)
{
    var pos = 0;
    
    haystack += '';
    pos = haystack.indexOf( needle );    if (pos == -1) {
        return false;
    } else{
        if (bool){
            return haystack.substr( 0, pos );        } else{
            return haystack.slice( pos );
        }
    }
}

function openShow($id)
{
	if ( $('#' + $id + ' .lrgDocLink').css('display') == 'none' )
	{
		$('#' + $id + ' img').attr("src","/images/close.gif");
	}
	else
	{
		$('#' + $id + ' img').attr("src","/images/open.gif");	
	}
	
	// When clicked, open the ID contents for viewing
	$('#' + $id + ' .lrgDocLink').toggle('normal');	
}

if (strstr(window.location.href, '#comments'))
{
	$(document).ready(function()
	{
		$.scrollTo( '#comments', 1800, {easing:'elasout'} );
	});
}
if (strstr(window.location.href, '#leaveComment'))
{
	$(document).ready(function()
	{
		$.scrollTo( '#leaveComment', 1800, {easing:'elasout'} );
	});
}
if (strstr(window.location.href, '#newsSubscribe'))
{
	$(document).ready(function()
	{
		$.scrollTo( '#newsSubscribe', 1800, {easing:'elasout'} );
	});
}
if (strstr(window.location.href, '#haveYourSay'))
{
	$(document).ready(function()
	{
		$.scrollTo( '#haveYourSay', 1800, {easing:'elasout'} );
	});
}
