/*function to validate the form*/
function validateupload(theform)
{
if (theform.sname.value=="")
{
alert("Please enter your name.");
theform.sname.focus();
theform.sname.select();
return false;
}
else
{
for(var i=0;i<theform.sname.value.length;i++)
{
 if(theform.sname.value.charAt(i)<'A' ||  theform.sname.value.charAt(i)>'Z')
{
 if(theform.sname.value.charAt(i)<'a' ||  theform.sname.value.charAt(i)>'z')
{
 if(!((theform.sname.value.charAt(i)=='.') || (theform.sname.value.charAt(i)==' ')))
 {
  alert("Only alphabets, a space and a . are allowed in the senders name field.");
  theform.sname.select();
  theform.sname.focus();
  return false;
 }
}
}
}
}

if (theform.sstreet.value=="")
{
alert("Please enter your street name.");
theform.sstreet.focus();
theform.sstreet.select();
return false;
}

if (theform.slocality.value=="")
{
alert("Please enter your locality name.");
theform.slocality.focus();
theform.slocality.select();
return false;
}

if (theform.scity.value=="")
{
alert("Please enter the name of the city.");
theform.scity.focus();
theform.scity.select();
return false;
}

if (theform.szipcode.value=="")
{
alert("Please enter your pin/zip code.");
theform.szipcode.focus();
theform.szipcode.select();
return false;
}
else
{
a = theform.szipcode.value;
var i=0;
for(i=0;i<a.length;i++)
{
if(a.charAt(i) < '0' || a.charAt(i) > '9') 
{
if(!(a.charAt(i) == ' ' || a.charAt(i) == '(' || a.charAt(i)==')' || a.charAt(i)==',' || a.charAt(i)=='/' || a.charAt(i)=='-' || a.charAt(i)=='+' || a.charAt(i)=='[' || a.charAt(i)==']')) 
{
alert("Characters and Special symbols are not allowed in the pin/zip Code field.");
theform.szipcode.select();
theform.szipcode.focus();
return false;
}
}
}
}

if (theform.scountry.value=="")
{
alert("Please enter the name of the country.");
theform.scountry.focus();
theform.scountry.select();
return false;
}

if (theform.sccode.value=="")
{
alert("Please enter your Country Code.");
theform.sccode.focus();
theform.sccode.select();
return false;
}
else
{
a = theform.sccode.value;
var i=0;
for(i=0;i<a.length;i++)
{
if(a.charAt(i) < '0' || a.charAt(i) > '9') 
{
if(!(a.charAt(i) == ' ' || a.charAt(i) == '(' || a.charAt(i)==')' || a.charAt(i)==',' || a.charAt(i)=='/' || a.charAt(i)=='-' || a.charAt(i)=='+' || a.charAt(i)=='[' || a.charAt(i)==']')) 
{
alert("Characters and Special symbols are not allowed in the Country Code field.");
theform.sccode.select();
theform.sccode.focus();
return false;
}
}
}
}

if (theform.sacode.value=="")
{
alert("Please enter your Area Code.");
theform.sacode.focus();
theform.sacode.select();
return false;
}
else
{
a = theform.sacode.value;
var i=0;
for(i=0;i<a.length;i++)
{
if(a.charAt(i) < '0' || a.charAt(i) > '9') 
{
if(!(a.charAt(i) == ' ' || a.charAt(i) == '(' || a.charAt(i)==')' || a.charAt(i)==',' || a.charAt(i)=='/' || a.charAt(i)=='-' || a.charAt(i)=='+' || a.charAt(i)=='[' || a.charAt(i)==']')) 
{
alert("Characters and Special symbols are not allowed in the Area Code field.");
theform.sacode.select();
theform.sacode.focus();
return false;
}
}
}
}

if (theform.sphone.value=="")
{
alert("Please enter your Phone Number.");
theform.sphone.focus();
theform.sphone.select();
return false;
}
else
{
a = theform.sphone.value;
var i=0;
for(i=0;i<a.length;i++)
{
if(a.charAt(i) < '0' || a.charAt(i) > '9') 
{
if(!(a.charAt(i) == ' ' || a.charAt(i) == '(' || a.charAt(i)==')' || a.charAt(i)==',' || a.charAt(i)=='/' || a.charAt(i)=='-' || a.charAt(i)=='+' || a.charAt(i)=='[' || a.charAt(i)==']')) 
{
alert("Characters and Special symbols are not allowed in the Phone Number field.");
theform.sphone.select();
theform.sphone.focus();
return false;
}
}
}
}

if (theform.semail.value=="")
{
alert("Please enter your email address.");
theform.semail.focus();
theform.semail.select();
return false;
}
else if(theform.semail.value.indexOf(".") == -1 || theform.semail.value.indexOf("@") == -1)
{
alert("Please enter your correct email address.");
theform.semail.select(); 
theform.semail.focus();
return false;
}

if (theform.rname.value=="")
{
alert("Please enter the recipients name.");
theform.rname.focus();
theform.rname.select();
return false;
}
else
{
for(var i=0;i<theform.rname.value.length;i++)
{
 if(theform.rname.value.charAt(i)<'A' ||  theform.rname.value.charAt(i)>'Z')
{
 if(theform.rname.value.charAt(i)<'a' ||  theform.rname.value.charAt(i)>'z')
{
 if(!((theform.rname.value.charAt(i)=='.') || (theform.rname.value.charAt(i)==' ')))
 {
  alert("Only alphabets, a space and a . are allowed in the recipients name field.");
  theform.rname.select();
  theform.rname.focus();
  return false;
 }
}
}
}
}

if (theform.rstreet.value=="")
{
alert("Please enter the recipients street name.");
theform.rstreet.focus();
theform.rstreet.select();
return false;
}

if (theform.rlocality.value=="")
{
alert("Please enter the recipients locality name.");
theform.rlocality.focus();
theform.rlocality.select();
return false;
}

if (theform.rcity.value=="")
{
alert("Please enter the recipients city.");
theform.rcity.focus();
theform.rcity.select();
return false;
}

if (theform.rzipcode.value=="")
{
alert("Please enter the recipients pin/zip code.");
theform.rzipcode.focus();
theform.rzipcode.select();
return false;
}
else
{
a = theform.rzipcode.value;
var i=0;
for(i=0;i<a.length;i++)
{
if(a.charAt(i) < '0' || a.charAt(i) > '9') 
{
if(!(a.charAt(i) == ' ' || a.charAt(i) == '(' || a.charAt(i)==')' || a.charAt(i)==',' || a.charAt(i)=='/' || a.charAt(i)=='-' || a.charAt(i)=='+' || a.charAt(i)=='[' || a.charAt(i)==']')) 
{
alert("Characters and Special symbols are not allowed in the pin/zip code field.");
theform.rzipcode.select();
theform.rzipcode.focus();
return false;
}
}
}
}

if (theform.rcountry.value=="")
{
alert("Please enter the name of the recipients country.");
theform.rcountry.focus();
theform.rcountry.select();
return false;
}

if (theform.rccode.value=="")
{
alert("Please enter the recipients Country Code.");
theform.rccode.focus();
theform.rccode.select();
return false;
}
else
{
a = theform.rccode.value;
var i=0;
for(i=0;i<a.length;i++)
{
if(a.charAt(i) < '0' || a.charAt(i) > '9') 
{
if(!(a.charAt(i) == ' ' || a.charAt(i) == '(' || a.charAt(i)==')' || a.charAt(i)==',' || a.charAt(i)=='/' || a.charAt(i)=='-' || a.charAt(i)=='+' || a.charAt(i)=='[' || a.charAt(i)==']')) 
{
alert("Characters and Special symbols are not allowed in the Country Code field.");
theform.rccode.select();
theform.rccode.focus();
return false;
}
}
}
}

if (theform.racode.value=="")
{
alert("Please enter the recipients Area Code.");
theform.racode.focus();
theform.racode.select();
return false;
}
else
{
a = theform.racode.value;
var i=0;
for(i=0;i<a.length;i++)
{
if(a.charAt(i) < '0' || a.charAt(i) > '9') 
{
if(!(a.charAt(i) == ' ' || a.charAt(i) == '(' || a.charAt(i)==')' || a.charAt(i)==',' || a.charAt(i)=='/' || a.charAt(i)=='-' || a.charAt(i)=='+' || a.charAt(i)=='[' || a.charAt(i)==']')) 
{
alert("Characters and Special symbols are not allowed in the Area Code field.");
theform.racode.select();
theform.racode.focus();
return false;
}
}
}
}

if (theform.rphone.value=="")
{
alert("Please enter the recipients Phone Number.");
theform.rphone.focus();
theform.rphone.select();
return false;
}
else
{
a = theform.rphone.value;
var i=0;
for(i=0;i<a.length;i++)
{
if(a.charAt(i) < '0' || a.charAt(i) > '9') 
{
if(!(a.charAt(i) == ' ' || a.charAt(i) == '(' || a.charAt(i)==')' || a.charAt(i)==',' || a.charAt(i)=='/' || a.charAt(i)=='-' || a.charAt(i)=='+' || a.charAt(i)=='[' || a.charAt(i)==']')) 
{
alert("Characters and Special symbols are not allowed in the Phone Number field.");
theform.rphone.select();
theform.rphone.focus();
return false;
}
}
}
}

if (theform.remail.value=="")
{
alert("Please enter the recipients email address.");
theform.remail.focus();
theform.remail.select();
return false;
}
else if(theform.remail.value.indexOf(".") == -1 || theform.remail.value.indexOf("@") == -1)
{
alert("Please enter the recipients correct email address.");
theform.remail.select(); 
theform.remail.focus();
return false;
}

return true;
}

