//高亮行
function mOver(obj){
    obj.style.backgroundColor='#f2f2f2';
}
function mOut(obj){
    obj.style.backgroundColor='#ffffff';
}
function show(objli,index){
 if(objli.id=="current")return;
 var obj_ul=document.all("objul");
   for(var i=0;obj_ul&&obj_ul.children&&obj_ul.children.length&&i<obj_ul.children.length;i++){
     if(obj_ul.children[i].id){
         obj_ul.children[i].removeAttribute("id");
	   break;
	 }
   }
   if(objli.id!="current"){objli.setAttribute("id","current");}
   var kind=document.all("kind");
   for(var i=0;kind&&kind.length&&i<kind.length;i++){
     kind[i].style.display=(parseInt(kind[i].tab_index)==index?"":"none"); 
   }
}


function doApplyFormSubject(column_code){
	if(column_code==null||column_code=="")return alert("建设中....未指定归属栏目");
	if($("apply_username").value==""){
		alert("申请人不能为空！");
		return $("apply_username").focus();
	}
	if($("apply_project_name").value==""){
		alert("项目名称不能为空！");
		return $("apply_project_name").focus();
	}
	var obj=new JSPSoftCallBack();

      obj.callback=function(){
			var contentx=replaceEx(applyForm.innerHTML," class=\"apply_input\""," class=\"apply_input_disabled\" disabled readonly");
			contentx=replaceEx(contentx," class=apply_input"," class=\"apply_input_disabled\" disabled readonly");
			contentx=replaceEx(contentx," class='apply_input'"," class=\"apply_input_disabled\" disabled readonly");
			contentx=replaceEx(contentx," style=\"display: none\"","");
			contentx=replaceEx(contentx," style='display: none'","");
            postRequest(
            {action:"post_news",subject:$("apply_username").value+" - "+$("apply_project_name").value,is_pub:0,content:contentx,column_code:column_code,path_url:location.pathname,article_author:applyForm.apply_username.value},//默认为顶
            function(responseData1){
				 if(responseData1=="OK") {alert("恭喜你，你的项目申请发送成功！请等待审核结果公布！"); top.location.reload();}
				 else alert("申请发送失败，请稍候重试！");
            }
           );
      }
     if(confirm("填写好了吗，真的要提交吗？"))obj.sendData();   
}
function doSiteSearch(surl,target_name){
 	var qstr =search_form.search.value;
 	if(qstr=="")return  alert("请输入要搜索的关键字");
	var stype="1";
	if(search_form.search_type[0].checked)stype="1";
	else if(search_form.search_type[1].checked)stype="2";
	else if(search_form.search_type[2].checked)stype="3";
	else return alert("请正确选择搜索类别");

	top.open(surl+"?q="+qstr+"&t="+stype,target_name?target_name:"_blank");
}
function show(objli, index){
    if (objli.id == "current")return;
    var obj_ul = document.all("objul");
    for (var i = 0; obj_ul && obj_ul.children && obj_ul.children.length && i < obj_ul.children.length; i++) {
        if (obj_ul.children[i].id) {
            obj_ul.children[i].removeAttribute("id");
			obj_ul.children[i].className="outMo";
            break;
        }
    }
    if (objli.id != "current")objli.setAttribute("id", "current");
	objli.className="onMo"
    var news = document.all("news");
    for(var i = 0; news && news.length && i < news.length; i++){
        news[i].style.display = (parseInt(news[i].tab_index) == index ? "" : "none");
    }
}


  
function changeClass(objli){
	var objs = $("objul").children;
	for (var i = 0; objs && objs.length && i < objs.length; i++) 
	  objs[i].className = (objli == objs[i] ? replaceEx(objs[i].className, "0", "1") : replaceEx(objs[i].className, "1", "0"));
}

