var defaultDomain = "http://www.investide.cn/";

var guilsMapping = new Array();
guilsMapping[0] = new Array (1 ,11 ,12 ,94 ,110);
guilsMapping[1] = new Array (4 ,5 ,6 ,7 ,20 ,21 ,95 ,111);
guilsMapping[2] = new Array (8 ,22 ,23 ,24 ,25 ,26 ,27 ,28 ,29 ,30 ,31 ,32 ,33 ,34 ,35 ,36 ,38 ,39 ,40 ,41 ,42 ,43 ,44 ,45 ,93 ,96 ,112 ,118 ,119 ,122);
guilsMapping[3] = new Array (81 ,82 ,83 ,84 ,85 ,106 ,115 ,124);
guilsMapping[4] = new Array (9 ,46 ,47 ,48 ,49 ,50 ,51 ,97 ,126);
guilsMapping[5] = new Array (10 ,52 ,53 ,54 ,98);
guilsMapping[6] = new Array (13 ,55 ,56 ,57 ,113);
guilsMapping[7] = new Array (14 ,58 ,59 ,61 ,99);
guilsMapping[8] = new Array (15 ,127 ,62 ,63 ,64 ,100 ,128);
guilsMapping[9] = new Array (16 ,65 ,66 ,67 ,68 ,101);
guilsMapping[10] = new Array (17 ,69 ,70 ,71 ,102 ,114 ,125);
guilsMapping[11] = new Array (18 ,116 ,72 ,73 ,74 ,75 ,76 ,77 ,78 ,79 ,80 ,86 ,91 ,92 ,103 ,109 ,120 ,121);

function tabs_z(o,o2,n,otag,o2tag){
	var m_n = document.getElementById(o).getElementsByTagName(otag);
	var c_n = document.getElementById(o2).getElementsByTagName(o2tag);
	for(i=0;i<m_n.length;i++){
		m_n[i].className=i==n?"s":"nos";
		c_n[i].className=i==n?"dis":"undis";
		}
}
function show_child(id)
{
	clear_parent_sign();
	var parent = document.getElementById("first_nav_" + id);
	parent.className = "choose";
	var child = document.getElementById("second_nav_"+id);
	if (child) {
		child.className = "";
	}
}

function clear_parent_sign()
{
	var firstNavObj = document.getElementById("first_nav_ul");
	var children = firstNavObj.childNodes;
	for (var i = 0; i < children.length; i++) {
		children[i].className = "";
	}
	var secondNavObj = document.getElementById("second_nav");
	for (var i = 0; i < secondNavObj.childNodes.length; i++) {
		if (secondNavObj.childNodes[i].id != "") {
			secondNavObj.childNodes[i].className = "hide";
		}
	}
}

function initialCurrentChild() {
	var currentHref = window.location.href;
	if (currentHref.indexOf("/guild/") > 0 && currentHref.indexOf("guildId=") > 0){		
		var guildId = currentHref.substring(currentHref.indexOf("guildId=") + 8);
		var flag = false;
		for (var i = 0; i < guilsMapping.length; i++) {
			var subArrasy = guilsMapping[i];
			for (var j = 0; j < subArrasy.length; j++) {
				if (guildId == subArrasy[j]) {
					show_child(i+1);
					flag = true;
					break;
				}
			}
			if (flag) {
				break;
			}
		}
		if (!flag) {
			show_child(0);		
		}
	} else {
		show_child(0);
	}
}

function chooseSelect(){
	var selectObj = document.getElementById("searchSelect");
	var keywordObj = document.getElementById("keyword");
	var formObj = document.getElementById("searchForm");
	if (keywordObj.value == "") {
		alert("请输入您要搜索的关键词!");
		return false;
	}
	if (selectObj.value == 0) {
		formObj.action = "/searchAll.do";
	} else if (selectObj.value == 1) {
		formObj.action = "/news/searchNews.do";
	} else if (selectObj.value == 2) {
		formObj.action = "/enterprise/searchEnterprise.do";
	} else if (selectObj.value == 3) {
		formObj.action = "/institution/searchInstitution.do";
	} else if (selectObj.value == 4) {
		formObj.action = "/event/searchEvent.do";
	} else if (selectObj.value == 5) {
		formObj.action = "/case/searchInvestCase.do";
	}else if(selectObj.value == 6){
		formObj.action = "/person/searchInvestPerson.do";
	}
	
	return true;
}

function adjustImageSize(imageId, width, height) {
	var imageObj = document.getElementById(imageId);	
	if (imageObj != null) {
		if(imageObj.width > width){
			imageObj.height = (imageObj.height*width)/imageObj.width;
		}
		if(imageObj.height > height){			
			imageObj.width =(imageObj.width*height)/imageObj.height;
		}		
	}
}

