function validate_form1()
{	
	
	var obj=document.contact;
	
		
		//Checks whether the "firstname" field is empty

		if (obj.txt_first.value == "" || obj.txt_first.value==null)
		{
			alert("Please enter a value for the \"First Name\" field.");
			obj.txt_first.style.backgroundColor = '#CFFF82';
			obj.txt_first.focus();
			return false;
		}
		
		//Checks whether the "lastname" field is empty

		if (obj.txt_last.value == "" || obj.txt_last.value==null)
		{
			alert("Please enter a value for the \"Last Name\" field.");
			obj.txt_last.style.backgroundColor = '#CFFF82';
			obj.txt_last.focus();
			return false;
		}
		
		//calls another function to check the validity of email entered

		if (validate_email1(obj.txt_email.value)==false)
		{
			alert("Please enter a valid email such as example@something.com!");
			obj.txt_email.style.backgroundColor = '#CFFF82';
			obj.txt_email.focus();
			obj.txt_email.select();
			return false;
		}
		
		//Checks whether the "company" field is empty

		if (obj.txt_com.value == "" || obj.txt_com.value==null)
		{
			alert("Please enter a value for the \"Company\" field.");
			obj.txt_com.style.backgroundColor = '#CFFF82';
			obj.txt_com.focus();
			return false;
		}
		
		//Checks whether the "address" field is empty

		if (obj.txt_add.value == "" || obj.txt_add.value==null)
		{
			alert("Please enter a value for the \"Address\" field.");
			obj.txt_add.style.backgroundColor = '#CFFF82';
			obj.txt_add.focus();
			return false;
		}
		
		//Checks whether the "city" field is empty

		if (obj.txt_city.value == "" || obj.txt_city.value==null)
		{
			alert("Please enter a value for the \"City\" field.");
			obj.txt_city.style.backgroundColor = '#CFFF82';
			obj.txt_city.focus();
			return false;
		}
		
		//Checks whether the "zipcode" field is empty

		if (obj.txt_zip.value == "" || obj.txt_zip.value==null)
		{
			alert("Please enter a value for the \"Zip Code\" field.");
			obj.txt_zip.style.backgroundColor = '#CFFF82';
			obj.txt_zip.focus();
			return false;
		}
		
		if(validateNumericZip(document.contact.txt_zip.value)==false)
		{
				alert("Please enter numeric character for Zip Code");
				obj.txt_zip.style.backgroundColor = '#CFFF82';
				obj.txt_zip.focus();
				return false
		}
		
		//Checks whether the "phone" field is empty

		if (obj.txt_phone.value == "" || obj.txt_phone.value==null)
		{
			alert("Please enter a value for the \"Phone\" field.");
			obj.txt_phone.style.backgroundColor = '#CFFF82';
			obj.txt_phone.focus();
			return false;
		}
	
		
		//Checks whether the "query" field is empty

		if (obj.query.value == "" || obj.query.value==null)
		{
			alert("Please enter a value for the \"Query\" field.");
			obj.query.style.backgroundColor = '#CFFF82';
			obj.query.focus();
			return false;
		}
		
				
}

function validate_email1(email) 
{	

	  	atpos=document.contact.txt_email.value.indexOf("@")
		dotpos=document.contact.txt_email.value.lastIndexOf(".");

		if (email==null || email=="") //Make sure email field is filled in
		{
			return false;
       		}
		
		if (! allValidChars(email)) //The email address must contain legal characters
		{
       			 return false;
		}

		if ( atpos < 1 || dotpos-atpos < 2 ) //The "@" must not be at the beginning and a dot (.) must be after the "@" sign
		{
       			 return false;
    		} 

		if (email.indexOf("..") >=0) // 2 successive dot (.) is not permitted
		{
			return false;
    		} 

		if (dotpos == (email.length-1)) //The  dot (.) must not be at the end of the email address
		{
			return false;
		}

		return true;
}

function allValidChars(email) 
{
	var parsed = true;
  	var validchars = "abcdefghijklmnopqrstuvwxyz0123456789@.-_"; // The email address must contain only these characters 
 	
	for (var i=0; i < email.length; i++) 
	{
 		var letter = email.charAt(i).toLowerCase(); //If an uppercase is entered, it is converted to lowercase
    				 
		if (validchars.indexOf(letter) != -1) //When no illegal character is detected, the check will continue
      		continue;
    		parsed = false;
    		break;
  	}

  	return parsed;
}

