/* jQuery.fn.yourfunctionname = function() {

    var o = $(this[0]) // It's your element

};
*/

$(function(){
	positionFooter(); 
	function positionFooter(){
		if($(document.body).height() < $(window).height()){
			$("#stickyFooter").css({position: "absolute",top:($(window).scrollTop()+$(window).height()-$("#stickyFooter").height())+"px"})
		}	
	}
	
	$(window)
		.scroll(positionFooter)
		.resize(positionFooter)
});

$(function(){
	/*
	 * Pretty forms
	 */
	$('form.prettyform input[@type*=radio]').css('border','none');
	$('form.prettyform input[@type*=checkbox]').css('border','none');
	if($.browser.mozilla) { prettyform(); }
	
	/*
	 * Blur on focus
	 */
	$('a').focus(function() { this.blur(); });
    
    $('label.required').append(' <em>*</em>');
    
    $("#navigation ul li a:last").addClass('last');
    
    $("#navigation ul li a").append('<span>></span>');
    
    
    $("div.custom_images a,#subscribeIcon").tipTip();
    
    $("#toggleComments").click( function(){
    	 $('#commentWrapper').toggle('fast',
    			 function(){
    		 			// account for height of form with floated submit button
	    				$("#stickyFooter").css({position: "absolute",top:($("#wrapper").height()-$("#stickyFooter").height() + $("blogCommentForm").height() +200 )+"px"});
	    			//alert( 'updated');
    		 });
    });
    
   
    
});


/*
 * Pretty forms
 */
function prettyform(){
  /*
   * Hide forms
   */
  $( 'form.prettyform' ).hide().end();
  /*
   * Label & list formatting
   */
  $( 'form.prettyform' ).find( 'label' ).not( '.noprettyform' ).each( function( i ){
    var labelContent = this.innerHTML;
    var labelWidth = document.defaultView.getComputedStyle( this, '' ).getPropertyValue( 'width' );
    var labelSpan = document.createElement( 'span' );
        labelSpan.style.display = 'block';
        labelSpan.style.width = labelWidth;
        labelSpan.innerHTML = labelContent;
    this.style.display = '-moz-inline-box';
    this.innerHTML = '';
    this.appendChild( labelSpan );
  } ).end();
  
  /*
   * Show forms
   */
  $( 'form.prettyform' ).show().end();
}

function clearSearch(i){
    if( $(i).val() == "" ){
        $(i).val('Enter keyword...');
        $(i).addClass('inactive');
    }else if( $(i).val() == "Enter keyword..." ){
        $(i).val('');
        $(i).removeClass('inactive');
    }else{
        $(i).select();
    }
}