var imagePath = '/admin/';
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 showMenu(obj) {
	if(obj) {
		obj.style.backgroundImage = 'url(images/menu_title.jpg)';
		obj.firstChild.style.display = '';
	}
}
function displayMenu(obj) {
	if(obj) {
		obj.style.backgroundImage = '';
		obj.firstChild.style.display = 'none';
	}
}
var AreaSpots = new Array();
function hotelAareaChange(area,catalog,key) {
	var spotid = $(catalog);
	if(!area || area == 0){ 
		spotid.options.length = 0;
		spotid.options[0] = new Option('请选择所在区域', '');
		return false;
	}
	var id = 'AREA' + area;
	if (!AreaSpots[id]) {
		var ajax = new XmlHttp;
		var text = ajax.doGet("/info.php?id=hotelcatalog&areaid="+area);
		if (text.substr(0,3)=='ok:' && text.length > 3){
			AreaSpots[id] = eval(text.substr(3));
		}else
			AreaSpots[id] = new Array();
	}
	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);
		if(item.id == key) {
			spotid.options[i+1].selected  = true;
		}
	}
}
var SkiTicket = new Array();
function sceneryAareaChange(area,catalog) {
	var spotid = $('catalog');
	if(!area || area == 0){ 
		spotid.options.length = 0;
		spotid.options[0] = new Option('请选择所在区域', '');
		return false;
	}
	var id = 'AREA' + area;
	if (!SkiTicket[id]) {
		var ajax = new XmlHttp;
		var text = ajax.doGet("/info.php?id=skiticketcatalog&catalog="+area);
		if (text.substr(0,3)=='ok:' && text.length > 3){
			SkiTicket[id] = eval(text.substr(3));
		}else
			SkiTicket[id] = new Array();
	}
	spotid.options.length = 0;
	spotid.options[0] = new Option('请选择所在区域', 0);
	var ski = SkiTicket[id].length;
	for (var i=0; i<ski; i++) {
		var item = SkiTicket[id][i];
		spotid.options[i+1] = new Option(item.title, item.id);
		if(item.id == catalog) {
			spotid.options[i+1].selected  = true;
		}
	}
}
var dayname = new Array("&nbsp;","周日","周一", "周二", "周三","周四", "周五", "周六");
function showDateList(item, dates) {
	var begins = $('begins').value;
	var ends = $('ends').value;
	var str = new Array();
	var houseCont = new Array();
	var wdate = new Array();
	var paypal = new Array();
	var breakfast = new Array();
	var url = "/info.php?id=hotelReDate&house=" + item;
	url += "&begins=" + begins + "&ends=" + ends;
	var ajax = new XmlHttp;
	var text = ajax.doGet(url);

	var list = $(dates);
	list.style.display = "block";
	var e = getEvent();
	list.style.zIndex = 10000;
	list.style.position = "absolute";
	var offset = windowScroll();
	list.style.top = (e.clientY + offset.y + 5) + 'px';
	list.style.left = (e.clientX + offset.x - 430) + 'px';
	addHandle('mouseout', function(e) {
		var obj = e.target?e.target:event.srcElement;
		if (obj!=table.input && !table.contains(obj))
			list.style.display = 'none';
	});

    if (text.substr(0,3)=='ok:' && text.length > 3)
	   houseCont = eval(text.substr(3));
	for(var i=0;i<houseCont.length;i++){
		paypal[i] = houseCont[i].paypal;
		if (paypal[i] == null)
			paypal[i] = '满房';
		wdate[i] = houseCont[i].wdate;
		breakfast[i] = houseCont[i].breakfast;
	}
	var table = document.createElement("TABLE");
	table.id = 'dates';
	table.setAttribute("cellpadding", "0");
	table.className = 'dateList';
	var row = table.insertRow(-1);
	row.insertCell(-1);
	row.insertCell(-1);
	row.insertCell(-1);
	row.insertCell(-1);
	row.insertCell(-1);
	row.insertCell(-1);
	row.insertCell(-1);
	row.insertCell(-1);
	var defter = eval(houseCont.length)+ eval((7 + wdate[0]));
	var rownum = Math.ceil(defter/7);
	for (var i=0; i<rownum; i++) {
	    var row = table.insertRow(-1);
		for (var j=0; j<8; j++)
			row.insertCell(-1);
	}
	list.appendChild(table);
if (table.makeButton) return table;
	table.forwardDays = null;
	table.cellPadding = 0;
	table.cellSpacing = 0;
	table.style.position = "absolute";
	with (table.rows[0]) {
		firstChild.nextSibling.className = "sunday";
		lastChild.className = "satday";
		for (var i=0; i<cells.length; i++) {
			cells[i].setAttribute('UNSELECTABLE','on');
			cells[i].innerHTML = dayname[i];
		}
	}
	var count = paypal.length;
	var last = 1; i = 1; week = wdate[0];j = 0;
	cell = table.rows[1].cells[week].nextSibling;
	for(var k=1;k<=week;k++)
		table.rows[1].cells[k].innerHTML = '&nbsp;';
	while (cell) {
		if (last++ <= count)
			cell.innerHTML = paypal[j]+'<br>'+breakfast[j];
		else cell.innerHTML = '&nbsp;';
		j++;
		week = (week + 1) % 7;
		cell = cell.nextSibling;
		table.rows[i].firstChild.innerHTML = '第'+ escNumber(i) +'周';
		if (!cell && ++i < rownum)
			cell = table.rows[i].firstChild.nextSibling;
	}
}
function escNumber (item) {
	var number = new Array('零','一','二','三','四','五','六','七','八','九','十','十一','十二','十三','十四','十五','十六');
	for (var i=0;i<number.length ;i++ ) {
		if (item == i)
			item = number[i];
	}
	return item;
}
function replaceDate() {
	var begins = $('begins').value;
	var ends = $('ends').value;
	var hotel = $('hotel').value;
	var url = "/info.php?id=replaceDate";
	url += "&begins=" + begins + "&ends" + ends + "&hotel=" + hotel;
	var ajax = new XmlHttp;
	var text = ajax.doGet(url);
}
function getPasswrod(form) {
	titleDialog("找回密码...");
	if(!form.userid.value)
		showDialog('[用户名] 字段不能为空！','error');
	else if (!isEmail(form.userid.value))
		showDialog('[用户名] 格式输入有误！', 'error');
	else {
		form.cmd.value = 'passwd';
		var ajax = new XmlHttp;
		ajax.doPost(function(succ,info){
			if(succ){
				showDialog('您的密码已发送至您的邮箱，请注意查收！',2000);
			}else showDialog(info,'error');
		}, form.action, form);
	}return false;
}
function memberLogin(form) {
	titleDialog("会员登录...");
	if(!form.userid.value)
		showDialog('[用户名] 字段不能为空！','error');
	else if (!isEmail(form.userid.value))
		showDialog('[用户名] 格式输入有误！', 'error');
	else if (!form.passwd.value)
		showDialog('[密码] 字段不能为空！','error');
	else {
		form.cmd.value = 'login';
		var ajax = new XmlHttp;
		ajax.doPost(function(succ,info){
			if(succ){
				location = info;
			}else showDialog(info,'error');
		}, form.action, form);
	}return false;
}
function memberRegister(form) {
	titleDialog("会员注册...");
	if(!form.mailbox.value)
		showDialog('请填写您的Email地址!','error');
	else if(!isEmail(form.mailbox.value))
		showDialog('[Email地址] 格式输入有误！','error');
	else if (!form.passwd.value)
		showDialog('请设定登录密码！','error');
	else if (!form.confirm.value)
		showDialog('请再次输入设定密码!','error');
	else if (form.passwd.value != form.confirm.value)
		showDialog('两次密码输入必须一致!','error');
	else if (!form.verify.value)
		showDialog('请输入验证码！','error');
	else {
		//showDialog("同意服务条款，并提交注册信息！",function(){do_memberregister(form)});
		showDialog("同意以下注册协议，并提交注册信息。", 
			function(){do_memberregister(form)});
	}return false;
}	
function do_memberregister(form) {
	var ajax = new XmlHttp;
		ajax.doPost(function(succ,info){
		if(succ){
			location = info;
		}else showDialog(info,'error');
	}, form.action, form);
}
//travelstart
function getEvent(){ //获取浏览器事件，同时兼容ie和ff的写法
	if(document.all) return window.event;
	func=getEvent.caller;
	while(func!=null){
		var arg0=func.arguments[0];
		if(arg0){
			if((arg0.constructor==Event && arg0.constructor == MouseEvent) || (typeof(arg0)=="object" && arg0.preventDefault && arg0.stopPropagation)){
				return arg0;
			}
		}
		func=func.caller;
	}
	return null;
} 
function dropDown(year,month,day) {
	var value = year+'-'+month+'-'+day;
	var parent = window.parent;
	var  pInput = parent.document.getElementById("starts");
	pInput.value = value;
	parent.document.getElementById('Tstart').style.visibility = "hidden";
}
function travelStart(id,input) {
	var div = $(id);
	var e = getEvent();
	if (!div) {
		div = document.createElement("DIV");
		div.id = id;
		div.className = 'calendar';
		div.style.position = 'absolute';
		div.style.zIndex = 10000;
	}
	iframe = document.createElement("IFRAME");
	iframe.id = 'popup';
	iframe.src = 'Tcalendar.php';
	iframe.className = 'iframe';
	div.appendChild(iframe);
	div.style.visibility = 'visible';

	var popup = $('popup');
	popup.style.zIndex = 10000;
	popup.style.opacity = 1;
	var pt = getPosition(input);
	pt.y += input.offsetHeight;
	popup.style.top = pt.y + 'px';
	popup.style.left = pt.x-2 +'px';
	popup.style.filter = "alpha(opacity=100)";
	popup.style.display = 'block';

	addHandle('mousedown', function(e) {
	var z_div = div;
	if (!z_div || z_div.style.visibility=='hidden') return;
	var el = e.target?e.target:e.srcElement;
	if (el!=z_div && !z_div.contains(el))
		z_div.style.visibility = 'hidden';
	});
}
function getIntDate(newDate,type) {
	var monthString;
	var dayString;
	 if ((newDate.getMonth() + 1).toString().length == 1) {  
		 monthString = 0 + "" + (newDate.getMonth() + 1).toString();   
	 } else {  
		 monthString = (newDate.getMonth() + 1).toString();  
	 }  
	 if (newDate.getDate().toString().length == 1) {  
		 dayString = 0 + "" + newDate.getDate().toString();  
	 } else {  
		 dayString = newDate.getDate().toString();  
	 }  
	 switch(type) {
		case 'd': return eval(newDate.getFullYear() + "" + monthString+ "" + dayString);
		case 'm': return eval(newDate.getFullYear() + "" + monthString);
		default:return '';
	 }
}
// 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 count1 = 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; s=0;
		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;
			cell = cell.nextSibling;
			if (last > count1) last = 1;
			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 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 {
		var ajax = new XmlHttp;
		if (form.flags && form.flags.value == 1) {			
			ajax.doPost(function(succ, info) {
				if (succ) {
					window.reload = true;
					showDialog("发表评论成功！谢谢您的参与！",1000);
				}else
					showDialog("很抱歉，发表评论失败...", 'error');
			}, form.action, form);
		}else
			ajax.doPost(function(succ, info) {
				if (succ){
					showDialog("谢谢您发表评论！您发表的评论将在<ins><b>审核之后</b></ins>显示。", 2000);
					window.reload = function() {location=form.action};
				}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 {
		var ajax = new XmlHttp;
		ajax.doPost(function(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 {
		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 setColumn(item) {
	var form = document.forms['community'];
	if(!item){
		form.action = '';
		return;
	}
	var linkof = $('linkof').childNodes;
	form.action = linkof[item-1];
}
function paypal(form) {
	titleDialog("开始付款...");
	var str = strSelected();
	if(!str)
		showDialog("请选择需要支付的订单！",'error');
	else {
		form.order.value = str;
		return true;
	}
	return false;
}
function checkPaypal(form) {
	titleDialog("开始付款...");
	if(!form.order.value)
		showDialog("请选择需要支付的订单！",'error');
	else if (form.inc.value && !form.incard.value)
		showDialog("请输入正确的卡号和密码！",'error');
	else {
		var ajax = new XmlHttp;
		ajax.doPost(function(succ,info){
			if(succ){
				if(info.length > 0) {
					location = info;
				}else {
					showDialog('<b>恭喜您，本次付款成功！</b>',1000);
					setTimeout(function(){window.reload=true},1000);
				}
			}else{
				if(info.substr(0,6) == 'false:') {
					showDialog("对不起，您输入的卡号中有部分暂时不能<br>使用，请重新输入或与管理员联系！",'error');
					$('errorcard').style.display = 'block';
					$('errorcard').innerHTML = "<font color='black'>下列卡号暂时不能使用：</font><br>"+info.substr(6);
				}else {
					showDialog(info,'error');
				}
			}
		},form.action,form);
	}return false;
}
function setIncard() {
	$('incard').style.display='block';
	$('button').style.display='none';
	$('inc').value = 1;
}


function browserType(){
	if(navigator.userAgent.indexOf("MSIE")>0){
		var isIE=!!window.ActiveXObject;
		var isIE6=isIE&&!window.XMLHttpRequest;
		var isIE8=isIE&&!!document.documentMode;
		var isIE7=isIE&&!isIE6&&!isIE8;
		if (isIE6)
			return "IE6";
		else if (isIE8)
			return "IE8";
		else if (isIE7)
			return "IE7";
	}
	if(navigator.userAgent.indexOf("Firefox")>0)
		return "Firefox";
	if(navigator.userAgent.indexOf("Safari")>0)
		return "Safari";
	if(navigator.userAgent.indexOf("Camino")>0)
		return "Camino";
	if(navigator.userAgent.indexOf("Gecko/")>0)
		return "Gecko";
}
/*********************** scroll js ******************************/
function ScrollText(content,btnPrevious,btnNext,autoStart,timeout,isSmoothScroll){
    this.Speed = 0;
    this.Timeout = timeout;
	this.stopscroll =false;//是否停止滚动的标志位
	this.isSmoothScroll= isSmoothScroll;//是否平滑连续滚动
    this.LineHeight = 20;//默认高度。可以在外部根据需要设置
    this.NextButton = this.$(btnNext);
    this.PreviousButton = this.$(btnPrevious);
    this.ScrollContent = this.$(content);
    this.ScrollContent.innerHTML += this.ScrollContent.innerHTML;//为了平滑滚动再加一遍

	if(this.PreviousButton){
		this.PreviousButton.onclick = this.GetFunction(this,"Previous"); 
		this.PreviousButton.onmouseover = this.GetFunction(this,"MouseOver");
		this.PreviousButton.onmouseout = this.GetFunction(this,"MouseOut");
	}
	if(this.NextButton){
		this.NextButton.onclick = this.GetFunction(this,"Next");
		this.NextButton.onmouseover = this.GetFunction(this,"MouseOver");
		this.NextButton.onmouseout = this.GetFunction(this,"MouseOut");
    }
    this.ScrollContent.onmouseover = this.GetFunction(this,"MouseOver");
    this.ScrollContent.onmouseout = this.GetFunction(this,"MouseOut");

    if(autoStart){
        this.Start();
    }
}
ScrollText.prototype = {
	$:function(element){
		return document.getElementById(element);
	},
	Previous:function(){
		this.stopscroll = true;
		this.Scroll("up");
	},
	Next:function(){
		this.stopscroll = true;
		this.Scroll("down");
	},
	Start:function(){
		if(this.isSmoothScroll){
			this.AutoScrollTimer = setInterval(this.GetFunction(this,"SmoothScroll"), this.Timeout);
		}else{		
			this.AutoScrollTimer = setInterval(this.GetFunction(this,"AutoScroll"), this.Timeout);
		}
	},
	Stop:function(){
		clearTimeout(this.AutoScrollTimer);
		this.DelayTimerStop = 0;
	},
	MouseOver:function(){	
		this.stopscroll = true;
	},
	MouseOut:function()
	{
		this.stopscroll = false;
	},
	AutoScroll:function()
	{
		if(this.stopscroll) 
			return;
		this.ScrollContent.scrollTop++;
		if(parseInt(this.ScrollContent.scrollTop) % this.LineHeight != 0){
			this.ScrollTimer = setTimeout(this.GetFunction(this,"AutoScroll"), this.Speed);
		}else{
			if(parseInt(this.ScrollContent.scrollTop) >= parseInt(this.ScrollContent.scrollHeight) / 2){
				this.ScrollContent.scrollTop = 0;
			}
			clearTimeout(this.ScrollTimer);
			//this.AutoScrollTimer = setTimeout(this.GetFunction(this,"AutoScroll"), this.Timeout);
		}
	},
	SmoothScroll:function(){
		if(this.stopscroll)
			return;
		this.ScrollContent.scrollTop++;
		if(parseInt(this.ScrollContent.scrollTop) >= parseInt(this.ScrollContent.scrollHeight) / 2){
			this.ScrollContent.scrollTop = 0;
		}
	},
	Scroll:function(direction){
		if(direction=="up"){
			this.ScrollContent.scrollTop--;
		}else{
			this.ScrollContent.scrollTop++;
		}
		if(parseInt(this.ScrollContent.scrollTop) >= parseInt(this.ScrollContent.scrollHeight) / 2){
			this.ScrollContent.scrollTop = 0;
		}else if(parseInt(this.ScrollContent.scrollTop)<=0){
			this.ScrollContent.scrollTop = parseInt(this.ScrollContent.scrollHeight) / 2;
		}
		if(parseInt(this.ScrollContent.scrollTop) % this.LineHeight != 0){
			this.ScrollTimer = setTimeout(this.GetFunction(this,"Scroll",direction), this.Speed);
		}
	},
	GetFunction:function(variable,method,param){
		return function(){
			variable[method](param);
		}
	}
}