/* 切换面板，兼容FireFox3,IE7
   2007年7月31日  钱浩 */
function SwitchPanel(Id,ClassOn,ClassOff,Count,AutoSwitch) 
{
	var tempFruit = new Object;
	tempFruit.Id=Id;
	tempFruit.ClassOn=ClassOn; 
	tempFruit.ClassOff=ClassOff; 
	tempFruit.Index = 1;
	tempFruit.Count=Count; 
	tempFruit.EventStr=(AutoSwitch?"mouseover":"click");
	tempFruit.Switch=function(id)
	{
		this.Index = id;
		for(var i=1;i<=Count;i++)
		{
			document.getElementById(this.Id+"_"+i).className=ClassOff;
			document.getElementById(this.Id+i).style.display="none";
		}
		document.getElementById(this.Id+"_"+id).className=ClassOn;	
		document.getElementById(this.Id+id).style.display="block";
		
		switch (id)
		{
			case 1: //专业
			 document.search_form.t.value = 'p';
			 break;
			case 2: //机构
			document.search_form.t.value = 'a';
			break;
			case 3: //网址
			document.search_form.t.value = 'n';
			break;
			case 4: //QQ
			document.search_form.t.value = 'q';
			break;
			case 5: //Email
			document.search_form.t.value = 'e';
			break;
			case 6:
			document.search_form.t.value = 'd';
			break;
			default:
		}
	}
	
	for(var i=1;i<=Count;i++)
	{
		if (window.attachEvent) {eval("document.getElementById(Id+'_'+i).attachEvent('on"+tempFruit.EventStr+"',function (){tempFruit.Switch("+i+")});")};
		if (window.addEventListener) {eval("document.getElementById(Id+'_'+i).addEventListener('"+tempFruit.EventStr+"',function(){tempFruit.Switch("+i+")},false);")};
	}
	return tempFruit;
}
function regEvent(obj,eventName,fun)
{
	eventName=eventName.replace("on","");
	if (eventName=="load") {onDOMComplete(window,fun);return;};
	if (window.attachEvent) {obj.attachEvent('on'+eventName,fun)};
	if (window.addEventListener) {obj.addEventListener(eventName,fun,false)};
}
//regEvent(window,'onload',function() {SwitchPanel('Pan','COn','COff',4,false)});
function onDOMComplete(w, f) {
	var d = w.document, done = false;
	wait();

	if ((/WebKit|KHTML|MSIE/i).test(navigator.userAgent)) {
		poll();
	}

	function load(e) {
		if (!done) {
			done = true; stop(); f(e);
		}
	}

	function has(p) { return typeof d[p] != 'undefined'; }

	function poll() {
		if (d.body !== null && d.getElementsByTagName) {
			// please see http://javascript.nwbox.com/IEContentLoaded/ for the IE improvement part of DOMComplete
			if (has('fileSize')) { try { d.documentElement.doScroll('left'); load('documentready'); } catch (e) { } }
			if (has('readyState') && (/loaded|complete/).test(d.readyState)) { load('readyState'); }
		}
		if (!done) { setTimeout(poll, 10); }
	}

	function stop() {
		if (typeof d.removeEventListener == 'function') {
			d.removeEventListener('DOMContentLoaded', load, false);
		}
	}

	function wait() {
		if (typeof d.addEventListener == 'function') {
			d.addEventListener('DOMContentLoaded', load, false);
		}
		var oldonload = w.onload;
		w.onload = function (e) {
			if (typeof oldonload == 'function') {
				oldonload();
			}
			load(e || this.event);
		};
	}
}
