   var timerValue = 500,stoptimer;
   var calendarinsession = false;
   var obj1;
   function calendarListener(){
      try{
          bool = win.document.calendarform.applybtn.statusvalue;
          if(bool == "true"){
              value = win.document.calendarform.T2.value;
   	      if(value != null){
   		 if(value.length>1){
   		    obj1.value = value;
   		    win.document.calendarform.applybtn.statusvalue = "false";
		    clearTimeout(stoptimer);
		    obj1.focus();
                    win.close();
		 }
	      }
	  }
	  clearTimeout(stoptimer);
   	  stoptimer = setTimeout('calendarListener()',timerValue);   			
      }catch(e){
        stoptimer = setTimeout('calendarListener()',timerValue);
      }
   }
   
   var win = null;
   var filepath = "http://www.jnarok.com/jos/util/cal/calendar.htm";
   function openCalendar(obj){ 
       obj1 = obj;
       path = filepath;
       win = window.open(path,null,"toolbar=no,height=360,width=310,status=yes,resizable=0");
       win.focus();
       if(calendarinsession == true){
          clearTimeout(stoptimer);    			
       }
       calendarinsession = true;
       stoptimer = setTimeout('calendarListener()',timerValue);	
   }
   function showCalendar(obj){
        value = obj.value;
	obj.value = "";
	obj.value = value;
	
	openCalendar(obj);
   }
   function transferFocus(obj){
	obj.focus();
   }
