var url='http://www.funsongs.co.uk/';
function email(str) {
	    var error = "";
  var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){  
		document.getElementById("CustomerEmail").style.backgroundColor = '#FFDFE3';	
		document.getElementById("CustomerEmail2").style.backgroundColor = '#FFDFE3';
		   error = "Invalid E-mail\n";
		   return error;
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){  
		document.getElementById("CustomerEmail").style.backgroundColor = '#FFDFE3';	
		document.getElementById("CustomerEmail2").style.backgroundColor = '#FFDFE3';
		   error = "Invalid E-mail\n";
		   return error;
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		document.getElementById("CustomerEmail").style.backgroundColor = '#FFDFE3';	
		document.getElementById("CustomerEmail2").style.backgroundColor = '#FFDFE3';
		       error = "Invalid E-mail\n";
		   return error;
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		document.getElementById("CustomerEmail").style.backgroundColor = '#FFDFE3';	
		document.getElementById("CustomerEmail2").style.backgroundColor = '#FFDFE3';
		     error = "Invalid E-mail\n";
		   return error;
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){	 
		document.getElementById("CustomerEmail").style.backgroundColor = '#FFDFE3';	
		document.getElementById("CustomerEmail2").style.backgroundColor = '#FFDFE3';
		      error = "Invalid E-mail\n";
		   return error;
		 }

		 if (str.indexOf(dot,(lat+2))==-1){	
		document.getElementById("CustomerEmail").style.backgroundColor = '#FFDFE3';	
		document.getElementById("CustomerEmail2").style.backgroundColor = '#FFDFE3';
		   error = "Invalid E-mail\n";
		   return error;
		 }
		
		 if (str.indexOf(" ")!=-1){
		     error = "Invalid E-mail\n";
		document.getElementById("CustomerEmail").style.backgroundColor = '#FFDFE3';	
		document.getElementById("CustomerEmail2").style.backgroundColor = '#FFDFE3';
		   return error;
		 }

		   return error; 
}
function validate_details() { 

var reason = "";

  	reason += validatetel();
	reason += validatecountry();
  	reason += validateaddr1();
 	reason += validateaddr4();
 	reason += validateaddr5();
 	reason += validatepcode();
  	reason += email(document.customerregistration.CustomerEmail.value);
  	reason += validatefirstname();
  	reason += validatesurname();
	reason += validateemail();
 	reason += validatepasswordmatch();
 	reason += validatepasswordlength();
 	
  if (reason != "") {
    alert("Some fields need correction:\n" + reason);
    return false;
  }
else
{  document.customerregistration.action=url+'do.updatedetails.php';
   document.customerregistration.submit();
   
   }
}
function validatetel() {
    var error = "";
 
    if (document.customerregistration.CustomerTel1.value == "") 
	{	
		document.getElementById("CustomerTel1").style.backgroundColor = '#FFDFE3';
        error = "Please specify telephone number.\n";
    } 
    return error;  
}
function validatecountry() {
    var error = "";
 
    if (document.customerregistration.CustomerCountry.value == "") 
	{  
		document.getElementById("CustomerCountry").style.backgroundColor = '#FFDFE3';
        error = "You havent sepcified your country.\n";
    } 
    return error;  
}
function validateaddr1() {
    var error = "";
 
    if ( document.customerregistration.CustomerAddr1.value=="")
	{  
		document.getElementById("CustomerAddr1").style.backgroundColor = '#FFDFE3';
        error = "The first line of your address is missing.\n";
    } 
    return error;  
}
function validateaddr4() {
    var error = "";
 
  if ( document.customerregistration.CustomerAddr4.value=="")
    {	
		document.getElementById("CustomerAddr4").style.backgroundColor = '#FFDFE3';	
	
        error= "Your city is missing.\n";
   
    } 
    return error;  
}
function validateaddr5() {
    var error = "";
 
 if ( document.customerregistration.CustomerAddr5.value=="")
    {	
		document.getElementById("CustomerAddr5").style.backgroundColor = '#FFDFE3';	
		
        error= "Your State/Province is missing.\n";
   
    } 
    return error;  
} 
function validatepcode() {
    var error = "";
 
 if ( document.customerregistration.CustomerPcode.value=="")
    {	
		document.getElementById("CustomerPcode").style.backgroundColor = '#FFDFE3';	
		
        error= "Your Postcode / Zipcode is missing.\n";
   
    } 
    return error;  
}
function validatefirstname() {
    var error = "";
 
    if (document.customerregistration.CustomerFirstName.value == "") 
	{	
		document.getElementById("CustomerFirstName").style.backgroundColor = '#FFDFE3';
        error = "Please specify your first name.\n";
    } 
    return error;  
}
function validatesurname() {
    var error = "";
 
    if (document.customerregistration.CustomerSurname.value == "") 
	{  
		document.getElementById("CustomerSurname").style.backgroundColor = '#FFDFE3';
        error = "Please specify your surname.\n";
    } 
    return error;  
}
function validateemail() {
    var error = "";
 
    if ( document.customerregistration.CustomerEmail.value != document.customerregistration.CustomerEmail2.value)
	{  
		document.getElementById("CustomerEmail").style.backgroundColor = '#FFDFE3';
        error = "Your email addresses do not match.\n";
    } 
    return error;  
}
function validatepasswordlength() {
    var error = "";
 
  if ( document.customerregistration.password.value.length < 8 || document.customerregistration.password.value.length > 15)
    {	
		document.getElementById("password").style.backgroundColor = '#FFDFE3';	
		document.getElementById("password2").style.backgroundColor = '#FFDFE3';
        error= "Password must be at betwen 7 and 15 digits in length.\n";
   
    } 
    return error;  
}
function validatepasswordmatch() {
    var error = "";
 
 if ( document.customerregistration.password.value != document.customerregistration.password2.value)
    {	
		document.getElementById("password").style.backgroundColor = '#FFDFE3';	
		document.getElementById("password2").style.backgroundColor = '#FFDFE3';
        error= "Your passwords do not match.\n";
   
    } 
    return error;  
}
function validatedobday() {
    var error = "";
 
 if (document.customerregistration.CustomerdobDay.value == "")
    {
        document.getElementById("CustomerdobDay").style.backgroundColor = '#FFDFE3';	
		error= "Your DOB Day is missing.\n";
   
    } 
    return error;  
}
function validatedobyear() {
    var error = "";
 
 if (document.customerregistration.CustomerdobYear.value == "")
    {
        document.getElementById("CustomerdobYear").style.backgroundColor = '#FFDFE3';	
		error= "Your DOB Year is missing.\n";
   
    } 
    return error;  
}
function validategender() {
    var error = "";
 
 if (document.customerregistration.CustomerGender.value == "")
    {
        document.getElementById("CustomerGender").style.backgroundColor = '#FFDFE3';	
		error= "Your gender is missing.\n";
   
    } 
    return error;  
}
//--------------------------------------------------------------	
function validate_deladdress() {
var reason = "";
   reason += validatedelcn();
  	reason += validatedeltel();
	reason += validatedelcountry();
  	reason += validatedeladdr1();
 	reason += validatedeladdr4();
 	reason += validatedeladdr5();
 	reason += validatedelpcode();
  
  if (reason != "") {
    alert("Some fields need correction:\n" + reason);
    return false;
  }
else
{  
	document.customerregistration.action=url+'do.updatedeladdress.php';
    document.customerregistration.submit();
   }
}
function validatedelcn() {
    var error = "";
 
    if (document.customerregistration.CustomerDelContactName.value == "") 
	{	
		document.getElementById("CustomerDelContactName").style.backgroundColor = '#FFDFE3';
        error = "Please specify delivery telephone contact number.\n";
    } 
    return error;  
}
function validatedeltel() {
    var error = "";
 
    if (document.customerregistration.CustomerDelTel.value == "") 
	{	
		document.getElementById("CustomerDelTel").style.backgroundColor = '#FFDFE3';
        error = "Please specify delivery telephone contact number.\n";
    } 
    return error;  
}

