$('document').ready(function(){
	$('legend').each(function(){
		var text = $(this).text();
		text = text.split(' ');
		if(array_search('Content', text) || array_search('Parking', text) || array_search('Special', text))
		{
			var html = $(this).html();
			$(this).html(html + '<a href="#icon" class="boot_help"><img src="/assets/images/help.png" alt="Need Help?" /></a><div class="help">a</div>');
		}		
	});
	$('.help').load('/assets/textile.txt');
	$('.help').slideUp(0);
	$('a.boot_help').live('click', function(){
		var text = $(this).parent().text();
		text = text.split(' ');
		if(array_search('Content', text) || array_search('Parking', text) || array_search('Special', text) || array_search('Introductory', text))
		{
			$(this).next('div.help').slideToggle('slow');
		}
		return false;
	});
	
});

function array_search (needle, haystack, argStrict) {
    // Searches the array for a given value and returns the corresponding key if successful  
    // 
    // version: 909.322
    // discuss at: http://phpjs.org/functions/array_search
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +      input by: Brett Zamir (http://brett-zamir.me)
    // +   bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // *     example 1: array_search('zonneveld', {firstname: 'kevin', middle: 'van', surname: 'zonneveld'});
    // *     returns 1: 'surname'

    var strict = !!argStrict;
    var key = '';

    for (key in haystack) {
        if ((strict && haystack[key] === needle) || (!strict && haystack[key] == needle)) {
            return key;
        }
    }

    return false;
}
