/*
 * @author - RamanujM
 * @created on - 21 Oct 2009 at 6:25 AM
 * @Purpose - For handling artist registration client side validation. 
 

$(function() {
	$('#user_birth_day').datepicker({
		yearRange: '1900:2100',
		maxDate: '+0d',
	   changeMonth: true,
	   changeYear: true
	});
});*/
function validateregistration()
{
	$('.txtboxcontrol').css('border-color','black');
	$('#td_genre').css('color','black');
	$('td').css('color','black');
	$('captchaword').css('color','black');
	$('.selboxcontrol').css('color','black');
	
	var firstName = document.getElementById("first_name").value;
	var lastName = document.getElementById("last_name").value;
	var email = document.getElementById("user_email").value;
	var con_email = document.getElementById("user_confirm_email").value;
	var birth_date = document.getElementById("user_birth_day").value;
	var user_name = document.getElementById("user_name").value;
	var password = document.getElementById("user_password").value;
	var con_password = document.getElementById("user_confirm_password").value;
	var genre = escape(document.getElementById('user_genre_name[]').value);
	var captcha = escape(document.getElementById("captchaword").value);

	
	
	var errorIdArr = new Array();
	
	if(isRequired(firstName))
		errorIdArr.push('first_name');

	if(isRequired(lastName))
		errorIdArr.push('last_name');
	
	if(isRequired(email)  ||  (!isEmail(email) )){
		errorIdArr.push('user_email');
	}
	
	if(isRequired(con_email) || !isEmail(con_email)){
		errorIdArr.push('user_confirm_email');
	}
	
	if(email != con_email){
		errorIdArr.push('user_confirm_email');
	}
  /* 
   * // 05/03/2011 Remove Date validation
	if(isRequired(birth_date))
		errorIdArr.push('user_birth_day');
	
	if (isDate(birth_date)==false){
		errorIdArr.push('user_birth_day');
	}
	*/
	if(isRequired(user_name))
		errorIdArr.push('user_name');
	
	
	if(isRequired(password))
		errorIdArr.push('user_password');
	
	if(isRequired(con_password))
		errorIdArr.push('user_confirm_password');
	
	if(password != con_password)
		errorIdArr.push('user_confirm_password');
	
	if(isRequired(captcha))		
		errorIdArr.push('captchaword');
	
	if(genre.length <= 0){
		$('#td_genre').css('color','red');
		$('.selboxcontrol').css('color','red');
		errorIdArr.push('user_genre_name');
	}
	
	var count = 0;
	for(i=0;i<errorIdArr.length;i++){
		count++;
		$('#'+errorIdArr[i]).css('border-color','red');
		$('#'+errorIdArr[i]).parents('tr').children('td:first').css('color','red');
	}
	
	$('#user_country').css('color','black');
	$('#user_state').css('color','black');
	
	if(count != 0)
		return false;
	
	return true;
}
function termChecker() {
	if (document.getElementById("term_con").checked == false) {
		document.getElementById("artist_reg").disabled = true;
	} else {
		document.getElementById("artist_reg").disabled = false;
	}
}
