function clearFeedbackForm(){
	var root=document.feedback;
	
	var name=root.full_name;
	var address=root.address;
	var street=root.street;
	var city=root.city;
	var country=root.country;
	var phone=root.phone;
	var email=root.email;
	var subject=root.subject;
	var message=root.message;
	
	if(confirm('Are you sure you want to clear this form?')){
		name.value="";
		address.value="";
		street.value="";
		city.value="";
		country.value="";
		phone.value="";
		email.value="";
		subject.value="";
		message.value="";
		
		return false;
	}
	
	return false;
}

function clearForm(){
	var root=document.contactForm;
	
	var name=root.full_name;
	var address=root.address;
	var street=root.street;
	var city=root.city;
	var country=root.country;
	var phone=root.phone;
	var email=root.email;
	var subject=root.subject;
	var message=root.message;
	
	if(confirm('Are you sure you want to clear this form?')){
		name.value="";
		address.value="";
		street.value="";
		city.value="";
		country.value="";
		phone.value="";
		email.value="";
		subject.value="";
		message.value="";
		
		return false;
	}
	
	return false;
}

function validateFeedback(){
	var root=document.feedback;
	
	var name=root.full_name;
	var company=root.company;
	var street=root.street;
	var address=root.address;
	var city=root.city;
	var state=root.state;
	var country=root.country;
	var phone=root.phone;
	var email=root.email;
	var department=root.department;
	var subject=root.subject;
	var message=root.message;
	
	
	if(name.value==""){
		alert('Please enter your full name.');
		name.focus();
		return false;
	}
	if(email.value==""){
		alert('Please enter an email address.');
		email.focus();
		return false;
	}
	var pattern = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/;

	flag=email.value.match(pattern);
	if(!flag){
		alert('Please insert a valid email address.');
		email.select();
		return false;
	}
	
	
	if(country.value==""){
		alert('Please select a country from the list.');
		country.focus();
		return false;
	}
	
	if(isNaN(phone.value)&&phone.value!=""){
		alert('The phone number should only contain digits.');
		phone.select();
		return false;
	}
	
	if(subject.value==""){
		alert('Please enter the subject.');
		subject.focus();
		return false;
	}
	if(message.value==""){
		alert('Please enter your message.');
		message.focus();
		return false;
	}
	return true;
	
}


function checkContactform(){
	var root=document.contactForm;
	
	var name=root.full_name;
	var company=root.company;
	var street=root.street;
	var address=root.address;
	var city=root.city;
	var state=root.state;
	var country=root.country;
	var phone=root.phone;
	var email=root.email;
	var department=root.department;
	var subject=root.subject;
	var message=root.message;
	
	
	if(name.value==""){
		alert('Please enter your full name.');
		name.focus();
		return false;
	}
	if(email.value==""){
		alert('Please enter an email address.');
		email.focus();
		return false;
	}
	var pattern = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/;

	flag=email.value.match(pattern);
	if(!flag){
		alert('Please insert a valid email address.');
		email.select();
		return false;
	}
	
	
	if(country.value==""){
		alert('Please select a country from the list.');
		country.focus();
		return false;
	}
	
	if(isNaN(phone.value)&&phone.value!=""){
		alert('The phone number should only contain digits.');
		phone.select();
		return false;
	}
	
	if(subject.value==""){
		alert('Please enter the subject.');
		subject.focus();
		return false;
	}
	if(message.value==""){
		alert('Please enter your message.');
		message.focus();
		return false;
	}
	return true;
}

function verifyGuestbook(){
	var name = document.sig_form.name.value;

	if(name == ""){
		alert('Please insert your name');
		document.sig_form.name.focus();
		return false;
	}
	var country = document.sig_form.countries[document.sig_form.countries.selectedIndex].value;
	if(country == ''){
		alert('Please Choose your country');
		document.sig_form.countries.focus();
		return false;
	}
	var email = document.sig_form.email.value;

	var pattern = /^([a-zA-Z0-9\._-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z]+)(\.[a-zA-Z]+)*$/;
	flag = pattern.test(email);
	if(!flag){
		alert("Please insert a valid e-mail address.");
		document.sig_form.email.select();
		return false;
	}
	var comments = document.sig_form.message.value;
	if(comments == ""){
		alert('Please insert your signature.');
		document.sig_form.message.focus();
		return false;
	}
	var vcode= document.sig_form.vcode.value;
	if(vcode == ""){
		alert('Please supply the visual code.');
		document.sig_form.vcode.focus();
		return false;
	}
}

function clearGuestbook(){
	var con=confirm('Are you sure you want to clear this form?');
	if(con){
		root = document.sig_form;
		root.name.value='';
		root.countries.value='';
		root.message.value='';
		root.email.value='';
	}
}