function validateNumericZip(param1)
{
	//var obj=document.contact;
	//var obj=param1;
	var str="0123456789";
	//var sid=obj.txt_zip.value;
	var sid=param1;
	if (sid.match(/^[0-9]{5}$/))
	{
		return true;
	}
	else
	{
		//alert("Please enter numeric character for Zip Code");
		//obj.txt_zip.style.backgroundColor = '#CFFF82';
		//obj.txt_zip.focus();
		return false;
	}
}


/////////---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//////////////////////
function validate_form2()
{	
	
	var obj=document.frm_logo;
	
		
		//Checks whether the "company name" field is empty

		if (obj.txt_comp.value == "" || obj.txt_comp.value==null)
		{
			alert("Please enter a value for the \"Company Name\" field.");
			obj.txt_comp.style.backgroundColor = '#CFFF82';
			obj.txt_comp.focus();
			return false;
		}
		
		//Checks whether the "laddress" field is empty

		if (obj.txt_address1.value == "" || obj.txt_address1.value==null)
		{
			alert("Please enter a value for the \"Address\" field.");
			obj.txt_address1.style.backgroundColor = '#CFFF82';
			obj.txt_address1.focus();
			return false;
		}
		
		//calls another function to check the validity of email entered

		if (validate_email2(obj.txt_contact.value)==false)
		{
			alert("Please enter a valid email such as example@something.com!");
			obj.txt_contact.style.backgroundColor = '#CFFF82';
			obj.txt_contact.focus();
			obj.txt_contact.select();
			return false;
		}
		
		//Checks whether the "product" field is empty

		if (obj.txt_prod.value == "" || obj.txt_prod.value==null)
		{
			alert("Please enter a value for the \"Product\" field.");
			obj.txt_prod.style.backgroundColor = '#CFFF82';
			obj.txt_prod.focus();
			return false;
		}
		
		//Checks whether the "companies" field is empty

		if (obj.txt_companies.value == "" || obj.txt_companies.value==null)
		{
			alert("Please enter a value for the \"Competing companies\" field.");
			obj.txt_companies.style.backgroundColor = '#CFFF82';
			obj.txt_companies.focus();
			return false;
		}
		
		//Checks whether the "substitiutes" field is empty

		if (obj.txt_subs.value == "" || obj.txt_subs.value==null)
		{
			alert("Please enter a value for the \"Substitutes\" field.");
			obj.txt_subs.style.backgroundColor = '#CFFF82';
			obj.txt_subs.focus();
			return false;
		}
		
		//Checks whether the "wordings" field is empty

		if (obj.txt_wordings.value == "" || obj.txt_wordings.value==null)
		{
			alert("Please enter a value for the \"Wordings\" field.");
			obj.txt_wordings.style.backgroundColor = '#CFFF82';
			obj.txt_wordings.focus();
			return false;
		}
		
		//Checks whether the "slogan" field is empty

		if (obj.txt_slogan.value == "" || obj.txt_slogan.value==null)
		{
			alert("Please enter a value for the \"Slogan\" field.");
			obj.txt_slogan.style.backgroundColor = '#CFFF82';
			obj.txt_slogan.focus();
			return false;
		}
		
		//checks if a radio button is checked for the audience

		if (obj.audience[0].checked == false && obj.audience[1].checked == false )
		{
			alert("Please enter the targetted audience");
			return false;
		}

		       
		//Checks whether the "please specify" field is empty
		
		if (obj.audience[1].checked== true)
		{
		if (obj.specify.value == "" || obj.specify.value==null)
		{
			alert("Please enter a value for the \"Please specify\" field.");
			obj.specify.style.backgroundColor = '#CFFF82';
			obj.specify.focus();
			return false;
		}
		}
		
		//Checks whether the "colors" field is empty

		if (obj.txt_colors.value == "" || obj.txt_colors.value==null)
		{
			alert("Please enter a value for the \"Preferred colours\" field.");
			obj.txt_colors.style.backgroundColor = '#CFFF82';
			obj.txt_colors.focus();
			return false;
		}
		
		//Checks whether the "ncolors" field is empty

		if (obj.txt_ncolors.value == "" || obj.txt_ncolrs.value==null)
		{
			alert("Please enter a value for the \"Colours to be avoided\" field.");
			obj.txt_ncolors.style.backgroundColor = '#CFFF82';
			obj.txt_ncolors.focus();
			return false;
		}
		
		
		//checks if a radio button is checked for the logotype

		if (obj.preference[0].checked == false && obj.preference[1].checked == false && obj.preference[2].checked == false)
		{
			alert("Please enter the logotype");
			return false;
		}
			
}

