String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g, '');
};
var imagePath = '/admin/';
var AreaSpots = new Array();
function $(id) {
	if (typeof id == 'object') return id;
	return document.getElementById(id);
}
function addHandle(name, func, obj) {
	if (!obj) obj = document;
	if (obj.attachEvent)
		obj.attachEvent('on'+name, func);
	else if (obj.addEventListener)
		obj.addEventListener(name, func, true);
}
function removeHandle(name, func, obj) {
	if (!obj) obj = document;
	if (obj.detachEvent)
		obj.detachEvent('on'+name, func);
	else if (obj.removeEventListener)
		obj.removeEventListener(name, func, true);
}
function dateChanged(begins) {
	if (begins.name != 'begins') return;
	var ends = begins.form.ends;
	if (!ends) return;
	var b = begins.value.split(/[-\.\/]/);
	var bd = new Date(b[0], b[1]-1, b[2]);
	if (ends.value) {
		var e = ends.value.split(/[-\.\/]/);
		var ed = new Date(e[0], e[1]-1, e[2]);
		if (ed > bd) return;
	}
	bd.setTime(bd.getTime()+86400000);
	var day = bd.getDate();
	if (day < 10) day = '0' + day;
	var month = bd.getMonth() + 1
	if (month < 10) month = '0' + month;
	ends.value = ''+bd.getFullYear()+'-'+month+'-'+day;
}
function elementValue(obj) {
	var i=0, result;
	switch (obj.type) {
	case "text":
	case "hidden":
	case "textarea":
	case "password":
		return obj.value;
	case "select-one":
	case "select":
		if (obj.selectedIndex >= 0)
		return obj.options[obj.selectedIndex].value;
	case "radio":
		for (i=0; i<obj.form.elements.length; i++) {
			var e = obj.form.elements[i];
			if (e.type != 'radio') continue;
			if (e.name == obj.name && e.checked) return e.value;
		}break;
	case "checkbox":
		for (i=0; i<obj.form.elements.length; i++) {
			var e = obj.form.elements[i];
			if (e.type != 'checkbox') continue;
			if (e.name == obj.name && e.checked) {
				if (result) result +=',';
				result += e.value;
			}
		}
	}return result;
}
function windowSize() {
	if (typeof(window.innerWidth) == 'number')
		return {'width':window.innerWidth, 'height':window.innerHeight};
	var base = null;
	if (!document.compatMode || document.compatMode == 'BackCompat')
		base = document.body;
	else
		base = document.documentElement;
	return {'width':base.clientWidth, 'height':base.clientHeight};
}
function windowScroll() {
	if (typeof(window.pageYOffset) == 'number')
		return {'x':window.pageXOffset, 'y':window.pageYOffset};
	var base = null;
	if (!document.compatMode || document.compatMode == 'BackCompat')
		base = document.body;
	else
		base = document.documentElement;
	return {'x':base.scrollLeft, 'y':base.scrollTop};
}
function UrlBuilder(url) {
	this.href = null;
	this.host = null;
	this.protocol = null;
	this.path = null;
	this.search = null;
	this.hash = null;
	this.params = null;
	this.dirty = false;
	if (url) this.parseUrl(url);
}