function showHideContent(name) {
    var obj = document.getElementById(name);
	if (obj != null) {
		var objs = obj.childNodes;
		for (var i = 0; i < objs.length; i++) {
			objs[i].style.display = "";
		}	
    }
    var divObj = window.event.srcElement.parentNode;
    if (divObj != null) {
    	divObj.style.display = "none";
    }
}

function setTab(name,cursel,n){
	for(i=1;i<=n;i++){
		var menu=document.getElementById(name+i);
		var con=document.getElementById("con_"+name+"_"+i);
		menu.className=i==cursel?"hover":"";
		con.style.display=i==cursel?"block":"none";
	}
}
function fillData(url,elementId){
	http_request=false;
	if(window.ActiveXObject){
		try{
			http_request=new ActiveXObject("MSXML2.XMLHttp"); 
		}catch(e){
			try{
				http_request=new ActiveXObject("Microsoft.XMLHTTP"); 
			}catch(e){}
		} 
	}else if (window.XMLHttpRequest) { // Mozilla, Safari, ...
		http_request = new XMLHttpRequest();
		http_request.overrideMimeType('text/xml');
	}
	http_request.onreadystatechange = function() {
		if (http_request.readyState == 4) {
			if (http_request.status == 200) {
				var str=http_request.responseText;
				document.getElementById(elementId).innerHTML=str;
			} else {
				alert("服务器忙，请稍候再试！");
			}
		} else {
			document.getElementById(elementId).innerHTML="载入中，请稍候...";
		}
	};
	http_request.open('GET', url+"&t="+new Date(), true);
	http_request.send(null);
}


/**  ie6 select helper.js  *****/
if (typeof(rdcjs) == "undefined")
	_rdc = rdcjs = {};
_rdc.IE6SelectHelper = function(){
	this.selectList = new Array();
}
_rdc.IE6SelectHelper.prototype = {
	isInRange : function( elem, containerId ){
		var containerDiv = document.getElementById( containerId );
		if( !containerDiv )
			return false;
		var elemX1 = this.getX( elem );
		var elemY1 = this.getY( elem );
		var elemX2 = elem.offsetWidth + elemX1;
		var elemY2 = elem.offsetHeight + elemY1;
		
		var containerX1 = this.getX( containerDiv );
		var containerY1 = this.getY( containerDiv);
		var containerX2 = containerDiv.offsetWidth + containerX1;
		var containerY2 = containerDiv.offsetHeight + containerY1;
		if( elemX1 < containerX1 && elemX2 < containerX1 )
			return false;
		if( elemX1 > containerX2 && elemX2 > containerX2 )
			return false;
		if( elemY1 < containerY1 && elemY2 < containerY1 )
			return false;
		if( elemY1 > containerY2 && elemY2 > containerY2 )
			return false;
		return true;
	}
	,
	hideSelect : function( containerId ){
		if ( this.msieversion() <= 6 && document.all ){
			
			var selects = document.getElementsByTagName("select");
			for( var i = 0; i < selects.length; i++ ){
				var oneSelect = selects[i];
						
				if( !this.isInRange( oneSelect, containerId ) )
					continue;
					
				if( oneSelect.style.visibility != "hidden" ){
					oneSelect.style.visibility = "hidden";
					this.selectList.push( oneSelect );
				}
			}
		}
	}
	,
	showSelect : function(){
		for( var i = 0; i < this.selectList.length; i++ )
			this.selectList[i].style.visibility = "visible";
		
		while( this.selectList.length > 0 )
			this.selectList.pop();
	}
	,
	getX : function( oElement )
	{
		var iReturnValue = 0;
		while( oElement != null ) {
			iReturnValue += oElement.offsetLeft;
			oElement = oElement.offsetParent;
		}
		return iReturnValue;
	}
	,
	getY : function( oElement )
	{
		var iReturnValue = 0;
		while( oElement != null ) {
			iReturnValue += oElement.offsetTop;
			oElement = oElement.offsetParent;
		}
		return iReturnValue;
	}
	,
	msieversion : function()
	{
	  var ua = window.navigator.userAgent
	  var msie = ua.indexOf ( "MSIE " )
	  if ( msie > 0 )      // If Internet Explorer, return version number
	     return parseInt (ua.substring (msie+5, ua.indexOf (".", msie )))
	  else                 // If another browser, return 0
	     return 0
	}
}

//打印顶部时间
var today=new Date();
var month=today.getMonth()+1;
if(month<10){
month="0"+month;
}

//用来修正弹出层无法遮罩select
var ie6select = new _rdc.IE6SelectHelper();
function displaySubMenu(li) {
var subMenu = li.getElementsByTagName("div")[0];
subMenu.style.display = "block";
ie6select.hideSelect(subMenu.id );
}
function hideSubMenu(li) {
var subMenu = li.getElementsByTagName("div")[0];
subMenu.style.display = "none";
ie6select.showSelect(); 
}
