/*
<SCRIPT language="JavaScript">
 function checkvalue(){
    var x;
    var y=0;
    x = Title(window.document.forms[0].number,"标准编号不能为空！");
    if(x==0){y=y+1;}
    x = Title(window.document.forms[0].name,"标准名称不能为空！");
    if(x==0){y=y+1;}
    x = Title(window.document.forms[0].issueunit,"发布单位不能为空！");
    if(x==0){y=y+1;}
    x =wordType(window.document.forms[0].word,"请检查上传文件类型，此处只允许上传word文件！")
    if(x==0){y=y+1;}
    if( y == 0 )
    {
        window.document.forms[0].submit();
    }

}
</SCRIPT>
*/

//删除确认,"确定要删除吗？\n  如果您点确定您选中的信息将被删除！"
function Del(url,Mess){
	if(confirm(Mess) ){
        window.location.href=url;
	}
	else{
      	return;
    }
}

//弹出窗口，url处为具体网页地址
function OpenWindow(url,wid,high){    
	window.open(url,'','left=130,top=110,height='+high+', width='+wid+',Status=yes,toolbar=no,menubar=no,scrollbars=yes,resizable=yes')    
}

//首页弹出
function indexOpen(url)
{
chitchat=window.open(url,'tt','Status=yes,scrollbars=no,resizable=yes')
//'indexfirst.jsp'
chitchat.moveTo(0,0)
chitchat.resizeTo(screen.availWidth,screen.availHeight)
chitchat.outerWidth=screen.availWidth
chitchat.outerHeight=screen.availHeight
}

//退出系统
function Exit(){
	if(confirm("真的要退出系统吗？") ){ 
		window.parent.close();
	}
	else{
		return;
	}
}



//更新框架
function ReFresh(){
	window.frames.refresh();
}

//检查表单长度是否为空
function Title(TitleForm,Mess){
	//表单不能为空
	if(TitleForm.value.length == 0){
		window.alert(Mess);
		return 0;
	}
}

//检查表单长度是否符合条件,Form.Table.value.length
function File(FileForm,Mess,len){
	if(TitleForm > len){
		window.alert(Mess);
		return ;
	}
}

//检查字符串最小长度
function MinLen(item,col,len){ 
	if (item.value.length < len) error(item,col,"您输入的长度不够，请输入至少 "+len+" 位");
}

//检查字符串长度，比如邮编
function EqualLen(item,col,len){ 
	if (item.value.length != len) error(item,col,"您输入的长度不够，应输入 "+len+" 位");
}

//附件名称不得大于len-4个字，Form.Table.value
function FileLen(FileTypeForm,Mess,len){
	if(FileTypeForm.length!=0){
	    var filetag=0
	    var filetag1=0;
	    var filetag2=0;
	    var filetag3=0;
        var filename=FileTypeForm;

        filetag2=FileTypeForm.length;
        filetag1=filename.lastIndexOf('\\');
        filetag = filename.substring(filetag1+1);//取出附件名
        filetag3=filetag2-filetag1-1;
  	    if(filetag3 > len){
           window.alert(Mess);
	       return ;
		}	        
	}
}

//上传mht文件类型，比如：上传的图片的类型必须是（*.jpg,*.gif），Form.Table
function htmlType(FileTypeForm,Mess){
	if(FileTypeForm.value.length!=0){
		var filetag=0
	    var filetag1=0;
        var filename=FileTypeForm.value;
        var filetype=new Array(".mht",".MHT",".mhtml",".MHTML");
        for(var j=0;j<4;j++){
        	filetag1=filename.indexOf(filetype[j]);
  	        if(filetag1!=-1){
  	 	    	filetag=1;
  		    }		     
  	    }
		if(filetag==0){
        	window.alert(Mess);
	        return 0;
		}
	}
}
//检索上传的 word文件类型
function wordType(FileTypeForm,Mess){
	if(FileTypeForm.value.length!=0){
		var filetag=0
	    var filetag1=0;
        var filename=FileTypeForm.value;
        var filetype=new Array(".doc",".DOC",".dot",".DOT");
        for(var j=0;j<4;j++){
        	filetag1=filename.indexOf(filetype[j]);
  	        if(filetag1!=-1){
  	 	    	filetag=1;
  		    }
  	    }
		if(filetag==0){
        	window.alert(Mess);
	        return 0;
		}
	}
}


//判断输入的必须为整数，编号必须输入整数，Form.Table.value
function Num(NumForm,Mess){  

	var strTemp="0123456789";
	var aa=NumForm;
	var bb=NumForm.length
	var j='0';

	for (var i=0;i<bb;i++){
		j = strTemp.indexOf(aa.charAt(i)); 
		if (j==-1){
			window.alert(Mess);
			return ;        
		}
	
	}     
}

//检查邮编的合法性
function PostCode(){			
	var s = window.event.keyCode;
	if (!(((s>=48) && (s<= 57)) || s==45 || (s==62)|| (s==13)||(s==27))){
		alert("对不起，该字符为非法字符！\n请您重新输入!例如：050054");
		window.event.keyCode = 0 ;
	}
}

// 检查EMAIL的合法性EmailForm包括表单名
function Email(EmailForm,Mess){
	if (EmailForm.value.length>0){  
		//输入了非法的EMAIL
		if (EmailForm.value.length<6){
			alert(Mess);
			EmailForm.value="";
			EmailForm.focus();
			return false;
		}
		//输入了非法的EMAIL地址或者EMAIL地址中含有非法字符
		if ((EmailForm.value.indexOf("@",0) == -1) || (EmailForm.value.indexOf(".",0) == -1) || (EmailForm.value.indexOf("'",0) != -1)||(EmailForm.value.indexOf("@.",0)!= -1)){
			alert(Mess);
			EmailForm.value="";
			EmailForm.focus();
			return false;
		}
	}
}

