
$(document).ready(function(){
  
   $('form div.content_bucket').click(function(e){
	   if(e.target.nodeName.toLowerCase() == 'a'){
		   return true;
	   }else{
		   $(this).parent().submit();
		   return false;   
	   }
   })

    //Script to align the top of the right sidebar with the sub_page header. 
    $.fn.exists = function(){
        return ($(this).length > 0);
    }
    
    if ($('#sub_page_col2_wrapper').exists()) {
        var sub_header = ($('#sub_header').height() + 30)
        $('#sub_page_col2_wrapper').css('top', (sub_header * (-1)));
    }
    
    //Error form wrapping
    $(".error_div").parent().addClass("error");
    
    // Super menu
    $(".MegaMenuLink").megamenu(".MegaMenuContent", {
        width: "952"
    });
    
    //Script to align the supermenu in the middle of the window 
    //var getLeft = $("#nav");
    //var offset = getLeft.offset();
    //$("#MegaMenuContent").css('left', + offset.left + 'px');
		
		/*------ GOOGLE SEARCH ----------*/
		/* Clear Search text on Focus */
  	$('#searchword').focus(function(){
    	$(this).val('');
  	})
	
	$('#loginEmail').focus(function(){
    	if($(this).val() == "E-Mail Address"){
			$(this).val('');	
		}
  	});
	
	$('#loginEmail').blur(function(){
    	if($(this).val() == ""){
			$(this).val('E-Mail Address');	
		}
  	})
	
	$('#loginPassword').focus(function(){
		$(this).removeClass('passwordDefault');	
  	})
	
	$('#loginPassword').blur(function(){
		if ($(this).val() == "") {
			$(this).addClass('passwordDefault');
		}	
  	})
		
		$('#searchword').blur(function(){
			search = $(this).val();
			//trim for whitespace
			trimmedSearch = jQuery.trim(search);
			length = trimmedSearch.length;
			//if 0 add default text
			if(length == 0){
				$(this).val('Search For...');
			}
  	})
		
		/* submit the search string to google */
		$('#searchForm').submit(function(event){
			//this grabs the search string and redirects to google in new window and appends site: 
			$('#searchForm input[name="q"]').val($('#searchForm input[name="searchword"]').val() + ' site:oregondivorce.com');
		})

});

