/**
 * @author Narayan Pai
 */

function vFreeTrial_Step1() {
	var err=false;
	if($('input[name="b1_CVBrand_Interest"]:checked').val() == undefined) {
		$('#errPrd').fadeIn('slow'); err=true;
	}
	/*if( $('input[name="b8_Wear_Lens"]:checked').val() == undefined ) {
		$('#errWear').removeClass('hide'); err=true;
	}
	if( $('input[name="b8_Wear_Lens"]:checked').val() == 'yes'  ) {
		if( $('#wLenses').val() == 'No Selection' ) {
			$('#errLens').removeClass('hide'); err=true;
		}
	} 
	else {
		if(!err)
			return 1;
	}
	if( $('#wLenses').val() != 'No Selection' ) {
		if( $('#lensBrand').val() == 'None' ) {
			$('#errBrand').removeClass('hide'); err=true;	
		}
	}*/
	if (!err)
		return 1;
	else 
		return 0;
}


function vFreeTrial_Step2() {
	var vBool = false;
	$('.err').hide();
	$(':input.required').each( function() {
		$this=$(this);
		$this.val($.trim($this.val() ) ); //clear the trailing spaces
		if(!$this.val().length) {
			$this.prev().find('span').fadeIn('fast');
			vBool = true;
		}
		if(document.getElementById('a12_YOB').value == ""){
			$('#yob').fadeIn('slow'); 
			vBool=true;
		}
	});
	
	if(!vBool) {
		var cEmail=false;
		$(':input.email').each( function() {
			$this=$(this);
			var oVal = $this.val();
			var emailFilter = /^[a-zA-Z0-9_\.\-]+\@([a-zA-Z0-9\-]+\.)+[a-zA-Z0-9]{2,4}$/;
			if( !emailFilter.test(oVal)) {
				$this.siblings('label').find('span').text('Email entered is not valid').fadeIn('fast'); vBool=true;
			} else {
				cEmail = true;
			}			
		});
		if(cEmail){
			var $email=$(':input.email');		
			if($email.eq(0).val()!=$email.eq(1).val()) {
				$email.eq(1).siblings('label').find('span').text('Verify Email doesnt match').fadeIn('fast'); vBool=true;
			}
				
		}		
	}
	if(vBool)
		return false;
	else
		return true; 
}

function v_SWF() {
	var vBool=false;
	$('.err').hide();
	$(':input.req').each( function() {
		$this=$(this)
		$this.val($.trim($this.val() ) );
		if(!$this.val().length) {
			$this.siblings('label').find('span').fadeIn('fast');
			vBool = true;
		}
	})
	if(!vBool) {
		$(':input.email').each( function() {
			$this=$(this);
			var oVal = $this.val();
			var emailFilter = /^[a-zA-Z0-9_\.\-]+\@([a-zA-Z0-9\-]+\.)+[a-zA-Z0-9]{2,4}$/;
			if( !emailFilter.test(oVal)) {
				$this.siblings('label').find('span').text('Enter valid email').fadeIn('fast'); vBool=true;
			}			
		});
	
	}	
	if(vBool)
		return false;
	else{
		pageTracker._linkByPost(document.share_with_friends_form);
		return true;
	}
}

(function($){
	$.fn.cibaTrim = function(){
		return this.each( function() {
			var $this = $(this);
			$this.val($.trim($this.val() ) );
		})
	}
})(jQuery);

