
function NewWindow(mypage,myname,w,h,scroll) 
{
	var win = null;
	LeftPosition = (screen.width) ? (screen.width - w) / 2 : 0;
	TopPosition = (screen.height) ? (screen.height - h) / 2 : 0;
	settings = 'height=' + h + ',width=' + w + ',top=' + TopPosition + ',left='
	+ LeftPosition + ',scrollbars=' + scroll + ',resizable=no,location=no';
	win = window.open(mypage, myname, settings);
	win.focus();
}


//弹出居中窗口（非模式窗口）
function WinPop(url, winName, width, height,scrollbar,resizable) //scrollbar为是否有滚动条，yes值为1，no值为0;//resizable是否可以最大化，yes为1，no为0；
/*function winPop(url, winName, width, height) */

{
xposition=0; yposition=0;

if ((parseInt(navigator.appVersion) >= 4 ))
{
xposition = (screen.width-10 - width) / 2;
yposition = (screen.height-30 - height) / 2;
}

theproperty= "width=" + width + "," 
+ "height=" + height + "," 
+ "location=0," 
+ "menubar=0,"
+ "resizable=" + resizable + ","//是否可以最大化，yes为1，no为0；
+ "scrollbars=" + scrollbar + ","
/*+ "scrollbars=0,"*///是否有滚动条，yes值为1，no值为0,
+ "status=0," 
+ "titlebar=0,"
+ "toolbar=0,"
+ "hotkeys=0,"
+ "screenx=" + xposition + "," //仅适用于Netscape
+ "screeny=" + yposition + "," //仅适用于Netscape
+ "left=" + xposition + "," //IE
+ "top=" + yposition; //IE 
window.open( url,winName,theproperty );
}

function WinPopBox(url, winName, width, height) //scrollbar为是否有滚动条，yes值为1，no值为0;//resizable是否可以最大化，yes为1，no为0；
/*function winPop(url, winName, width, height) */

{
xposition=0; yposition=0;

if ((parseInt(navigator.appVersion) >= 4 ))
{
xposition = (screen.width-10 - width) / 2;
yposition = (screen.height-30 - height) / 2;
}

theproperty= "width=" + width + "," 
+ "height=" + height + "," 
+ "location=0," 
+ "menubar=0,"
+ "resizable=yes,"//是否可以最大化，yes为1，no为0；
+ "scrollbars=0,"
/*+ "scrollbars=0,"*///是否有滚动条，yes值为1，no值为0,
+ "status=0," 
+ "titlebar=0,"
+ "toolbar=0,"
+ "hotkeys=0,"
+ "screenx=" + xposition + "," //仅适用于Netscape
+ "screeny=" + yposition + "," //仅适用于Netscape
+ "left=" + xposition + "," //IE
+ "top=" + yposition; //IE 
window.open( url,winName,theproperty );
}
//链接

function link(url){
	window.location.href=url;
}
//弹出模式窗口
function popboxshow(sUrl,winName, iwidth, iheight)
{
	sFeatures = "dialogWidth:"+iwidth+"px;dialogHeight:"+iheight+"px;  certer: no; help:no; resizable: no; tustatus: no;status:no;";
	window.showModalDialog(sUrl,winName,sFeatures);
}

/*
function addActivity() {
	sFeatures = "dialogWidth:712px; dialogHeight:531px; certer:yes; help:no; resizable:no; tustatus:no; status:no;scroll:no;";
	url = "addActivity.htm";
	result = window.showModalDialog(url,"",sFeatures);
	if (result!="")
		document.location.replace("editFlow1.htm");
}
*/
/*有返回值的模式窗口*/
function popbox(sUrl,xUrl,iwidth,iheight) {
	sFeatures = "dialogWidth:"+iwidth+"px;dialogHeight:"+iheight+"px;  certer: no; help:no; resizable: no; tustatus: no;status:no;";
	result = window.showModalDialog(sUrl,"",sFeatures);
	if (result!="")
		document.location.replace(xUrl);
}

function indexpop(sURL)
{
	/*模式窗口
	var screenwidth=screen.width-160;
	var screenheight=screen.height-109;
	window.showModalDialog(sURL,self, 'dialogHeight: '+screenheight+'px; dialogWidth: '+screenwidth+'px;dialogTop: 55;dialogLeft: 155;center: yes; status=no;help:no;');
	*/
   var iWidth = 0 ;
   var iHeight = 0 ;
   iWidth=window.screen.availWidth-165;
   //iWidth=window.screen.availWidth-10;
   //iHeight=window.screen.availHeight-216;
   iHeight=window.screen.availHeight-146;
   xposition=0;
   yposition=0;
	if ((parseInt(navigator.appVersion) >= 4 ))
	{
	xposition = (screen.width-10 - iWidth) / 2;
	yposition = (screen.height-30 - iHeight) / 2;
	}

	theproperty= "width=" + iWidth + "," 
	+ "height=" + iHeight + "," 
	+ "location=0," 
	+ "menubar=0,"
	+ "resizable=1,"//是否可以最大化，yes为1，no为0；
	+ "scrollbars=1,"
	/*+ "scrollbars=0,"*///是否有滚动条，yes值为1，no值为0,
	+ "status=1," 
	+ "titlebar=0,"
	+ "toolbar=0,"
	+ "hotkeys=0,"
	+ "screenx=" + xposition + "," //仅适用于Netscape
	+ "screeny=" + yposition + "," //仅适用于Netscape
	//+ "left=153," //IE
	//+ "top=168"//IE 
	+ "left=155," //IE
	+ "top=94"//IE 
	window.open(sURL,'',theproperty);
}

