var obj, tpl, list, scroll_obj;

function createXmlHttp()
{
	var xmlHttp = false;
	try{
		xmlHttp = new ActiveXObject("MSXML2.XMLHTTP");
	}catch(e){
		try{
			xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		}catch(e){
			xmlHttp = false;
		}
	}
	if(!xmlHttp && typeof XMLHttpRequest != 'undefined') {
		xmlHttp = new XMLHttpRequest();
	}
	return xmlHttp;
}
function getform(formid)
{
	var fInfo = document.getElementById(formid);
	var fArr = new Array();
	for(var i=0; i<fInfo.length; i++) {
		if(fInfo[i].type != "button") {
			fArr.push(fInfo[i].name+"="+encodeURIComponent(fInfo[i].value));
		}
	}
	fArr = fArr.join("&");
	return fArr;
}
function linkmoverover(obj, ename){
	var linkobj = document.getElementsByName('link[]');
	var linkid = 'link_' + ename;
	
	classarr = eval(classarr);
	var hid;
	for(var i=0; i<linkobj.length; i++) {
		linkobj.item(i).style.background = "url('./lib/view/default/images/link_bg.jpg') no-repeat left top";
		hid = 'link_' + classarr[i];
		if(document.getElementById(hid)) {
			document.getElementById(hid).style.display = 'none';
		}
	}
	
	obj.style.background = "url('./lib/view/default/images/link_bg1.jpg') repeat-y left top";
	document.getElementById(linkid).style.display = '';
}
function scrolldiv(obj, tpl, list)
{
	var obj_scrollleft = obj.scrollLeft;
	obj.scrollLeft = obj_scrollleft + 1;
	
	if(obj_scrollleft == obj.scrollLeft) {
		list.style.width = list.offsetWidth + max_width + 'px';
		list.innerHTML += tpl.innerHTML;
		scrolldiv(obj, tpl, list);
		return false;
	}
	
	scroll_obj = window.setTimeout(function(){scrolldiv(obj, tpl, list);}, 20);
}

function closeTips(){
	document.getElementById('msg-portal').style.display = 'none';
	return false;
}
function minTips() {
	document.getElementById('msg_min').style.display = 'none';
	document.getElementById('msg_max').style.display = 'block';
	document.getElementById('msg_close').style.background = 'url(./lib/view/default/images/close1.gif) center no-repeat';
	
	document.getElementById('msg_info').style.display = 'none';
	resize_div();
}
function maxTips() {
	document.getElementById('msg_min').style.display = '';
	document.getElementById('msg_max').style.display = 'none';
	document.getElementById('msg_close').style.background = 'url(./lib/view/default/images/close.gif) center no-repeat';
	
	document.getElementById('msg_info').style.display = '';
	resize_div();
}
function addLoadEvent(func) {
	var oldonload = window.onload;
	if(typeof(window.onload) != 'function'){
		window.onload = func;
	}else{
			window.onload = function () {
			oldonload();
			func();
		}
	}
}
function resize_div() {
	var tips = document.getElementById('msg-portal');
	if(tips) {
		tips.style.display = 'block';
		tips.style.top = document.documentElement.clientHeight + document.documentElement.scrollTop - tips.offsetHeight - 3 + 'px';
		tips.style.left = document.documentElement.clientWidth + document.documentElement.scrollLeft - tips.offsetWidth - 3 + 'px';
		
		window.onscroll = function () {
			resizeobj(tips);
		}
		
		window.onresize = function () {
			resizeobj(tips);
		}
	}
}
addLoadEvent(resize_div);

function resizeobj (obj) {
	if(obj.style.display != 'none') {
		var top  = document.documentElement.scrollTop + document.documentElement.clientHeight - obj.offsetHeight - 3;
		var left = document.documentElement.scrollLeft + document.documentElement.clientWidth - obj.offsetWidth - 3;
		obj.style.top = top + 'px';
		obj.style.left = left + 'px';
	}
}
function index_onload() {
	
	if(typeof(is_scroll) != 'undefined') {
		obj = document.getElementById('expert_info');
		tpl = document.getElementById('tmp_list');
		list = document.getElementById('expert_list');
		tpl.innerHTML = list.innerHTML;
	
		scrolldiv(obj, tpl, list);
	}
}