UrlBuilder.prototype.parseUrl = function(url)
{
	var pos = url.indexOf("//");
	this.protocol = "";
	this.host = "";
	if (pos > 0) {
		this.protocol = url.substring(0, pos);
		var pos2 = url.indexOf("/", pos+2);
		if (pos2 > 0) {
			this.host = url.substring(pos+2, pos2);
			this.path = url.substr(pos2);
		}else
			this.path = "/";
	}else
		this.path = url;
	pos = this.path.indexOf('#');
	if (pos > 0) {
		this.hash = this.path.substr(pos+1);
		this.path = this.path.substring(0, pos);
	}else
		this.hash = "";
	pos = this.path.indexOf('?');
	this.params = {};
	if (pos > 0) {
		this.search = this.path.substr(pos+1);
		this.path = this.path.substring(0, pos);
		var parts = this.search.split('&');
		for (var i=0; i<parts.length; ++i) {
			var part = parts[i];
			var index = part.indexOf('=');
			if (index != -1)
				this.params[part.substring(0, index)] = part.substr(index+1);
			else
				this.params[part] = '';
		}
	}else
		this.search = '';
	this.dirty = false;
	this.href = url;
};
UrlBuilder.prototype.getVal = function(key)
{
	return this.params[key];
}
UrlBuilder.prototype.serVal = function(key, value)
{
	this.dirty = true;
	this.params[key] = value;
}
UrlBuilder.prototype.getUrl = function()
{
	if (this.dirty) {
		if (this.protocol && this.host)
			this.href = this.protocol + "//" + this.host + this.path;
		else
			this.href = this.path;
		if (this.params) {
			this.href += '?';
			var first = true;
			for (key in this.params) {
				if (key == 'page') continue;
				if (!first) this.href += '&';
				first = false;
				this.href += key + '=' + this.params[key];
			}
		}
		this.dirty = false;
	}
	return this.href;
}
function doSearch(form) {
	var builder = new UrlBuilder(location.href);
	for (var i=0; i<form.elements.length; i++) {
		var e = form[i];
		if (e.type=='button' || !e.name) continue;
		if ((e.type=="radio"||e.type=="checkbox")
			&& !e.checked) continue;
		builder.serVal(e.name, e.value);
	}
	location = builder.getUrl();
	return false;
}
function checkAll(obj) {
	var form = obj.form;
	var pre = (arguments.length>1)?arguments[1]:'';
	for (var i=1; i<form.elements.length; i++) {
		var e = form.elements[i];
		if (pre && e.name.indexOf(pre)!=0)
			continue;
		if (e.type == 'checkbox')
			e.checked = obj.checked;
	}
}
function getSelected(form) {
	var ids = new Array();
	if (!form) form = document.forms[0];
	var items = 0, index = 0;
	for (var i=0; i<form.elements.length; i++) {
		var e = form.elements[i];
		if (e.type!='checkbox') continue;
		if (++items == 1) continue;
		if (!e.checked||!e.value) continue;
		ids[index++] = e.value;
	}return ids;
}
function isSelected(form) {
	if (!form) form = document.forms[0];
	var items = 0, name='';
	if (arguments.length > 1)
		name = arguments[1];
	for (var i=0; i<form.elements.length; i++) {
		var e = form.elements[i];
		if (e.type!='checkbox') continue;
		if (++items == 1) continue;
		if (name&&e.name!=name) continue;
		if (e.checked) return true;
	}return false;
}
function strSelected(form) {
	var items=0, name='', ids='';
	if (arguments.length > 1)
		name = arguments[1];
	if (!form) form = document.forms[0];
	for (var i=0; i<form.elements.length; i++) {
		var e = form.elements[i];
		if (e.type!='checkbox') continue;
		if (++items == 1) continue;
		if (!e.checked||!e.value) continue;
		if (name&&e.name!=name) continue;
		if (ids) ids += ',';
		ids += e.value;
	}return ids;
}
function selectValue(id, value, defindex) {
	var obj = $(id);
	if (!obj) return;
	if (value == '' && defindex) {
		obj.options[defindex].selected = true;
		return;
	}
	for (var i=0; i<obj.options.length; i++) {
		if (obj.options[i].value == value) {
			obj.options[i].selected = true;
			return;
		}
	}
}
function autoWidget() {
	var re = new RegExp("\\bmarquee\\b");
	var all = document.getElementsByTagName('div');
	for (var i=0; i<all.length; i++)
		if (re.test(all[i].className)) Marquee(all[i], true);
}
function addClass(e, cls) {
	var re = new RegExp("\\b"+cls+"\\b");
	if (!re.test(e.className))
		e.className += " "+cls;
}
function removeClass(e, cls) {
	var re = new RegExp("\\b"+cls+"\\b");
	e.className = e.className.replace(re, ' ');
}
function getPosition(el) {
	if (el.getBoundingClientRect) {
		var box = el.getBoundingClientRect();
		var scrollTop = Math.max(document.documentElement.scrollTop, document.body.scrollTop);
		var scrollLeft = Math.max(document.documentElement.scrollLeft, document.body.scrollLeft);
		return {x:box.left + scrollLeft, y:box.top + scrollTop};
	}
	var r = {'x': el.offsetLeft, 'y': el.offsetTop};
	if (el.scrollLeft)
		r.x -= el.scrollLeft;
	if (el.scrollTop)
		r.y -= el.scrollTop;
	var par = el.offsetParent;
	while (par) {
		r.x += par.offsetLeft;
		r.y += par.offsetTop;
		par = par.offsetParent;
	}
	r.x -= document.body.scrollLeft;
	r.y -= document.body.scrollTop;
	return r;
}
function createModal() {
	var modal = $('modal');
	if (modal) return;
	modal = document.createElement("div");
	modal.id = "modal";
	with (modal.style) {
		position = 'absolute';
		backgroundColor = '#333';
		backgroundImage = 'url(.png)';
		left = '0px';
		top = '0px';
		width = '100%';
		opacity = 0.1;
		MozOpacity = 0.1;
		filter = "alpha(opacity=10)";
		height = document.body.scrollHeight + 'px';
		zIndex = 9999;
	}
	document.body.appendChild(modal);
}
function destroyModal() {
	var modal = $('modal');
	if (!modal) return;
	document.body.removeChild(modal);
}
function titleDialog(title) {
	$('dlg_title').innerHTML = title;
}
function showDialog(text) {
	$('dlg_info').innerHTML = text;
	var btnOk = $('dlg_ok');
	var btnClose = $('dlg_close');
	var img = $('dlg_icon');
	if (arguments.length < 2 ||
		typeof arguments[1] == 'number') {
		img.src = imagePath + "info.gif";
		btnOk.style.display = '';
		btnClose.style.display = 'none';
		btnOk.onclick = closeDialog;
		if (arguments.length > 1)
			setTimeout('closeDialog()', arguments[1]);
	}else if (typeof arguments[1] == 'string') {
		if (arguments[1] == 'warn')
			img.src = imagePath + "warning.gif";
		else if (arguments[1] == 'error')
			img.src = imagePath + "error.gif";
		else
			img.src = imagePath + "info.gif";
		btnOk.style.display = '';
		window.reload = false;
		btnClose.style.display = 'none';
		btnOk.onclick = closeDialog;
	}else {
		img.src = imagePath + "question.gif";
		btnOk.style.display = '';
		var callback = arguments[1];
		btnOk.onclick = function() {
			callback();
			$('dialog').style.display = 'none';
			document.body.removeChild($('modal'));
		}
		btnClose.style.display = '';
		window.reload = false;
		btnClose.innerHTML = '取消(<u>C</u>)';
		btnClose.onclick = closeDialog;
	}
	if (!document.all) createModal();
	var dlg = $('dialog');
	var size = windowSize();
	dlg.style.left = (size.width-400)/2+"px";
	var value = size.height - 160;
	value = value*0.4 + windowScroll().y;
	dlg.style.top = parseInt(value) + "px";
	dlg.style.zIndex = 10001;
	dlg.style.opacity = 1;
	dlg.style.MozOpacity = 1;
	dlg.style.filter = "alpha(opacity=100)";
	dlg.style.display = 'block';
	dlg.focus();
}
function closeDialog() {
	var popup = $('dialog');
	var opacity = parseFloat(popup.style.opacity) - 0.2;
	if (opacity > 0.1) {
		popup.style.opacity = opacity;
		popup.style.MozOpacity = opacity;
		opacity = opacity * 100;
		popup.style.filter = "alpha(opacity="+opacity+")";
		setTimeout('closeDialog()', 50);
	}else if (typeof window.reload == 'function') {
		window.reload();
		window.reload = null;
	}else if (window.reload) {
		window.location = location.href;
		window.reload = false;
	}else {
		destroyModal();
		popup.style.display = 'none';
	}
}
function commentSubmit(form) {
	titleDialog("发表评论...");
	if (!form.author.value)
		showDialog("请输入[您的用户名]", 'warn');
	else if (!form.content.value)
		showDialog("请输入[您的评论内容]", 'warn');
	else if (form.content.value.length > 1000)
		showDialog("您的评论内容最多为<b class='error'>1000字</b>", 'warn');
	else if(!form.verify.value)
		showDialog("请输入[验证码]");
	else {
		var ajax = new XmlHttp;
		if (form.flags && form.flags.value == 1) {			
			ajax.doPost(function(succ, info) {
				if (succ) {
					window.reload = true;
					showDialog("发表评论成功！谢谢您的参与！");
				}
				else if(info == 2)
					showDialog("验证码错误",'error');
				else
					showDialog("很抱歉，发表评论失败！请稍后再试，谢谢您的参与！", 'error');
			}, form.action, form);
		}else{
			ajax.doPost(function(succ, info) {
				if (succ)
					showDialog("谢谢您发表评论！您发表的评论将在<ins><b>审核之后</b></ins>显示。");
				else if(info == 2)
					showDialog("验证码错误",'error');
				else
					showDialog("很抱歉，发表评论失败！请稍后再试，谢谢您的参与！", 'error');
			}, form.action, form);
		}
	}
	return false;
}
function askingSubmit(form) {
	titleDialog("发表问题...");
	if (!form.areaid.selectedIndex)
		showDialog("请输入[问题分类] 的区域", 'error');
	else if (!form.spotid.selectedIndex)
		showDialog("请输入[问题分类] 的景区", 'error');
	else if (!form.catalog.selectedIndex)
		showDialog("请输入[问题分类] 的分类", 'error');
	else if (!form.title.value)
		showDialog("请输入[问题标题]", 'warn');
	else if (!form.content.value)
		showDialog("请输入[详细内容]", 'warn');
	else if (form.content.value.length > 1000)
		showDialog("[详细内容]最多为<b class='error'>1000字</b>", 'warn');
	else if (!form.verify.value)
		showDialog("验证码 不能为空！",'warn');
	else {
		var ajax = new XmlHttp;
		ajax.doPost(function(succ, info) {//alert(succ+'---'+info);
			window.reload = function() {location = location.href.replace("qaquery", "qalist");}
			on_result(succ, info);
		}, form.action, form);
	}
	return false;
}
function askingFinish(q, a) {
	titleDialog("结束问题...");
	var ajax = new XmlHttp;
	var str = "cmd=finishQuestion";
	str += "&question="+q+"&answer="+a;
	ajax.doPost(function(succ, info) {
		window.reload = true;
		on_result(succ, info);
	}, location.href, str);
}
function answerSubmit(form) {
	titleDialog("回答问题...");
	if (!form.content.value)
		showDialog("请输入[我的回答]", 'warn');
	else if (form.content.value.length > 1000)
		showDialog("[我的回答]最多为<b class='error'>1000字</b>", 'warn');
	else if (!form.verify.value)
		showDialog("验证码 不能为空！",'warn');
	else {
		var ajax = new XmlHttp;
		ajax.doPost(function(succ, info) {
			window.reload = function() {location = location.href.replace("qareply", "qaitem");}
			on_result(succ, info);
		}, form.action, form);
	}
	return false;
}
function areaChanged(area) {
	var id = 'AREA' + area.value;
	if (!AreaSpots[id]) {
		var ajax = new XmlHttp;
		var text = ajax.doGet("/info.php?id=spots&areaid="+area.value);
		if (text.substr(0,3)=='ok:' && text.length > 3)
			AreaSpots[id] = eval(text.substr(3));
		else
			AreaSpots[id] = new Array();
	}
	var spotid = area.nextSibling;
	spotid.options.length = 0;
	spotid.options[0] = new Option('请选择景区', "0");
	for (var i=0; i<AreaSpots[id].length; i++) {
		var item = AreaSpots[id][i];
		spotid.options[i+1] = new Option(item.title, item.id);
	}
}

