/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
var processing;
var loading;
$(function(){
	$(document).ajaxError(function(e, xhr, settings, exception) {

		if (xhr.status != 403) {
			return;
		}

		processing.overlay().close();

		$("<div></div>", {
			id : 'sessionExpired',
			className: 'modal'
		})
		.html('<h2>Sesija istekla. Molimo logirajte se ponovo.</h2>')
		.appendTo('body')
		.overlay({

			mask: {
				color: '#fff',
				loadSpeed: 200,
				opacity: 0.7
			},
			// disable this for modal dialog-type of overlays
			closeOnClick: true,
			load: true,
			// load it immediately after the construction
			oneInstance: true,
			top: '30%',

			onClose: function(){
				location.href = '/login';
			},
			onBeforeLoad: function(){
				Cufon.replace('#sessionExpired h2');
			}
		});

	});

	processing = $("#processing").overlay({
		// some mask tweaks suitable for facebox-looking dialogs
		mask: {
			// you might also consider a "transparent" color for the mask
			color: '#fff',
			// load mask a little faster
			loadSpeed: 200,
			// very transparent
			opacity: 0.5
		},
		// disable this for modal dialog-type of overlays
		closeOnClick: false,
		// load it immediately after the construction
		load: false,
		oneInstance: false,
		top: '30%',
		close: ''
	});

});

loading = function(toggle){

	if(toggle==false) {
		if(typeof processing != 'undefined') {
			processing.overlay().close();
		}
		return;
	}

	if(typeof processing != 'undefined') {
		processing.overlay().load();
	}
};