/*this function is called when the address of the sender and the reciever are the same.*/
function sameaddress()
{
if (document.uploadform.recpaddress.checked==true)
{
document.uploadform.rname.value=document.uploadform.sname.value;
document.uploadform.rstreet.value=document.uploadform.sstreet.value;	
document.uploadform.rlocality.value=document.uploadform.slocality.value;
document.uploadform.rcity.value=document.uploadform.scity.value;
document.uploadform.rzipcode.value=document.uploadform.szipcode.value;
document.uploadform.rcountry.value=document.uploadform.scountry.value;
document.uploadform.rccode.value=document.uploadform.sccode.value;
document.uploadform.racode.value=document.uploadform.sacode.value;
document.uploadform.rphone.value=document.uploadform.sphone.value;
document.uploadform.remail.value=document.uploadform.semail.value;
}
else
{
document.uploadform.rname.value="";
document.uploadform.rstreet.value="";	
document.uploadform.rlocality.value="";
document.uploadform.rcity.value="";
document.uploadform.rzipcode.value="";
document.uploadform.rcountry.value="";
document.uploadform.rccode.value="";
document.uploadform.racode.value="";
document.uploadform.rphone.value="";
document.uploadform.remail.value="";
}
}


var amount=0
var flag=0
var s
var amt1,amt2,amt3;
var z,p
z = new Array;
var nc

