
//Initialize variables.
var MinMilli = 1000 * 60;
var HrMilli = MinMilli * 60;
var DyMilli = HrMilli * 24;


function Calendar2(t) {
	var sPath = ServiceContentPath+"/import/html/calendar_1.htm";
	strFeatures = "dialogWidth=206px;dialogHeight=208px;center=yes;help=no;status=no";
	st = t.value;
	sDate = showModalDialog(sPath,st,strFeatures);
	//alert(sDate)
	t.value = formatDate(sDate, 0);
}


function Calendar(t){
	var sPath = ServiceContentPath+"/import/html/calendar_1_new.htm";
	var args='width=175,height=185';
	str = t.value;	
	ModalDialogShow(sPath,str,args,"ReturnMethodCalendar('"+t.id+"')");
}

function ReturnMethodCalendar(id){
	    document.getElementById(id).value = ModalDialog.value;
	    ModalDialogRemoveWatch();
}



function formatDate(sDate) {
	var sScrap = "";
	var dScrap = new Date(sDate);
	if (dScrap == "NaN") return sScrap;

    sScrap = SimpleDateFormat("yyyy/MM/dd",dScrap);
    //alert(sScrap);
	return sScrap;
}

function CalendarWithTime(t) {
	var sPath = ServiceContentPath+"/import/html/calendar_2.htm";
	strFeatures = "dialogWidth=206px;dialogHeight=230px;center=yes;help=no;status=no";
	st = t.value;
	sDate = showModalDialog(sPath,st,strFeatures);
	t.value = formatDateWithTime(sDate, 0);
}

function formatDateWithTime(sDate) {
	var sScrap = "";
	var dScrap = new Date(sDate);
	if (dScrap == "NaN") return sScrap;

	sScrap = SimpleDateFormat("yyyy/MM/dd hh:mm",dScrap);
	return sScrap;
}

function SimpleDateFormat(patten,dScrap){

    iDay = dScrap.getDate();
    iMon = dScrap.getMonth();
    iYea = dScrap.getFullYear();
    iHor = dScrap.getHours();

    if(iHor<10) iHor = "0"+iHor;
    iMin = dScrap.getMinutes();
    if(iMin<10) iMin = "0"+iMin;

    if(patten=="yyyy/MM/dd hh:mm") iDate = iYea + "/" + (iMon + 1) + "/" + iDay +" "+iHor+":"+iMin;
    else iDate = iYea + "/" + (iMon + 1) + "/" + iDay;

    return iDate
}