function validate_email2(email) 
{	

	  	atpos=document.frm_logo.txt_contact.value.indexOf("@")
		dotpos=document.frm_logo.txt_contact.value.lastIndexOf(".");

		if (email==null || email=="") //Make sure email field is filled in
		{
			return false;
       		}
		
		if (! allValidChars(email)) //The email address must contain legal characters
		{
       			 return false;
		}

		if ( atpos < 1 || dotpos-atpos < 2 ) //The "@" must not be at the beginning and a dot (.) must be after the "@" sign
		{
       			 return false;
    		} 

		if (email.indexOf("..") >=0) // 2 successive dot (.) is not permitted
		{
			return false;
    		} 

		if (dotpos == (email.length-1)) //The  dot (.) must not be at the end of the email address
		{
			return false;
		}

		return true;
}

/////////---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//////////////////////
function validate_form3()
{	
	
	var obj=document.frm_web;
			
		//Checks whether the "company name" field is empty

		if (obj.txt_comp.value == "" || obj.txt_comp.value==null)
		{
			alert("Please enter a value for the \"Company Name\" field.");
			obj.txt_comp.style.backgroundColor = '#CFFF82';
			obj.txt_comp.focus();
			return false;
		}
		
		//Checks whether the "name" field is empty

		if (obj.txt_name.value == "" || obj.txt_name.value==null)
		{
			alert("Please enter a value for the \"Name\" field.");
			obj.txt_name.style.backgroundColor = '#CFFF82';
			obj.txt_name.focus();
			return false;
		}
		
		//Checks whether the "telephone" field is empty

		if (obj.txt_tel.value == "" || obj.txt_tel.value==null)
		{
			alert("Please enter a value for the \"Phone\" field.");
			obj.txt_tel.style.backgroundColor = '#CFFF82';
			obj.txt_tel.focus();
			return false;
		}
		
		//calls another function to check the validity of email entered

		if (validate_email3(obj.txt_add.value)==false)
		{
			alert("Please enter a valid email such as example@something.com!");
			obj.txt_add.style.backgroundColor = '#CFFF82';
			obj.txt_add.focus();
			obj.txt_add.select();
			return false;
		}
				
		//Checks whether the "product" field is empty

		if (obj.prod.value == "" || obj.prod.value==null)
		{
			alert("Please enter a value for the \"Product\" field.");
			obj.prod.style.backgroundColor = '#CFFF82';
			obj.prod.focus();
			return false;
		}
		
		//Checks whether the "objectives" field is empty

		if (obj.objectives.value == "" || obj.objectives.value==null)
		{
			alert("Please enter a value for the \"Objecives\" field.");
			obj.objectives.style.backgroundColor = '#CFFF82';
			obj.objectives.focus();
			return false;
		}
		
		//Checks whether the "logo" field is empty

		if (obj.txt_logo.value == "" || obj.txt_logo.value==null)
		{
			alert("Please enter a value for the \"Logo\" field.");
			obj.txt_logo.style.backgroundColor = '#CFFF82';
			obj.txt_logo.focus();
			return false;
		}
		
		//Checks whether the "wordings" field is empty

		if (obj.txt_ideal.value == "" || obj.txt_ideal.value==null)
		{
			alert("Please enter a value for the \"Wordings\" field.");
			obj.txt_ideal.style.backgroundColor = '#CFFF82';
			obj.txt_ideal.focus();
			return false;
		}
		
		//Checks whether the "pages" field is empty

		if (obj.txt_pages.value == "" || obj.txt_pages.value==null)
		{
			alert("Please enter a value for the \"Pages\" field.");
			obj.txt_pages.style.backgroundColor = '#CFFF82';
			obj.txt_pages.focus();
			return false;
		}
		
		//Checks whether the "list pages" field is empty
		
		if (obj.pages.value == "" || obj.pages.value==null)
		{
			alert("Please enter a value for the \"List pages\" field.");
			obj.pages.style.backgroundColor = '#CFFF82';
			obj.pages.focus();
			return false;
		}
		
		//Checks whether the "function" field is empty

		if (obj.functions.value == "" || obj.functions.value==null)
		{
			alert("Please enter a value for the \"Functions\" field.");
			obj.functions.style.backgroundColor = '#CFFF82';
			obj.functions.focus();
			return false;
		}
		
		//Checks whether the "upating" field is empty

		if (obj.txt_update.value == "" || obj.txt_update.value==null)
		{
			alert("Please enter a value for the \"updating\" field.");
			obj.txt_update.style.backgroundColor = '#CFFF82';
			obj.txt_update.focus();
			return false;
		}
		
		//Checks whether the "budget" field is empty

		if (obj.txt_budget.value == "" || obj.txt_budget.value==null)
		{
			alert("Please enter a value for the \"budget\" field.");
			obj.txt_budget.style.backgroundColor = '#CFFF82';
			obj.txt_budget.focus();
			return false;
		}
		
		//Checks whether the "deadline" field is empty

		if (obj.txt_date.value == "" || obj.txt_date.value==null)
		{
			alert("Please enter a value for the \"date\" field.");
			obj.txt_date.style.backgroundColor = '#CFFF82';
			obj.txt_date.focus();
			return false;
		}
		
		//Checks whether the "hosting" field is empty

		if (obj.txt_host.value == "" || obj.txt_host.value==null)
		{
			alert("Please enter a value for the \"hosting\" field.");
			obj.txt_host.style.backgroundColor = '#CFFF82';
			obj.txt_host.focus();
			return false;
		}
		
}

