﻿
function secBoard(n)
{
//var secTable=document.getElementById("secTable");
var secC=document.getElementById("secCorp");
var secP=document.getElementById("secPerson");
if(n==0)
{
	secC.className="sec2";
	secP.className="sec1";
}
else
{
	secC.className="sec1";
	secP.className="sec2";
}
var mainTable=document.getElementById("mainTable");
// for(i=0;i<secTable.rows[0].cells.length-1;i++)
//  secTable.rows[0].cells[i].className="sec1";
// secTable.rows[0].cells[n].className="sec2";
 for(i=0;i<mainTable.tBodies.length;i++)
  mainTable.tBodies[i].style.display="none";
 mainTable.tBodies[n].style.display="block";
}
function setCooperateVisible(n)
{
	var secC=document.getElementById("secCoo");
	var secT=document.getElementById("secTeam");
	var mainC=document.getElementById("mainCoo");
	var mainT=document.getElementById("mainTeam");
	if(n==0)
	{
		secC.className="sec2";
		secT.className="sec1";
		mainC.className="over";
		mainT.className="out";
	}
	else
	{
		secC.className="sec1";
		secT.className="sec2";
		mainC.className="out";
		mainT.className="over";
	}
}
function setConsultVisible(n)
{
	var latest=document.getElementById("LatestSimplyConsult");
	var best=document.getElementById("BestLegalConsult");
	var sLatest=document.getElementById("sLatest");
	var sBest=document.getElementById("sBest");
//	var aMore=document.getElementById("aMore");
//	var sInfo=document.getElementById("sInfo");
//	var lawInfo=document.getElementById("LawInfo");
	if(n==0)
	{
		latest.className="over"
		best.className="out";
//		lawInfo.className="out";
		sLatest.className="overStyle";
		sBest.className="outStyle";
//		sInfo.className="outStyle";
//		aMore.href="/UI/Consult.aspx";
	}
//	else
//	{
//		latest.className="out";
////		best.className="out";
//		lawInfo.className="over";
//		sLatest.className="outStyle";
////		sBest.className="outStyle";
//		sInfo.className="overStyle";
//		aMore.href="#";
//	}
	else if(n==1)
	{
		latest.className="out";
		best.className="over";
//		lawInfo.className="out";
		sLatest.className="outStyle";
		sBest.className="overStyle";
//		sInfo.className="outStyle";
//		aMore.href="/UI/LegalConsultSearch.aspx";
	}
}

// 清空下拉菜单
function DropSelectOption(obj) {
	for (var i=obj.options.length-1; i>=0; i--) {
		obj.options[i].parentNode.removeChild(obj.options[i]);
	}
}

function RemoveNode(obj, name) {
	var node = obj;
	while (node.nodeName.toLowerCase() != name.toLowerCase()) {
		node = node.parentNode;
	}

	node.parentNode.removeChild(node);
}

function KeyEnterToOnClick(nodeId) {
	if (event.keyCode == 13) {
		var node = document.getElementById(nodeId);
		node.click();

		return false;
	}
}

function AddToFavorite(url, title) {
	if (window.sidebar) { 
		window.sidebar.addPanel(title, url, "");
	}
	else if(document.all) {
		window.external.AddFavorite(url, title);
	}
	else if(window.opera && window.print) {
		return false;
	}
}
 function save(url,title){ 
if (document.all) 
window.external.AddFavorite(url, title); 
else if (window.sidebar) 
window.sidebar.addPanel(title, url, "") 
}
//检查Email格式
function IsEmail(str) {
	var reg = /^[-_a-za-z0-9]+@([_a-za-z0-9]+\.)+[a-za-z0-9]{2,3}$/;
	return reg.test(str);
}

//检查电话号码格式
function IsPhone(str) {
	var reg = /^[-0-9]+$/;
	return reg.test(str);
}
//检查联系电话包括手机
function IsPhone2(str)
{
    var reg = /(^[0-9]{3}-[0-9]{8}$)|(^[0-9]{4}-[0-9]{7}$)|(^[0-9]{7,8}$)|(^\([0-9]{3}\)[0-9]{8}$)|(^\([0-9]{4}\)[0-9]{7}$)|(^0{0,1}13[0-9]{9}$)/;
    return reg.test(str);
}
//检查日期格式
function IsDate(str) {
	var r = str.match(/^(\d{1,4})(-|\/)(\d{1,2})\2(\d{1,2})$/);
	if(r==null) {return false;}
	var d = new Date(r[1], r[3]-1, r[4]);
	return (d.getFullYear()==r[1] && (d.getMonth()+1)==r[3] && d.getDate()==r[4]);
}
//去除首尾空格
String.prototype.Trim=function()
{
    return this.replace(/(^\s*)|(\s*$)/g,"");
}
//请firefox支持selectnodes方法
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";}
    }
}
}