function on_result(succ, info) {
	if (succ)
		showDialog('<b>恭喜您，本次操作执行成功！</b>', 1000);
	else
		showDialog(info, 'error');
}
function XmlHttp() {
	if(window.XMLHttpRequest)
		this.objXmlHttp = new XMLHttpRequest();
	else if(window.ActiveXObject) {
		var success = false;
		try {
			this.objXmlHttp = new ActiveXObject('MSXML2.XMLHTTP');
			success = true;
		}catch(e) {}
		if (!success)
			this.objXmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
	}else {
		this.objXmlHttp = null;
		throw "XmlHttp Error!";
	}
	this.async = true;
	this.typeXml = false;
	this.onsuccess = null;
	this.doGet = function(url, callback) {
		var self = this.objXmlHttp;
		this.objXmlHttp.onreadystatechange = function() {
			if (self.readyState != 4 || !callback) return;
			var text = self.responseText;
			if (self.status != 200)
				callback(false, text);
			else if (text=='' || text.substr(0,3)=='ok:')
				callback(true, text.substr(3));
			else {
				if (text.substr(0,9) == "<!DOCTYPE")
					text = '';
				callback(false, text);
			}
		}
		this.objXmlHttp.open("GET", url, callback?true:false);
		this.objXmlHttp.setRequestHeader("If-Modified-Since","0");
		this.objXmlHttp.send("");
		return callback?"":self.responseText;
	}
	this.doPost = function(callback, url, form) {
		var self = this.objXmlHttp;
		var ajax = this;
		this.objXmlHttp.onreadystatechange = function() {
			if (self.readyState != 4) return;
			var text = self.responseText;
			if (text.indexOf('<!DOCTYPE') == 0)
				text = 'failed';
			if (self.status != 200)
				callback(false, text);
			else if (text=='') {
				callback(true, '');
				if (ajax.onsuccess)
					ajax.onsuccess('');
			}else if (text.substr(0,3)=='ok:') {
				var str = text.substr(3);
				callback(true, str);
				if (ajax.onsuccess)
					ajax.onsuccess(str);
			}else
				callback(false, text);
		}
		this.objXmlHttp.open("POST", url, this.async);
		if (this.typeXml)
			this.objXmlHttp.setRequestHeader("Content-Type", "text/xml");
		else
			this.objXmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		this.objXmlHttp.setRequestHeader("If-Modified-Since","0");
		if (typeof form != 'string')
			this.objXmlHttp.send(this.strForm(form));
		else if (this.typeXml)
			this.objXmlHttp.send("<?xml version='1.0' encoding='UTF-8'?>" + form);
		else
			this.objXmlHttp.send(form);
	}
	this.postForm = function(url, str) {
		var form = document.createElement("FORM");
		form.method = "post";
		form.action = url;
		str = str.replace(/\+/g, ' ');
		var args = str.split('&');
		for (var i=0; i<args.length; i++) {
			var pair = args[i].split('=');
			if (pair.length < 2) pair[1] = '';
			var input = document.createElement("INPUT");
			input.type = 'hidden';
			input.name = pair[0];
			input.value = pair[1];
			form.appendChild(input);
		}
		document.body.appendChild(form);
		form.submit();
	}
	this.strForm = function(form) {
		var params = '';
		for (var i=0; i<form.length; i++) {
			var type = form[i].type.toLowerCase();
			if ((type=="radio"||type=="checkbox")
				&& !form[i].checked) continue;
			if (params != '') params += "&";
			params += form[i].name + "=" + encodeURIComponent(form[i].value);
		}
		return params;
	}
}
function TabCtrl(id) {
	var tab = $(id);
	if (!tab || typeof tab.activeTab == 'object')
		return tab;
	tab.activeTab = null;
	tab.items = new Array();
	var all = tab.getElementsByTagName('a');
	if (all.length < 1) return;
	tab.selectTab = function(index) {
		if (index < 0 || index >= this.items.length) return;
		this.items[index].clicked();
	}
	var i, index = 0;
	for (i=0; i<all.length; i++) {
		var tabid = all[i].getAttribute('tabid');
		if (!tabid) continue;
		all[i].related = $(tabid);
		all[i].owner = tab;
		all[i].clicked = function() {
			if (this.owner.activeTab) {
				var active = this.owner.activeTab;
				if (active == this) return;
				if (active.parentNode != this.owner)
					active.parentNode.className = '';
				active.related.style.display = 'none';
			}
			this.owner.activeTab = this;
			if (this.parentNode != this.owner)
				this.parentNode.className = 'active';
			this.related.style.display = 'block';
		}
		all[i].onclick = function() {
			this.clicked();
			return false;
		}
		tab.items[index++] = all[i];
	}tab.selectTab(0);
	for (i=1; i<index; i++) {
		tab.items[i].related.style.display = 'none';
	}return tab;
}
// Calendar
var daysInMonth = new Array(31,28,31,30,31,30,31,31,30,31,30,31);
var daynames = new Array("日","一", "二", "三","四", "五", "六");
function getTitle(year, month) {
	month++;
	return year + "年" + month + "月";
}
function Calendar(id) {
	var table = $(id);
	if (!table) {
		table = document.createElement("TABLE");
		table.id = id;
		table.setAttribute("cellpadding", "0");
		table.className = 'calendar';
		var row = table.insertRow(-1);
		row.insertCell(-1).innerHTML = '&#171;';
		row.insertCell(-1).innerHTML = '&#8249;';
		row.insertCell(-1).colSpan = 3;
		row.insertCell(-1).innerHTML = '&#8250;';
		row.insertCell(-1).innerHTML = '&#187;';
		for (var i=0; i<7; i++) {
			var row = table.insertRow(-1);
			for (var j=0; j<7; j++)
				row.insertCell(-1);
		}
		/*@cc_on
		this.iframe = document.createElement("IFRAME");
		this.iframe.style.position = "absolute";
		this.iframe.style.left = "-2px";
		this.iframe.style.top = "-2px";
		this.iframe.style.zIndex = -1;
		this.iframe.style.filter = "mask()";
		table.appendChild(iframe);@*/
		table.style.display = "none";
		document.body.appendChild(table);
	}
	if (table.makeButton) return table;
	table.input = null;
	table.forwardDays = null;
	table.cellPadding = 0;
	table.cellSpacing = 0;
	table.style.position = "absolute";
	table.makeButton = function(el, step) {
		el.table = table;
		el.className = "btnUp";
		el.setAttribute('UNSELECTABLE', 'on');
		el.style.cursor = 'pointer';
		el.onclick = function() {
			this.table.nextMonth(step);
		}
		el.onmouseup = function() {
			this.className = "btnUp";
		}
		el.onmousedown = function() {
			this.className = "btnDown";
		}
	}
	addHandle('mousedown', function(e) {
		var obj = e.target?e.target:event.srcElement;
		if (obj!=table.input && !table.contains(obj))
			table.style.display = 'none';
	});
	table.getDays = function(year, month) {
		if (month != 1) return ((month%7)&1)?30:31;
		return ((0==year%4)&&(year%100))||(0==year%400)?29:28;
	}
	with (table.rows[0]) {
		table.makeButton(cells[0], -12);
		table.makeButton(cells[1], -1);
		cells[2].className = "month btnUp";
		table.makeButton(cells[3], 1);
		table.makeButton(cells[4], 12);
	}
	with (table.rows[1]) {
		firstChild.className = "sunday";
		lastChild.className = "satday";
		for (var i=0; i<cells.length; i++) {
			cells[i].setAttribute('UNSELECTABLE','on');
			cells[i].innerHTML = daynames[i];
		}
	}
	for (i=2; i<table.rows.length; i++) {
		var cell = table.rows[i].firstChild;
		while (cell) {
			cell.table = table;
			cell.onmousedown = function() {
				this.table.dateClicked(this);
			}
			cell.onmouseover = function(e) {
				addClass(this, 'hover');
			}
			cell.onmouseout = function(e) {
				removeClass(this, 'hover');
			}
			cell = cell.nextSibling;
		}
	}
	table.nextMonth = function(delta) {
		var year, month = this.month + delta;
		if (month > 11) {
			month -= 12;
			year = this.year + 1;
		}
		else if (month < 0) {
			month += 12;
			year = this.year - 1;
		}
		else year = this.year;
		var day = this.getDays(year, month);
		if (this.day < day) day = this.day;
		this.populate(year, month, day);
	}
	table.populate = function(year, month, day) {
		this.year = year = parseInt(year);
		this.month = month = parseInt(month);
		this.day = day = parseInt(day);
		this.rows[0].cells[2].innerHTML = getTitle(year, month);
		var first = new Date(year, month, 1);
		var count = this.getDays(year, month);
		if (i = week = first.getDay()) {
			if (month == 0)
				last = 31;
			else
				last = this.getDays(year, month - 1);
			while (i--) {
				this.rows[2].cells[i].className = "notday";
				this.rows[2].cells[i].innerHTML = last--;
			}
		}
		last = 1; i = 2;
		cell = this.rows[2].cells[week];
		while (cell) {
			if (day == last) {
				day = 0;
				cell.className = "today";
			}else if (i>5&&last<21)
				cell.className = "notday";
			else if (week == 0)
				cell.className = "sunday";
			else if (week == 6)
				cell.className = "satday";
			else
				cell.className = "theday";
			cell.innerHTML = last++;
			week = (week + 1) % 7;
			if (last > count) last = 1;
			cell = cell.nextSibling;
			if (!cell && ++i < this.rows.length)
				cell = this.rows[i].firstChild;
		}
		this.style.display = "block";
		if (this.iframe) {
			this.iframe.style.width = this.offsetWidth + 'px';
			this.iframe.style.height = this.offsetHeight + 'px';
		}
		this.style.zIndex = 1000;
	}
	table.dropdown = function(input, forwards) {
		var pt = getPosition(input);
		pt.y += input.offsetHeight;
		this.forwardDays = forwards;
		this.style.left = pt.x + 'px';
		this.style.top = pt.y + 'px';
		this.input = input;
		var theday;
		if (input.tagName == 'INPUT') {
			if (!input.setValue) {
				input.setValue = function(value) {
					if (value == this.value) return;
					this.value = value;
					if (input.form)
						input.form.dirty = true;
					try{this.onchange();}catch(e){}
				}
				input.autocomplete = "off";
			}
			theday = input.value.split(/[-\.\/]/);
		}else
			theday = input.innerText.split(/[-\.\/]/);
		if (theday.length == 3)
			this.populate(theday[0], theday[1]-1, theday[2])
		else {
			var day = new Date();
			this.populate(day.getFullYear(), day.getMonth(), day.getDate());
		}
		if (pt.y + this.offsetHeight > document.body.offsetHeight) {
			pt.y -= this.offsetHeight;
			pt.y -= input.offsetHeight;
			this.style.top = pt.y + 'px';
		}
		setTimeout(function(){input.focus();},0);
	}
	table.dateClicked = function(cell) {
		if (!this.input) return;
		var month, day = cell.innerText;
		var year = this.year;
		if (cell.className.indexOf('notday') < 0)
			month = this.month;
		else if (day > 15) {
			month = this.month - 1;
			if (month < 0) {
				month = 11;
				year--;
			}
		}else {
			month = this.month + 1;
			if (this.month > 11) {
				month = 0;
				year++;
			}
		}
		if (typeof this.forwardDays == 'number') {
			var now = new Date();
			now.setHours(0, 0, 0, 0);
			var msec = now.getTime();
			msec += this.forwardDays * 86400000;
			var current = new Date(year, month, day);
			if (current.getTime() < msec) return;
		}
		if (++month < 10) month = '0'+month;
		if (day < 10) day = '0' + day;
		var date = year+"-"+month+"-"+day;
		this.input.setValue(date);
		this.style.display = "none";
	}
	return table;
}
function Marquee(id, autostop) {
	var marquee = $(id);
	if (!marquee || typeof marquee.timer == 'object')
		return marquee;
	marquee.timer = null;
	marquee.autostop = autostop?true:false;
	marquee.style.position = 'relative';
	marquee.style.overflow = 'hidden';
	var attr = marquee.getAttribute('height');
	if (attr) marquee.style.height = height + 'px';
	attr = marquee.getAttribute('width');
	if (attr) marquee.style.width = width + 'px';
	marquee.direction = marquee.getAttribute('direction');
	if (!marquee.direction)
		marquee.direction = 'left';
	if (marquee.direction == 'left' || marquee.direction == 'right') {
		marquee.style.whiteSpace = 'nowrap';
		if (marquee.offsetWidth >= marquee.scrollWidth) return;
		if (marquee.direction == 'right')
			marquee.scrollLeft = marquee.scrollWidth;
		marquee.size = marquee.scrollWidth;
	}else {
		if (marquee.offsetHeight >= marquee.scrollHeight) return;
		if (marquee.direction == 'bottom')
			marquee.scrollTop = marquee.scrollHeight;
		marquee.size = marquee.scrollHeight;
	}
	attr = marquee.getAttribute('scrollamount');
	if (!attr)
		marquee.scrollamount = 1;
	else
		marquee.scrollamount = parseInt(attr);
	attr = marquee.getAttribute('scrolldelay');
	if (!attr)
		marquee.scrolldelay = 50;
	else
		marquee.scrolldelay = parseInt(attr);
	attr = marquee.getAttribute('bgcolor');
	if (attr) marquee.style.backgroundColor = attr;
	attr = marquee.getAttribute('hspace');
	if (attr != null) {
		marquee.style.marginLeft = attr + 'px';
		marquee.style.marginRight = attr + 'px';
	}
	attr = marquee.getAttribute('vspace');
	if (attr != null) {
		marquee.style.marginTop = attr + 'px';
		marquee.style.marginBottom = attr + 'px';
	}
	marquee.innerHTML += marquee.innerHTML;
	marquee.onmouseout = function(e) {
		if (!this.autostop) return;
		if (!e) e = window.event;
		var obj = e.toElement||e.relatedTarget;
		if (obj && !this.contains(obj)) this.start();
	}
	marquee.onmouseover = function(e) {
		if (!this.autostop) return;
		if (!e) e = window.event;
		var obj = e.fromElement||e.relatedTarget;
		if (obj && !this.contains(obj)) this.stop();
	}
	marquee.doscroll = function() {
		if (this.direction == 'left') {
			if (this.size <= this.scrollLeft)
				this.scrollLeft -= this.size;
			else this.scrollLeft ++;
		}else if (this.direction == 'right') {
			if (this.scrollLeft <= 0)
				this.scrollLeft += this.size;
			else this.scrollLeft --;
		}else if (this.direction == 'top') {
			if (this.size <= this.scrollTop)
				this.scrollTop -= this.size;
			else this.scrollTop ++;
		}else if (this.direction == 'bottom') {
			if (this.scrollTop <= 0)
				this.scrollTop += this.size;
			else this.scrollTop --;
		}
	}
	marquee.start = function() {
		if (this.timer) clearInterval(this.timer);
		this.timer = setInterval(function() {
			marquee.doscroll();
		}, this.scrolldelay);
	}
	marquee.stop = function() {
		if (!this.timer) return;
		clearInterval(this.timer);
		this.timer = null;
	}
	marquee.start();
	return marquee;
}
function Switcher(id, times) {
	var switcher = $(id);
	if (!switcher) return switcher;
	if (!times) times = 3000;
	switcher.current = null;
	switcher.active = null;
	switcher.timer = null;
	if (switcher.style.position != 'absolute')
		switcher.style.position = 'relative';
	switcher.control = document.createElement('DIV');
	var height = parseInt(switcher.style.height);
	with (switcher.control) {
		className = "control";
		style.zIndex = 9999;
		style.top = (height - 24) + "px";
	}
	switcher.addImage = function(image) {
		if (!this.current)
			this.current = image;
		else
			image.style.zIndex = -1;
		with (image.style) {
			position = "absolute";
			width = "100%";
			height = "100%";
			overflow = "hidden";
		}
		image.random = -1;
		var span = document.createElement('SPAN');
		var href = image.getAttribute('href');
		if (href) {
			image.style.cursor = 'pointer';
			image.onclick = function() {location=this.getAttribute('href');}
			span.onclick = function() {location=image.getAttribute('href');}
		}
		span.innerHTML = image.title;
		span.style.cursor = 'pointer';
		image.span = span;
		span.onmouseover = function(e) {switcher.switchTo(image);}
		this.control.appendChild(span);
	}
	switcher.addItem = function(photo, link, title) {
		var image = document.createElement('IMG');
		image.title = title;
		image.setAttribute('href', link);
		this.appendChild(image);
		this.addImage(image);
	}
	switcher._reset = function(image) {
		var random = image.random;
		if (random < 0) return;
		var style = image.style;
		if (random == 0) {
			style.opacity = 1;
			style.filter = "";
		}else if (random < 3) {
			style.left = "0px";
		}else if (random < 5) {
			style.top = "0px";
		}else {
			style.left = "0px";
			style.top = "0px";
			style.width = "100%";
			style.height = "100%";
			var img = image.firstChild;
			img.style.left = "0px";
			img.style.top = "0px";
		}
		image.random = -1;
	}
	switcher.switchTo = function(image) {
		if (image == this.current) return;
		if (!image) image = this.active;
		if (image) {
			this.current.style.zIndex = -1;
			this.current.span.className = '';
			if (this.active)
				this.active.style.zIndex = -1;
			this.current = image;
		}else image = this.current;
		image.span.className = 'hover';
		this._reset(image);
		image.style.zIndex = 0;
		this.active = this.nextItem();
		if (this.active == image) return;
		this._reset(this.active);
		var random = Math.floor(Math.random() * 6);
		var style = this.active.style;
		if (random == 0) {//alpha
			style.opacity = 0;
			style.filter = "alpha(opacity=0)";
		}else {
			style.opacity = 1;
			style.filter = "";
			if (random == 1) {//right
				style.left = (-this.offsetWidth) + "px";
			}else if (random == 2) {//left
				style.left = this.offsetWidth + "px";
			}else if (random == 3) {//bottom
				style.top = (-this.offsetHeight) + "px";
			}else if (random == 4) {//top
				style.top = this.offsetHeight + "px";
			}else if (random == 5) {//box out
				style.left = parseInt(this.offsetWidth/2) + "px";
				style.top = parseInt(this.offsetHeight/2) + "px";
				style.width = "0px";
				style.height = "0px";
				var img = this.active.firstChild;
				img.style.width = this.offsetWidth + "px";
				img.style.height = this.offsetHeight + "px";
			}else return;
		}
		style.zIndex = 1;
		this.active.random = random;
		clearTimeout(this.timer);
		this.timer = setTimeout(function() {switcher._action();}, times);
	}
	switcher._action = function() {
		var type = this.active.random;
		var style = this.active.style;
		var finish = false;
		if (type == 0) {//alpha
			var opacity = parseFloat(style.opacity) - 0.1;
			if (opacity >= 0.9)
				finish = true;
			else {
				opacity += 0.2;
				style.opacity = opacity;
				opacity = opacity * 100;
				style.filter = "alpha(opacity="+opacity+")";
			}
		}else if (type == 1) {//right
			var left = parseInt(style.left) + 10;
			if (left >= 0)
				finish = true;
			else style.left = left + 'px';
		}else if (type == 2) {//left
			var left = parseInt(style.left) - 10;
			if (left <= 0)
				finish = true;
			else style.left = left + 'px';
		}else if (type == 3) {//bottom
			var top = parseInt(style.top) + 10;
			if (top >= 0)
				finish = true;
			else style.top = top + 'px';
		}else if (type == 4) {//top
			var top = parseInt(style.top) - 10;
			if (top <= 0)
				finish = true;
			else style.top = top + 'px';
		}else if (type == 5) {//box out
			var img = this.active.firstChild;
			var left = parseInt(style.left) - 5;
			if (left <= 0) {
				style.left = "0px";
				style.width = "100%";
				img.style.left = "0px";
			}else {
				style.left = left + 'px';
				var width = parseInt(style.width) + 10;
				style.width = width + 'px';
				img.style.left = (-left) + 'px';
			}
			var top = parseInt(style.top) - 5;
			if (top <= 0) {
				style.top = "0px";
				style.height = "100%";
				img.style.top = "0px";
			}else {
				style.top = top + 'px';
				var height = parseInt(style.height) + 10;
				style.height = height + 'px';
				img.style.top = (-top) + 'px';
			}
			if (left < 1 && top < 1) {
				finish = true;
				this.active.random = -1;
			}
		}else return;
		clearTimeout(this.timer);
		if (finish) {
			this._reset(this.active);
			this.current.span.className = '';
			this.active.span.className = 'hover';
			this.timer = setTimeout(function() {switcher.switchTo();}, times);
		}else
			this.timer = setTimeout(function() {switcher._action();}, type?50:300);
	}
	switcher.nextItem = function() {
		var image = this.current.nextSibling;
		while (image != this.current) {
			if (!image) image = this.firstChild;
			if (image.tagName && image != this.control) return image;
			image = image.nextSibling;
		}
		return null;
	}
	var image = switcher.firstChild;
	while (image) {
		if (image.tagName)
			switcher.addImage(image);
		image = image.nextSibling;
	}
	switcher.appendChild(switcher.control);
	switcher.switchTo();
	return switcher;
}
function ImgAuto(i,W,H){
	var MaxW = W, MaxH = H;
	var o=new Image();
	o.src=i.src;
	var w=o.width;
	var h=o.height;
	var t;
	if (w>MaxW){
		t=MaxW;
	}else{
		t=w;
	}
	if ((h*t/w)>MaxH){i.height=MaxH;i.width=MaxH/h*w;}else{i.width=t;i.height=t/w*h;}
}
function features(item) {
	if(item == 'new_top') {
		$('new_top').style.display = 'block';
		$('new_copy').style.display = 'none';
		$('new_tops').className = 'new_div click';
		$('new_copys').className = 'new_divCopy click';
	}else {
		$('new_top').style.display = 'none';
		$('new_copy').style.display = 'block';
		$('new_tops').className = 'new_divCopy click';
		$('new_copys').className = 'new_div click';
	}
}
function ResumeError() { return true; } 
//window.onerror = ResumeError;