function SetFocus() {
	var control = document.getElementById(arguments[0]);
	if (control != null) {
		control.focus();
		control.select();
	}
}

function countdown_clock(seconds)
{
	document.write('<span id="countdown"></span>');

	var Target = new Date( new Date().getTime() + (seconds * 1000) );
	countdown(Target.getFullYear(), Target.getMonth()+1, Target.getDate(), Target.getHours(), Target.getMinutes(), Target.getSeconds());
}
function countdown(year, month, day, hour, minute, second)
{
	Today = new Date();

	//Convert both today's date and the target date into miliseconds.                           
	Todays_Date = Today.getTime();                                 
	Target_Date = new Date(year, month - 1, day, hour, minute, second).getTime();                  

	//Find their difference, and convert that into seconds.                  
	Time_Left = Math.round((Target_Date - Todays_Date) / 1000);

	if(Time_Left < 0)
		Time_Left = 0;

	days = Math.floor(Time_Left / (60 * 60 * 24));
	Time_Left %= (60 * 60 * 24);
	hours = Math.floor(Time_Left / (60 * 60));
	Time_Left %= (60 * 60);
	minutes = Math.floor(Time_Left / 60);
	Time_Left %= 60;
	seconds = Time_Left;

	dps = 's'; hps = 's'; mps = 's'; sps = 's';
	//ps is short for plural suffix.
	if(days == 1) dps ='';
	if(hours == 1) hps ='';
	if(minutes == 1) mps ='';
	if(seconds == 1) sps ='';

	datestring = '(';
	if (days > 0) datestring += days + ' day' + dps + ', ';
	datestring += hours + ':';
	if (minutes < 10) minutes = '0' + minutes;
	datestring += minutes + ':';
	if (seconds < 10) seconds = '0' + seconds;
	datestring += seconds + ')';

	document.getElementById("countdown").innerHTML = datestring;

	//Recursive call, keeps the clock ticking.
	setTimeout('countdown(' + year + ',' + month + ',' + day + ',' + hour + ',' + minute + ',' + second + ');', 1000);
}

function FindStock(controlname)
{
	var clientid = document.all[controlname].value;
	clientid = window.showModalDialog(approot + "dialogs/stocks.aspx", clientid, "dialogHeight: 290px; dialogWidth: 314px; help: no; scroll: no; status: no; unadorned: yes;");
	if( clientid != null )
	{
		document.all[controlname].value = clientid;
		return true;
	}
	return false;
}