function Alors(){
	Alpha=Alpha-I_Alpha;
	for (x=0;x<Nb;x++){
		Alpha1=Alpha+Decal*x;
		Cosine=Math.cos(Alpha1);
		Ob=document.all("L"+x);
		Ob.style.posLeft=Midx+100*Math.sin(Alpha1)+50;
		Ob.style.zIndex=20*Cosine;
		Ob.style.fontSize=Taille+20*Cosine;
		Ob.style.color="rgb("+ (27+Cosine*80+50) + ","+ (127+Cosine*80+50) + ",0)";
	}
}


/////////////////////////////////////
var isIE =   (navigator.appName=="Microsoft Internet Explorer");

function parseXML(st){
     if(isIE){
         var result = new ActiveXObject("Microsoft.XMLDOM");
		 result.async=false;
         result.loadXML(st);
     }else if (document.implementation &&document.implementation.createDocument){//FF
		  result= document.implementation.createDocument("","",null);	 
		  result.async=false;
		  result.loadXML(st);
	 }else{
		alert('浏览器不支持脚本,无法加载XML文件');
	 } 
	try{result.setProperty("SelectionLanguage","XPath");}catch(exp){}
    return result;
}

/////////////////////////////////////
var GetNodeValue = function(obj){
	var str = "";
	if(window.ActiveXObject){    //IE
		str = obj.text;
	}else{ //Mozilla
		try{
		   str = obj.childNodes[0].nodeValue;
		}catch(ex){
		   str = "";
		}
	}
	return str;
}

if(document.implementation && document.implementation.createDocument){
	XMLDocument.prototype.loadXML = function(xmlString){
		var childNodes = this.childNodes;
		for (var i = childNodes.length - 1; i >= 0; i--)this.removeChild(childNodes[i]);
		var dp = new DOMParser();
		var newDOM = dp.parseFromString(xmlString, "text/xml");
		var newElt = this.importNode(newDOM.documentElement, true);
		this.appendChild(newElt);
	};

// check for XPath implementation
if(document.implementation.hasFeature("XPath", "3.0")){
    // prototying the XMLDocument
    XMLDocument.prototype.selectNodes = function(cXPathString, xNode){
			if( !xNode ) { xNode = this; }
			var oNSResolver = this.createNSResolver(this.documentElement)
			var aItems = this.evaluate(cXPathString, xNode, oNSResolver,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null)
			var aResult = [];
			for( var i = 0; i < aItems.snapshotLength; i++){
				aResult[i] = aItems.snapshotItem(i);
			}
			return aResult;
		}
		// prototying the Element
		Element.prototype.selectNodes = function(cXPathString){
		if(this.ownerDocument.selectNodes)
		{
		  return this.ownerDocument.selectNodes(cXPathString, this);
		}else{
			throw "For XML Elements Only";
		}
    }
}

// check for XPath implementation
if(document.implementation.hasFeature("XPath", "3.0"))
{
    // prototying the XMLDocument
    XMLDocument.prototype.selectSingleNode = function(cXPathString, xNode)
    {
		if( !xNode ) { xNode = this; }
		var xItems = this.selectNodes(cXPathString, xNode);
		if( xItems.length > 0 )
		{
			return xItems[0];
		}else{
			return null;
		}
    }  
    // prototying the Element
    Element.prototype.selectSingleNode = function(cXPathString)
    {  
		if(this.ownerDocument.selectSingleNode)
		{
			return this.ownerDocument.selectSingleNode(cXPathString, this);
		}else{
			throw "For XML Elements Only";
		}
    }
}
}

