//鼠标滚轮放大缩小图片
//debugger

function DoZoom(e, CtrlID)
{
	var zoom = parseInt(CtrlID.style.zoom, 10);// || 100;
	zoom += event.wheelDelta / 12;
	if (zoom > 0) CtrlID.style.zoom = zoom + '%';
		return false;
}

//页面调用代码：onmousewheel="return DoZoom(event,this)"

//改变字体大小
function DoSize(size)
{
	document.getElementById('divContent').style.fontSize=size+'px'
}

//设置页面焦点 CtrlID 为要设置焦点的 ID

function SetFocus(CtrlID)
{
	if(document.getElementById(CtrlID) != null)
		document.getElementById(CtrlID).focus();
}


//取得控件的绝对位置
function GetPosition(CtrlID)
{
	if(document.getElementById(CtrlID) != null)
	{
		var Ctrl = document.getElementById(CtrlID);
		var t = Ctrl.offsetTop;
		var l = Ctrl.offsetLeft;
		while(Ctrl=Ctrl.offsetParent)
			alert("top = " + t + "\nleft = " + l);
	}
}	
// offsetHeight 获取对象相对于版面或由父坐标 offsetParent 属性指定的父坐标的高度
// offsetWidth  获取对象相对于版面或由父坐标 offsetParent 属性指定的父坐标的宽度
// offsetLeft   获取对象相对于版面或由 offsetParent 属性指定的父坐标的计算左侧位置
// offsetTop    获取对象相对于版面或由 offsetTop 属性指定的父坐标的计算顶端位置 
// offsetParent 获取定义对象 offsetTop 和 offsetLeft 属性的容器对象的引用
// scrollHeight 获取容器实际内容的高度
// clientHeight 获取原始的高度

//光标是停在文本框文字的最后
function InLastPosition()
{
	var e = event.srcElement;
	var sStr =e.createTextRange();
	sStr.moveStart('character',e.value.length);
	sStr.collapse(true);
	sStr.select();
}

//页面调用代码：onfocus="inLastPosition()"

//输入框清空
function ClearTextBox(CtrlID)
{
	document.getElementById(CtrlID).value = "";	
}


function TrimStr(str)
{
	if (str == null || str.length == 0)
		return "";	
	//剔除左边空格
	while (str.substring(0,1) == " ")
		str = str.substring(1);
	
	//剔除右边空格
	while (str.substring(str.length -1)== " ")
		str = str.substring(0,str.length - 1);		
	return str;
}


//判断输入是否为数字类型，并大于0，根据参数i_dig控制其小数位数
function IsNumber(CtrlID,i_dig)
{
	var oSource = document.all[CtrlID].value;
	if(isNaN(oSource))
	{
		alert("请输入数字类型值!");
		if(oSource*1<0)
		alert("退款金额不能为负数!");
		document.all[CtrlID].value = "0";
		return false;
	}
	document.all[CtrlID].value=new Number(oSource).toFixed(i_dig).toString();
	return true;
}


//xmlhttp同步调用
function XmlHttpPost(url)
{
	var result= "";
	var xmlHttp = new ActiveXObject('Microsoft.XMLHTTP');
	xmlHttp.open('POST',url,false);	//同步调用
	xmlHttp.setRequestHeader('content-Type','application/x-www-form-urlencoded');
	xmlHttp.setRequestHeader('content-Type','GB2312');
	xmlHttp.send();
	result = xmlHttp.responseText;
	return result;
}	

//插入表情图片到留言编辑框里
function InsertSmilies( inputTextID , strCode) 
{
	var txtarea = document.getElementById( inputTextID );
	if (txtarea.createTextRange && txtarea.caretPos) 
	{
		var caretPos = txtarea.caretPos;
		caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? strCode + ' ' : strCode;
		txtarea.focus();
	} else {
		txtarea.value  += strCode;
		txtarea.focus();
	}
}

//延时后自动跳转到指定页面
function RedirectAuto(url,timeout)
{
	setTimeout("Rediredt("+url+");",timeout);
	
}
function Rediredt(url)
{
	window.location.replace(url);
}



