/*
  Custom ready function
  This should be used to reposition elements or to define and use custom functions
*/
$(document).ready(function(){

    // reposition elements
    $('.header .logo h1').after( $('.byline')[0] );   
    $('.bg-header').after( $('.bg-mainnav'), $('.bg-photo-block') );    
    $('.wrapper').prepend( $('.partners') );
    $('.content-left').prepend( $('.features'), $('.photo-interior') );
    // end repositioning
     
    // append clear fix to each ul with floated children 
    $('.content-right ul, .sitemap ul, .home_articles ul, .state_ul').each(function(){
        $(this).append('<div class="clear0"><!--ie--></div>');   
    });

    // make sure that floated li items clear the previous row
    // 6 columns in .sitemap_cities and .state_articles             
    $('ul li:nth-child(6n)', '.sitemap_cities, .state_articles').after( '<div class="clear0"><!--ie--></div>' );

	// attach to_digits() to zip code keyup event
	$('#zip').bind('keyup', function(){
		to_digits( $(this).attr('id'), true );
	});

	// attach to_digits() to phone number blur event
	$('#homephone').bind('blur', function(){
		to_digits( $(this).attr('id'), true );
	});

    if( $('.footer ul a').length == 2 ){        
        $('.footer ul a').bind('click', function(){
        	window.open( $(this).attr('href'),
        				'form_pop_up',
        				'width=300, height=300, status=0, toolbar=0, location=1, menubar=0, directories=0, resizable=1, scrollbars=1');
        	return false;
        });
    }

});//ready
