// JavaScript Document
//全局变量
var prevBtn,prevItem4Btn,clicked=null,clicked2=null,tag,mid;
var obj_list_cache = new Array();
//初始变量
var init_var = function(){
    prevBtn= $("#yh");prevItem4Btn=$(".item4Over");
    if(!clicked){clicked=null;}
    if(!clicked2){clicked2=null;}
}
var init = function(){
//   prevBtn = $("#yh");
//   prevItem4Btn = $(".item4Over")
//	clicked = null
	$(".liOut, .liOver").mouseover(function(){
		$(this).parent().children().attr("class", "liOut")	
		$(this).attr("class", "liOver");
		showContent($(this))
	})
	
	$(".infoList").mouseover(function(){
		$(this).css("background","url(/images/icon_g.gif) no-repeat 4px 4px;");
		$(this).css("font-weight","normal");
	}).mouseout(function(){
		$(this).css("background","url(/images/icon_ga.gif) no-repeat 4px 4px;");
		$(this).css("font-weight","normal");
	})
	
	$(".listOver, .listOut").mouseover(function(){
		$(this).attr("class", "listOver");
		prevBtn.attr("class", "listOut");
		/*加载数据
		var thisObj = $(this);
	    var lid = $(this).attr("id");
	    obj_list_cache[0] = "yh";
	    var isa=false;
	    for(var i=0;i<=obj_list_cache.length;i++){
	        if(obj_list_cache[i]==lid) {isa =true;break;}
	    }
	    if(!isa){
	        $.post("xml_"+lid+".aspx","",function(data){
	        thisObj.parent().parent().children("."+lid).html(data);
	        obj_list_cache[obj_list_cache.length] = lid;
	    })}//加载结束*/
		showContent2($(this))
		prevBtn = $(this);							  
	})
	
	$(".item4Over, .item4Out").mouseover(function(){
		$(this).attr("class", "item4Over");	
		prevItem4Btn.attr("class","item4Out");
		prevItem4Btn = $(this);
//		if(prevItem4Btn && prevItem4Btn != $(this)){
//			prevItem4Btn.attr("class", "item4Out")	
//		}
//		this.prevItem4Btn = $(this)
	})
	
	//List page menu mouse event
	$(".menuOver, .menuOut").mouseover(function(){
		$(this).attr("class", "menuOver");										
	}).mouseout(function(){
		if(clicked){
			if(clicked.html() != $(this).html()){
				$(this).attr("class", "menuOut");
			}
		}else{
			$(this).attr("class", "menuOut");	
		}
	}).mousedown(function(){
		showSubMenu($(this))
	})
	
	function showSubMenu(thisBtn){
		if(clicked == null || clicked.html() != thisBtn.html()){
			var btnToMenu = $("."+thisBtn.attr("id"))
			btnToMenu.slideDown("slow"); 
			if(clicked){
				var clickedMenu = $("."+clicked.attr("id"))
				clicked.attr("class", "menuOut");
				clickedMenu.slideUp("slow"); 
			}
		    clicked = thisBtn;
		}else{
		    $("."+clicked.attr("id")).slideUp("slow"); clicked=null;
		}
	}
	
	//list page submenu
	/*
	$(".bottomListOver, .bottomListOut").mouseover(function(){
	    if(clicked2==$(this)){$(this).attr("class", "bottomListOver");}														
	}).mouseout(function(){
	    if(clicked2==$(this)){$(this).attr("class", "bottomListOut");}
	})
	*/
	//list page content
	$(".infoTitle").mouseover(function(){
		$(this).attr("class", "infoTitle titleOver")
		//$(this).find("a").css("background", "url(/images/open_hover.gif) no-repeat")
	}).mouseout(function(){
		$(this).attr("class", "infoTitle titleOut")
		//$(this).find("a").css("background", "url(/images/open.gif) no-repeat")
	}).mousedown(function(){
		listContent($(this))
	})
	
	function listContent(thisTitle){
	    //显示数据
	    var isa = false;
	    var lid = thisTitle.attr("id");
	    for(var i=0;i<=obj_list_cache.length;i++){
	        if(obj_list_cache[i]==lid) {isa =true;break;}
	    }
	    if(!isa){$.post("action.aspx?act=content&id="+lid,"",function(data){
	    thisTitle.next().children(".my").html(data);
	    obj_list_cache[obj_list_cache.length] = lid;
	    })}//请求数据
		if(thisTitle.next().css("display")=="none"){
		    thisTitle.find("a").css("background", "url(/images/close.gif) no-repeat");
	        thisTitle.find("span").css("background","url(/images/icon_aa.gif) no-repeat 0px 8px");
	    }else{
		    thisTitle.find("a").css("background", "url(/images/open.gif) no-repeat");
	        thisTitle.find("span").css("background","url(/images/icon_a.gif) no-repeat 0px 8px");
	    }
		thisTitle.next().slideToggle("normal");
	}

}

var loadinit=$(document).ready(init);
$(document).ready(init_var);


function showContent(thisBtn){
	var btnToSpace = $("."+thisBtn.attr("id"))
	btnToSpace.parent().children().hide();
	btnToSpace.show(); 
}
function showContent2(thisBtn){
	var btnToSpace = $("."+thisBtn.attr("id"))
	btnToSpace.parent().children(".rightContent").hide();
	btnToSpace.show(); 
}


//得到url中指定参数值
  function getUrlByParm(fieldName)
    {  
      var urlString = document.location.search;
      if(urlString != null)
      {
           var typeQu = fieldName+"=";
           var urlEnd = urlString.indexOf(typeQu);
           if(urlEnd != -1)
           {
                var paramsUrl = urlString.substring(urlEnd+typeQu.length);
                var isEnd =  paramsUrl.indexOf('&');
                if(isEnd != -1)
                {
                     return paramsUrl.substring(0, isEnd);
                }
                else
                {
                    return paramsUrl;
                }
           }
           else 
           {
                return null;
           }
      }
     else
     {
        return null;
     }
    }
    
    
  var cutstr =  function(text,length){if(text.replace(/[^\x00-\xff]/g,"**").length>length){   return text.substring(0,length)+"..."}else{return text; }}