function showMessage(msg,url)
{
	if(msg!=null && msg!="")
		alert(msg);
	if(url!=null && url!="")
		window.location.href=url;
}

function checkNumber(str,requied) {
	if(!requied)
	{
		if(str==null || str.length<1)
			return true;
	}
    var i;
    var len = str.length;
    var chkStr = "1234567890";
    if (len == 1) {
    if (chkStr.indexOf(str.charAt(i)) < 0) {
        return false;
    }
    } else {
    //comment by SJNS/TaoWeisong @ 2001/05/14
    //aim: '0012' is number
    //if ((chkStr.indexOf(str.charAt(0)) < 0) || (str.charAt(0) == "0")) {
    if ((chkStr.indexOf(str.charAt(0)) < 0)) {
        return false;
    }
     for (i = 1; i < len; i++) {
        if (chkStr.indexOf(str.charAt(i)) < 0) {
                return false;
        }
    }
    }
    return true;
}

function checkEmail(str,requied) {
	if(!requied)
	{
		if(str==null || str.length<1)
			return true;
	}
    var addressPos = 0;
    if((addressPos=str.indexOf("<")) != -1)
        str = str.substring(addressPos+1,str.length-1);
    var i;
    var len = str.length;
    var aPos = str.indexOf("@");
    var dPos = str.indexOf(".");
    var aaPos = str.indexOf("@@");
    var adPos = str.indexOf("@.");
    var ddPos = str.indexOf("..");
    var daPos = str.indexOf(".@");
    var chkStr = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890-_@.";
//	if ((aPos <= 0) || (aPos == len - 1) || (dPos <= 0) || (dPos == len - 1) ||	(adPos > 0) || (daPos > 0) ||
//      remove by SJNS/zq in order to use Mail at intranet like admin@mailhost, this mail address is ok.
    if ((aPos <= 0) || (aPos == len - 1) || (dPos == len - 1) ||	(adPos > 0) || (daPos > 0) ||
        (str.charAt(len - 1) == "@") || (str.charAt(len - 1) == ".") || (aaPos > 0) || (ddPos > 0)) {
        return false;
    }
	if(dPos<=0)
		return false;
    if (str.indexOf("@", aPos + 1) > 0) {
        return false;
    }

    return true;
}

/**
* 判断整个页面是否有被选中的checkbox
*/
function IsSelected(){
   for(var i=0;i<document.all.length;i++){
       	if(document.all[i].tagName.toUpperCase() =="INPUT"){
            var tmp = document.all[i].type.toUpperCase();
            if((tmp == "CHECKBOX")&&(document.all[i].checked == true)){
                return true;
            }
        }
    }
    return false;
}

/**
*判断指定名字的checkbox是否被选中
*/
function validCheckBox(chkbox)
{

	if(!chkbox)
	{
		return false;
	}

	if(chkbox.length==undefined)
	{
		if(chkbox.checked)
		{
			return true;
		}

		return false;
	}
	for(var i=0;i<chkbox.length;i++)
	{
		if(chkbox[i].checked)
		{
			return true;
		}
	}
	return false;
}

   function formatFloat(value,digits)
   { 
      digits = digits==null?2:digits;
    var baseValue = Math.pow(10,digits);
    value = Math.round(parseFloat(value)*baseValue)/baseValue;
    // alert(value.toString().indexOf(".")+1);
	 var kk = value.toString().indexOf(".")+1;
	// alert("kk="+kk);
    value = value.toString();
	var mm = value.substr(kk).length;
// alert("mm="+mm);
  //  digits = digits - mm ;
  //  alert("digits="+digits);
    if(value.indexOf(".")<0  )
    {
     if(value.indexOf(".")<0) value += ".";
     for(var i=0;i<digits;i++)
      {
	  value += "0";}
    }
    
    return value;
   }

function CheckCaValid(ret)
{

	if(ret==10)
	{
		return true;
	}
	else
	{
		if(ret==-1)
		{
			alert("CVM初始化错误");
		}
		else if(ret==1)
		{
			alert("您的数字证书已过期！");
		}
		else if(ret==2)
		{
			alert("您的数字证书已被吊销！");
		}
		else if(ret==3)
		{
			alert("您的数字证书颁发者不被平台支持！");
		}
		else if(ret==4)
		{
			alert("您的数字证书颁发者不被平台支持！");
		}
		else if(ret==5)
		{
			alert("您的数字证书CLR不可用！");
		}
		else if(ret==6)
		{
			alert("您的数字证书已被吊销并且已过期！");
		}
		else if(ret==7)
		{
			alert("您的数字证书状态未知！");
		}
		else if(ret==8)
		{
			alert("您的数字证书状态未知！");
		}
		 return false;
	}
	
	return true;
}
