var ie = (navigator.appName=="Microsoft Internet Explorer");
var ie8 = (ie && (navigator.appVersion.indexOf('MSIE 8.0') != -1));
var ie7 = (ie && (navigator.appVersion.indexOf('MSIE 7.0') != -1));
var ie6 = (ie && (navigator.appVersion.indexOf('MSIE 6.0') != -1));

String.prototype.trim = function () {
	return this.replace(/(^\s*)|(\s*$)/g, "");
}

function $(id) {
	return document.getElementById(id);
}

function addfav() {
	if (document.all) window.external.AddFavorite(location.href, document.title);
	else if (window.sidebar) window.sidebar.addPanel(document.title, location.href, '');
	else alert('请使用Ctrl+D添加收藏。');
}

function ohref(o) {
	var href = o.options[o.selectedIndex].value;
	if (!href) return;
	try {
		window.open(href);
	} catch (e) {
		location.href = href;
	}
}
function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function'){
		window.onload = func;
	} else {
		window.onload = function() {
			func();
			oldonload();
		}
	}
}

function wheel() {
	setTimeout('wheela()', 3000);
}
function wheela() {
	wheeln();
	wheel();
}
function wheeln() {
	if (!wheels) return;
	var n = wheelc + 1;
	if (!$('p' + n)) n = 1;
	wheel2(n);
}
var wheelc = 1;
var wheels = true;
function wheel2(n) {
	if (wheelc == n) return;
	var cp = $('p' + n);
	var cn = $('n' + n);
	var op = $('p' + wheelc);
	var on = $('n' + wheelc);
	op.className = 'hidden';
	cp.className = 'pic';
	on.className = '';
	cn.className = 'curr';
	wheelc = n;
}
function wheelon() {
	wheels = false;
}
function wheelout() {
	wheels = true;
}

function checksearch() {
	var k = $('key');
	if (k.value.trim() == '') {
		alert('请输入搜索关键字');
		k.focus();
		return false;
	}
	return true;
}

var currtab = 1;
function ctab(n) {
	if (currtab == n) return;
	$('t' + n).className = 'title curr';
	$('c' + n).className = 'cont';
	$('t' + currtab).className = 'title';
	$('c' + currtab).className = 'hidden';
	currtab = n;
}


function floatg() {
	var o = $('float');
	if (!o) return;
	var ow = 49;
	var oh = 310;
	var height = (document.documentElement.clientHeight - oh);
	var top = (height / 2);
	if (ie6) top += document.documentElement.scrollTop;
	o.style.top = top + 'px';
	var width = document.documentElement.clientWidth;
	var right = (width - 980) / 2 - ow - 10;
	if (right < 5) right = 5;
	o.style.right = right + 'px';
	o.className = '';
}
function floatf() {
	var o = $('float');
	if (!o) return;
	if (ie6) window.onscroll = floatg;
	window.onresize = floatg;
	floatg();
}

addLoadEvent(floatf);