////////////////////////////////////
function showColumnMenu(aObj){
	if(!document||!document.body||!$("xmldoc"))return;
	var xmlobj=parseXML("<?xml version=\"1.0\" encoding=\"gb2312\"?>"+$("xmldoc").innerHTML).documentElement;
	//if(xmlobj==null||xmlobj.readyState!="complete")return;
	var current_code=aObj.getAttribute("code");
	if(current_code==""){
		$("column_menu").innerHTML="";
		return;
	}
	var menuObj=document.createElement("span");
	menuObj.style.cssText="position:absolute;top:0";
	if(xmlobj){
		var nodes=xmlobj.selectNodes("/a/b");
		for(var i=0;i<nodes.length;i++){
			if(isIE){
				if(nodes[i].getAttribute("b").indexOf(current_code)==0&&nodes[i].getAttribute("b").length>current_code.length){
					var newmenu=document.createElement("A");
					newmenu.href=nodes[i].getAttribute("d");
					newmenu.id="submenu";
					newmenu.innerText=nodes[i].getAttribute("c");
					menuObj.appendChild(newmenu);
				}
			}else{
				var code1	=getAttribute("b",nodes[i].attributes);
				var href1	=getAttribute("d",nodes[i].attributes);
				var text11	=getAttribute("c",nodes[i].attributes);
				if(code1.indexOf(current_code)==0&&code1.length>current_code.length){
					var newmenu=document.createElement("A");
					newmenu.href=href1;
					newmenu.id="submenu";
					newmenu.innerHTML=text11;
					menuObj.appendChild(newmenu);
				}
			}
		}
	}
	$("column_menu").innerHTML="";
	$("column_menu").appendChild(menuObj);
	var pos=getElementRect(aObj);
	var rect=getElementRect(menuObj);
	var left_min=parseInt(pos.x-getAbsolutePosition($("column_menu")).x+(pos.w/2)-(rect.w/2));
	if(left_min+rect.w>=960)menuObj.style.left=960-rect.w-(isIE?0:50);
	else menuObj.style.left=left_min-(isIE?0:50);
}
function getAttribute(name,list){
    if(!list)return false;
    for(var i=0;i<list.length;i++){
        if(list[i].nodeName.toLowerCase()==name.toLowerCase()){
            return list[i].nodeValue;
        }
    }
    return false;    
} 

function gourl(url){
    if(url==""){return;}
    window.open(url,"_blank");
}
function AotoScrollToView(){
        var yMenuFrom, yMenuTo, yButtonFrom, yButtonTo, yOffset, timeoutNextCheck;

	yButtonFrom = parseInt (divMenu.style.top, 10);
	yButtonTo   = document.body.scrollTop + document.body.clientHeight - 108;
   
        timeoutNextCheck = 500;

        if(Math.abs (yButtonFrom - (yMenuTo + 152)) < 6 && yButtonTo < yButtonFrom){
                setTimeout ("AotoScrollToView()", timeoutNextCheck);
                return;
        }

        if(yButtonFrom != yButtonTo){
		yOffset = Math.ceil( Math.abs( yButtonTo - yButtonFrom )/10 );
		if(yButtonTo < yButtonFrom )yOffset = -yOffset;
		divMenu.style.top = parseInt (divMenu.style.top, 10) + yOffset;
		timeoutNextCheck = 10;
        }
        if(yMenuFrom != yMenuTo){
		yOffset = Math.ceil( Math.abs( yMenuTo - yMenuFrom )/20 );
		if(yMenuTo < yMenuFrom )yOffset = -yOffset;
		divMenu.style.top = parseInt (divMenu.style.top, 10) + yOffset;
		timeoutNextCheck = 10;
        }

        setTimeout ("AotoScrollToView()", timeoutNextCheck);
}

function goTop(){
      /* var y;
       var divMenu=null;
       if(divMenu==null){
          document.body.insertAdjacentHTML("beforeEnd",'<DIV id=divMenu style="VISIBILITY: hidden; left:891; WIDTH: 17px; POSITION: absolute"><a href="#top" onclick="this.blur();"><img src="/resource/_tpl/jspsoft/images/top.gif" border="0"></a></DIV>');
          divMenu=document.all("divMenu");
       }
                divMenu.style.top = document.body.scrollTop + document.body.clientHeight - 108;
                divMenu.style.visibility = "visible";

        AotoScrollToView();*/
}
