var collectScriptData;

//function setTab(name, m, n) {
//	for (var i = 1; i <= n; i++) {
//		var menu = document.getElementById(name + i);
//		var showDiv = document.getElementById("cont_" + name + "_" + i);
//		menu.className = i == m ? "on" : "";
//		showDiv.style.display = i == m ? "block" : "none";
//	}
//}

function getScriptObject(scriptId,usePlugin) {
	$.post("getScript", {
		scriptId : scriptId
	}, function(data) {
		if (!data.success) {
			information("failed to get script:" + data.failedMessage);
			return;
		} else {
			var scriptObj = eval("(" + data.script + ")");
			
			usePlugin.initPluginAndPages(scriptObj);
		}
	}, "json");
}

$(function() {
	var scriptId = getvars()['scriptId'];
	var usePlugin = new UsePlugin("useBehaviorList");
	getScriptObject(scriptId,usePlugin);
	$("#scriptName").val(getvars()['name']);

	$("#tabs").tabs();

	
	$("#submitScript").click(function() {
		var plugins = usePlugin.getPlugins();
		var pages = usePlugin.getPages();
		if(checkPluginsInput(plugins) && checkPagesInput(pages))
			updateScript(scriptId,pages,plugins);
		else
			information("必填的参数没有填写完整,请补充完整后提交");

	});
});
