//allFuncs.js
//(c) Saleem Jeelani 2002
// For strict use for Vintage Logos file upload forms only
var result = null;
//alert("hello Shawn")
// graphics glb vars
var tz = null;
var drumSize = null;
var makeWhat = null;
var filename="";
var flag="";
var errorMessage="";


function validatePassreq()
{
	if (checkName() && checkEmail())
	{
		document.mForm.submit()		
	}
}


function validateUploadCustom()
{
	flag="y"
	errorMessage="Please enter information for the following errors \n"
	//alert("checkpoint A")
	if (document.upCustForm.orderID.value.length == 0)
	{errorMessage += "Order ID cannot be blank \n"}
	if (document.upCustForm.name.value.length == 0)
	{errorMessage += "Enter your name \n"}
	emailerror=""
	if (document.upCustForm.email.value.length == 0)
	{
		emailerror = "E-mail address is required \n"
	} else {
		if (!isEmail(document.upCustForm.email.value))
		{
		emailerror = "Enter a valid e-mail address \n"
		}
	}
	if (emailerror.length > 0 )
	{errorMessage += emailerror}
	
	if ( document.upCustForm.macPCOption[0].checked == false &&document.upCustForm.macPCOption[1].checked == false && document.upCustForm.macPCOption[2].checked == false)
	{errorMessage += "Choose your computer platform  \n"}

	if (result == "no selection"  || result == null)
	{errorMessage+= "Choose the software program used to create your digital files \n" }
	
	if (!document.upCustForm.convertCheck.checked == true)
	{errorMessage += "Check the box \"I have converted all fonts to curves or paths..\" \n"}
	
	filename=document.upCustForm.upload_file.value.substr(-4)

	
ext=getext(filename)
//alert("extension is "+ext)
	//changed to file length
	//if (document.upCustForm.upload_file.value.length <= 3)
	//{errorMessage += "Please attach the file to upload \n"}
	
	if (ext == ".zip" || ext == ".sit" || ext == ".jpg" || ext == ".jpeg")
	{
		//do nothing 	
	}else {
		errorMessage += "The files have to be compressed in zip or sit or jpg or jpeg format  \n"
	}

	if (document.upCustForm.tmcheck.checked!=true)
	{
		errorMessage += "Please acknowledge that you have read our policies and agree to the terms \n"
	}
	
	if (errorMessage.length > 52)
	{ 
		alert(errorMessage)
		flag="n"
	}

if (flag=="y")
{
	alert("Depending on your net connection and the file size this may take a few minutes.  Please do not close this window or click submit again.  You will see a confirmation once the file has been successfully uploaded")
	//alert("checkpoint submit - voila ")
	document.upCustForm.submit()
}

}




function validateGraphics()
{
flag="y"
errorMessage=""
errorMessage="Please enter information for the following errors \n"

//graphicsGenericCheck()
if (document.upGraphicsForm.name.value.length == 0)
	{errorMessage += "Enter your name \n"}
emailerror=""
if (document.upGraphicsForm.email.value.length == 0)
{
	emailerror = "Enter a valid e-mail address \n"
} else {
	if (!isEmail(document.upGraphicsForm.email.value))
	{
		emailerror = "The email you entered is not valid \n"
	}
}
if (emailerror.length > 0 )
{errorMessage += emailerror}

if (document.upGraphicsForm.phone1.value.length == 0)
	{errorMessage += "Phone number cannot be blank \n"}

if (tz == "no selection"  || tz == null)
	{errorMessage+= "Enter your time zone\n" }


filename=document.upGraphicsForm.upload_file.value.substr(-4)
//alert("filename is "+filename)
ext=getext(filename)
if (filename.length>0)
{
	//fileTypeCheck()
	//if (document.upGraphicsForm.upload_file.value == undefined)
	//{errorMessage += "Please attach the file to upload \n"}
	
	if (ext == ".zip" || ext == ".sit" || ext == ".jpg" || ext == ".jpeg")
	{
		//do nothing 	

	}else {
		errorMessage += "The files have to be compressed in zip or sit or jpg or jpeg format  \n"
	}

	if ( document.upGraphicsForm.macPCOption[0].checked == false &&document.upGraphicsForm.macPCOption[1].checked == false && document.upGraphicsForm.macPCOption[2].checked == false)
	{errorMessage += "Choose your computer platform  \n"}
	if (!document.upGraphicsForm.convertCheck.checked == true)
	{errorMessage += "Check the box \"I have converted all fonts to curves or paths..\" \n"}
	
	if (result == "no selection"  || result == null)
	{errorMessage+= "Choose the software program used to create your digital files \n" }

	if (document.upGraphicsForm.tmcheck.checked!=true)
	{
		errorMessage+="Please acknowledge that you have read our policies and agree to the terms. \n"	
	}

}

if (errorMessage.length > 52)
{ 
	alert(errorMessage)
	flag="n"
}
if (flag=="y" )
{
	alert("Depending on your net connection and the file size this may take a few minutes.  Please do not close this window or click submit again.  You will see a confirmation once the file has been successfully uploaded")
	document.upGraphicsForm.submit()
}
}




function fileTypeCheck()
{
if (!(filename == ".zip" || filename == ".sit" || filename == ".jpg" || filename == ".jpeg"))
{errorMessage += "The files have to be compressed in zip or sit or jpg or jpeg format  \n "}
}


function getext(str) {
   //if (!str) return '';
	//alert("checkpoint str file extension type") 
	ctr=(str.length)
	holdstr=""
	donow="n"
   for (i = 0; i <= ctr; i++)
   {    
   	if(str.charAt(i)== "." || donow=="y")
	{
		holdstr+=str.charAt(i)
		donow="y"
	}
   }
   return holdstr;
}




function graphicsGenericCheck()
{
if (document.upGraphicsForm.name.value.length == 0)
	{errorMessage += "Enter your name \n"}
emailerror=""
if (document.upGraphicsForm.email.value.length == 0)
{
	emailerror = "Enter a valid e-mail address \n"
} else {
	if (!isEmail(document.upGraphicsForm.email.value))
	{
		emailerror = "The email you entered is not valid \n"
	}
}
if (emailerror.length > 0 )
{errorMessage += emailerror}

if (document.upGraphicsForm.phone1.value.length == 0)
	{errorMessage += "Phone number cannot be blank \n"}

if (tz == "no selection"  || tz == null)
	{errorMessage+= "Enter your time zone\n" }
}

function checkName()
{
	x=document.mForm.naam.value
	y=x.length
	//alert(x)
	if (y != 0)
	{ 
		return true; 
	} else {
		alert("Name cannot be blank")
		return false;
	}
}

function isEmail(string) {
    if (string.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
        return true;
    else
        return false;
}



function checkEmail(){
	if (isEmail(document.mForm.email.value)){
		//alert("Voila "+document.mForm.email.value)
		return true
	} else {
		alert("Please enter a valid email address")
		document.mForm.email.value=""
		document.mForm.email.focus()
		return false
	} 
}
