// JavaScript Document
// http://www.inbusiness.no



// Popup Window:
function MM_openBrWindow(theURL,winName,features){
	window.open(theURL,winName,features);
}



/*	Clearing form fields:

	Call this function using this:
	$('elements').clearMe();
*/
(function( $ ){
	$.fn.clearMe = function( options ) {

		return this.each(function() {
			// Clear input fields focus function:
			$(this).focus(function() {
				var $input = $(this);
				if ($input.prop('value') === $input.prop('defaultValue')) {
					$input.prop('value', '');	
				}
			});
			// Clear input fields blur function:
			$(this).blur(function () {
				var $input = $(this);
				if ($input.prop('value') === '') {
					$input.prop('value', $input.prop('defaultValue'));	
				}
			});
		});

	};
})( jQuery );



/*	Fill height with footer:

	Call this function using this:
	$('elements').setHeight();
*/
(function( $ ){
	$.fn.setHeight = function( options ) {

		return this.each(function() {
			var usedHeight = $('#top').outerHeight() + $('#backgroundbottom').outerHeight();
			if ( $(window).height() > (usedHeight + $(this).outerHeight()) ) {
				$(this).css('height', $(window).height() - usedHeight);
			}
		});

	};
})( jQuery );



/*	Add <hr /> for front news

	Call this function using this:
	$('elements').addhr();
*/
(function( $ ){
	$.fn.addhr = function( options ) {

		return this.each(function() {
			if ( $(this).is(':nth-child(4)') ) {
			} else {
				$(this).append('<hr>');
			}
		});

	};
})( jQuery );



/*	Slide open on link click

	Call this function using this:
	$('LINKELEMENT').openthis({
		showthis: 'ELEMENTTOSHOW',
		duration: 300 // Optional, default(300)
	});
*/
(function( $ ){
	$.fn.openthis = function( options ) {
		
		// Default settings here:
		var settings = {
			showthis : '',
			duration : 300
		};
	
		return this.each(function() {        
			// If options exist, lets merge them with our default settings
			if ( options ) { $.extend( settings, options ); }
			// CODE:
			$(this).click(function() {
				$(settings.showthis).toggle(settings.duration);
			});
		});
	};
})( jQuery );


(function( $ ){
	$.fn.setBoxHeights = function( options ) {
		
		// Default settings here:
		var settings = {
		};
	
		return this.each(function() {        
			// If options exist, lets merge them with our default settings
			if ( options ) { $.extend( settings, options ); }
			// CODE:
			
		});
	};
})( jQuery );
