window.onload = function() {
	if( document.getElementById('url') )
	{
		document.getElementById('url').focus();
	}
}

var choose = 0;

function select(format, td)
{
		for(i = 1; i <= 6; i++)
		{
			document.getElementById('s'+i).style.fontWeight = 'normal';
			document.getElementById('s'+i).style.background = '#ff641d';
		}

		td.style.fontWeight = 'bold';
		td.style.background = '#ff841a';

		choose = td.id;

		document.getElementById('format').value = format;
}

function mouseover(td)
{
		if( choose != td.id )
		{
			td.style.background = '#ff841a';
		}
}

function mouseout(td)
{
		if( choose != td.id )
		{
			td.style.background = '#ff641d';
		}
}

function IsEmpty(aTextField)
{
	if ( (aTextField.value.length==0) || (aTextField.value==null) )
	{
      		return true;
	}

	else
	{
		return false;
	}
}

function CheckURL (str)
{
	return (new RegExp("^http://[-a-zA-Z_0-9\\\\\\?\\!'\"&%\\+\\.](.*)+$", "g")).test(str);
}

function convert()
{
	if( IsEmpty(document.getElementById('url')) )
	{
		alert('L\'adresse est obligatoire.');
	}

	else if( !CheckURL(document.getElementById('url').value) )
	{
		alert('Adresse non valide.');
	}

	else if( IsEmpty(document.getElementById('format')) )
	{
		alert('Le format de conversion est obligatoire.');
	}

	else
	{
		document.getElementById('form').submit();
	}
}
