﻿$(document).ready(
				  function(){
					  $('#caseListContainer > ul > li:odd').addClass('gray');
					  $('#newsListContainer > ul > li:odd').addClass('gray');
					  $('#agentTitle > div').toggle();
					  $('#agentTitle > h1').mouseover(function(){
					  	$('#agentTitle > div').show('slow');
					  });
					  $('#agentTitle > h1').mouseout(function(){
					  	$('#agentTitle > div').hide('slow');
					  });
					  if($('div.infoSwitcher') != null){			  
					  	initSwitch();
					  }
					  if($('.level1') != null){
					  	initMenu();
					  }
					  if($('#guide p') != null)
					  {
					  	changeCurrentPoint();
					  }
					  }				 
				  );
 function initSwitch(){
	$('div.infoSwitcher>div:eq(0)').removeClass('hide').addClass('show');
	var $infoSwitcherTitle = $('div.infoSwitcher > h3');
	 $('div.infoSwitcher h3 span').bind('click',function(event)
																 {
																	 var i = $('div.infoSwitcher > h3 > span').index(this);
																	 $('div.infoSwitcher > h3 > span').removeClass();
																	 $(this).addClass('currentItem_S');
																	 $('div.infoSwitcher>div').removeClass().addClass('hide');
																	 $('div.infoSwitcher>div').eq(i).removeClass().addClass('show');
																	 }
																 );
}
function changeItem2(event){
	var $h3 =  $('div.infoSwitcher h3');
	var i = $('div.infoSwitcher h3').index(event.target);
}

/**
 * 功能：切换不同页面时游标指向当前页面[主菜单]
 */
function changeCurrentPoint()
{
	var $currentPageTxt = $($('#guide p').children()[1]).html();			//当前页面文本
	
	var mainNav = $('#mainNav ul a');										//主菜单文本
	var txt;
	for(var i=0;i<mainNav.length;i++)
	{
	    var txt = $(mainNav[i]).text(); 
	    if( txt == $currentPageTxt )
	    {
	    	$('#mainNav ul a').removeClass();
	    	$(mainNav[i]).addClass('currentItem');
	    }   
	}
		
}


function initMenu()
{
	$('.level1 a').bind('mouseover',function(e){
		var $t = $(e.target);
		var $p = $t.parent();
		$p.addClass('currentNav');
	});
	$('.level1 a').bind('mouseout',function(e){
		var $t = $(e.target);
		var $p = $t.parent();
		$p.removeClass('currentNav');
	});	
	if($('.level2').length != 0)
	{
		$('.level1>a:first-child').addClass('close');
		$('.level1>a:first-child').bind('click',function(e){
			var target = e.target;
			var pli = $(target).parent();
			var cUL = pli.children('ul');
			$('.level2').hide('slow');			
			cUL.slideToggle('slow',function(){
				$('.level1>a:first-child').addClass('close');
				$(target).removeClass().addClass('open');				
			});			
		});
	}
	setCurrentItem();
}

//设置当前页面的指针

function setCurrentItem(){
	var index = $('#guide > p').children().length;
	var str = $('#guide > p > span').text().toString();
	if(str != null){
		var menuStr = ".sideNavBody a:contains("+ str +")";
		var menu = $(menuStr);
		var pLi = menu.eq(0).parent();
		
		pLi.addClass('currentNav');
		
		var target = menu.eq(0);
		target.unbind();
			
		if ($('.level2').length != 0) {
			var ppLi = pLi.parent();
			var pppLi = ppLi.parent();		
			ppLi.show();
			pppLi.children().eq(0).addClass('open');
		}
	}	
}

//切换选项卡
function switchTab(tabid,index){
     $('#tabNav li').children('a').each(function(){
			$(this).removeClass('selected')
		});
	 $(tabid).children('a').addClass('selected');
	 $('#tabCon').children('div').each(function(){$(this).hide();});
	 $('#tabCon').children('div')[index].style.display = 'block';
	 
}
