/* * * * * * * * * * * * * * * *
 *                             *
 * @author   Mike Cavaliere    *
 * @company  DraftFCB          *
 *                             *
 * * * * * * * * * * * * * * * *
 *
 * Global event handlers.
 *
 * Events on any sitewide elements should be added here, NEVER to the html. 
 * This keeps our JS in one place and is better for SEO. 
 *
 *
 */

$(function() {
		   
	/*
	 * Default landmark search text
	 */
	var srch = $('#search-city-zip');
	
	if (srch.length)
	{
		srch.defaultText("enter a city");
	}
	
	/*
	 * Adds slide up/down animation to certain areas
	 */
    $('#landmark_search')
        .topBottom()
        .find('label.expandable-trigger')
        .expandable();
        
	$('#site-search-text').defaultText('enter keyword');
		
	/*
	 * Set <a class="submit"> to submit its parent form when clicked
	 */
    $('a.submit').click(function()
    {
       $(this).parents('form:first').submit(); 
    });		
	
	/*
	 * Inject rounded corner elements
	 */
	$('#col-primary .content-box').topBottom();

	/*
	 * Add 'restored' class to an <a class="thumb">, and this will add the restored icon
	 */
	$('#body a.restored').inject('restored');
	
	// check/uncheck all
	function jqCheckAll( id, name, flag )
	{
		if (flag == 0)
		{
			$("form#" + id + " INPUT[@name=" + name + "][type='checkbox']").attr('checked', false);			
		}
		else
		{
			$("form#" + id + " INPUT[@name=" + name + "][type='checkbox']").attr('checked', true);
		}
	}
	
	$('input[name=search_category_action]')
		.eq(0)
			.click(function() {
				jqCheckAll('landmark_search', 'search-categories', 1);
			})
			.end()
		.eq(1)
			.click(function() {
				jqCheckAll('landmark_search', 'search-categories', 0);
			})
			.end();
	
});

