﻿// 根据鼠标或焦点事件，设置文本框和按钮样式,此函数会与样式相关
function IEvent(sType,oInput)
{
	var onStyle,offStyle,eleType;
	eleType = oInput.type;
	// 设置关联样式
	if("button" == eleType || "submit" == eleType || "reset" == eleType)
	{
		onStyle = "button_on";
		offStyle = "button_off";
	}
	else
	{
		onStyle = "input_on";
		offStyle = "input_off";
	}
	// 根据事件选择样式
	switch (sType)
	{
		case "focus" :
			oInput.isfocus = true;
		case "mouseover" :
			oInput.className = onStyle;
			break;
		case "blur" :
			oInput.isfocus = false;
		case "mouseout" :
			if(!oInput.isfocus)
			{
				oInput.className = offStyle;
			}
			break;
	}
}

// 根据ID获取页面元素
function $(id)
{	
	return document.getElementById(id);
}
function trim(str)
{
	return str.replace(/(^[\s　]*)|([\s　]*$)/g, '');
}
String.prototype.trim = function()
{
	return this.replace(/(^[\s　]*)|([\s　]*$)/g, '');
}

