/***************************/
//@Author: Adrian "yEnS" Mato Gondelle & Ivan Guardado Castro
//@website: www.yensdesign.com
//@email: yensamg@gmail.com
//@license: Feel free to use it, but keep this credits please!					
/***************************/

jQuery(document).ready(function(){
	//global vars
	var form = jQuery("#customForm");
	
	
	var verif_box = jQuery("#captcha");
	var verif_boxInfo = jQuery("#captchaInfo");
	
	
	//On blur
	//name.blur(validateName);
	verif_box.blur(validateVerif_box);
	
	//On key press
	//name.keyup(validateName);
	verif_box.keyup(validateVerif_box);
	
	//On Submitting
	form.submit(function(){
		if(validateVerif_box())
			return true
		else
			return false;
	});
	
	//validation functions
	
	function validateVerif_box(){
		//if it's NOT valid
		if(verif_box.val().length < 4){
			verif_box.addClass("error");
			verif_boxInfo.text("Mohon isikan kode verifikasi yang tertera");
			verif_boxInfo.addClass("error");
			return false;
		}
		//if it's valid
		else{
			verif_box.removeClass("error");
			verif_boxInfo.text("Kode verifikasi Anda");
			verif_boxInfo.removeClass("error");
			return true;
		}
	}
	
	function validateDisclaimer(){
		
		//it's NOT valid
		if(!jQuery("input[name=disclaimerbox]:checked").size()){
			disclaimer_box.addClass("error");
			disclaimer_boxInfo.text("Mohon isikan kotak disclaimer disamping");
			disclaimer_boxInfo.addClass("error");
			return false;
		}
		//it's valid
		else{			
			disclaimer_boxInfo.removeClass("error");
			return true;
		}
	}
});