//检查日期合法性
function CheckDate(DateForm,col){
	if (DateForm.value.length>0){
		var year=0,month=0,day=0,n=0,i;
		var yn=0,mn=0,dn=0;
		for (i=0;i<DateForm.value.length;i++){
			var ch=DateForm.value.substring(i,i+1);
			if (ch=="-") {
				n++;
			}
			else{
				if ("0"<=ch && ch<="9"){
					if (n==0){
						year=year*10+parseInt(ch);yn++;
					}
					if (n==1){
						month=month*10+parseInt(ch);mn++;
					}
					if (n==2){
						day=day*10+parseInt(ch);dn++;
					}
				}
				else {
					error(DateForm,col,"请不要输入无关字符");
				}
			}
		}
		if (n!=2) 
			error(DateForm,col,"您输入了非法的日期\n\n正确的日期格式为YYYY-MM-DD，如2000-01-01为2000年1月1日\n年份必须输入4位");
		if (year<1800 || year>3000 || yn>4) 
			error(DateForm,col,"年份输入错误\n请输入1800～3000之间的年份");
		if ((year%4==0&&year%100!=0)||(year%400==0))
			leap=1;
		else
			leap=0; 
			if (month>12 || month<1  ) error(DateForm,col,"月份输入错误");
			else{
				switch (month){  
					case 1 :
					case 3 :
					case 5 :
					case 7 :
					case 8 :
					case 10 :
					case 12 :rq=31;break;
					case 4 :
					case 6 :
					case 9 :
					case 11 :rq=30;break;
					case 2 :  
					if  (leap==1) 
						rq=29;
					else  
						rq=28;
				}    
	
			if (day>rq || day<1) error(DateForm,col,"日输入错误");
		}
	}
}

//检查两个表单的内容是否相等
function CheckEqual(EqualForm,Table1,Table2,Mess){
	if(EqualForm.Table1.value!=EqualForm.Table2.value) {
		alert(Mess);  
		EmailForm.focus(); 
		return(false); 
	}
}

//检查两个表单的长度是否相等
function CheckEqual(EqualForm,Table1,Table2,Mess){
	if(EqualForm.Table1.value.length!=EqualForm.Table2.value.length) {
		alert(Mess);  
		EmailForm.Table1.focus(); 
		return(false); 
	}
}

//检查录入框值是否是包含给定字串,StrForm.Table
function CheckStrYes(StrForm,Str,Mess){
	if(StrForm.value.indexOf(Str) != 0) {
		alert(Mess);
		StrForm.focus();
		return(false);
	}  
}

//检查录入框值是否是包含给禁止的字串,StrForm.Table
function CheckStrNo(StrForm,Str,Mess){
	if (StrForm.value.length == 0 || StrForm.value.indexOf(Str) != -1) {
		alert(Mess);
		StrForm.focus();
		return(false);
	}  
}

//检查录入框值是否是电话号码
function CheckTel(StrForm,Str,Mess){
	if(fucCheckTEL(document.StrForm.value) == 0) {
		alert(Mess);
		StrForm.focus();
		return(false);
	}	
}
//函数名：fucCheckTEL
//功能介绍：检查是否为电话号码"
//参数说明：要检查的字符串
//返回值：1为是合法，0为不合法" + "\n" +
function fucCheckTEL(TEL){
	var i,j,strTemp;
	strTemp = "0123456789-";
	if (TEL.length == 0) 
		return 0;
	for (i=0;i<TEL.length;i++){
		j=strTemp.indexOf(TEL.charAt(i));
		if (j==-1) {
			//说明有字符不合法
			return 0;
		}
	}
//说明合法" + "\n" +
	return 1;
}

//关闭窗口<input type="button" value="确定" onClick="javascript:addSelectedItemsToParent()">

function addSelectedItemsToParent() {
self.opener.addToParentList(window.document.forms[0].destList);
window.close();
}


//向右添加<input type="button" value=" >> " onClick="javascript:addSrcToDestList()">

// Fill the selcted item list with the items already present in parent.

// Add the selected items from the source to destination list
function addSrcToDestList() {
destList = window.document.forms[0].destList;
srcList = window.document.forms[0].srcList;
var len = destList.length;
for(var i = 0; i < srcList.length; i++) {
if ((srcList.options[i] != null) && (srcList.options[i].selected)) {

//Check if this value already exist in the destList or not
//if not then add it otherwise do not add it.

var found = false;
for(var count = 0; count < len; count++) {
if (destList.options[count] != null) {
var str = srcList.options[i].value;
if (srcList.options[i].value == destList.options[count].text || str.substring(".") > 0) {
found = true;
break;
      }
   }
}
if (found != true) {
destList.options[len] = new Option(srcList.options[i].value);
len++;
         }
      }
   }
}

//从右边删除<input type="button" value=" << " onclick="javascript:deleteFromDestList();">

// Deletes from the destination list.
function deleteFromDestList() {
var destList  = window.document.forms[0].destList;
var len = destList.options.length;
for(var i = (len-1); i >= 0; i--) {
	if ((destList.options[i] != null) && (destList.options[i].selected == true)) {
		destList.options[i] = null;
      	}
   }
}




