var errMsg="";
function UploadArtwork()
{
	ObjForm=document.FrmArtwork;
	if(chkSpace(ObjForm.Name)=="")
		errMsg="Your Name\n";
	if(checkEmail(ObjForm.Email.value)==0)
		errMsg+="Your Email\n";
	if(chkSpace(ObjForm.Phone)=="")
		errMsg+="Your Phone\n";
	if(chkSpace(ObjForm.file)=="")
		errMsg+="Select File\n";

	if(errMsg=="")
	{
		ObjForm.method="post";
		ObjForm.action=arguments[0];
		ObjForm.submit();
	}
	else
	{
		alert("Please complete the following:\n"+errMsg);
		errMsg="";
	}
}

/*----------------------------------------------------------*/

function CheckNumber(txtfield,MinOrderValue)
{
	txtfield=eval(txtfield)
	txtval=txtfield.value;
	var newVal=parseInt(txtval);
	if (isNaN(newVal))
		txtfield.value=MinOrderValue;
	else if (newVal<0)
		txtfield.value=MinOrderValue;
	else
	{
		if(newVal<MinOrderValue)
		{
			alert("You cannot order less than "+MinOrderValue);
			newVal=MinOrderValue;
			txtfield.focus();
		}
		txtfield.value=newVal;
	}
}

/*----------------------------------------------------------*/


function checkEmail()
	{
	var strEmail, strError, countAtRate, countDot, i;
	var checkAtRate, checkDot;
	var ValidChars,CountValidChars;
	ValidChars="abcdefghijklmnopqrstuvwxyz0123456789_.@ABCDEFGHIJKLMNOPQRSTUVWXYZ-";
	strEmail = checkEmail.arguments[0];
	countAtRate=0;
	countDot=0;
	CountValidChars=0;
	if (strEmail.length >= 7)
		{
		for(i=0;i<strEmail.length;i++)
			{
			if(strEmail.charAt(i)=="@")
				countAtRate++;
			if(strEmail.charAt(i)==".")
				countDot++;
			CountValidChars=0;
			for(j=0;j<ValidChars.length;j++)
				{
				if(strEmail.charAt(i)==ValidChars.charAt(j))
					{
					CountValidChars++;
					}
				}
			if(CountValidChars==0)
				{
				strError=0;
				break;
				}
			}
		}
	checkAtRate=strEmail.indexOf("@",1);
	checkDot=strEmail.indexOf(".",1);
	for(i=1;i<countDot;i++)
		checkDot=strEmail.indexOf(".",checkDot+1);
	if(countAtRate==1 && countDot > 0 && strEmail.length >=7 && strError != 0)
		strError=1;
	else
		strError=0;
	if(checkDot>=strEmail.length-2)
		strError=0;
	if(strEmail.charAt(0)=="@" || strEmail.charAt(strEmail.length-1)=="@")
		strError=0;
	if(strEmail.charAt(0)=="." || strEmail.charAt(strEmail.length-1)==".")
		strError=0;
	if(checkDot < checkAtRate)
		strError=0;

	return strError;
}


/*----------------------------------------------------------*/


function chkSpace(txtfield)
{
var i,j;
j=0;
txtfield=eval(txtfield)
var txtval=txtfield.value;
for(i=0;i<txtval.length;i++)
{
	j++
    if(txtval.substr(i,1)!=" ")
    	break;
}
txtval=txtval.substr(j-1,txtval.length);
if(txtval==" ")
   txtval="";

txtfield.value=txtval;
return(txtval);

}


/*----------------------------------------------------------*/