// Author:	Ravi Gupta

function validateForm(obj) {

	errors = false;
	
	// Validate form Values

	// Name
	if (((obj == document.getElementById('sub_name')) || (obj == null)) && ((!document.getElementById('sub_name').value) || (document.getElementById('sub_name').value == 'name'))) {
		document.getElementById('sub_name').style.color = 'red';
		document.getElementById('sub_name').style.border = '1px solid red';
		document.getElementById('sub_name').style.background = '#FBEBD6 url(../images/error.png) no-repeat right center';
		errors = true;
	} else if ((obj == document.getElementById('sub_name')) || (obj == null)) {
		document.getElementById('sub_name').style.color = 'green';
		document.getElementById('sub_name').style.border = '1px solid green';
		document.getElementById('sub_name').style.background = '#FBEBD6 url(../images/pass.png) no-repeat right center';
	}
	// Comment
//	if (((obj == document.getElementById('sub_comment')) || (obj == null)) && ((!document.getElementById('sub_comment').value) || (document.getElementById('sub_comment').value == 'comment'))) {
//		document.getElementById('sub_comment').style.color = 'red';
//		document.getElementById('sub_comment').style.border = '1px solid red';
//		document.getElementById('sub_comment').style.background = '#FBEBD6 url(../images/error.png) no-repeat right center';
//		errors = true;
//	} else if ((obj == document.getElementById('sub_comment')) || (obj == null)) {
//		document.getElementById('sub_comment').style.color = 'green';
//		document.getElementById('sub_comment').style.border = '1px solid green';
//		document.getElementById('sub_comment').style.background = '#FBEBD6 url(../images/pass.png) no-repeat right center';
//	}
	// phone
	if (((obj == document.getElementById('sub_phone')) || (obj == null)) && ((!document.getElementById('sub_phone').value) || (document.getElementById('sub_phone').value == '(area code) phone number'))) {
		document.getElementById('sub_phone').style.color = 'red';
		document.getElementById('sub_phone').style.border = '1px solid red';
		document.getElementById('sub_phone').style.background = '#FBEBD6 url(../images/error.png) no-repeat right center';
		errors = true;
	} else if ((obj == document.getElementById('sub_phone')) || (obj == null)) {
		document.getElementById('sub_phone').style.color = 'green';
		document.getElementById('sub_phone').style.border = '1px solid green';
		document.getElementById('sub_phone').style.background = '#FBEBD6 url(../images/pass.png) no-repeat right center';
	}
	// visitor interest
	if (((obj == document.getElementById('sub_interested')) || (obj == null)) && ((!document.getElementById('sub_interested').value) || (document.getElementById('sub_interested').value == 'i\'m interested in'))) {
		document.getElementById('sub_interested').style.color = 'red';
		document.getElementById('sub_interested').style.border = '1px solid red';
		document.getElementById('sub_interested').style.background = '#FBEBD6 url(../images/error.png) no-repeat 165px center';
		errors = true;
	} else if ((obj == document.getElementById('sub_interested')) || (obj == null)) {
		document.getElementById('sub_interested').style.color = 'green';
		document.getElementById('sub_interested').style.border = '1px solid green';
		document.getElementById('sub_interested').style.background = '#FBEBD6 url(../images/pass.png) no-repeat 165px center';
	}
	// Email Address
	var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	var address = document.getElementById('sub_email').value;
	if (((obj == document.getElementById('sub_email')) || (obj == null)) && (reg.test(address) == false)) {
		document.getElementById('sub_email').style.color = 'red';
		document.getElementById('sub_email').style.border = '1px solid red';
		document.getElementById('sub_email').style.background = '#FBEBD6 url(../images/error.png) no-repeat right center';
		errors = true;
	} else if ((obj == document.getElementById('sub_email')) || (obj == null)) {
		document.getElementById('sub_email').style.color = 'green';
		document.getElementById('sub_email').style.border = '1px solid green';
		document.getElementById('sub_email').style.background = '#FBEBD6 url(../images/pass.png) no-repeat right center';
	}

	if ((document.getElementById('sub_address').value == 'postal address (optional)') && (obj == null)) {
		document.getElementById('sub_address').value = '';
	} else if (((obj == document.getElementById('sub_address')) || (obj == null))  && ((document.getElementById('sub_address').value != 'postal address (optional)') && (document.getElementById('sub_address').value != ''))) {
		document.getElementById('sub_address').style.color = 'green';
		document.getElementById('sub_address').style.border = '1px solid green';
		document.getElementById('sub_address').style.background = '#FBEBD6 url(../images/pass.png) no-repeat right center';
	}
	
	if (errors == true) {
		return false;
	} else {
		return true;
	}
}
