function confirmBox(message,url)
{
	if (confirm (message)) {
		window.location=url;
	} else {
		return false;
	}
}

function getImgSize(imgSrc)
{
	var newImg = new Image();
	newImg.src = imgSrc;
	var height = newImg.height;
	var width = newImg.width;

	var returnarr = new Array();
	returnarr['width'] = width;
	returnarr['height'] = height;

	return returnarr;
}

function swapImage(targetID,swapImg)
{
	var el = document.getElementById(targetID);

	var size = getImgSize(swapImg);

	if (size['width'] > 320)
	{
		var str = '<a href="' + swapImg + '" target="_blank"><img src="' + swapImg + '" width="320px" /></a>';
	}
	else 
	{
		var str = '<img src="' + swapImg + '" />';
	}

	el.innerHTML = str;
}

function resizeImg(image,maxWidth,maxHeight,targetID)
{
	var size = getImgSize(image);
	var el = document.getElementById(targetID);	
	var imgStr;
	var width;
	var height;

	if (maxWidth != 0)
	{
		width = 'width="' + maxWidth + '"';
	}

	if (maxHeight != 0)
	{
		height = 'height="' + maxHeight + '"';
	}
	
	if (size['width'] > maxWidth || size['height'] > maxHeight)
	{
		imgStr = '<img src="' + image + '" ' + width + ' ' + height + ' />';
	}
	else 
	{
		imgStr = '<img src="' + image + '" />';
	}

	el.innerHTML = imgStr;
}

var fields = 1;
var count = 2;
function addInput()
{
	if (fields <= 5)
	{
		document.getElementById('imageFields').innerHTML += '<input type="file" size="59" name="ridesImage' + count + '" /><br />';
		fields++;
		count++;
	}
	else 
	{
		document.addRide.addImageField.disabled=true;
	}
}