Deprecated: Assigning the return value of new by reference is deprecated in /home/bluestat/public_html/source/index.php on line 477
Kalens - Blob - ViewGit - Blue Static
/*=====================================================================*\
|| ###################################################################
|| # Kalens [#]version[#]
|| # Copyright ©2002-[#]year[#] Iris Studios, Inc.
|| #
|| # This program is free software; you can redistribute it and/or modify
|| # it under the terms of the GNU General Public License as published by
|| # the Free Software Foundation; version [#]gpl[#] of the License.
|| #
|| # This program is distributed in the hope that it will be useful, but
|| # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|| # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|| # more details.
|| #
|| # You should have received a copy of the GNU General Public License along
|| # with this program; if not, write to the Free Software Foundation, Inc.,
|| # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|| ###################################################################
\*=====================================================================*/

// ###################################################################
// A JavaScript version of construct_phrase, no phrase manipulation is
// necessary
function construct_phrase()
{
	var args = arguments;
	var langobj = args[0];

	for (var i = 1; i < args.length; i++)
	{
		var expr = new RegExp('%' + i, 'g');
		langobj = langobj.replace(expr, args[i]);
	}

	return langobj;
}

// ###################################################################
// Function to open a new window with a given URL, width, and height
function open_window(location, callingcard, width, height)
{
	window.open(location, (!callingcard ? 'PopupWindow' : callingcard), 'statusbar=no,menubar=no,toolbar=no,scrollbar=yes,resizable=yes' + (width ? ',width=' + width : '') + (height ? ',height=' + height : ''));
}

// ###################################################################
// Older version-compatible getElementById
function newobj(id)
{
	if (document.getElementById)
	{
		obj = document.getElementById(id);
	}
	else if (document.all)
	{
		obj = document.all[id];
	}
	else if (document.layers)
	{
		obj = document.layers[id];
	}

	if (obj && obj != undefined)
	{
		return obj;
	}
	else
	{
		return;
	}
}

// ###################################################################
// Changes the display mode of an object
function toggle_display_mode(obj)
{
	controlobj = newobj(obj);
	controlobj.style.display = (controlobj.style.display == 'none' ? 'block' : 'none');
}

// ###################################################################
// Handle the change of the pattern type listmenu
function pattern_change_handler()
{
	selected_value = newobj('recur_type_select').value;

	if (selected_value == '' || selected_value == undefined || !selected_value || selected_value == 0)
	{
		selected_value = 1;
	}
	else
	{
		var i = 1;
		while (newobj('controlbox_' + i) != undefined)
		{
			newobj('controlbox_' + i).style.display = 'none';
			i++;
		}
		newobj('controlbox_' + selected_value).style.display = 'block';
	}

	action_specific_handler();
}

// ###################################################################
// Control boxes for recurring events
function action_specific_handler()
{
	globobj = newobj('recur_type_select');

	newobj('end_month').style.display = 'inline';
	newobj('end_day').style.display = 'inline';
	value = globobj.value;

	if (value == 1 || value == 2)
	{
		return;
	}
	else if (value == 3)
	{
		newobj('end_day').style.display = 'none';
	}
	else if (value == 4)
	{
		newobj('end_day').style.display = 'none';
		newobj('end_month').style.display = 'none';
	}
	else
	{
		return;
	}
}

// ###################################################################
// Go to the new event screen
function make_new_event(id, dateargs)
{
	window.location = 'event.php?do=add&id=' + id + (dateargs ? '&' + dateargs : '');
}

// ###################################################################
// Switch event types
function change_type(newtype)
{
	var obj =
	{
		'recur_controls' : newobj('recur_controls'),
		'allday_box' : newobj('allday_box'),
		'allday_checkbox' : newobj('allday_checkbox'),
		'times' : newobj('times'),
		'end_date' : newobj('end_date'),
		'end_month' : newobj('end_month'),
		'end_day' : newobj('end_day')
	};

	obj['recur_controls'].style.display = 'none';
	obj['allday_box'].style.display = 'block';
	obj['end_date'].style.display = 'block';
	obj['end_month'].style.display = 'inline';
	obj['end_day'].style.display = 'inline';

	if (newtype == 'recur')
	{
		obj['recur_controls'].style.display = 'block';
		action_specific_handler();
	}

	if (newtype == 'range')
	{
		obj['allday_checkbox'].checked = 'checked';
		obj['allday_box'].style.display = 'none';
		obj['times'].style.display = 'none';
	}

	if (newtype == 'sing')
	{
		obj['end_date'].style.display = 'none';
	}
}

/*=====================================================================*\
|| ###################################################################
|| # $HeadURL$
|| # $Id$
|| ###################################################################
\*=====================================================================*/