// Description	: General Javascript Functions

// Checks if value is blank
function isBlank(n) 
{
	var nl = n.length;
	var retval = true;

	for (c = 0; n.length > c; c++)
	{
		t = n.charAt(c);
		if ((t != '') && (t != ' '))
		{
			retval = false;
		}
	}
	return retval;
}

// Checks integer field
function CheckIntField(TheField)
{
	var NewValue = parseInt(TheField.value,10);
	if (isNaN(NewValue))
		TheField.value = TheField.defaultValue;
	else
		TheField.value = NewValue;
}

// Checks float field
function CheckFloatField(TheField)
{
    var NewValue = parseFloat(TheField.value);
    if (isNaN(NewValue))
    {
        TheField.value = TheField.defaultValue;
    }
    else
    {
        TheField.value = NewValue;
    }
}

var locationwindow = null;
function openLocationWindow(url, title, width, height) 
{
	// Set window parameters
	windowoptions = 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=' + width + ',height=' + height;
	
	// check if window is already open
	if (locationwindow != null)
	{
		if (locationwindow.closed)
			locationwindow = window.open(url, title, windowoptions);
		else
		{
			locationwindow.focus();
			locationwindow.location = url;
		}
	}
	else
		locationwindow = window.open(url, title, windowoptions);
}
