function fPopUpDlg(endtarget,ctl,WINname,WINwidth,WINheight){	
	showx = (screen.width - WINwidth)/2  ; // + deltaX;
	showy = (screen.height - WINheight)/2; // + deltaY;
	SetCookieEx("PopUpURL",endtarget);
	var features =
		'dialogWidth:'  + WINwidth  + 'px;' +
		'dialogHeight:' + WINheight + 'px;' +
		'dialogLeft:'   + showx     + 'px;' +
		'dialogTop:'    + showy     + 'px;' +
		'directories:no; localtion:no; menubar:no; status=no; toolbar=no;scrollbars:yes;Resizeable=no';	
	retval = window.showModalDialog("/manage/include/dialog/index.html",WINname,features );
	if( retval != null ){
		ctl.value = retval;
	}else{
		//alert("canceled");
	}
	return retval;
}
function fPopUpDlgEx(endtarget,ctl,WINname,WINwidth,WINheight){	
	showx =  WINwidth - 60  ; // + deltaX;
	showy = WINheight -100 ; // + deltaY;
	newWINwidth = WINwidth + 4 + 18;
	var features =
		'dialogWidth:'  + newWINwidth  + 'px;' +
		'dialogHeight:' + WINheight + 'px;' +
		'dialogLeft:'   + showx     + 'px;' +
		'dialogTop:'    + showy     + 'px;' +
		'directories:no; localtion:no; menubar:no; status=no; toolbar=no;scrollbars:yes;Resizeable=no';	
	retval = window.showModalDialog(endtarget, WINname , features );
	if( retval != null ){
		ctl.value = retval;
	}else{
		//alert("canceled");
	}
}
function ShowPopModalDlg(url,w,h){
	showx = (screen.width - w)/2  ; // + deltaX;
	showy = (screen.height - h)/2; // + deltaY;
	SetCookieEx("PopUpURL",url);
	var features =
		'dialogWidth:'  + w  + 'px;' +
		'dialogHeight:' + h + 'px;' +
		'dialogLeft:'   + showx     + 'px;' +
		'dialogTop:'    + showy     + 'px;' +
		'directories:no; localtion:no; menubar:no; status=no; toolbar=no;scrollbars:yes;Resizeable=no';
	var retval = window.showModalDialog("/manage/include/dialog/index.html","_blank",features );
	return retval;
}
function OpenWindow(URL,WindowName,Width,Height,Left,Top,Scro){window.open(URL,WindowName,'width='+Width+',height='+Height+',left='+Left+',top='+Top+',toolbar=no,menubar=no,scrollbars='+Scro)}
function OpenCenterWindow(URL,WindowName,Width,Height,scroll){
    startx = (screen.width/2) - (Width/2);
    starty = (screen.height/2) - (Height/2) - 60;
	if(starty >=60){
		starty = starty - 60;
	}else{
		starty = 0;
	}
    window.open(URL,WindowName,"width=" + Width+",height=" + Height + ",top=" + starty + ",left=" + startx + ",scrollbars=" + scroll + ",statu=1");
}
function CheckDelSel(ButtonValue){
var isselected=0;
	if(form2.TID!=null){
		if(form2.TID.length==null){if(form2.TID.checked==true){isselected=1}}
		else{for(var i=0;i<form2.TID.length;i++){if(form2.TID[i].checked==true){isselected=1;break;}}}
	}
	if(form2.CID!=null){
			if(form2.CID.length==null){if(form2.CID.checked==true){isselected=1}}
			else{for(var i=0;i<form2.CID.length;i++){if(form2.CID[i].checked==true){isselected=1;break;}}}
		}
	if(isselected==0){
		alert("请选择你要"+ButtonValue+"的内容！");
	}else{
		if(confirm("你确认要"+ButtonValue+"选中的内容吗？")){
			form2.button.value=ButtonValue;
			form2.submit();
		}
	}			
}

