
var iFlag=0;
function click11(){
var temp;
temp=window.event.srcElement.type;

if (temp=="checkbox" ||temp=="radio" || temp=="button" || temp=="select-one"){
       ++iFlag;
     }
}
function keypress11(){
 /* // ESC keyŁ¬close this page
    var KEY_ESC = 27
    if (event.keyCode == KEY_ESC) {
	    event.keyCode =null;
        winClose();
		return false;
     }
	*/ 
//alert(event.keyCode);
var temp;
temp=window.event.srcElement.type;
if (temp=="text" || temp=="password" || temp=="textarea"){
       ++iFlag;
  }
}

document.onclick=click11;
document.onkeyup=keypress11;

function winClose(){
  if (iFlag<1){ 
   // window.opener=null;  
   // window.close();
	//window.parent.parent.opener=null;
	window.parent.parent.close();
   }
  else{
    openDialog();
   }
}

function openDialog(){
  stats='toolbar=no;location=no;directories=no;titlebar=no;status=no;menubar=no;help=no;dependent=1;';
  stats += 'scrollbars=no;dialogWidth=300px;dialogHeight=220px;dialogLeft='+(screen.width/2-150)+';dialogTop='+(screen.height/2-100)+';';
  var url='/mars/shared/saveOrNo.jsp';
  var iSaveOrNo=window.showModalDialog(url,"dialog",stats);
  if (iSaveOrNo==1){
        formSubmit();	 
  }
  else if (iSaveOrNo==2){
      // window.opener=null;
      // window.close();
	 //  window.parent.parent.opener=null;
	   window.parent.parent.close();
  }
  else if (iSaveOrNo==3){     
  }
}

function trim()
{
	var formObj = document.form1;
	for (i = 0; i < formObj.length; i++) 
	{			
		var el = formObj.elements[i];
		el.value=el.value.replace(/^ + /,"").replace(/ + $/,"");
		
		
	}
}
/* //the formName is not all same in the different pages ,
   //so below codes need be copy to the page and modifty the formName to 
   //the form name in the page ,
   //and add two input <input name="p_close" type="hidden" value="0"> .
   //<input type="button" name='btn_close' onClick="winClose();" value='<%=session.getAttribute("btn.close")%>'> in form
function formSubmit(){
   formName.p_close.value=1;
   return SubmitCheckForm(); 
   formName.submit();
 }  
 
*/

/*
//should need  add  below two line codes in the Action page
String strClose= request.getParameter("p_close");

if (strClose.equals("1")){
out.print("<script language='JavaScript'>self.close();</script>");
  }
else{
  // response.sendRedirect("user.jsp"); // do the originally doing	
}						
		
%>
*/