function validate_email3(email) 
{	
	  	atpos=document.frm_web.txt_add.value.indexOf("@")
		dotpos=document.frm_web.txt_add.value.lastIndexOf(".");

		if (email==null || email=="") //Make sure email field is filled in
		{
			return false;
       		}
		
		if (! allValidChars(email)) //The email address must contain legal characters
		{
       			 return false;
		}

		if ( atpos < 1 || dotpos-atpos < 2 ) //The "@" must not be at the beginning and a dot (.) must be after the "@" sign
		{
       			 return false;
    		} 

		if (email.indexOf("..") >=0) // 2 successive dot (.) is not permitted
		{
			return false;
    		} 

		if (dotpos == (email.length-1)) //The  dot (.) must not be at the end of the email address
		{
			return false;
		}

		return true;
}


   /////////---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//////////////////////
function validate_form4()
{	
	
	var obj=document.frm_media;
			
		//Checks whether the "company name" field is empty

		if (obj.txt_comp.value == "" || obj.txt_comp.value==null)
		{
			alert("Please enter a value for the \"Company Name\" field.");
			obj.txt_comp.style.backgroundColor = '#CFFF82';
			obj.txt_comp.focus();
			return false;
		}
		
		//Checks whether the "name" field is empty

		if (obj.phy_add.value == "" || obj.phy_add.value==null)
		{
			alert("Please enter a value for the \"Physical address\" field.");
			obj.phy_add.style.backgroundColor = '#CFFF82';
			obj.phy_add.focus();
			return false;
		}
		
		//calls another function to check the validity of email entered

		if (validate_email4(obj.txt_email.value)==false)
		{
			alert("Please enter a valid email such as example@something.com! ");
			obj.txt_email.style.backgroundColor = '#CFFF82';
			obj.txt_email.focus();
			obj.txt_email.select();
			return false;
		}
		
		//Checks whether the "description" field is empty

		if (obj.desc.value == "" || obj.desc.value==null)
		{
			alert("Please enter a value for the \"Basic description\" field.");
			obj.desc.style.backgroundColor = '#CFFF82';
			obj.desc.focus();
			return false;
		}
		
		//Checks whether the "value" field is empty

		if (obj.txt_val.value == "" || obj.txt_val.value==null)
		{
			alert("Please enter a value for the \"Value of proposition\" field.");
			obj.txt_val.style.backgroundColor = '#CFFF82';
			obj.txt_val.focus();
			return false;
		}
		
		//Checks whether the "audience" field is empty

		if (obj.txt_audience.value == "" || obj.txt_audience.value==null)
		{
			alert("Please enter a value for the \"Target audience\" field.");
			obj.txt_audience.style.backgroundColor = '#CFFF82';
			obj.txt_audience.focus();
			return false;
		}
		
		//Checks whether the "perception" field is empty

		if (obj.a_perception.value == "" || obj.a_perception.value==null)
		{
			alert("Please enter a value for the \"perception\" field.");
			obj.a_perception.style.backgroundColor = '#CFFF82';
			obj.a_perception.focus();
			return false;
		}
		
		//Checks whether the "idea" field is empty

		if (obj.idea.value == "" || obj.idea.value==null)
		{
			alert("Please enter a value for the \"Single most important idea\" field.");
			obj.idea.style.backgroundColor = '#CFFF82';
			obj.idea.focus();
			return false;
		}
		
		//Checks whether the "voice" field is empty

		if (obj.txt_voice.value == "" || obj.txt_voice.value==null)
		{
			alert("Please enter a value for the \"Tone of voice\" field.");
			obj.txt_voice.style.backgroundColor = '#CFFF82';
			obj.txt_voice.focus();
			return false;
		}
		
		//Checks whether the "competitors" field is empty
		
		if (obj.txt_competitors.value == "" || obj.txt_competitors.value==null)
		{
			alert("Please enter a value for the \"Competitors\" field.");
			obj.txt_competitors.style.backgroundColor = '#CFFF82';
			obj.txt_competitors.focus();
			return false;
		}
		
		//Checks whether the "substitutes" field is empty

		if (obj.txt_subs.value == "" || obj.txt_subs.value==null)
		{
			alert("Please enter a value for the \"Substitutes\" field.");
			obj.txt_subs.style.backgroundColor = '#CFFF82';
			obj.txt_subs.focus();
			return false;
		}
		
		//Checks whether the "material" field is empty

		if (obj.material.value == "" || obj.material.value==null)
		{
			alert("Please enter a value for the \"Material\" field.");
			obj.material.style.backgroundColor = '#CFFF82';
			obj.material.focus();
			return false;
		}
		
		//Checks whether the "objective" field is empty

		if (obj.txt_obj.value == "" || obj.txt_obj.value==null)
		{
			alert("Please enter a value for the \"objective\" field.");
			obj.txt_obj.style.backgroundColor = '#CFFF82';
			obj.txt_obj.focus();
			return false;
		}
		
		//Checks whether the "communication" field is empty

		if (obj.comm.value == "" || obj.comm.value==null)
		{
			alert("Please enter a value for the \"Communication\" field.");
			obj.comm.style.backgroundColor = '#CFFF82';
			obj.comm.focus();
			return false;
		}
		
		//Checks whether the "design" field is empty

		if (obj.design.value == "" || obj.design.value==null)
		{
			alert("Please enter a value for the \"Design issues\" field.");
			obj.design.style.backgroundColor = '#CFFF82';
			obj.design.focus();
			return false;
		}
		
		//Checks whether the "deadline field is empty

		if (obj.txt_date.value == "" || obj.txt_date.value==null)
		{
			alert("Please enter a value for the \"Deadline\" field.");
			obj.txt_date.style.backgroundColor = '#CFFF82';
			obj.txt_date.focus();
			return false;
		}
}