function doSelCheckBox(varsel,varto)
{
  try{
   if(confirm("确定要执行么？"))
   {
     var selobj = eval("document.all." + varsel);
     var toobj = eval("document.all." + varto);
     var objnum = selobj.length;
     if(objnum!=undefined)
     {
		var selnum = 0;
		var strsel = "";
		for(var i=0;i<objnum;i++)
		{
			var objitem = eval("document.all." + varsel + "[" + i + "]");
			if(objitem.checked)
			{
				//如果有选择项，则赋值
				if(selnum == 0)
				 strsel +=objitem.value;
				else
				 strsel += "," + objitem.value;
				selnum += 1;
			}
		}
		if(selnum == 0)
		{
		 alert("还没有选择任何一条记录");
		 return false;
		}
		else
		{
		 toobj.value = strsel;
		 return true;
		}
     }
     else
     {
	   //////////////////////////////
       if(selobj.value!=undefined)
       {
         if(selobj.checked)
         {
           toobj.value = selobj.value;
           return true;
         }
         else
         {
			alert("没有选择任何一条记录");
			return false;
         }
       }
       else
	   {
			alert("无法选择");
			return false;
	   }
	 ////////////////////////////////
     }
   }
   else
   {
     return false;
   }
  }catch(e)
  {
     alert("可能没有选择足够的条件以完成操作");
     return false;
  }
}
function showflash(url,divobj){
	var tmp = "";
	tmp += "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0\" width=\"585\" height=\"181\">\r\n";
    tmp += "<param name=\"movie\" value=\"" + url + "\">\r\n";
    tmp += "<param name=\"quality\" value=\"high\">\r\n";
	tmp += "<param name=\"wmode\" value=\"opaque\" />"
    tmp += "<embed src=\"" + url + "\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width=\"585\" height=\"181\"></embed>\r\n";
    tmp += "</object>\r\n";
	divobj.innerHTML = tmp;
}
function ismail(str)
{
	if(str.indexOf('@')<1) return false;
	var a;a=new Array(2);
	a=str.split('@');if(a.length!=2) return false;
	username=a[0];servername=a[1]
	if(username.length<2) return false;
	if(servername.length<6) return false;
	if(servername.indexOf('.')<1) return false;
	return true;
}
function isdate(str)
{
var	a,b
a=new Array(10)
a=str.split('-');
if(a.length!=3){
	return false;
}
b=new Array(13);b[1]=31;b[2]=28;b[3]=31;b[4]=30;b[5]=31;b[6]=30;b[7]=31;b[8]=31;b[9]=30;b[10]=31;b[11]=30;b[12]=31;y=a[0];m=a[1];d=a[2];
if(!(IsN(y,1900,2069))){
	return false;
}
if(!(IsN(m,1,12))){
	return false;
}
if((((y%4==0)&&(y%100!=0))||(y%400==0))&&(m==2)){
	if(!(IsN(d,1,29))){
		return false;
	}
}
else{
	if(!(IsN(d,1,b[m]))){
		return false;
	}
}
return true;
}
function IsN(x,l,u){
	if(x<l){
		return false;
	}
	else{
		if(x>=l){
			if(x>u){
				return false;
			}
			else{ 
				return true;
			}
		}
		else{
			return false;
		}
	}
}

function InputFile(FormName,ElementName){
	tmp=eval(FormName+"."+ElementName);
	File=tmp.value;
	OpenWindow('/manage/include/upload/inputfile.asp?ClassID=<%=ClassID%>&FormName='+FormName+'&ElementName='+ElementName,'Uploadfile','430','152','100','190','no')
}

function DelFile(FormName,ElementName){
	tmp=eval(FormName+"."+ElementName);
	File=tmp.value;
	OpenWindow('/manage/include/upload/delfile.asp?ClassID=<%=ClassID%>&File='+File+'&FormName='+FormName+'&ElementName='+ElementName,'DelFile',"250","100","200","200","no");
}

