var calendars = [];

function colorpopup(obj_target) {

	// assigning methods
	this.popup    = cal_popupc;
	this.vider    = cal_viderc;

	// validate input parameters
	if (!obj_target)
		return cal_errorc("Error calling the popup: no target control specified");
	if (obj_target.value == null)
		return cal_errorc("Error calling the popup: parameter specified is not valid target control");
	this.target = obj_target;
	this.page = '../color_picker.html';
	
	// register in global collections
	this.id = calendars.length;
	calendars[this.id] = this;
}

function cal_popupc (str_datetime) {
	var obj_calwindow = window.open(
		this.page + '?id=' + this.id,
		'Selection', 'width=400,height=220,status=no,resizable=no,top=20,left=20,dependent=yes,alwaysRaised=yes'
	);
	obj_calwindow.opener = window;
	obj_calwindow.focus();
}

function cal_errorc (str_message) {
	alert (str_message);
	return null;
}

function cal_viderc (str_message) {
	this.target.value = '';
}


