var parent_year;
var parent_month;
var parent_day;
var disableWeekend = false;

//the day that we need to go back
var  back_day ;
var back_month;
var back_year;


var parent_form = new String();
var parent_field = new String();

function openDateWindowDisableWeekend(page, form, field) {
	disableWeekend = true;
	openDateWindow(page, form, field);
	
}

function openDateWindow(page, form, field) {

	var yes = 1;
	var no = 0;

	var width = 250;
	var height = 300;
	var chasm = screen.availWidth;
	var mount = screen.availHeight;

	var menubar = no;      // The File, Edit, View Menus
	var scrollbars = no;   // Horizontal and vertical scrollbars
	var locationbar = no;  // The location box with the site URL
	var resizable = no;    // Can the window be resized?
	var statusbar = no;    // Status bar (with "Document: Done")
	var toolbar = no;      // Back, Forward, Home, Stop toolbar
	
	
//  if (validateDate(field, "", "", false, true)) {
 //   parent_day = field.value.substring(0,2) - 0; //automatic convert to int
 //   parent_month = field.value.substring(3,5) - 1;
 //   parent_year = field.value.substring(6,10) - 0;//automatic convert to int
 // }
 // else {
 
    field.value = "";
    today = new Date();
    parent_day = today.getDate();
    parent_month = today.getMonth();
    parent_year = y2k(today.getYear());
  //}
  back_day = parent_day;
  back_month = parent_month;
  back_year = parent_year;

	windowprops = "WIDTH=" + width + ",HEIGHT=" + height + ",LEFT=" + ((chasm - width - 10) * .5) + ",TOP=" + ((mount - height - 30) * .5);

	windowprops += (menubar ? ",menubar=yes" : ",menubar=no") +
		(scrollbars ? ",scrollbars=yes" : ",scrollbars=no") +
		(locationbar ? ",locationbar=yes" : ",locationbar=no") +
		(resizable ? ",resizable=yes" : ",resizable=no") +
		(statusbar ? ",status=yes" : ",status=no") +
		(toolbar ? ",toolbar=yes" : ",toolbar=no");

	var DateWindow = window.open(page, "DateWin", windowprops);

	if ((document.window != null) && (!DateWindow.opener)) {
		DateWindow.opener = document.window;
		DateWindow.focus();
	}
	else {
		if (DateWindow.blur) DateWindow.focus();
	}
	parent_form = form;
	parent_field = field.name;
}

function y2k(number) {
	return (number < 1000) ? number + 1900 : number;
}


function add_days(adate,days) {
	return new Date(adate.getTime() + (days * 86400000));
}

function sub_days(sdate,days) {
	return new Date(sdate.getTime() - (days * 86400000));
}
