/*
* This functions returns an array containing 36 points to draw an
* ellipse.
*
* @param x {double} X coordinate
* @param y {double} Y coordinate
* @param a {double} Semimajor axis
* @param b {double} Semiminor axis
* @param angle {double} Angle of the ellipse
*/
function calculateEllipse(x, y, a, b, angle, steps) 
{
  if (steps == null)
    steps = 36;
  var points = [];
 
  // Angle is given by Degree Value
  var beta = -angle * (Math.PI / 180); //(Math.PI/180) converts Degree Value into Radians
  var sinbeta = Math.sin(beta);
  var cosbeta = Math.cos(beta);
 
  for (var i = 0; i < 360; i += 360 / steps) 
  {
    var alpha = i * (Math.PI / 180) ;
    var sinalpha = Math.sin(alpha);
    var cosalpha = Math.cos(alpha);
 
    var X = x + (a * cosalpha * cosbeta - b * sinalpha * sinbeta);
    var Y = y + (a * cosalpha * sinbeta + b * sinalpha * cosbeta);
 
    points.push(new OpenLayers.Geometry.Point(X, Y));
   }
 
  return points;
}

function checkform()
{
	if (document.amiform.amiheight.value == '')
	{
		alert('Please mention the desired height of your amigurumi in centimeters! Decimals allowed.');
		return false;
	}

	if (document.amiform.hgauge.value == '')
	{
		alert('Please mention your knitting tension (gauge) in stitches per centimeters. Decimals are allowed.');
		return false;
	}

	if (document.amiform.vgauge.value == '')
	{
		alert('Please mention your knitting tension (gauge) in rows per centimeters. Decimals are allowed.');
		return false;
	}

	if (document.amiform.aminame.value == '')
	{
		alert('Your amigurumi is worth a name!');
		return false;
	}

	return true;
}

function resize(sign,shape,part,value) {
if (value == 'height') {
	var imgId1 = part+shape+'1';
	var imgId2 = part+shape+'2';
	var inputId = part+shape+'height';
//alert(document.getElementById(inputId).value);
		if (sign == 'plus') {
		document.getElementById(imgId1).height ++;
		document.getElementById(inputId).value = document.getElementById(imgId1).height;
		document.getElementById(imgId2).height ++;

		} else {
			if (document.getElementById(imgId1).height !== 0) {
			document.getElementById(imgId1).height --;
			document.getElementById(inputId).value = document.getElementById(imgId1).height;
			document.getElementById(imgId2).height --;

			} else {
			alert('You have decreased this size to zero, I cannot decrease it any further. ;)');
			}
		}
}

if (value == 'width') {
	var imgId1 = part+'top1';
	var imgId2 = part+'top2';
	var imgId3 = part+'bottom1';
	var imgId4 = part+'bottom2';
	var imgId5 = part+'high1';
	var imgId6 = part+'high2';
	var inputId = part+'width';
//alert(imgId5);
		if (sign == 'plus') {
		document.getElementById(imgId5).width ++;
		document.getElementById(inputId).value = document.getElementById(imgId5).width;
		document.getElementById(imgId1).width ++;
		document.getElementById(imgId3).width ++;
		document.getElementById(imgId6).width ++;
		document.getElementById(imgId2).width ++;
		document.getElementById(imgId4).width ++;
		} else {
			if (document.getElementById(imgId5).width !== 0) {
		document.getElementById(imgId5).width --;
		document.getElementById(inputId).value = document.getElementById(imgId5).width;
		document.getElementById(imgId1).width --;
		document.getElementById(imgId3).width --;
		document.getElementById(imgId6).width --;
		document.getElementById(imgId4).width --;
		document.getElementById(imgId2).width --;
			} else {
			alert('You have decreased this size to zero, I cannot decrease it any further. ;)');
			}
		}
}




//alert(document.getElementById(inputId));
//document.getElementById(inputId).value = size1;
}

