function showElement(element, text) {
	if(typeof text != 'undefined') {
		$(element).fadeIn(500).html(text);
	}
	setTimeout(function() {
		$(element).fadeOut(500);
	},5000);
}

showHide = function(element, callback_open, callback_close) {
	if($(element).is(':visible')) {
		$(element).slideUp(500, (jQuery.isFunction(callback_close) ? callback_close(element) : function() { }));
	} else {
		$(element).slideDown(500, (jQuery.isFunction(callback_open) ? callback_open(element) : function() { }));
	}
	return false;
};

function scrilTo(el, callback) {
	if($(el).size() > 0) {
		$('html, body').animate({scrollTop:$(el).offset().top}, 'slow', (jQuery.isFunction(callback) ? callback(el) : function() { }));
	}
	return false;
}


//notifikations
function WMHumanMessages(msg, title, type, options, callback) {
	$(document).ready(function() {
		function clear_box(time, type) {
	        setTimeout(function() { $('.' + type + '_message_box').fadeOut(300); }, time);
	    }
		if($('.' + type + '_message_box').size() < 1) {
			$('body').append('<div class="' + type + '_message_box"><h4 class="title"></h4><div class="msg"></div></div>');
		}
		$('.' + type + '_message_box .title').css({'text-align':'center'}).html((title||''));
		$('.' + type + '_message_box .msg').css({'text-align':'center'}).html((msg||''));
		def = {
					position: 'fixed',
					//top: '200px',
					left: '25%',
					width: '50%',
					'background': '#000000',
					'-moz-border-radius': '5px',
					'-webkit-border-radius': '5px',
					'opacity': '0.9',
					'border': '1px solid #ffffff',
					'padding': '5px',
					'z-index': '999999',
					'color': '#ffffff'
				 };
		def.top = ( $(window).height() - $('.' + type + '_message_box').height() ) / 2;
		setCss = $.extend(def, (options||{}));
		$('.' + type + '_message_box').css(setCss).fadeIn(500);
		clear_box(5000, type);
		//$(document).mousemove(function() { clear_box(1000, type); });
		
		callback();
	});
}

function formatNumber(num, dec, thou, pnt, curr1, curr2, n1, n2) {
    var x = Math.round(num * Math.pow(10, dec));
    if (x >= 0) n1 = n2 = '';
    var y = ('' + Math.abs(x)).split('');
    var z = y.length - dec;
    if (z < 0) z--;
    for (var i = z; i < 0; i++) y.unshift('0');
    if (z < 0) z = 1;
    y.splice(z, 0, pnt);
    if (y[0] == pnt) y.unshift('0');
    while (z > 3) {
        z -= 3;
        y.splice(z, 0, thou);
    }
    var r = curr1 + n1 + y.join('') + n2 + curr2;
    return r;
}


function success(msg, title, callback) {
	options = {'background': '#006600'};
	if(jQuery.isFunction(callback)) { callback = callback; } else { callback = function() { } };
	return WMHumanMessages(msg, title, 'success', options, callback);
}
function warning(msg, title, callback) {
	options = {'background': '#CCCC00','color': '#000000'};
	if(jQuery.isFunction(callback)) { callback = callback; } else { callback = function() { } };
	return WMHumanMessages(msg, title, 'warning', options, callback);
}
function error(msg, title, callback) {
	options = {'background': '#660800'};
	if(jQuery.isFunction(callback)) { callback = callback; } else { callback = function() { } };
	return WMHumanMessages(msg, title, 'error', options, callback);
}
function info(msg, title, callback) {
	options = {'background': '#00CCFF'};
	if(jQuery.isFunction(callback)) { callback = callback; } else { callback = function() { } };
	return WMHumanMessages(msg, title, 'info', options, callback);
}



