// JavaScript Document
$(document).ready(function(){
	//左侧导航动作脚本
	var arrOpened = new Array();
	$('.lv1').find('span:eq(0)').click(function(){
		OpenLv($(this),arrOpened[1]);
	})
	$('.lv2').find('span:eq(0)').click(function(){
		OpenLv($(this),arrOpened[2]);
	})
	$('.lv3').find('span:eq(0)').click(function(){
		OpenLv($(this),arrOpened[3]);
	})
	var SelectedLv = parseInt($('.selected').attr('lv'));
	var tmpCode='';
	var evalCode='';
	for(var i=0 ; i<SelectedLv-1 ; i++){
		tmpCode += '.parent().parent()';
		evalObject = " $('.selected')"+tmpCode+".find('span:eq(0)')";
		evalOpen = "OpenLv("+evalObject+",null)";
		eval(evalOpen);
	}
	
	function OpenLv(Obj,Opened){
		if(Opened!=null){
			if($(Obj).parent().find('ul:eq(0)').css('display') != 'block'){
				Opened.parent().find('ul:eq(0)').slideUp('fast');
				Opened.parent().css('background-position','0px 0px');
			}
		}
		$(Obj).parent().find('ul:eq(0)').slideToggle('fast',function(){
			if($(Obj).parent().find('ul:eq(0)').css('display') != 'block'){
				$(Obj).parent().css('background-position','0px 0px');
			}
		});
		$(Obj).parent().css('background-position','0px -50px');
		lvIndex = parseInt($(Obj).parent().attr('lv'));
		arrOpened[lvIndex] = $(Obj);
	}
	
});