function chgamount(j)
{
isize=eval("document.uploadform2.imgsize"+j+".selectedIndex")
if (isize==1)
{
amt=9;
}
else if (isize==2)
{
amt=20;
}
else if (isize==3)
{
amt=48;
}
else if (isize==4)
{
amt=155;
}
else if (isize==0)
{
amt=0;
}
copies=eval("document.uploadform2.copies"+j+".options[document.uploadform2.copies"+j+".selectedIndex].value");
amt1=amt*copies;
eval("document.uploadform2.amt"+j+".value="+amt1);
calamount();
}


function calamount()
{
j=document.uploadform1.tp.value;
for(i=1;i<=j;i++)
{
z[i]=eval("document.uploadform2.amt"+i+".value");
}
amount=0;
for(i=1;i<=j;i++)
{
amount = amount + parseInt(z[i]);
}
if (amount==0)
{
document.uploadform2.amount.value="";
}
else
{
if (document.uploadform2.delmode[0].checked==true)
document.uploadform2.amount.value=amount+60;
else if (document.uploadform2.delmode[1].checked==true)
document.uploadform2.amount.value=amount;
else
document.uploadform2.amount.value=amount;
}
}


function validateform2(theform)
{
j=document.uploadform1.tp.value
nc=0
nos=0;

if (theform.uploadfile1.value=="")
{
alert("Please enter the location of the photograph.");
theform.uploadfile1.focus();
theform.uploadfile1.select();
return false;
}

for(i=1;i<=j;i++)
{

if (theform.elements[nos].value=="" && theform.elements[nos+2].selectedIndex!=0)
{
alert("Please enter the location of the photograph.");
theform.elements[nos].focus();
theform.elements[nos].select();
return false;
}

if (theform.elements[nos+1].selectedIndex==0 && theform.elements[nos].value!="")
{
alert("Please select the size of the photograph.");
theform.elements[nos+1].focus();
return false;
}

if (theform.elements[nos+2].selectedIndex==0 && theform.elements[nos].value!="")
{
alert("Please select the number of copies you require.");
theform.elements[nos+2].focus();
return false;
}

if (theform.elements[nos+1].selectedIndex!=0 && theform.elements[nos+2].selectedIndex==0)
{
alert("Please select the number of copies you require.");
theform.elements[nos+2].focus();
return false;
}

if (theform.elements[nos+1].selectedIndex==0 && theform.elements[nos+2].selectedIndex!=0)
{
alert("Please select the size of the photograph.");
theform.elements[nos+1].focus();
return false;
}

copies=theform.elements[nos+2].options[theform.elements[nos+2].selectedIndex].value;
if (copies=="")
copies=0
nc=nc+parseInt(copies)
nos=nos+4;
}

if (nc<20)
{
alert("The total order should be for a minimum of 20 prints.");
return false;
}

if (theform.delmode[0].checked==false && theform.delmode[1].checked==false)
{
alert("Please select the delivery mode.")
theform.delmode[0].focus();
return false;
}

return true;
}