function clear_scroll() {
	if(scroll_obj) clearTimeout(scroll_obj);
}
function showFlash(width,height,src)
{
	document.write("<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0' width=" + width + " height=" + height + "><param name='movie' value='" + src + "'><param name='quality' value='high'><param name='wmode' value='transparent'><embed src='" + src +"' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width=" + width + " height='" + height + "'></embed></object>");
}
function get(pre)
{
	var get = window.location.search;

	if(get.indexOf('?') == 0) {
		get = get.replace('?', '');
	}

	get = get.split('&');
	
	var get_pre;
	for(var key in get) {
		if(key != 'index') {
			get_pre = get[key].split('=');
			if(get_pre[0] == pre) {
				return get_pre[1];
			}
		}
	}
	return '';
}

$ = function( id ){
	return (typeof id == 'string')?document.getElementById( id ):id;
};

var bEvent = {
	eventCache : [],
	addEvent : function(obj, eventType, func){
		if (obj.attachEvent){
			obj.attachEvent('on'+eventType, func);
		} else if (obj.addEventListener) {
			obj.addEventListener(eventType, func, false);
		}
		this.eventCache.push({'obj': obj, 'eventType': eventType, 'func': func});
	},
	removeEvent : function(obj, eventType, func) {
		if (obj.detachEvent) {
			obj[eventType+func] = null;
			obj['e'+eventType+func] = null;
			obj.detachEvent("on"+eventType, obj[eventType+func]);
		} else if (obj.removeEventListener) {
			obj.removeEventListener(eventType, func, false);
		}
	},
	preventDefault : function(e) {
		var e = window.event || e;
		if (e.preventDefault) {
			e.preventDefault();
		} else {
			e.returnValue = false;
		}
	},
	stopPropagation : function(e) {
		var e = window.event || e;
		if (e.stopPropagation) {
			e.stopPropagation();
		}
	},
	formatEvent : function(e) {
		e.charCode = (e.type == "keypress") ? e.keyCode : 0;
		e.stopPropagation = function() {
			this.cancelBubble();
		};
		e.preventDefault = function() {
			this.returnValue = false;
		};
		try {
			e.pageX = e.clientX + document.body.scrollLeft;
			e.pageY = e.clientY + document.body.scrollTop;
			e.target = e.srcElement;
		} catch (e) {}
		var relatedTarget = {
			"mouseout" : e.toElement,
			"e" : e.fromElement
		}[e.Type];
		if (relatedTarget) e.relatedTarget = relatedTarget;
		return e;
	},
	getEvent : function() {
		if (window.event && document.all) {
			return this.formatEvent(window.event);
		} else {
			return this.getEvent.caller.arguments[0];
		}
	}
};

bAjax = {
	xmlHttpRequestPool: [],
	queryUrl: '',
	callback: null,
	method: '',
	content: '',
	post: function(queryUrl, callbackFunc) {
		this.queryUrl = queryUrl;
    	this.callback = callbackFunc;
    	this.method   = arguments[2]?arguments[2].toUpperCase():"GET";
    	this.content = arguments[3]?arguments[3]:null;
    	var xhr = this.getInstance();
    	xhr.open(this.method, this.queryUrl, true);
    	if (this.method == "POST") xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    	var t = this;
    	xhr.onreadystatechange = function() {
    		if (xhr.readyState == 4) {
    			if (xhr.status == 200) {
    				t.callback(xhr.responseText);
    			}
    		}
    	}
    	xhr.send(this.content);
	},
	getInstance: function() {
		for (var i=0; i<this.xmlHttpRequestPool.length; i++) {
			if (this.xmlHttpRequestPool[i].readyState == 0 || this.xmlHttpRequestPool[i].readyState == 4) {
				return this.xmlHttpRequestPool[i];
			}
		}
		this.xmlHttpRequestPool[this.xmlHttpRequestPool.length] = this.createObject();
		return this.xmlHttpRequestPool[this.xmlHttpRequestPool.length-1];
	},
	createObject: function() {
		var XHR = null;
		try {
			XHR = new XMLHttpRequest();
		} catch(e) {
			var aXHRVersion = ["msxml2.xmlhttp.6.0","msxml2.xmlhttp.5.0","msxml2.xmlhttp.4.0","msxml2.xmlhttp.3.0","msxml2.xmlhttp", "Microsoft.XMLHTTP"];
			for (var i=0; i<aXHRVersion.length && !XHR; i++) {
				try {
					XHR = new ActiveXObject(aXHRVersion[i]);
				} catch(e) {}
			}
		}
		if (XHR) return XHR;
		else throw("not proper");
	}
}

Array.prototype.index = function(clue) {
	for (var j=this.length, i=0; i<j;) {
		if (this[i] == clue) return i;
		if (this[j] == clue) return j;
		i++; j--;
	}
}