function validatedelcountry() {
    var error = "";
 
    if (document.customerregistration.CustomerDelCountry.value == "") 
	{  
		document.getElementById("CustomerDelCountry").style.backgroundColor = '#FFDFE3';
        error = "You havent sepcified your delivery country.\n";
    } 
    return error;  
}
function validatedeladdr1() {
    var error = "";
 
    if ( document.customerregistration.CustomerDelAddr1.value=="")
	{  
		document.getElementById("CustomerDelAddr1").style.backgroundColor = '#FFDFE3';
        error = "The first line of your delivery address is missing.\n";
    } 
    return error;  
}
function validatedeladdr4() {
    var error = "";
 
  if ( document.customerregistration.CustomerDelAddr4.value=="")
    {	
		document.getElementById("CustomerDelAddr4").style.backgroundColor = '#FFDFE3';	
	
        error= "Your delivery city is missing.\n";
   
    } 
    return error;  
}
function validatedeladdr5() {
    var error = "";
 
 if ( document.customerregistration.CustomerDelAddr5.value=="")
    {	
		document.getElementById("CustomerDelAddr5").style.backgroundColor = '#FFDFE3';	
		
        error= "Your delivery state / Province is missing.\n";
   
    } 
    return error;  
} 
function validatedelpcode() {
    var error = "";
 
 if ( document.customerregistration.CustomerDelPcode.value=="")
    {	
		document.getElementById("CustomerDelPcode").style.backgroundColor = '#FFDFE3';	
		
        error= "Your delivery Postcode / Zipcode is missing.\n";
   
    } 
    return error;  
}
	

function checkad (fname)
{
fullName = fname;
shortName = fullName.match(/[^\/\\]+$/);
splitName = fullName.split(".");
fileType = splitName[1];
fileType = fileType.toLowerCase();
if (fileType != 'jpg' && fileType != 'jpeg')
    {
        alert ( "Invalid file format - File format must be jpeg/jpg not any other." );
		document.photo.reset();
    }
}

//--------------------------------------------------------------	

