(function(){
	resize();
	
	var opt = {con:"draw",width:$("#draw").width(),height:$("#draw").height()};
	var graph = new Graph(opt);
	graph.init();
	//graph.loadData(""+ctx+"/data/graph.json"); /KnowledgeGraph/KG/getGraph.do /KnowledgeGraph/data/graph.json
	_.MessageManager.on("loadGraph",function($ev,data){
		if(data.idsStr==null || data.idsStr==""){
			graph.clear();
		}else{
			graph.loadData("/KnowledgeGraph/graph/getGraphd3rel.do",data);
		}
	});
	var dataSource = new DataSource({con:"dataSource",targetCon:"draw"});
	dataSource.init();	
	
	var searchBox = new SearchBox({con:"searchBox"});
	searchBox.init();
	
	$(window).resize(function(){
		resize();
		var h=$(window).height();
		var w=$(window).width();
		graph.resize(w,h);
	});
	//窗口改变大小，页面布局改变
	function resize(){
		//获取窗口高度
		var upperPadding = 187;
		var windowheight=$(window).height();
		$("#draw").css("height",windowheight-upperPadding);
		$("#searchBox").css("height",windowheight-100);
	}
	//阻止网页右键事件
	function stopRightClickDefaultEvent(){
		if (window.Event)
			document.captureEvents(Event.MOUSEUP);

		function nocontextmenu(event){
			event.cancelBubble = true
			event.returnValue = false;
			return false;
		}
		function norightclick(e){
			if (window.Event){
				 if (e.which == 2 || e.which == 3)
				 return false;
			}
			else if (event.button == 2 || event.button == 3){
				event.cancelBubble = true
				event.returnValue = false;
				return false;
			 }
		}

		document.oncontextmenu = nocontextmenu; // for IE5+
		document.onmousedown = norightclick; // for all others
	}
	//stopRightClickDefaultEvent();
})()
