function formfocus()
{
	document.myform.articlenumber.focus();
	return(true);
} 
function fmValidate(theform)
{
	var anumber=theform.articlenumber.value.toUpperCase();
	//first check length is ok
	if (!checklength(anumber))
	{
		theform.articlenumber.focus();
		return false;
	}
	// check the string
	if (!checkstring(anumber))
	{
		theform.articlenumber.focus();
		return false;
	}

	return true;
}
function checklength(an)
{
	var len=an.length;
	if(len<13)
	{
		window.alert("Article Number is not correct.Minimum 13 characters required.");
		return false;
	}
	if (len==13)
		return true;
	var div,mod;
	div=len/13;
	mod=len%13;
	if((Math.floor(div)-1)==mod)
		return true;
	window.alert("Article Number is not correct.Total number of characters does not tally.");
	return false;
}
function checkstring(an)
{
	var start=0;
	var ss,ss2;
	do
	{
		ss=an.substr(start,13);
		for(i=2;i<10;i++) //3 to 10 whether number
		{ 
			if(!isnumber(ss.substr(i,1)))
			{
				window.alert("Article Number is not correct.Please check the numbers typed between position "+(start+1)+" and "+(start+13));
				return false;
			}
		} 
		for(i=11;i<13;i++) // 12 & 13 whether chars
		{
			if(!ischar(ss.substr(i,1)))
			{
				window.alert("Article Number is not correct.Please check the numbers typed between position "+(start+1)+" to "+(start+13));
				return false;
			}
		}
		//increment start to length already covered
		start+=13;
		if(start<an.length)
		{
			//check the separator
			ss=an.substr(start,1);
			if(ss!=";")
			{
				window.alert("Article Number is not correct.Please check the numbers typed at position "+(start+1));
				return false;
			}
			start++;
		}
	}
	while(start<an.length)
	return true;
}
function isnumber(str)
{
	if(str>=0 && str<=9)
		return true;
	return false;
}
function ischar(str)
{
	if(str>="A" && str<="Z")
		return true;
	return false;
}




