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

		$('.partner_with_us textarea').click(function(){
   			this.select();
   			return false;
			});

		$('em.error').remove();
        
        $('#form_holder').append($('#form_temp'));
		$('#form_full_holder').prepend($('#theform'));
        
        //form slider
        $('#submitslider').click(function(){
            //sets main form value with promo form input
            $("input[name='__match__85cb8928-2a14-7ab7-860d-83930af69dea']").val($("input[name=promo_form_input]:checked").val());
            
            //$('#promo').fadeOut(display_speed);
            $('#content_text').fadeOut('fast');
            $('#maincontent').css({
                'margin-top'  : '-2px',
                'z-index'     : '-99999',
                'margin-left' : '1px'
            });	
            $('#form_full_holder').fadeIn('fast');
            $('html, body').animate({scrollTop:450}, '500');
            return false;
		});
        
        /* */
        
        /**   Aircompressors.org site-specific functions       **/
        
        $('img.nav').hover(function(){
			var src = $(this).attr('src');
			var	pos = src.lastIndexOf('.jpg');
			var new_src = src.substring(0,pos);
			 		new_src += '-hover.jpg';
					$(this).attr('src',new_src);
		},function(){
			var src = $(this).attr('src');
			var	pos = src.lastIndexOf('-hover.jpg');
			var new_src = src.substring(0,pos);
			 		new_src += '.jpg';
					$(this).attr('src',new_src);
		});
		
		$('#home_form_a').click(function(){
		  $('#theform').submit();
		  return false;
		});
        
        // just say no to script defined on an HTML tag
        $('#HP').live('blur', function(){
            to_digits( $(this).attr('id'), true);
            console.info( $(this).attr('id') + " called to_digits()." );
            return false;
        });

        // just say no to script called in an HTML tag event attribute       
        $('#PC, #zip').live('keyup', function(){
            to_digits( $(this).attr('id'), true);
            console.info( $(this).attr('id') + " called to_digits()." );
            return false;
        });
        
        
});//ready
