/**
 * common JS function
 */

function a( what, label = 'javascript debug' ){
	if( typeof what === 'object' ){
		label += ' -- JSON.stringify() result';
		what = JSON.stringify( what );
	}
	
	alert ( label + "\n" + what );
}

function d( what, label = 'JS debug', verbose = false, breakpoint = false ){
	console.log( "<<<<< BEGIN: " + label + " >>>>>" );
	console.log( what );
	if( verbose == true ){
		console.trace();
	}
	if( breakpoint == true ){
		alert( 'break ' +  label );
	}
	console.log( "<<<<< END: " + label + " >>>>>" );
	
}

function getGet(name, url) {
    if (!url) {
      url = window.location.href;
    }
    name = name.replace(/[\[\]]/g, "\\$&");
    var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
        results = regex.exec(url);
    if (!results) return null;
    if (!results[2]) return '';
    return decodeURIComponent(results[2].replace(/\+/g, " "));
}
