﻿
function siblingPrevious(ele) {
	if (ele == null || typeof ele.previousSibling == 'undefined') return null;
	while (ele.previousSibling != null && ele.previousSibling.nodeType != 1) ele = ele.previousSibling;
	return ele.previousSibling;
}
function siblingNext(ele) {
	if (ele == null || typeof ele.nextSibling == 'undefined') return null;
	while (ele.nextSibling != null && ele.nextSibling.nodeType != 1) ele = ele.nextSibling;
	return ele.nextSibling;
}

//字符串重写。
String.prototype.trim = function() {
	return this.replace(/(^\s*)|(\s*$)/g, '');
}
String.prototype.leftb = function(n) {
	var r = /[^\x00-\xff]/g;
	if (this.replace(r, '  ').length <= n) return this;
	n = n - 3;
	var m = Math.floor(n / 2);
	for (var i = m; i < this.length; i++) if (this.substr(0, i).replace(r, '  ').length >= n) return this.substr(0, i) + '..';
	return this;
}

//
function searchMode(e, delay) {
	if (!delay) { var thisdelay = window.setTimeout(function() { searchMode(e, thisdelay); }, 400); e.onmouseout = function(e) { window.clearTimeout(thisdelay); }; return; }
	if (e.onmouseout != null) e.onmouseout = null;

	var t;
	if (typeof e != 'string') {
		t = e.getAttribute('mode'); if (t == null) return;
		var cs = e.parentNode.childNodes;
		for (var i = 0; i < cs.length; i++) if (cs[i].tagName && cs[i].getAttribute('mode') != null) cs[i].className = 'btnchannel';
		e.className = 'btnchannel_hover';
	} else t = e;
	var f = document.getElementById('fsearch'); if (!f) return;
	switch (t) {
		case '1': f.tag.disabled = true; f.onsubmit = null; f.action = 'http://op.68design.net/news/search.aspx'; break;
		case '2': f.tag.disabled = false; f.onsubmit = function(e) { try { switch (f.tag.value) { case 'wd': f.action = 'http://my.68design.net/search/personal'; break; case 'od': f.action = 'http://my.68design.net/search/personal'; var iptt = document.createElement('INPUT'); iptt.type = 'hidden'; iptt.name = 't'; iptt.value = 'od'; f.appendChild(iptt); break; case 'c': f.action = 'http://my.68design.net/search/company'; break; case 'o': f.action = 'http://my.68design.net/search/outsource'; break; case 'cp': f.action = 'http://my.68design.net/search/position'; break; case 'aq': f.action = 'http://my.68design.net/search/ask'; break; case 'w': f.action = 'http://my.68design.net/search/works'; break; case 't': f.action = 'http://my.68design.net/search/template'; break; } f.tag.disabled = true; } catch (e) { return false; } }; break;
	}
}