function validate_email4(email) 
{	
	  	atpos=document.frm_media.txt_email.value.indexOf("@")
		dotpos=document.frm_media.txt_email.value.lastIndexOf(".");

		if (email==null || email=="") //Make sure email field is filled in
		{
			return false;
       		}
		
		if (! allValidChars(email)) //The email address must contain legal characters
		{
       			 return false;
		}

		if ( atpos < 1 || dotpos-atpos < 2 ) //The "@" must not be at the beginning and a dot (.) must be after the "@" sign
		{
       			 return false;
    		} 

		if (email.indexOf("..") >=0) // 2 successive dot (.) is not permitted
		{
			return false;
    		} 

		if (dotpos == (email.length-1)) //The  dot (.) must not be at the end of the email address
		{
			return false;
		}

		return true;
}

function validate_form5()
{	
	
	var obj=document.frm_edit;
		
		//Checks whether the "Password" field is empty

		if (obj.txt_pass.value == "" || obj.txt_pass.value==null)
		{
			alert("Please enter a value for the \"Password\" field.");
			obj.txt_pass.style.backgroundColor = '#CFFF82';
			obj.txt_pass.focus();
			return false;
		}
		//Checks whether the "Confirm password" field is empty
				
		if (obj.txt_conf.value == "" || obj.txt_conf.value==null)
		{
			alert("Please enter a value for the \"Confirm password\" field.");
			obj.txt_conf.style.backgroundColor = '#CFFF82';
			obj.txt_conf.focus();
			return false;
		}

		//checks if what is entered in the "Confirm password" is the same as that of the "username" field
		
		if (obj.txt_conf.value != obj.txt_pass.value)
		{
			alert("The passwords submitted are not the same");
			obj.txt_conf.focus();
			return false;
		}
}