﻿// JScript 文件/******************************************************/
 
 var $=function(node)
{
	return document.getElementById(node);
}

function EnterTab()
{
    if(event.keyCode == 13)event.keyCode = 9;
}

function chboxselreverse(itemname,checkstatus) {
	if(!itemname) 
		return;
	if(!itemname.length) {
		itemname.checked=checkstatus;
	}
	else
	{
		for(var i=0;i<itemname.length;i++)
		{	
			itemname[i].checked=!itemname[i].checked;
		}
	}
}

function CheckIsNull(obj,msg)
{
	if(obj.value=="")
	{
		alert(msg);
		obj.focus();
		return false;
	}
	return true;
}


function CheckIsZero(obj,msg)
{
	if(obj.value==""||obj.value=="0")
	{
		alert(msg);
		obj.focus();
		return false;
	}
	return true;
}

function chkfloat(sId)
{
	if(isNaN(sId.value))
	{
		alert("非法输入，输入格式应该为小数（如：xxxx.xx,123.40）！");
		while(isNaN(sId.value))
			sId.value=sId.value.substring(0,sId.value.length-1);
			return false;
	}
}

function chkint(sId)
{
	if(/[^0-9]/g.test(sId.value))
	{
		alert("非法输入，输入格式应该为整数（如：3100）！");
		while(/[^0-9]/g.test(sId.value))
		sId.value=sId.value.substring(0,sId.value.length-1);
		return false;
	}
}


function isEmail(strEmail) 
{
    if (strEmail.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
    {
        return true;
    }
    else
    {
       alert('Email格式不对');
    }   
}

function copyToClipBoard()
{
    var clipBoardContent=document.location; 
    clipBoardContent+='rn'; 
    window.clipboardData.setData("Text",clipBoardContent); 
    alert("复制成功！");
} 


//鼠标触发显示和隐藏层
function byId(domid)
{
    return document.getElementById(domid);
}
function htmlshow(dom)
{
    byId(dom).style.display = "";
}
function htmlhide(dom)
{
    byId(dom).style.display = "none";
}

//放大缩小图片
function re_img(e, o)
{
var zoom = parseInt(o.style.zoom, 10) || 100;
zoom += event.wheelDelta / 12;
if (zoom > 0) o.style.zoom = zoom + '%';
return false;
}

  function imgzoom(img,maxsize){
	
	var a=new Image();
	 
	a.src=img.src
		
	if(a.width > maxsize * 4)
	{
		img.style.width=maxsize;
	}
	else if(a.width >= maxsize)
	{
		img.width=Math.round(a.width * Math.floor(4 * maxsize / a.width) / 4);
	}
	return false;
}

function imgautoresize(o){
	 
	 	if(o.width > 500 ){
				o.style.width='500px';
			}
			if(o.height > 800){
				o.style.height='800px';
			}
		
	}

//修复高度


	
function fixheight(objname){
	
		var brInfo = navigator.userAgent.toLowerCase();
	var brie=true;

	if (brInfo.indexOf("msie") ==-1 || brInfo.indexOf("msie 7.0") !=-1) {	
	
		var obj=document.getElementById(objname);
	if (obj){
		obj.className="topic_firefox";
	}

		
	}
	
	}

String.prototype.get   =   function(name)   
  {   
      var   reg   =   new   RegExp("(^|&|\\?)"+   name   +"=([^&]*)(&|$)"),   r;   
      if   (r=this.match(reg))   return   unescape(r[2]);   return   null;   
  }
function getCookieVal (offset)
{
	var endstr = document.cookie.indexOf (";", offset);
	if (endstr == -1)
		endstr = document.cookie.length;
	return unescape(document.cookie.substring(offset, endstr));
}
function fAddFavorite(sTitle, sURL)
{ 
if(document.all)
    window.external.AddFavorite(sURL, sTitle); 
else
    window.sidebar.addPanel(sTitle, sURL, "");
}
