//感应图片透明度变换
if (typeof(webroot) == 'undefined'){
	var webroot = "/hany/";
}
var xmlhttp = null;
var BrowerType = 'IE';
if(window.XMLHttpRequest){
	xmlhttp = new XMLHttpRequest();
	var BrowerType = 'FF';
}else if(window.ActiveXObject){
	var msxml = new Array('MSXML2.XMLHTTP.5.0', 'MSXML2.XMLHTTP.4.0', 'MSXML2.XMLHTTP.3.0', 'MSXML2.XMLHTTP', 'Microsoft.XMLHTTP');
	for(var i=0; i<msxml.length; i++){
		try{
			xmlhttp = new ActiveXObject(msxml[i]); 
			break;
		}catch(e){}
	}
}
function checkform(obj){
	var errmsg = object('errormessage');
	if (errmsg!=null)errmsg.innerHTML = '';
	for (i=0; i<obj.length; i++){
		var cn = obj[i];
		if (cn.className == 'errbox'){
			cn.className = 'needbox';
		}
		if (cn.className == 'needbox' && cn.value == ''){
			cn.className = 'errbox';
			cn.focus();
			if (cn.getAttribute('hint') != null){
				if (errmsg!=null)errmsg.innerHTML = cn.getAttribute('hint');
				else alert(cn.getAttribute('hint'));
			}
			return false;
		}
		if (cn.getAttribute('match') != null){
			var m = cn.getAttribute('match');
			var r = new RegExp(m);
			if (!r.test(cn.value)){
				cn.className = 'errbox';
				cn.focus();
				if (cn.getAttribute('hint') != null){
					if (errmsg!=null)errmsg.innerHTML = cn.getAttribute('hint');
					else alert(cn.getAttribute('hint'));
				}
				return false;
			}
		}
	}
	return true;
}
function checkradio(radioname, message){
	var errmsg = object('errormessage');
	if (errmsg!=null)errmsg.innerHTML = '';
	var hascheck;
	hascheck = false;
	var rn = document.getElementsByName(radioname);
	for (var i=0; i<rn.length; i++){
		if (rn[i].checked){
			hascheck = true;
			break;
		}
	}
	if (!hascheck){
		if (errmsg!=null)errmsg.innerHTML = message;
		else alert(message);
		return false;
	}
	return true;
}
function object(objId){
	return document.getElementById(objId);
}
function message(msg, url){
	if (url!=''){
		if (confirm(msg)){
			window.location.href=url;
		}else{
			return false;
		}
	}else{
		alert(msg);
	}
}
function _location(url){
	window.location.href=url;
}
function addHandleEvent(obj, type, func){
	if (obj.attachEvent){
		obj.attachEvent('on'+type, func);
		return true;
	}else if (obj.addEventListener){
		obj.addEventListener(type, func, false);
		return true;
	}else{
		return false;
	}
}

function button(obj){
}

/* cookie class */
function cookie() {
	if (document.cookie.length) {
		this.cookies = ' ' + document.cookie;
	}
}
cookie.prototype.set = function (key, value) {
	var expdate = new Date();
	var argv = this.set.arguments;
	var argc = this.set.arguments.length;
	var expires = (argc > 2) ? argv[2] : null;
	var path    = (argc > 3) ? argv[3] : null;
	var domain  = (argc > 4) ? argv[4] : null;
	var secure  = (argc > 5) ? argv[5] : false;
	if(expires!=null) expdate.setTime(expdate.getTime() + ( expires * 1000 ));
	document.cookie = key + "=" + escape (value) + 
		((expires == null) ? "" : ("; expires="+ expdate.toGMTString())) +
		((path == null) ? "" : ("; path=" + path)) +((domain == null) ? "" : ("; domain=" + domain)) +
		((secure == true) ? "; secure" : "");
}
cookie.prototype.get = function (key) {
	if (this.cookies) {
		var start = this.cookies.indexOf(' ' + key + '=');
		if (start == -1) {
			return null;
		}
		var end = this.cookies.indexOf(";", start);
		if (end == -1) {
			end = this.cookies.length;
		}
		end -= start;
		var cookie = this.cookies.substr(start,end);
		return unescape(cookie.substr(cookie.indexOf('=') + 1, cookie.length - cookie.indexOf('=') + 1));
	}else {
		return null;
	}
}
cookie.prototype.remove = function (key) {
	var expdate = new Date();
	expdate.setTime (expdate.getTime() - 1);
	var cval = this.get(key);
	document.cookie = key + "=" + cval + "; expires="+ expdate.toGMTString();
}






// 淡入淡出函数
function fade(id, colorSource, colorFade, fadeStep, background)
{
	var element = document.getElementById(id);
	// 分解源色彩
	var rSource = sprRGB(colorSource, 0);    //红 R
	var bSource = sprRGB(colorSource, 1);    //绿 G
	var gSource = sprRGB(colorSource, 2);    //蓝 B
	
	// 分解渐变色彩
	var rFade = sprRGB(colorFade, 0);
	var bFade = sprRGB(colorFade, 1);
	var gFade = sprRGB(colorFade, 2);
	
	// 步数统计
	var step = 0;
	// 设置定时器
	var fadeTimer = setInterval(
	function()
	{
		var tmpStep = fadeStep - step;
		// 由于 floor() 计算不准确，当达到指定步数后直接赋值源色彩
		if(step < fadeStep)
		{
			with(Math)
			{
				var rStep = floor((rSource - rFade) / tmpStep);
				var gStep = floor((gSource - gFade) / tmpStep);
				var bStep = floor((bSource - bFade) / tmpStep);
			}
			rFade += rStep;
			gFade += gStep;
			bFade += bStep;
			
			if(background)
			{
				element.style.backgroundColor = 'rgb('+rFade+','+bFade+','+gFade+')';
			}
			else
			{
				element.style.color = 'rgb('+rFade+','+bFade+','+gFade+')';
			}
		}
		else
		{
			if(background)
			{
				element.style.backgroundColor = colorSource;
			}
			else
			{
				element.style.color = colorSource;
			}
			
			// 清除定时器
			clearInterval(fadeTimer);
		}
		step ++;
	}, 20);
} 	

// 分离RGB颜色 0:R | 1:G | 2:B
function sprRGB(color, type)
{
	var start, len, result;
	len = (color.length == 4)?1:2;
	start = type * len + 1;
	result = color.substr(start, len);
	if(result.length == 1)
	{
		result += result;
	}
	return parseInt(result, 16);
} 
