//popup calendar
function enformiaCalendarPopup(qstring){
	var path="../Static/Common/Calendar/calendar.htm";
	if(qstring){
		if(qstring.substring(0,1)!="?")qstring="?"+qstring;
		path=path+qstring;
	}
	if(!this.openedCaledar || this.openedCaledar && this.openedCaledar.closed){
		this.openedCaledar = window.open(path,null,
			"width=275,height=180,resizable=0,status=0,menubar=0,scrollbars=0,fullscreen=0");
	}else{
		this.openedCaledar.location.href=path;
	}
	this.openedCaledar.focus();
	return this.openedCaledar;
}
 
//repopulate date select list when month or year changes
function enformiaPopulateDates(theYear,theMonth,theDay){
	var e=theDay.options[0].value;
	var selectedDay=theDay.options[theDay.selectedIndex].value;
	//skip if not both month and year are non blanck
	if(!theYear.options[theYear.selectedIndex].text ||
		!theMonth.options[theMonth.selectedIndex].value)return;
	//get no of days in month
	var getDaydInMonth=function(y, m){
		timeA = new Date(y, m, 1);
		timeDifference = timeA - 86400000;
		timeB = new Date(timeDifference);
		return timeB.getDate();
	}
	var daysInMonth=getDaydInMonth(theYear.options[theYear.selectedIndex].text,
		theMonth.options[theMonth.selectedIndex].value);
	//empty all options
	theDay.options.length=0;
	//replace with new options
	var j=0;
	//first blank option - if was present
	if(!e){
		theDay.options[j] = new Option("","");
		j++; 
	}
	if(!selectedDay)selectedDay=1;
	if(selectedDay>daysInMonth)selectedDay=daysInMonth;
	var k=1;
    for (var i = j; i-j < daysInMonth; i++){
     	theDay.options[i] = new Option(k,k);
		if(k==selectedDay){
			theDay.options[i].selected=true;
			//theDay.options[i].defaultSelected=true;			
		}
		k++;
    }
}

//prompt user to confirm delete
function confirmDelete(URL,item,customMsg){
	var msg="Are you sure you want to delete this item ?";
	if(item)msg="Are you sure you want to delete item "+item+" ?";
	if(customMsg)msg=customMsg;
	var ret=confirm (msg);
	if(ret && URL){
		location.href=URL;
	}else if(!URL){
		return ret;
	}
}
