
chrome.browserAction.onClicked.addListener(function(tab) {
	doScripts(true);
});

function getClickHandler(info, tab) {
	doScripts(false);
}

function doScripts(context){
	chrome.tabs.executeScript(null, {file:"js/jquery.js"}, function() {
		chrome.tabs.executeScript(null, {file:"js/jquery.easing.min.js"}, function(){
			chrome.tabs.executeScript(null, {file:"js/jquery.frameAnimationSprite.js"}, function(){
				chrome.tabs.executeScript(null, {file:"js/box2d.js"}, function(){
					chrome.tabs.executeScript(null, {code: "var doingBrowserAction = "+context+";"}, function(){
						chrome.tabs.executeScript(null, {file: "js/myscript.js"}, function(){
								
								
						});
					});
				});
			});
		});
	});
}

chrome.contextMenus.create({
  "title" : "DESTROY!",
  "type" : "normal",
  "contexts" : ["page","selection","link","editable","image","video","audio"],
  "onclick" : getClickHandler
});

/*
function doScripts(context){
	chrome.tabs.executeScript(null, {file:"js/jquery.js"}, function() {
		chrome.tabs.executeScript(null, {file:"js/jquery.lettering.js"}, function(){
			chrome.tabs.executeScript(null, {file:"js/jquery.easing.min.js"}, function(){
				chrome.tabs.executeScript(null, {file:"js/jquery-css-transform.js"}, function(){
					chrome.tabs.executeScript(null, {file:"js/jquery-animate-css-rotate-scale.js"}, function(){
						chrome.tabs.executeScript(null, {file:"js/jquery.frameAnimationSprite.js"}, function(){
							chrome.tabs.executeScript(null, {file:"js/box2d.js"}, function(){
								chrome.tabs.executeScript(null, {code: "var doingBrowserAction = "+context+";"}, function(){
									chrome.tabs.executeScript(null, {file: "js/myscript.js"}, function(){
										//all injected
									});
								});
							});
						});
					});
				});
			});
		});
	});
}
*/



