/* index */
$(document).ready(function()
{
	/*防止被 iframe */
	if(top!=self){
		top.location=self.location;
	}
	/* resize #main and .sidebar */
	$('#main').css("width" , $(window).width() - 200)
		.css("height" , $(window).height() - 120);
	$('#sidebar').css("height" , $(window).height() - 120);
	$(window).resize(function() {
		$('#main').css("width" , $(window).width() - 200)
			.css("height" , $(window).height() - 120);
		$('#sidebar').css("height" , $(window).height() - 120);
	});
});
/*s: shortcut */
$('#shortcutSwitch').hover(
	function(){
		$('#shortcutItems').show();
	},
	function(){
		$('#shortcutItems').hide();
	}
);
/*e: shortcut */
/* mainMenu */
$("#mainMenu li:first").addClass("current");setPositon();
$(".subMenu").not(":first").hide();
$("#mainMenu li").unbind("click").bind("click", function(){
	if($("#sidebar").is(":hidden")){
		$('#sidebarSwitch').trigger('click');
	}
	$(this).siblings("li").removeClass("current").end().addClass("current");
	$(".subMenu").hide();
	$('#'+$(this).attr('for')).fadeIn();
	setPositon();
});
/* load subMenu to mainFrame */
$(".subMenu li[url]").bind('click',function(){
	$(".subMenu li[url]").removeClass("current");
	$(this).addClass("current");
	$('#mainiFrame').attr('src', $(this).attr('url'))
	setPositon($(this).text());
});
/*setPosition*/
function setPositon(menuText){
	document.title = l_manage+" - "+$("#mainMenu li.current").text();
	$("#position").text(l_manage+" » "+$("#mainMenu li.current").text());
	if(menuText)
	{
		$("#position").text($("#position").text()+" » "+menuText);
	}
}
/* toggle sidebar */
$("#sidebarSwitch").live('click',function(){
	$(this).toggle(
		function(){
			$("#sidebar").hide();
			$("#main").css("left", "0");
			$('#main').css("width" , $(window).width());
			$(window).resize(function() {
				$('#main').css("width" , $(window).width());
			});
		},
		function(){
			$("#sidebar").show();
			$("#main").css("left", "200px");
			$('#main').css("width" , $(window).width() - 200);
			$(window).resize(function() {
				$('#main').css("width" , $(window).width() - 200);
			});
		}
	).trigger('click');
});
/* operation map */
$('#operationMapSwitch').bind('click', function(){
	art.dialog({
		lock:true,
		background:'#000',
		opacity:0.8,
		title:operation_map_title,
		content:document.getElementById('operationMap'),
		padding:'10px 5px',
		id:'OM'
	});
});
$('#operationMap a').click(function(){
	art.dialog({id:'OM'}).close();
});

