
function getdate(textId,btnId,isTimeNotReqd){
YAHOO.util.Event.onDOMReady(function(){
        var Event = YAHOO.util.Event,
            Dom = YAHOO.util.Dom,
            dialog,
            calendar;
        var showBtn = Dom.get(btnId);
			var selectedDate;
			var selectedTime;
			if(textId) {
				var trimDate = YAHOO.lang.trim(Dom.get(textId).value);
				
				// for MM/dd/yyyy HH:mm:ss and for yyyy/MM/dd HH:mm:ss.SSS
				if(trimDate.length>0 && trimDate.indexOf('/')!=-1){
					selectedTime = trimDate.substring(trimDate.length-8);
					selectedDate = trimDate.substring(0,trimDate.length-9);
				}else if(trimDate.length>0 && trimDate.indexOf('-')!=-1){
					selectedTime = trimDate.substring(trimDate.length-10,trimDate.length-2);
					selectedDate = trimDate.substring(0,trimDate.length-11);
					var selectedDatearry = selectedDate.split("-");
					if(selectedDatearry && selectedDatearry.length==3){
					selectedDate = selectedDatearry[1] +'/'+ selectedDatearry[2] +'/' +selectedDatearry[0];
					}

				}
			}
					

            // Lazy Dialog Creation - Wait to create the Dialog, and setup document click listeners, until the first time the button is clicked.
            if (!dialog) {

                // Hide Calendar if we click anywhere in the document other than the calendar
                Event.on(document, "click", function(e) {
                    var el = Event.getTarget(e);
                    var dialogEl = dialog.element;
                    if (el != dialogEl && !Dom.isAncestor(dialogEl, el) && el != showBtn && !Dom.isAncestor(showBtn, el)) {
                        dialog.hide();
                    }
                });

                function resetHandler() {
                    // Reset the current calendar page to the select date, or 
                    // to today if nothing is selected.
                    var selDates = calendar.getSelectedDates();
                    var resetDate;
        
                    if (selDates.length > 0) {
                        resetDate = selDates[0];
                    } else {
                        resetDate = calendar.today;
                    }
					
                    calendar.cfg.setProperty("pagedate", resetDate);
                    calendar.render();
                }
        
                function closeHandler() {
                    dialog.hide();
                }

                dialog = new YAHOO.widget.Dialog("container", {
                    visible:false,
                    context:[btnId, "tl", "bl"],
                   // buttons:[ {text:"Reset", handler: resetHandler, isDefault:true}, {text:"Close", handler: closeHandler}],
                    draggable:false,
                    close:true
                });
                if(isTimeNotReqd){
					dialog.setHeader('Pick A Date');
					dialog.setBody('<div id="cal"></div>');
                }else{
					dialog.setHeader('Pick A Date With Time');
					var body = "<div id='time' style='padding:5px;background-color:#F7F9FB;border:1px solid #7B9EBD;_overflow:hidden;text-align:left;'>Time: &nbsp;<select id='hr'><option value='00' selected>00</option><option value='01'>01</option><option value='02'>02</option><option value='03'>03</option><option value='04'>04</option><option value='05'>05</option><option value='06'>06</option><option value='07'>07</option><option value='08'>08</option><option value='09'>09</option><option value='10'>10</option><option value='11'>11</option><option value='12'>12</option><option value='13'>13</option><option value='14'>14</option><option value='15'>15</option><option value='16'>16</option><option value='17'>17</option><option value='18'>18</option><option value='19'>19</option><option value='20'>20</option><option value='21'>21</option><option value='22'>22</option><option value='23'>23</option> </select>&nbsp;<select id='min'><option value='00' selected>00</option><option value='01'>01</option><option value='02'>02</option><option value='03'>03</option><option value='04'>04</option><option value='05'>05</option><option value='06'>06</option><option value='07'>07</option><option value='08'>08</option><option value='09'>09</option><option value='10'>10</option><option value='11'>11</option><option value='12'>12</option><option value='13'>13</option><option value='14'>14</option><option value='15'>15</option><option value='16'>16</option><option value='17'>17</option><option value='18'>18</option><option value='19'>19</option><option value='20'>20</option><option value='21'>21</option><option value='22'>22</option><option value='23'>23</option><option value='24'>24</option><option value='25'>25</option><option value='25'>26</option><option value='27'>27</option><option value='28'>28</option><option value='29'>29</option><option value='30'>30</option><option value='31'>31</option><option value='32'>32</option><option value='33'>33</option><option value='34'>34</option><option value='35'>35</option><option value='36'>36</option><option value='37'>37</option><option value='38'>38</option><option value='39'>39</option><option value='40'>40</option><option value='41'>41</option><option value='42'>42</option><option value='43'>43</option><option value='44'>44</option><option value='45'>45</option><option value='46'>46</option><option value='47'>47</option><option value='48'>48</option><option value='49'>49</option><option value='50'>50</option><option value='51'>51</option><option value='52'>51</option><option value='53'>53</option><option value='54'>54</option><option value='55'>55</option><option value='56'>56</option><option value='57'>57</option><option value='58'>58</option><option value='59'>59</option></select></div><div id='cal'></div>";
					dialog.setBody(body);
				}
                
                dialog.render(document.body);

                dialog.showEvent.subscribe(function() {
                    if (YAHOO.env.ua.ie) {
                        // Since we're hiding the table using yui-overlay-hidden, we 
                        // want to let the dialog know that the content size has changed, when
                        // shown
                        dialog.fireEvent("changeContent");
                    }
                });
            }

            // Lazy Calendar Creation - Wait to create the Calendar until the first time the button is clicked.
            if (!calendar) {
                calendar = new YAHOO.widget.Calendar("cal", {
                    iframe:false,          // Turn iframe off, since container has iframe support.
                    hide_blank_weeks:true,  // Enable, to demonstrate how we handle changing height, using changeContent
               		navigator:true		// Enabling user to navigate calendar to any year.
                });
				
					if(isTimeNotReqd){
					
					}else{
					var currentDate = new Date();
					var hour = Dom.get("hr");
					var minutes = Dom.get("min");
					if(hour && minutes && currentDate){
					var currentHour = currentDate.getHours()+'';
					var currentMinute = currentDate.getMinutes()+'';
					if(currentHour && currentHour.length==1)
					currentHour = "0"+currentHour;
					if(currentMinute && currentMinute.length==1)
					currentMinute = "0"+currentMinute;
					hour.selectedIndex=currentHour;
					minutes.selectedIndex=currentMinute;
					}
					}
				if(selectedDate)
					calendar.cfg.setProperty("selected", selectedDate);

				calendar.render();
				if(isTimeNotReqd && selectedTime){
				
				}else if(selectedTime && selectedTime.indexOf(':')!=-1){
					var arry = selectedTime.split(":");
					var hour = Dom.get("hr");
					var minutes = Dom.get("min");
					var h = arry[0];
					var m = arry[1];
					hour.selectedIndex=h;
					minutes.selectedIndex=m;
				}
				
                calendar.selectEvent.subscribe(function() {
                    if (calendar.getSelectedDates().length > 0) {
						
                        var selDate = calendar.getSelectedDates()[0];
						//MM/dd/yyyy HH:mm:ss
                        // Pretty Date Output, using Calendar's Locale values: Friday, 8 February 2008
                        var wStr = calendar.cfg.getProperty("WEEKDAYS_LONG")[selDate.getDay()];
                        var dStr = selDate.getDate();
						var ddStr = dStr +""; 
						var mmStr = selDate.getMonth()+1;
						var mStr = mmStr+"";
						
						if(mStr.length==1)	
							mStr = "0"+mStr;
						
						if(ddStr.length==1)	
							ddStr = "0"+ddStr;

                        //var mStr = calendar.cfg.getProperty("MONTHS_LONG")[selDate.getMonth()];
                        var yStr = selDate.getFullYear();
        				
						if(isTimeNotReqd){
							Dom.get(textId).value = mStr + "/" + ddStr + "/" + yStr + " 00:00:00";
						}else{
        				var hour = Dom.get("hr");
                       	var minutes = Dom.get("min");
                       	if(hour && minutes){
                       	var timeDetails = hour.options[hour.selectedIndex].value+":"+minutes.options[minutes.selectedIndex].text+":00";
                       		Dom.get(textId).value = mStr + "/" + ddStr + "/" + yStr + " "+timeDetails;
                   		}else
                   			Dom.get(textId).value = mStr + "/" + ddStr + "/" + yStr +" 00:00:00";
                   		}
                    } else {
						
                        Dom.get(textId).value = "";
                    }
                    dialog.hide();
                });

                calendar.renderEvent.subscribe(function() {
                    // Tell Dialog it's contents have changed, which allows 
                    // container to redraw the underlay (for IE6/Safari2)
                    dialog.fireEvent("changeContent");
                });
            }
		
            var seldate = calendar.getSelectedDates();
			
            if (seldate && seldate.length > 0) {
                // Set the pagedate to show the selected date if it exists
                calendar.cfg.setProperty("pagedate", seldate[0]);
			
                calendar.render();
            }

            dialog.show();
        
    });};