
// (debug mode) err_count helps breaking from error loops in code segments
// they happen when dynamically linking js scripts in a potentially recursive/loop construct
err_count = 0;

function err_handle(msg) {

	// kill the loading animation
	if(window.application) {
		while(application.loadCount > 0) application.stopLoad();
	}

    // don't pop that recurring error
    switch(msg) {
    case 'Permission denied to access property \'dom\' from a non-chrome context':
    case 'console is not defined':

        return;

    default:

        err_count++;
        alert(msg);
    }
}

window.onerror = err_handle;

// prevent errors from console.log's forgotten in the code
if(typeof(console) == 'undefined') console = {log:function(){}};