function Look(FormName,ElementName){
	tmp=eval(FormName+"."+ElementName);
	File=tmp.value;
	OpenWindow('/manage/include/upload/lookfile.asp?ClassID=<%=ClassID%>&File='+File,'LookFile',"600","400","100","100","yes");
}
function SetCookieEx(name, value) 
{
	try{
		var argv = SetCookieEx.arguments;
		var argc = SetCookieEx.arguments.length;  
		var expires = (argc > 2) ? argv[2] : null;  
		//var path = (argc > 3) ? argv[3] : null;  
		var domain = (argc > 4) ? argv[4] : null;  
		var secure = (argc > 5) ? argv[5] : false;  
		var path = "/"; //allows the tree to remain open across pages with diff names & paths

		document.cookie = name + "=" + escape (value) + 
		((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + 
		((path == null) ? "" : ("; path=" + path)) +  
		((domain == null) ? "" : ("; domain=" + domain)) +    
		((secure == true) ? "; secure" : "");
	}catch(e){
		alert(e);
	}
}

function ExpireCookieEx(name) 
{  
	var exp = new Date();  
	exp.setTime (exp.getTime() - 1);  
	var cval = GetCookieEx(name);  
	document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}
function GetCookieEx(name)
{  
	var arg = name + "=";  
	var alen = arg.length;  
	var clen = document.cookie.length;  
	var i = 0;  
	while (i < clen) {    
		var j = i + alen;    
		if (document.cookie.substring(i, j) == arg)      
			return getCookieValEx(j);    
		i = document.cookie.indexOf(" ", i) + 1;    
		if (i == 0) break;   
	}  
	return null;
}
function getCookieValEx(offset) {  
	var endstr = document.cookie.indexOf (";", offset);  
	if (endstr == -1)    
	endstr = document.cookie.length;  
	return unescape(document.cookie.substring(offset, endstr));
}
function getSelCheckBox(varsel)
{
  try{
   if(1==1)
   {
     var selobj = eval("document.all." + varsel);
     var objnum = selobj.length;
     if(objnum!=undefined)
     {
		var selnum = 0;
		var strsel = "";
		for(var i=0;i<objnum;i++)
		{
			var objitem = eval("document.all." + varsel + "[" + i + "]");
			if(objitem.checked)
			{
				//如果有选择项，则赋值
				if(selnum == 0)
				 strsel +=objitem.value;
				else
				 strsel += "," + objitem.value;
				selnum += 1;
			}
		}
		if(selnum == 0)
		{
		 return "";
		}
		else
		{
		 return strsel;
		}
     }
     else
     {
	   //////////////////////////////
       if(selobj.value!=undefined)
       {
         if(selobj.checked)
         {
           return selobj.value;
         }
         else
         {
			 return "";
         }
       }
       else
	   {
			return "";
	   }
	 ////////////////////////////////
     }
   }
   else
   {
     return "";
   }
  }catch(e)
  {
     alert("可能没有选择足够的条件以完成操作");
     return "";
  }
}
function scalePhoto(imgId,width,height){
	var img = document.getElementById(imgId);
	if(img!= null && img!=undefined){
		var imgWidth = img.width;
		var imgHeight = img.height; 
		if(imgWidth>width&&imgHeight>height){
			//both image's width and height are larger than required one
			var widthRate = imgWidth/width;
			var heightRate = imgHeight/height;
			if(widthRate>heightRate){
				//use width to retrieve the image
				img.width=width;
				img.height=imgHeight*(width/imgWidth);
			}else{
				img.height=height;
				img.width=imgWidth*(height/imgHeight);
			}
		}else if(imgWidth>width){
				//the image width lg than the required width
				img.width=width;
				img.height=imgHeight*(width/imgWidth);
		}else if(imgHeight>height){
				//the image height lg than the required
				img.height=height;
				img.width=imgWidth*(height/imgHeight);
		}
	}
}
function jtrim(s)
{
var i,b=0,e=s.length;
for(i=0;i<s.length;i++) if(s.charAt(i)!=' '){b=i;break;}
if(i==s.length) return "";
for(i=s.length-1;i>b;i--) if(s.charAt(i)!=' '){e=i;break;}
return s.substring(b,e+1);
}
function PopUpInputFileEx(ClassID,FileList,resultObj){
	var filename = ShowPopModalDlg("../manage/include/UploadEx/InputFileEx.asp?ClassID=" + ClassID+"&FileList="+FileList,440,210);
	if(jtrim(filename)!='' && filename!=undefined){
		resultObj.value = filename;
	}
}
function removeFromArray(srclist,strRemove,strSplit){
	var strTemp = "";
	var arrlist = srclist.split(strSplit);
	for(var i=0;i<arrlist.length;i++){
		if(arrlist[i]!=strRemove){
			if(strTemp==""){
				strTemp = arrlist[i]
			}else{
				strTemp += strSplit + arrlist[i];
			}
		}
	}
	return strTemp;
}