
var dummy = false;
var fsep = '\x01', rsep = '\x02', rnul = '\x03';

function trim(stringToTrim) 
{
	return stringToTrim.replace(/^\s+|\s+$/g,"");
};

function ltrim(stringToTrim) 
{
	return stringToTrim.replace(/^\s+/,"");
};

function rtrim(stringToTrim) 
{
	return stringToTrim.replace(/\s+$/,"");
};

function setElementText(elt, text)
{
	if(typeof(elt.textContent) == "string") elt.textContent = text;
	else if(typeof(elt.innerText) == "string") elt.innerText = text;
};

function abortclick()
{
	return dummy;
};

function showWaitCursor(frame)
{
	frame.contentWindow.parent.document.body.style.cursor = 'Wait';
};

function showDefaultCursor(frame)
{
	frame.contentWindow.parent.document.body.style.cursor = 'Default';
};

function hideParentFrame()
{
	var frame = parent.window.currentframe();
	if(!frame.style || !frame.style.visibility)
		return;
		
	frame.style.visibility = 'hidden';
	showWaitCursor(frame);
};

function showParentFrame()
{
	var frame = parent.window.currentframe();
	if(!frame.style || !frame.style.visibility)
		return;
		
	frame.style.visibility = 'visible';
	showDefaultCursor(frame);
};

function resubmit(theform)
{
	hideParentFrame(); 
	theform.submit();
};

////////////////////////////////////////////////////////////////////////////
function checkaccount(theform)
{
	var name = trim(theform.name.value);
	if(0 == name.length){
		
		alert('Please enter your name.');
		theform.name.focus();
		return false;
	};
			
	var email1 = trim(theform.email1.value);
	var email2 = trim(theform.email2.value);
	if(0 == email1.length){
		
		alert('Please enter your email address.');
		theform.email1.focus();
		return false;
		
	} else if(email1 != email2){

		alert('Email addresses do not match!');
		theform.email2.focus();
		return false;
	};
		
	var passwd1 = trim(theform.password1.value);
	var passwd2 = trim(theform.password2.value);
	if(0 == passwd1.length){
	
		alert('Please enter your password.');
		theform.password1.focus();
		return false;

	} else if(passwd1 != passwd2){

		alert('Passwords do not match!');
		theform.password2.focus();
		return false;
	};
	
	return true;
};

function updatechecklist(obj, dest)
{
	var list = '', sep =';';
	var j = 0, k = obj.elements.length;
	for( j=0 ; j < k ; ++j){
	
		var chk = obj.elements[j];
		if((chk.type != 'checkbox') || !chk.checked)
			continue;
			
		if(list != '') list += sep;
		list += chk.value;
	};	
	
	dest.value = list;
	return true;		
};

function docheckboxes(theform, thecheckbox)
{
 	if(!theform.chkids) return;
	
	var k = theform.chkids.length;
	if((0 == k) || isNaN(k)){

		var elt = theform.chkids;
		if(elt.checked == thecheckbox.checked)
			return;
			
		elt.checked = thecheckbox.checked;
		updatecmds(theform, elt);
		return;
	}; 

	for(var j = 0; j < k; ++j){
	
		var elt = theform.chkids[j];
		if(elt.checked == thecheckbox.checked)
			continue;
			
		elt.checked = thecheckbox.checked;				
		updatecmds(theform, elt);
	};
};

function makesuspdata(theform)
{
	theform.suspdata.value = '';
 	if(!theform.chkids){
	
		hideParentFrame();
		return;
	};
	
	var data = '', k = theform.chkids.length;
	if((0 == k) || isNaN(k)){

		var elt = theform.chkids;
		if(elt.checked) data += (elt.value == '') ? rnul : elt.value;

	} else { 

		for(var j = 0; j < k; ++j){
		
			var elt = theform.chkids[j];
			if(!elt.checked) continue;
			
			var val = elt.value;
			if(val == '') val = rnul;
			
			if(data != '') data += rsep;
			data += val;
		};
	};
		
	theform.suspdata.value = data;
	hideParentFrame();
};







