var problem = false;
var strProblem = "";
var doTimeout = true;
var doScrolling = true;

function findPos(objectID)
{
  myObject = document.getElementById(objectID);
  var x = 0;
  var y = 0;
  var width = 0;
  var height = 0;
  while (myObject != null)
  {
    x = x + myObject.offsetLeft;
    y = y + myObject.offsetTop;
    myObject = myObject.offsetParent;
  }
  if (myObject != null)
  {
	width = myObject.currentStyle.width;
	height = myObject.currentStyle.height;
  }
  return new Pos(x,y,width,height)
}

function Pos(_x,_y,width,height)
{
  this.x = _x;
  this.y = _y;
  this.width = width;
  this.height = height;
}

function stripPX(inputString)
{
  inputStringLen = inputString.length;
  outputVal = parseInt(inputString.substring(0,inputStringLen-2));
  if (isNaN(outputVal))
  {
	outputVal = 0;
  }
  return outputVal;
}

function displayImage(image,width,height)
{
	var sFeatures = "toolbar=no,directories=no,location=no,menubar=no,resizable=no,scrollbars=no,width=" + width + ",height=" + height;
	var sUrl = "../display_image.asp?image=" + escape(image);
	limoWindow = window.open(sUrl,"Limo",sFeatures);
}

function errorAlert()
{
  if (problem == false)
  {
    problem = false;
    strProblem = "";
    return false;
  }
  else
  {
    var str = "The following errors have occured while trying to process the page:\n\n";
    str += strProblem;
    str += "\nPlease contact webtechy.co.uk customer support at support@webtechy.co.uk.";
    alert(str);
    problem = false;
    strProblem = "";
    return true;
  }
}

function validateMail(sEMail)
{
	if (sEMail == "")
	{
		alert("You have not entered an e-mail address.");
		return false;
	}
	else
	{
		return true;
	}
}

function getSelectedRadioValue(buttonGroup)
{
	// Returns the value of the selected radio button or "" if no button is selected
   
	var i = getSelectedRadio(buttonGroup);
	if (i == -1)
	{
		return "";
	}
	else
	{
		if (buttonGroup[i])
		{
			// Make sure the button group is an array (not just one button)
			return buttonGroup[i].value;
		}
		else
		{
			// The button group is just the one button, and it is checked
			return buttonGroup.value;
		}
	}
}

function getSelectedRadio(buttonGroup)
{
	// returns the array number of the selected radio button or -1 if no button is selected
	if (buttonGroup[0])
	{
		// if the button group is an array (one button is not an array)
		for (var i=0; i<buttonGroup.length; i++)
		{
			if (buttonGroup[i].checked)
				{
				return i
				}
		}
	}
	else
	{
		if (buttonGroup.checked) { return 0; } // if the one button is checked, return zero
	}
	// if we get to this point, no radio button is selected
	return -1;
}
