$(document).ready(function(){
	$('div.ajax').ajaxLink();
	$('form.ajax').ajaxForm();
});// document.ready

//------ functions -------//
jQuery.fn.ajaxForm = function(){
	$(this).submit(function(){
		$.post( $(this).attr('action'), $(this).serialize() );
		return false;
		} //function
	);// click
	}// end ajaxForm

jQuery.fn.ajaxLink = function(){
	this.click(
		function(){
			$.get( $(this).attr('href') );
			return false;
		} //function
	);// click
	}// end ajaxLink

jQuery.fn.heightOfChildren = function(){
	element = this;
	var $heights = 0 ;
	$(element).children().each(function(){
	$heights = $heights + $(this).heightOfElement();
	});
	return $heights;
	}// end heightOfChildren

jQuery.fn.heightOfElement = function(){
	element = this;
	$h = 0;
	$h = $h + parseInt( $(element).height() ); // gets height of content
	$h = $h + $(element).heightOfPerimeter(); // adds height of box model
	return $h;
	}//end fn.heightOfElement

jQuery.fn.widthOfElement = function(){
	element = this;
	$w = 0;
	$w = $h + parseInt( $(element).width() ); // gets width of content
	$w = $h + $(element).widthOfPerimeter(); // adds width of box model
	return $w;
	}//end fn.heightOfElement

jQuery.fn.heightOfPerimeter = function(){
	$p = 0;
	$p = $p + parseInt( $(this).css("margin-top") ); // adds height of box model
	$p = $p + parseInt( $(this).css("margin-bottom") );
	$p = $p + parseInt( $(this).css("border-top-width") );
	$p = $p + parseInt( $(this).css("border-bottom-width") );
	$p = $p + parseInt( $(this).css("padding-top") );
	$p = $p + parseInt( $(this).css("padding-bottom") );
	return $p;
	} //end fn.heightOfPerimeter

jQuery.fn.widthOfPerimeter = function(){
	$p = 0;
	$p = $p + parseInt( $(this).css("margin-left") ); // adds height of box model
	$p = $p + parseInt( $(this).css("margin-right") );
	$p = $p + parseInt( $(this).css("border-left-width") );
	$p = $p + parseInt( $(this).css("border-right-width") );
	$p = $p + parseInt( $(this).css("padding-left") );
	$p = $p + parseInt( $(this).css("padding-right") );
	return $p;
	} //end fn.heightOfPerimeter

jQuery.fn.expandY = function($offSet){
	var element = this[0] ;
	var parentInnerHeight = $(element).parent().innerHeight();
	parentInnerHeight = parentInnerHeight - parseInt( $(element).parent().css('padding-top') );
	parentInnerHeight = parentInnerHeight - parseInt( $(element).parent().css('padding-bottom') );
	var childNewHeight = parentInnerHeight - $(element).heightOfPerimeter();
	if( !isNaN($offSet) ) childNewHeight = childNewHeight + $offSet ;
	$(element).css({'height': childNewHeight + 'px'});
	}; // end fn.expandY

//------ time ------//
jQuery.fn.wait = function(time, type) {
    time = time || 1000;
    type = type || "fx";
    return this.queue(type, function() {
        var self = this;
        setTimeout(function() {
            $(self).dequeue();
        }, time);
    });
};//end fn.wait
