/*------------------------DEMO REGISTRATION FORM VALIDATION---------------------------*/
function ajax_validate_contact_form_part_two(errors_arr) {

			//if(errors_arr!='') {
			//if(typeof(errors_arr)!='number') {
			if(errors_arr!=1) {
				jQuery("#contact_form_msgbox").fadeTo(200,0.1,function() //start fading the messagebox
				{
					error = errors_arr.split('|');
					var parent = '';
					jQuery(this).html('').removeClass().addClass('messageboxerror').fadeTo(900,1).hide();
					for(j=0;j<error.length;j++) {
						if(error[j]=='firstname_too_short' || error[j]=='firstname_too_long') {
							parent = jQuery("#contact_form_firstname").parents('.RegistrationFormContainer');
							parent.addClass('input_error');
							if(error[j]=='firstname_too_short') {
								jQuery(parent).children('.ErrorText').show();
							}
							if(error[j]=='firstname_too_long') {
								jQuery(parent).children('.ErrorText1').show();
							}
						}
						
						if(error[j]=='email_empty'){
							parent = jQuery("#contact_form_email").parents('.RegistrationFormContainer');
							parent.addClass('input_error');
							jQuery(parent).children('.ErrorText').show();
						}
						if(error[j]=='email_wrong' || error[j]=='email_not_match') {
							if(error[j]!='email_not_match') {
								parent = jQuery("#contact_form_email").parents('.RegistrationFormContainer');
								parent.addClass('input_error');
								jQuery(parent).children('.ErrorText').show();
							}
							else {
								parent = jQuery("#contact_form_VerifyEmail").parents('.RegistrationFormContainer');
								parent.addClass('input_error');
								jQuery(parent).children('.ErrorText1').show();
							}
						} else if(error[j]=='invalid_email_domain') {
							parent = jQuery("#contact_form_email").parents('.RegistrationFormContainer');
							parent.addClass('input_error');
							jQuery(parent).children('.ErrorText2').show();
							
						} else if(error[j]=='email_already_exist'){
							parent = jQuery("#contact_form_email").parents('.RegistrationFormContainer');
							parent.addClass('input_error');
							jQuery(parent).children('.ErrorText3').show();
						}
						
						
						if(error[j]=='message_too_short' || error[j]=='message_too_long') {
							parent = jQuery("#contact_form_content").parents('.RegistrationFormContainer');
							parent.addClass('input_error');
							if(error[j]=='message_too_short') {
								jQuery(parent).children('.ErrorText').show();
							} else if(error[j]=='message_too_long') {
								jQuery(parent).children('.ErrorText1').show();
							}
						}
						

						if(error[j]=='wrong_captcha_answer') {
							parent = jQuery("#contact_form_security_code").parents('.RegistrationFormContainer');
							parent.addClass('input_error');
							jQuery(parent).children('.ErrorText').show();
						}
						
						//alert(error[j]);
						
					}
				});
				jQuery("#contact_form_submit_button").click(function() { ajax_validate_contact_form(); });
			} else {
				jQuery("#contact_form_msgbox").fadeTo(200,0.1,function()  //start fading the messagebox
		        {
		          //print success message and redirect
		          jQuery(this).html(_logging_in).removeClass().addClass('messageboxok').fadeTo(900,1,
		          function() {
		             document.forms.contact_form.submit();
		          });
		        });
			}	    
}

function ajax_validate_contact_form() {
	jQuery.scrollTo( jQuery('#anchor'), 500);
		jQuery("#contact_form_msgbox").removeClass().addClass('messagebox').text(_validating).fadeIn(1000);
		jQuery("#contact_form_submit_button").unbind('click');
        //remove all the class add the messagebox classes and start fading
        /*
        jQuery("#register_form_firstname").removeClass('input_error');
        jQuery("#register_form_lastname").removeClass('input_error');
        jQuery("#register_form_email").removeClass('input_error');
        jQuery("#register_form_VerifyEmail").removeClass('input_error');
        jQuery("#register_form_country_ID").removeClass('input_error');
        jQuery('#register_form_countryCode').removeClass('input_error');
        jQuery('#register_form_areaCode').removeClass('input_error');
        jQuery('#register_form_phone').removeClass('input_error');
        jQuery('#register_form_mobile_countryCode').removeClass('input_error');
        jQuery('#register_form_mobile_phone').removeClass('input_error');
        jQuery('#register_form_password').removeClass('input_error');
        jQuery("#register_form_VerifyPassword").removeClass('input_error');
        jQuery('#register_form_security_code').removeClass('input_error');*/
        jQuery('.RegistrationFormContainer').removeClass('input_error');
        jQuery('.ErrorText').hide();
        jQuery('.ErrorText1').hide();
        jQuery('.ErrorText2').hide();
        jQuery('.ErrorText3').hide();
        jQuery('.ErrorText4').hide();
        jQuery('.ErrorText5').hide();

	//check all fields
	jQuery.get('/ajax/ajax_func.php', {action: 'contact_form_validation',
		firstname:jQuery('#contact_form_firstname').val(),
		email:jQuery('#contact_form_email').val(),
		subject:jQuery("input[name='contact_form_subject']:checked").val(),
		content:jQuery('#contact_form_content').val(),
		security_code:jQuery('#contact_form_security_code').val() }, function(data) {
		
			ajax_validate_contact_form_part_two(data);
			
	});
}
/*------------------------DEMO REGISTRATION FORM VALIDATION---------------------------*/
