jQuery(document).ready(function($)
{
//Added JS {Kolawole Balgun}
$('.eachstepheader').click(function(){
var activatedEventElement = $(this);
$('.eachstepcontent').stop().animate({
height : 0
});
if($(this).next().height() == 0){
$(this).next().hide();
var autoheight = $(this).next().css('height', 'auto');
var curheight = $(this).next().height();
var zeroheight = $(this).next().css('height', '0px');
$(this).next().show();
$(this).next().stop().animate({
height : curheight + 70
}, function(){
$('.expand_collapse_icon', activatedEventElement).html('-');
});
}else{
$(this).next().stop().animate({
height : 0
}, function(){
$('.expand_collapse_icon', activatedEventElement).html('+');
});
}
});
// getter and setter
$( "#dd_dbirth, #benef_dbirth1, #benef_dbirth2, #benef_dbirth3, #benef_dbirth4" ).datepicker({
dateFormat: "yy-mm-dd",
changeMonth: true,
changeYear: true,
yearRange: "-80:+2"
});
//Form Validation
$('#desiredprem').blur(function(){
var desiredprem = $('#desiredprem').val();
var premfrq_val = $('#dd_premfrq_val').val();
var annual_prem = desiredprem * premfrq_val;
});
x=0;
$('.eachstepheader').each(function(){
if( x == parseInt(localStorage.getItem("clickbtn_index"))+parseInt(1)) { //retrive the clicked index and initialte the step toggle
$(this).click();
}
x++;
})
//Personal Details Validation
$('#save_personal_details').click(function(){
$("#regstatus").removeAttr("name");
var dd_title = $('#dd_title').val();
var lname = $('#lname').val();
var fname = $('#fname').val();
var placeofb = $('#placeofb').val();
var dd_dbirth = $('#dd_dbirth').val();
var mm_name = $('#mm_name').val();
var dd_occupa = $('#dd_occupa').val();
var dd_gender = $('input[name=dd_gender]:checked', '#frm_quote').val();
var dd_mstatus1 = $('input[name=dd_mstatus1]:checked', '#frm_quote').val();
//if(required(dd_title, 'dd_title', '', '', '', '')){
// $('#personal_details_msg').html("NOTE: Please, select your title.");
// }else
if(required(lname, 'lname', '', '', '', '')){
$('#personal_details_msg').html("NOTE: Please, type your last name.");
}else if(required(fname, 'fname', '', '', '', '')){
$('#personal_details_msg').html("NOTE: Please, type your other name.");
}else if(required(dd_dbirth, 'dd_dbirth', '', '', '', '')){
$('#personal_details_msg').html("NOTE: Please, type your date of birth.");
}else if(required(dd_occupa, 'dd_occupa', '', '', '', '')){
$('#personal_details_msg').html("NOTE: Please, select your occupation.");
}else if(!dd_gender){
$('#personal_details_msg').html("NOTE: Please, select your gender.");
}else if(required(placeofb, 'placeofb', '', '', '', '')){
$('#personal_details_msg').html("NOTE: Please, type your place of birth.");
}else if(required(mm_name, 'mm_name', '', '', '', '')){
$('#personal_details_msg').html("NOTE: Please, type your mother's maiden name.");
}else if(required(dd_mstatus1, 'dd_mstatus1', '', '', '', '')){
$('#personal_details_msg').html("NOTE: Please, Select Your Marital Status");
}else{
$('#personal_details_msg').html("");
document.forms.frm_quote.submit();
}
//End Personal Details Validation
///
///
});
//Contact Details Validation
/////////////////////////////
$('#save_contact_details').click(function(){
$("#regstatus").removeAttr("name");
var lphone = $('#lphone').val();
var gsm = $('#gsm').val();
var femail = $('#email').val();
var fax = $('#fax').val();
var comm_addr = $('input[name=comm_addr]:checked', '#frm_quote').val();
var address1 = $('#address1').val();
var postaddr1 = $('#postaddr1').val();
//checking this later//
if(gsm == '' || undefined === typeof gsm){
$('#contact_details_msg').html("NOTE: Type your mobile number");
}else if(isNaN(gsm)){
$('#contact_details_msg').html("NOTE: Please enter a valid mobile number");
}else if(femail == '' || undefined === typeof femail){
$('#contact_details_msg').html("NOTE: Type your email address");
}else if(emailChecks(femail, 'femail', '', '', '', '')){
$('#contact_details_msg').html("NOTE: Type a valid email address");
}else if(address1 == '' || undefined === typeof address1){
$('#contact_details_msg').html("NOTE: Type your current address");
}else{
$('#contact_details_msg').html("");
//todo on valid form
document.forms.frm_quote.submit();
}
});
//End Contact Details Validation
//Employer Details Validation
/////////////////////////////
$('#save_employer_details').click(function(){
$("#regstatus").removeAttr("name");
var empname = $('#empname').val();
var empphone = $('#empphone').val();
var empaddr1 = $('#empaddr1').val();
if(plainNumber(empphone, 'empphone', '', '', '', '')){
$('#employer_details_msg').html("NOTE: Type, valid number of employer");
}else if(required(empname, 'empname', '', '', '', '')){
$('#employer_details_msg').html("NOTE: Please, type your employer's name.");
}else if(required(empphone, 'empphone', '', '', '', '')){
$('#employer_details_msg').html("NOTE: Please, type your employer's phone.");
}else if(required(empaddr1, 'empaddr1', '', '', '', '')){
$('#employer_details_msg').html("NOTE: Please, type your employers address.");
}else{
//todo on valid form
document.forms.frm_quote.submit();
}
});
//End Employer Details Validation
//Decalration
/////////////////////////////
$('#save_declearation').click(function(){
var check = $('#regstatus').is(':checked');
if (check)
{
var dd_title = $('#dd_title').val();
var kycsave_text = $('#kycsave_text').val();
var lname = $('#lname').val();
var fname = $('#fname').val();
var placeofb = $('#placeofb').val();
var dd_dbirth = $('#dd_dbirth').val();
var mm_name = $('#mm_name').val();
var dd_occupa = $('#dd_occupa').val();
var dd_gender = $('input[name=dd_gender]:checked', '#frm_quote').val();
var dd_mstatus1 = $('input[name=dd_mstatus1]:checked', '#frm_quote').val();
var lphone = $('#lphone').val();
var gsm = $('#gsm').val();
var femail = $('#femail').val();
var fax = $('#fax').val();
var comm_addr = $('input[name=comm_addr]:checked', '#frm_quote').val();
var address1 = $('#address1').val();
var postaddr1 = $('#postaddr1').val();
var empname = $('#empname').val();
var empphone = $('#empphone').val();
var empaddr1 = $('#empaddr1').val();
var sumass = $('input[name=sumass]:checked', '#frm_quote').val();
var sumass2 = $('#sumass2').val();
var paymode = $('input[name=paymode]:checked', '#frm_quote').val();
var paymode_b = $('#paymode_b').val();
var actnum = $('#actnum').val();
var acct_name = $('#acct_name').val();
var bnkname = $('#bnkname').val();
var nok = $('#nok').val();
var nokphone = $('#nokphone').val();
var nok_addr1 = $('#nok_addr1').val();
var dd_nok_rel = $('#dd_nok_rel').val();
var dd_country = $('#dd_country').val();
var dd_state = $('#dd_state').val();
var nok_above_18 = $('#nok_above_18').is(':checked');
if($('#plan').val() != 'ITRM4'){ // DON NOT VALIDATE FOR PROTECTION PLAN
var init_contrib = $('#init_contrib').val();
var esc = $('input[name=esc]:checked', '#frm_quote').val();
var qterm_a = $('input[name=qterm_a]:checked', '#frm_quote').val();
var qterm_b = $('#qterm_b').val();
var annual_prem_a = $('input[name=annual_prem_a]:checked', '#frm_quote').val();
var annual_prem_b = $('#annual_prem_b').val();
var dd_premfrq_a = $('input[name=dd_premfrq_a]:checked', '#frm_quote').val();
var annual_prem = $('#annual_prem').val().replace(/,/g,"");
var desiredprem = $('#desiredprem').val().replace(/,/g,"");
var insureval = $('#insureval').val().replace(/,/g,"");
//
$('#annual_prem').val(annual_prem);
$('#desiredprem').val(desiredprem);
$('#insureval').val(insureval);
}
//todo check all required credentials are set
var confirmation = confirm(kycsave_text);
if (confirmation) {
if ((lname != '' || $('#lname').length == 0) &&
(fname != '' || $('#fname').length == 0) &&
(placeofb != '' || $('#placeofb').length == 0) &&
(dd_dbirth != '' || $('#dd_dbirth').length == 0) &&
(mm_name != '' || $('#lname').length == 0) &&
(dd_occupa != '' || $('#dd_occupa').length == 0) &&
(empname != '' || $('#empname').length == 0) &&
(empphone != '' || $('#empphone').length == 0) &&
(empaddr1 != '' || $('#empaddr1').length == 0) &&
(gsm != '' || $('#gsm').length == 0) &&
(email != '' || $('#email').length == 0) &&
(address1 != '' || $('#address1').length == 0) &&
(actnum != '' || $('#actnum').length == 0) &&
(acct_name != '' || $('#acct_name').length == 0) &&
(bnkname != '' || $('#bnkname').length == 0) &&
(nok != '' || $('#nok').length == 0) &&
(nokphone != '' || $('#nokphone').length == 0) &&
(nok_addr1 != '' || $('#nok_addr1').length == 0) &&
(dd_nok_rel != '' || $('#dd_nok_rel').length == 0) &&
(nok_above_18 != '' || $('#nok_above_18').length == 0) &&
(dd_country != '' || $('#dd_country').length == 0) &&
(dd_state != '' || $('#dd_state').length == 0) &&
(dd_gender != '' || $('input[name=dd_gender]').length == 0)){
var querystring = $('#frm_quote').serialize();
quote_calculator(querystring);
//document.forms.frm_quote.submit();
}
else {
alert('Some Required Fields Are Not Entered');
}
}
}
else {
if ($("#declaration_msg").length > 0){ //chceck if it exist first
$('#declaration_msg').html("NOTE:Confirm Checkbox Selection");
}
else {
$('#declaration_msg').html("");
alert("Check Licence Agreement Before Proceeding");
}
}
});
//declaration
//Coverage Details Validation
/////////////////////////////////
$('#save_coverage_details').click(function(){
$("#regstatus").removeAttr("name");
var sumass = $('input[name=sumass]:checked', '#frm_quote').val();
var sumass2 = $('#sumass2').val();
var insureval = $('#insureval').val();
if($('#plan').val() != 'ITRM4'){ // we dont do any form of premium and contribution validation for Protection Plan
var desiredprem = $('#desiredprem').val();
var esc = $('input[name=esc]:checked', '#frm_quote').val();
var qterm_a = $('input[name=qterm_a]:checked', '#frm_quote').val();
var qterm_b = $('#qterm_b').val();
var annual_prem_a = $('input[name=annual_prem_a]:checked', '#frm_quote').val();
var annual_prem_b = $('#annual_prem_b').val();
var annual_prem = $('#annual_prem').val();
//
annual_prem = annual_prem.replace(/,/g,"");
desiredprem = desiredprem.replace(/,/g,"");
insureval = insureval.replace(/,/g,"");
//
$('#annual_prem').val(annual_prem);
$('#desiredprem').val(desiredprem);
$('#insureval').val(insureval);
var dd_premfrq_a = $('input[name=dd_premfrq_a]:checked', '#frm_quote').val();
var paymode = $('input[name=paymode]:checked', '#frm_quote').val();
var paymode_b = $('#paymode_b').val();
var init_contrib = $('#init_contrib').val();
if(required(insureval, 'insureval', '', '', '', '')){
$('#coverage_details_msg').html("NOTE: Type sum assured");
//return;
}
else if((plainRawNumber(insureval, 'insureval', '', '', '', ''))){
$('#coverage_details_msg').html("NOTE: Type valid sum assured");
//return;
}else{
//todo on valid form
document.forms.frm_quote.submit();
}
}
//
// if(!esc){
// $('#coverage_details_msg').html("NOTE: Choose Sum Assured Escalation");
// return;
// }
//
// if((qterm_a == '__o__') && (required(qterm_b, 'qterm_b', '', '', '', ''))){
// $('#coverage_details_msg').html("NOTE: Type Proposed Tenure");
// return;
// }
//
//
// if((plainRawNumber(qterm_b, 'qterm_b', '', '', '', ''))){
// $('#coverage_details_msg').html("NOTE: Type Valid Proposed Tenure");
// return;
// }
//
//
// if((annual_prem_a == '__o__') && (required(annual_prem_b, 'annual_prem_b', '', '', '', ''))){
// $('#coverage_details_msg').html("NOTE: Type Annual Contribution");
// return;
// }
//
//
// if((plainRawNumber(annual_prem_b, 'annual_prem_b', '', '', '', ''))){
// $('#coverage_details_msg').html("NOTE: Type Valid Annual Contribution");
// return;
// }
//
//
// if(!dd_premfrq_a){
// $('#coverage_details_msg').html("NOTE: Choose Contribution Payment Pattern");
// return;
// }
//
//
// if((annual_prem_a == '__o__') && (required(annual_prem_b, 'annual_prem_b', '', '', '', ''))){
// $('#coverage_details_msg').html("NOTE: Type Annual Contribution");
// return;
// }
//
//
// if((plainRawNumber(annual_prem_b, 'annual_prem_b', '', '', '', ''))){
// $('#coverage_details_msg').html("NOTE: Type Valid Annual Contribution");
// return;
// }
//
//
// if((paymode == '__o__') && (required(paymode_b, 'paymode_b', '', '', '', ''))){
// $('#coverage_details_msg').html("NOTE: Type Contribution Payment");
// return;
// }
//
//
// if((required(init_contrib, 'init_contrib', '', '', '', ''))){
// $('#coverage_details_msg').html("NOTE: Type Initial Contribution");
// return;
// }
//
//
// if((plainRawNumber(init_contrib, 'init_contrib', '', '', '', ''))){
// $('#coverage_details_msg').html("NOTE: Type Valid Initial Contribution");
// return;
// }
//
else {
//todo on valid form
document.forms.frm_quote.submit();
}
});
//End Coverage Details Validation
////save_initial_payment_details START
$('#save_initial_payment_details').click(function(){
$("#regstatus").removeAttr("name");
var bnkname = $('#bnkname').val();
var acct_name = $('#acct_name').val();
var actnum = $('#actnum').val();
if(required(bnkname, 'bnkname', '', '', '', '')){
$('#initial_payment_details_msg').html("NOTE: Please, select your Bank.");
}
else if(required(acct_name, 'acct_name', '', '', '', '')) {
$('#initial_payment_details_msg').html("NOTE: Please Enter Account Name");
}
else if(required(actnum, 'actnum', '', '', '', '')) {
$('#initial_payment_details_msg').html("NOTE: Please Enter Account Number");
}
else {
//todo on valid form
document.forms.frm_quote.submit();
}
//$('#initial_payment_details_msg').html("");
});
////save_initial_payment_details END
////save_other_assurance_details START
$('#save_other_assurance_details').click(function(){
$("#regstatus").removeAttr("name");
$('#other_assurance_details_msg').html("");
//todo on valid form
document.forms.frm_quote.submit();
});
////save_initial_paymsave_other_assurance_detailsent_details END
////save_medical_details START
$('#save_medical_details').click(function(){
$("#regstatus").removeAttr("name");
$('#medical_details_msg').html("");
var health = $('input[name=health]:checked', '#frm_quote').val();
var dd_binfirmity = $('input[name=dd_binfirmity]:checked', '#frm_quote').val();
var aids = $('input[name=aids]:checked', '#frm_quote').val();
var symp = $('input[name=symp]:checked', '#frm_quote').val();
var absent = $('input[name=absent]:checked', '#frm_quote').val();
var fem_preg = $('input[name=fem_preg]:checked', '#frm_quote').val();
var weight = $('#weight').val();
var height = $('#height').val();
if(required(height, 'height', '', '', '', '') || parseInt(height) <= 0) {
$('#medical_details_msg').html("NOTE: Please Enter Your Height");
}
else if(required(weight, 'weight', '', '', '', '') || parseInt(weight) <= 0) {
$('#medical_details_msg').html("NOTE: Please Enter Your Weight");
}
else if(!health){
$('#medical_details_msg').html("NOTE: Please, Select Your Health.");
}
else if(!dd_binfirmity) {
$('#medical_details_msg').html("NOTE: Please, Enter Your Bodily Infirmity.");
}
else if(!aids) {
$('#medical_details_msg').html("NOTE: Please, Select You Have Some Illeness.");
}
else if(!symp) {
$('#medical_details_msg').html("NOTE: Please, Select Your Symptoms.");
}
else if(!absent) {
$('#medical_details_msg').html("NOTE: Please, Select Your Absence.");
}
else if(!fem_preg) {
$('#medical_details_msg').html("NOTE: Please, Select If You Are Pregnant");
}
else {
//todo on valid form
document.forms.frm_quote.submit();
}
});
////save_medical_details END
////save_kinship_details START
$('#save_kinship_details').click(function(){
$("#regstatus").removeAttr("name");
$('#kinship_details_msg').html("");
var nok = $('#nok').val();
var nokphone = $('#nokphone').val();
var nok_addr1 = $('#nok_addr1').val();
var dd_nok_rel = $('#dd_nok_rel').val();
var nok_above_18 = $('#nok_above_18').is(':checked');
if(required(nok, 'nok', '', '', '', '')){
$('#kinship_details_msg').html("NOTE: Please, Enter Your Next Of Kin Name");
}
else if(required(nokphone, 'nokphone', '', '', '', '')) {
$('#kinship_details_msg').html("NOTE: Please Enter Your Next Of Kin Phone Number");
}
else if(isNaN(nokphone)) {
$('#kinship_details_msg').html("NOTE: Please Enter A Valid Next Of Kin Phone Number");
}
else if(required(nok_addr1, 'nok_addr1', '', '', '', '')) {
$('#kinship_details_msg').html("NOTE: Please Enter Your Next Of Kin Address");
}
else if(required(dd_nok_rel, 'dd_nok_rel', '', '', '', '')) {
$('#kinship_details_msg').html("NOTE: Please Enter Next Of Kin Relation");
}
else if(nok_above_18 == false) {
$('#kinship_details_msg').html("NOTE: Please Confirm The Next Of Kin Is above 18");
}
else {
//todo on valid form
document.forms.frm_quote.submit();
}
});
////save_kinship_details END
//@author Maison Armani
//$('*[ch-class]').attr("value" ,'N'); // just predefined
// Validate the beneficiary proportion
var validateProportion = function(){
//$('#beneficiary_details_msg').html("");
var $all_benefprop = $("#beneficiary_form *[name *= 'benef_prop']");
var $all_benefname = $("#beneficiary_form *[name *= 'benef_name']");
var $all_matbenefprop = $("#mat_beneficiary_form *[name *= 'benef_prop']");
var $all_matbenefname = $("#mat_beneficiary_form *[name *= 'benef_name']");
var n_prop = l_prop = 0;
var $PROGRESS_FLAG = $N_PROGRESS_FLAG = false;
var $gu_flag = true;
$all_benefprop.each(function(index,elem){
l_prop += isNaN(parseInt(elem.value)) ? 0 : parseInt(elem.value);
});
$all_matbenefprop.each(function(index,elem){
n_prop += isNaN(parseInt(elem.value)) ? 0 : parseInt(elem.value);
});
$all_benefname.each(function(indx,elem){
if(elem.value == '') $PROGRESS_FLAG = true;
else $PROGRESS_FLAG = false;
});
$all_matbenefname.each(function(indx,elem){
if(elem.value == '') $N_PROGRESS_FLAG = true;
else $N_PROGRESS_FLAG = false;
});
if(($all_benefname.length > 0 && (l_prop != 100 && !$PROGRESS_FLAG)) || ($all_matbenefname.length > 0 && (n_prop != 100 && !$N_PROGRESS_FLAG))){
$('#beneficiary_details_msg').html("Warning:The Cummulative proportion should be equal to 100");
$ret = false;
}else{
$ret = true;
$('#beneficiary_details_msg').html("");
}
return $ret && $gu_flag;
}
var validateBenef = function(){
var $ret = $gu_flag = true;
$('#beneficiary_form > tbody > tr,#mat_beneficiary_form > tbody > tr').each(function(index,row){
var _row = $(row).find('input');
if(_row[1] != undefined){
var checked = true;
_row.each(function(index, elem){
// if the box is checked all the other fields must be filled
if(checked){
if(elem.name.indexOf('dbirth') >= 0){
//check the other sibling for
if(elem.value != ''){
// do something
var greater18 = getdatediff(elem.value,'','Y') >= 18 ? true : false;
if(!greater18){
if($('#guardian')[0].value == ''){
$('#guardian_errmsg').html("Please add the guardian name...");
$('#guardian').focus();
$gu_flag = false;
}
else if($('#guardian_phone')[0].value == ''){
$('#guardian_errmsg').html("Please add the guardian phone number...");
$('#guardian_phone').focus();
$gu_flag = false;
}
else if($('#guardian_addr')[0].value == ''){
$('#guardian_errmsg').html("Please add the guardian address...");
$('#guardian_addr').focus();
$gu_flag = false;
}
$ret = $gu_flag;
return;
}
}
}
}
});
}
});
return $ret;
}
////save_beneficiary_details
$('#save_beneficiary_details').on('click', function(evt){ // Calculate
$("#regstatus").removeAttr("name");
$r_flag = false;
$r_flag = ($("#benef_name1").val() != '' && $("#matbenef_name1").val() != "");
if(!$r_flag){
$('#beneficiary_details_msg').html("Warning:At least one sum assured and maturity beneficiary is required.");
}else{
$('#beneficiary_details_msg').html("");
}
if($r_flag && validateBenef()){
$('#guardian_errmsg').hide(); // hide the error message
if(validateProportion.apply(evt,{})){
document.forms.frm_quote.submit();
}
}
evt.preventDefault(); // return false;
});
$('#addbeneficiaryrow').on('click', function(evt){ // add the click rows....
var BREAK = 20;
var $length = $('#beneficiary_form > tbody > tr').length;
var $l_length = new Number($length - 1).toString();
if($l_length <= BREAK){
var $last = $('#beneficiary_form > tbody > tr:last');
var $newRow = $last.clone(true);
var $regex = new RegExp($l_length,'g');
$newRow[0].innerHTML = $newRow[0].innerHTML.replace($regex, $length);
$newRow[0].innerHTML = $newRow[0].innerHTML.replace(' hasDatepicker', '');
$.each($($newRow[0]).find('input'), function(index,elem){ elem.value = ''; });
$last.after($newRow[0]); // append
rebound.apply({},{}); // run a rebound
}
evt.preventDefault();
});
$('#removebeneficiaryrow').on('click', function(evt){ // remove the click rows....
var $length = $('#beneficiary_form > tbody > tr').length;
var $l_length = new Number($length - 1).toString();
if($l_length > 1){
var $last = $('#beneficiary_form > tbody > tr:last');
var $newRow = $last.remove();
}
evt.preventDefault();
});
// Maturity Beneficiaries
$('#addmatbenrow').on('click', function(evt){ // add the click rows....
var BREAK = 12;
var $length = $('#mat_beneficiary_form > tbody > tr').length;
var $l_length = new Number($length - 1).toString();
if($l_length <= BREAK){
var $last = $('#mat_beneficiary_form > tbody > tr:last');
var $newRow = $last.clone(true);
var $regex = new RegExp($l_length,'g');
$newRow[0].innerHTML = $newRow[0].innerHTML.replace($regex, $length);
$newRow[0].innerHTML = $newRow[0].innerHTML.replace(' hasDatepicker', '');
$.each($($newRow[0]).find('input'), function(index,elem){ elem.value = ''; });
$last.after($newRow[0]); // append
rebound.apply({},{}); // run a rebound
}
evt.preventDefault();
});
$('#removematbenrow').on('click', function(evt){ // remove the click rows....
var $length = $('#mat_beneficiary_form > tbody > tr').length;
var $l_length = new Number($length - 1).toString();
if($l_length > 1){
var $last = $('#mat_beneficiary_form > tbody > tr:last');
var $newRow = $last.remove();
}
evt.preventDefault();
});
var rebound = function(){
var st = setTimeout(function(){
$("input[name *= 'benef_dbirth'],input[name *= 'matbenef_dbirth']").datepicker({
dateFormat: "yy-mm-dd",
changeMonth: true,
changeYear: true,
yearRange: "-80:+2"
});
clearTimeout(st);
},250);
$('*[ch-class]').on('change', function(evt){
if(this.checked){
this.value = this.attributes['ch-true-value'].value;
}else{
this.value = this.attributes['ch-false-value'].value;
}
evt.preventDefault();
});
$("input[name *= 'benef'], input[name *= 'matbenef']").on('change',function(evt){
this.defaultValue = this.value;
});
// for each chk_cloak
$('.chk_cloak').each(function(){
if($(this).is(':checked')){
$(this).parent('.chk_icon').css({'background-position':'-48px 0'}).parents('.chkbox').addClass('checked');
}
else{
$(this).parent('.chk_icon').css({'background-position':'-24px 0'}).parents('.chkbox').addClass('checked');
}
}).on('click', function(){
if($(this).is(':checked')){
$(this).parent('.chk_icon').css({'background-position':'-48px 0'}).parents('.chkbox').addClass('checked');
} else {
$(this).parent('.chk_icon').css({'background-position':'-24px 0'}).parents('.chkbox').removeClass('checked');
}
});
}
rebound.apply({},{});
///AJAX IMAGE UPLOAD//////////////
$("#uploadimagebtn").on('click',(function(e) {
e.preventDefault();
var obj = $("#fileimage").get(0).files[0];
photoSizeLimit = 100000000;
console.log(obj);
var imagedatatypes = ['image/jpeg', 'image/jpg', 'image/png', 'image/PNG', 'image/JPG',];
if(typeof(obj) !== 'undefined') {
if(obj.size <= photoSizeLimit) {
if( $.inArray(obj.type, imagedatatypes)!== -1) {
//add file object to the form data
ajaxloader(false);
formData = new FormData();
formData.append('fileimage', obj);
formData.append('filetype', 'fileimage');
$.ajax({
//"iesmain.php?targ=login&op=&act="(removed)
url: window.location.href, // Url to which the request is send
type: "POST", // Type of request to be send, called as method
data: formData, // Data sent to server, a set of key/value pairs (i.e. form fields and values)
contentType: false, // The content type used when sending data to the server.
cache: false, // To unable request pages to be cached
processData:false, // To send DOMDocument or non processed data file it is set to false
success: function(data) // A function to be called if request succeeds
{
//on success place the uploaded image in the image container
// parseHTML gets a selected html string and turns them into nodes
var parse = $($.parseHTML(data)).find('#imagepreviewnode');
var image_status = $($.parseHTML(data)).find('#image_status');
$('.viewer').replaceWith(parse.html());
$('#personal_details_msg').html(image_status.html());
$("#fileimage").val('');
ajaxloader(true);
}
});
}
else {$('#personal_details_msg').html("NOTE:Invalid Image Type"); }
}
else {$('#personal_details_msg').html("NOTE:Invalid Image Size"); }
}
else {$('#personal_details_msg').html("NOTE: No Image Selected"); }
}));
////FOR IMAGE delete
$("#deleteimagebtn").on('click',(function(e) {
e.preventDefault();
//iesmain.php?targ=login&op=&act=(removed)
ajaxloader(false);
$.post( window.location.href, {deleteimage:true, type:'image'}, function( data ) {
var delete_status = $($.parseHTML(data)).find('#delete_status');
var parse = $($.parseHTML(data)).find('#imagepreviewnode');
$('#personal_details_msg').html(delete_status.html());
$('#previewing').replaceWith(parse.html());
ajaxloader(true);
});
}));
//////////
/* TABS */
//////////
$( "#users_tab" ).tabs();
///////////////////
/* DROPDOWN MENU */
///////////////////
var $menu = $('div#menu > ul > li'),
$child_menu = $('div#menu > ul > li > ul > li'),
$grand_child_menu = $('div#menu > ul > li > ul > li > ul > li'),
$down_arrow = "▼",
$up_arrow = "▲",
$left_arrow = "◄",
$right_arrow = "►";
$menu.find('ul').hide();
/* First List */
$menu.has('ul').children('a').append(' ' + $down_arrow);
$menu.on('mouseenter',function(){
$(this).children('a').css({'background-color':'#777','color':'#FFF'});
$(this).children('ul').show();
});
$menu.on('mouseleave',function(){
$(this).children('a').css({'background-color':'transparent','color':'#777'});
$(this).children('ul').hide();
});
/* Second List */
$child_menu.has('ul').children('a').append(" " + $right_arrow + '');
$child_menu.on('mouseenter',function(){
$(this).children('a').css({'background-color':'#777','color':'#FFF'});
$(this).children('ul').show();
});
$child_menu.on('mouseleave',function(){
$(this).children('a').css({'background-color':'transparent','color':'#E2E2E2'});
$(this).children('ul').hide();
});
///////////////////
/* SEARCH BUTTON */
///////////////////
$('#search .search_box #txt_search').on('focus', function(){
$(this).animate({'width':'155px'});
})
$('#search .search_box #txt_search').on('blur', function(){
$(this).animate({'width':'55px'});
})
////////////////////////
/* General Formatting */
////////////////////////
$('#ui li a').on('mouseenter', function()
{
$(this).css({
'background-image':'images/interface/prelogin/blind.png',
'background-repeat':'repeat'
});
});
// Prevent default behaviour in UI Blocker
$( "#ui_header div ul li a" ).on('click', function($this)
{
$this.preventDefault();
});
// Repositioning the UI Blocker
$(window).on('resize', function()
{
// Don't reposition if the ui blocker is maximized
if($ui_engine.config.status != 'maximized')
{
// Reposition the ui blocker
clearTimeout($.data(this, "scrollTimer"));
$.data(this, "scrollTimer", setTimeout(function()
{
$ui_engine.preload_ui();
}, 250));
}
if($ui_engine.config.status == 'maximized')
{
// Resize the UI
clearTimeout($.data(this, "scrollTimer"));
$.data(this, "scrollTimer", setTimeout(function()
{
$('#ui').animate({
'width' :$('#ui_bg').width(),
'height' :$('#ui_bg').height(),
'top' :'0',
'left' :'0'
});
}, 250));
}
});
$(window).on('scroll', function()
{
// Don't reposition if the ui blocker is maximized
if($ui_engine.config.status != 'maximized')
{
clearTimeout($.data(this, "scrollTimer"));
$.data(this, "scrollTimer", setTimeout(function()
{
$ui_engine.preload_ui();
}, 250));
}
});
////////////////
//* Checkbox *//
////////////////
$('.chk_cloak').each(function()
{
if($(this).is(':checked'))
{
$(this).parent('.chk_icon').css({'background-position':'-48px 0'}).parents('.chkbox').addClass('checked');
} else {
$(this).parent('.chk_icon').css({'background-position':'-24px 0'}).parents('.chkbox').addClass('checked');
}
}).on('click', function(){
if($(this).is(':checked'))
{
$(this).parent('.chk_icon').css({'background-position':'-48px 0'}).parents('.chkbox').addClass('checked');
} else {
$(this).parent('.chk_icon').css({'background-position':'-24px 0'}).parents('.chkbox').removeClass('checked');
}
});
///////////////////
// Radio Button *//
///////////////////
$('.rad_cloak').each(function()
{
if($(this).is(':checked'))
{
$(this).parent('.rad_icon').css({'background-position':'-168px 0'}).parents('.radbox').addClass('checked');
} else {
$(this).parent('.rad_icon').css({'background-position':'-144px 0'}).parents('.radbox').addClass('checked');
}
}).on('click', function(){
if($(this).is(':checked'))
{
var $name = $(this).attr('name');
$('input[name='+ $name +']').parent('.rad_icon').css({'background-position':'-144px 0'}).parents('.radbox').removeClass('checked');
$(this).parent('.rad_icon').css({'background-position':'-168px 0'}).parents('.radbox').addClass('checked');
}
});
});
var $ui_engine =
{
block: function($settings, func)
{
$.extend(this.config,$settings);
var arg = arguments.length;
$( "#ui_title" ).html(this.config.title);
$( "#ui_content" ).height(parseInt(this.config.height) - parseInt(70));
ajaxloader(false);
$( "#ui_content" ).html(''); //remove previous content first before loading
$( "#ui_content" ).load('prelogin_utils/' + this.config.file + '.php' , this.config.querystring, function(responseTxt, statusTxt, xhr){
if(statusTxt == "success") ajaxloader(true);
if(statusTxt == "error") {alert("Error Loading, Check Internet Connection Or Contact Site Administrator: " + xhr.status + ": " + xhr.statusText); ajaxloader(true); }
});
this.preload_ui();
//this.draggable('#ui');
$( "#ui_bg" ).fadeIn('slow', function()
{
$( "#ui" ).fadeIn('fast',function(){
if ( arg > 1 ) func();
});
});
},
config:
{
title: 'Application',
file: 'default',
width: '600',
height: 'auto',
status: 'default',
buttons: 'YYY', //minimize_maximize_close
querystring: ''
},
close: function()
{
ajaxloader(true);
// Hide the blinder
$('#ui').fadeOut('slow', function()
{
$('#ui_bg').fadeOut('fast');
// The resize method image (toggle_size())
var $resize_btn = $('#ui ul li').eq(1).children('a');
$resize_btn.css({'background-position':'-33px 0'});
$resize_btn.attr('title', 'Maximize');
$ui_engine.config.status = 'default';
});
},
toggle_size: function()
{
if (this.config.status == 'default') // the "minimized" keyword is reserved
{
$( "#ui_content" ).height($('#ui_bg').height());
$('#ui').animate({
'width' :$('#ui_bg').width(),
'height' :$('#ui_bg').height(),
'top' :'0',
'left' :'0'
}, function() {
// Enlarge the screen
var $resize_btn = $('#ui ul li').eq(1).children('a');
$resize_btn.css({'background-position':'-99px 0'});
$resize_btn.attr('title', 'Restore Down');
// Set status to "maximized"
$ui_engine.config.status = 'maximized';
});
}
else if (this.config.status == 'maximized')
{
this.cleanup_size();
var $w, $h;
$w = (($(window).width() / 2) - (this.config.width / 2)),
$h = (($(window).height() / 2) - (this.config.height / 2));
$('#ui').animate({
'width' :this.config.width,
'height' :this.config.height,
'top' :$h,
'left' :$w
}, function() {
// Enlarge the screen
var $resize_btn = $('#ui ul li').eq(1).children('a');
$resize_btn.css({'background-position':'-33px 0'});
$resize_btn.attr('title', 'Maximize');
// Set status to "maximized"
$ui_engine.config.status = 'default';
});
}
},
toggle_fold: function()
{
alert('minimize?');
},
cleanup_size: function()
{
// Width manager
if(this.config.width < 400)
{
this.config.width = 400;
}
// Height manager
if(this.config.height < 100)
{
this.config.height = 100;
}
},
preload_ui: function()
{
// The resize method image (toggle_size())
var $resize_btn = $('#ui ul li').eq(1).children('a');
$resize_btn.css({'background-position':'-33px 0'});
$resize_btn.attr('title', 'Maximize');
$ui_engine.config.status = 'default';
this.preload_buttons();
var $w, $h, $ui = $('#ui');
this.cleanup_size();
// Centralize DIV
$ui.css({
'width' :this.config.width + 'px',
'height' :this.config.height + 'px',
});
$w = (($(window).width() / 2) - ($ui.outerWidth() / 2)),
$h = (($(window).height() / 2) - ($ui.outerHeight() / 2)) + $(window).scrollTop();
$ui.animate({
'left' :$w + 'px',
'top' :$h + 'px',
'position' :'absolute'
});
},
draggable: function(element)
{
element = $(element);
// Move the element by the amount of change in the mouse position
var $move = function(event)
{
if(element.data('mouseMove'))
{
var change_X = event.clientX - element.data('mouseX');
var change_Y = event.clientY - element.data('mouseY');
var new_X = parseInt(element.css('left')) + change_X;
var new_Y = parseInt(element.css('top')) + change_Y;
element.css('left', new_X);
element.css('top', new_Y);
element.data('mouseX', event.clientX);
element.data('mouseY', event.clientY);
}
}
element.mousedown(function(event)
{
element.data('mouseMove', true);
element.data('mouseX', event.clientX);
element.data('mouseY', event.clientY);
});
element.parents(':last').mouseup(function()
{
element.data('mouseMove', false);
});
element.mouseout($move);
element.mousemove($move);
},
preload_buttons: function()
{
// Fetch the button status
var $btn = this.config.buttons;
// Buttons
$min = $btn[0];
$max = $btn[1];
$close = $btn[2];
if ($min == 'N')
// Deactivate the Minimize button
{
var $min_btn = $('#ui ul li').eq(0).children('a');
$min_btn.css({
'background-position':'0 30px',
'cursor':'default'
});
$min_btn.attr({
'title':'',
'onclick':''
});
}
if ($max == 'N')
// Deactivate the Maximize button
{
var $max_btn = $('#ui ul li').eq(1).children('a');
$max_btn.css({
'background-position':'-33px 30px',
'cursor':'default'
});
$max_btn.attr({
'title':'',
'onclick':'return false'
});
}
if ($close == 'N')
// Deactivate the Maximize button
{
var $close_btn = $('#ui ul li').eq(2).children('a');
$close_btn.css({
'background-position':'-66px 30px',
'cursor':'default'
});
$close_btn.attr({
'title':'',
'onclick':''
});
}
}
},
$user_auth = function($form)
{
// Init.
var $id = uppercase($form.loginid.value),
//$pass = uppercase($form.loginpass.value);
$pass = $form.loginpass.value;
console.log($form.loginpass.value);
if ($id != "")
{
if ($pass != "")
{
// Assigning values back to form
$form.loginid.value = $id;
$form.loginpass.value = $pass;
$.ajax({
url: "prelogin_utils/switch.php",
type: "POST",
data: {'opt':'auth','id':$id,'pass':$pass},
dataType: "json",
success: function($json)
{
if(typeof $json.clientlink_userid !== 'undefined') $form.loginid.value = $json.clientlink_userid;
/* if($json.status == "true")
{
$('#login_msg').html("" + $json.msg + "");
//$form.action = iesurl + "iesmain.php?targ=login&op=&act=";
//$form.submit();
logindata = {'loginid':$id, 'loginpass':$pass};
proc_console(iesurl + "iesmain.php?targ=login&op=&act=", logindata);
} */
if($json.status == "true")
{
$.ajax({
url: "prelogin_utils/ajax_val1.php",
type: "GET",
dataType: "json",
success: function($json2)
{ alert
if($json2.status == "true")
{
security_question_blocker();
}
else{
$('#login_msg').html("" + $json.msg + "");
//$form.action = iesurl + "iesmain.php?targ=login&op=&act=";
//$form.submit();
logindata = {'loginid':$id, 'loginpass':$pass};
proc_console(iesurl + "iesmain.php?targ=login&op=&act=", logindata);
}
},
error: function(request, status, error)
{
//alert(request.responseText);
$('#login_msg').html("LOGIN ERROR: Please, Try Again.");
}
})
/*
$('#login_msg').html("" + $json.msg + "");
$form.action = iesurl + "iesmain.php?targ=login&op=&act=";
$form.submit();
*/
}
else if($json.expired == "true"){
//alert('Password Has Expired!:-)');
change_expired_password_blocker();
}
else{
$('#login_msg').html("" + $json.msg + "");
}
},
error: function(request, status, error)
{
//alert(request.responseText);
$('#login_msg').html("LOGIN ERROR: Please, Try Again!!");
}
})
} else {
$('#login_msg').html("ERROR: Please, Enter Your Password.");
$form.loginpass.focus();
}
} else {
$('#login_msg').html("ERROR: Please, Enter Your Login ID.");
$form.loginid.focus();
}
},
$securityquest_save = function($form)
{
var savok = true;
var checkAllArguments = function() {
var len = arguments.length;
var obj;
if(len == 0) {
return true;
}
else {
if(arguments[0] == null) {
return false;
}
else {
obj = arguments[0];
}
}
for(var i=1; i" + $json.msg + "");
$form.action = iesurl + "iesmain.php?targ=login&op=&act=";
$form.submit();
}
else{
$('#login_msg').html("" + $json.msg + "");
}
},
error: function(request, status, error)
{
$('#login_msg').html("" + $json.msg + "");
}
});
}
},
$security_auth = function($form)
{
// Init.
var $qcode = $form.qcode.value,
$qresp = $form.qresponse.value;
$userid = $form.userid.value;
//alert($qresp+' '+$qcode+' '+$userid);
if ($qcode != "")
{
if ($qresp != "")
{
// Assigning values back to form
$form.qcode.value = $qcode;
$form.qresponse.value = $qresp;
$form.userid.value = $userid;
$.ajax({
url: "prelogin_utils/switch.php",
type: "GET",
data: {'opt':'sec_auth','userid':$userid,'id':$qcode,'pass':$qresp},
dataType: "json",
success: function($json)
{
if($json.status == "true")
{
//change_expired_password_blocker();
$('#login_msg').html("" + $json.msg + "");
$form.action = iesurl + "iesmain.php?targ=login&op=&act=";
$form.submit();
}
else{
$('#login_msg').html("" + $json.msg + "");
}
},
error: function(request, status, error)
{
//alert(request.responseText);
$('#login_msg').html("LOGIN ERROR: Please, Try Again.");
}
})
} else {
$('#login_msg').html("ERROR: Please, Enter Your Security Answer.");
$form.loginpass.focus();
}
} else {
$('#login_msg').html("ERROR: Unable to generate Security Question.");
$form.loginid.focus();
}
},
$submit_access = function(){
alert("yes");
}
$chg_password = function($form){
var oldpass = $form.oldpassword.value,
newpass = $form.newpassword.value,
confirmpass= $form.confirmpass.value,
passwordReset = "N";
$url = "change_pass.php";
//
if( typeof $form.passwordReset != "undefined"){
passwordReset = $form.passwordReset.value;
}
if (oldpass == "") {
alert("Please Enter Your Old Password");
oldpass.focus();
}
else if (newpass.value == "") {
alert("Please Enter Your New Password");
newpass.focus();
}
else if (confirmpass.value == "") {
alert("Please Re-Enter Your New Password");
confirmpass.focus();
}
else if (newpass != confirmpass) {
alert("Inconsistency in new password ...\n Please Re-Enter New Password");
confirmpass.focus();
}
$conf = confirm('Please Confirm Password Change Request');
if($conf){
$.ajax({
url: $url,
type: "POST",
data: {
'act' : 'pwsave',
'oldpwd' : oldpass,
'newpwd' : newpass,
'newpwd2' : confirmpass,
'reset' : passwordReset,
'ajaxRec' : "true"
},
dataType: "json",
success: function($json)
{
if($json.status == "true")
{
//$('#login_msg').html("" + $json.msg + "");
alert($json.msg);
//login_blocker();
interface_close();
}
else{
$('#password_msg').html("" + $json.msg + "");
}
},
error: function(request, status, error)
{
$('#password_msg').html("" + $json.msg + "");
}
});
}
}
$reset_password = function(arr){
if((typeof arr != "undefined") && (arr.length != 0)){
var email = arr['em'];
var vcode = arr['chkok'];
var act = arr['act'];
var result= null;
var $url = "forget_password.php";
$.ajax({
url: $url,
type: "POST",
data: {
'act' : 'validate_reset',
'em' : email,
'vcode' : vcode
},
dataType: "json",
success: function($json)
{
//var xjson = JSON.parse($json2);
console.log($json);
if($json.status)
{
//alert($json.odp);
reset_forget_password_blocker(function(){
$('#oldpassword').val($json.odp);
});
//var promise =
//alert(reset_forget_password_blocker());
//if ( $("#ui").is(':visible') ) {
//}
//$('#login_msg').html("" + $json.msg + "");
//$('#oldpassword').value('testeing');
//$('#resetpassword_msg').html("" + $json.msg + "");
//$('input[name=oldpassword]').val('testeing');
//$("#frm_chgpass input[name=frm_chgpass]").val('sample');
$('#frm_chgpass').find('input[name=frm_chgpass]').val('sample');
}
else{
get_loss_access_blocker();
}
},
error: function(request, status, error)
{
alert('Error');
//$('#resetpassword_msg').html("" + $json.msg + "");
}
});
}
//
//console.log($json);
//return $json;
}
$get_lostpass = function($form){
var email = $form.usermail.value;
if(email == ""){
//alert("Please Enter Your Valid Email Address");
$('#forgetpassword_msg').html("Please enter a valid email address.");
email.focus();
}
//
$url = "forget_password.php";
$conf = confirm('Please confirm reset of your password');
if($conf){
$.ajax({
url: $url,
type: "POST",
data: {
'act' : 'sndmail',
'em' : email
},
dataType: "json",
success: function($json)
{
if($json.status == "true")
{
//$('#login_msg').html("" + $json.msg + "");
alert($json.msg);
login_blocker();
}
else{
$('#forgetpassword_msg').html("" + $json.msg + "");
}
},
error: function(request, status, error)
{
$('#forgetpassword_msg').html("" + $json.msg + "");
}
});
}
}
$get_access = function($form, $mode, $quicksignup, $id)
{
//Check Button State
var activatedelement = $('#' + $id);
var currentClassName = $(activatedelement).attr('class');
if (currentClassName.indexOf('dim__X__123') == -1){
// Init.
if(!$quicksignup){
var $chk_agtbro = (($form.chk_agtbro.checked) || ($form.chk_agtbro.value == 'checked')) ? 'checked': '',
$chk_staff = (($form.chk_staff.checked) || ($form.chk_staff.value == 'checked')) ? 'checked': '',
$chk_client = (($form.chk_client.checked) || ($form.chk_client.value == 'checked')) ? 'checked': '',
$chk_mgt = (($form.chk_mgt.checked) || ($form.chk_mgt.value == 'checked')) ? 'checked': '',
$ccompany = $form.ccompany.value;
}
var $csurname = $form.csurname.value,
$cothname = $form.cothname.value,
$cemail = $form.cemail.value,
$cgsm = $form.cgsm.value,
$url = "prelogin_utils/switch.php";
$display_captcha = $form.display_captcha != undefined ? $form.display_captcha.value : 'Y'; //display captcha condition from company header
if($display_captcha != "N"){
$cap_code = $form.captcha_code.value
}
else {
$cap_code = "";
}
generate_quote_without_login = "N";
if(typeof $form.generate_quote_without_login != "undefined") {
generate_quote_without_login = $form.generate_quote_without_login.value;
}
plan = "";
if(typeof $form.plan != "undefined") { //form submission from api link
plan = $form.plan.value;
}
// User Type (At least one must be selected)
if (($chk_agtbro == '') && ($chk_staff == '') && ($chk_client == '') && ($chk_mgt == ''))
{
$('#access_msg').html("ERROR: Please, Select at least, one User Type.");
return false;
}
// Surname (Must not be empty)
else if ($csurname == '')
{
$('#access_msg').html("ERROR: Please, Enter Your Surname.");
$form.csurname.focus();
return false;
}
// Other Names (Must not be empty)
else if ($cothname == '')
{
$('#access_msg').html("ERROR: Please, Enter Your Other Names.");
$form.cothname.focus();
return false;
}
// Email (Must not be empty)
else if ($cemail == '')
{
$('#access_msg').html("ERROR: Please, Enter Your Email Address.");
$form.cemail.focus();
return false;
}
// Phone (Must not be empty)
else if ($cgsm == '')
{
$('#access_msg').html("ERROR: Please, Enter Your Phone Number.");
$form.cgsm.focus();
return false;
}
else if (($.trim($cap_code) == '') && $display_captcha != "N") {
$('#access_msg').html("ERROR: Please, Enter The Captcha Code.");
$form.captcha_code.focus();
return false;
}
//Deactivate btn
$(activatedelement).addClass('dim__X__123');
// Company (Set a defaul value if it is empty)
if ($ccompany == '')
{
$ccompany = '- -';
}
//Client Quick Sign Up
if($quicksignup){
$chk_agtbro == '';
$chk_staff == '';
$chk_client == 'checked';
$chk_mgt == '';
loadcalulator_flag = false; //this flag loads calculator directly from an api request externally
if( (typeof $form.url != "undefined") && $form.url.value != "" && plan != "" ) { //meaning this url is from the api section
$url = $form.url.value;
loadcalulator_flag = true;
}
else {
$url = "prelogin_utils/quicklogin_processor.php";
}
$act = 'testrequest';
}
ajaxloader(false);
$.ajax({
url: $url,
type: "POST",
data: {
'act' : 'testrequest',
'cb_client' : $chk_client,
'cb_agency' : '',
'cb_staff' : '',
'cb_manage' : '',
'csurname' : $csurname,
'cothname' : $cothname,
'ccompany' : '',
'cemail' : $cemail,
'captcha_code': $cap_code,
'display_captcha': $display_captcha,
'cgsm' : $cgsm,
'requestid' : '',
'txt_message' : 'Save my details',
'subjectm' : ''
},
dataType: "json",
success: function($json)
{
ajaxloader(true);
//console.log($json.error_msg);
if($json.error_msg == '' || $json.error_msg == undefined) { // if no save visitors error
if($json.email_return == false) { //non existing client
if(loadcalulator_flag == true){ /* when the system is being called by an api directly, it loads the calculator direcly*/
param = {'loadcalulator_flag' : loadcalulator_flag, 'plan' : plan };
proc_console(iesurl, param);
}
else {
//console.log($json.email_return);
product_blocker(blocker_title,blocker_calculatorfile);
//todo code on success:
$(activatedelement).removeClass('dim__X__123');
}
}
else if( typeof $json.email_return === 'string' && $json.email_return != "" ) { //already exisiting client
if(generate_quote_without_login == "N") { //if generate quote without loggining on company header is off, display error
$('#access_msg').html("ACCESS ERROR: This Email Already Exist, Kindly Use Another Email Address.");
//$(activatedelement).removeClass('dim__X__123');
}
else {
if(!loadcalulator_flag) { //if its not coming from load calculator api, then alert
alert("Note That You Are An Already Existing Client, Continuing This Process Will generate A New Quotation")
}
if(loadcalulator_flag == true){
param = {'loadcalulator_flag' : loadcalulator_flag, 'plan' : plan };
proc_console(iesurl, param);
}
else {
product_blocker(blocker_title,blocker_calculatorfile);
}
}
}
else {
$(activatedelement).removeClass('dim__X__123');
$('#access').html("ACCESS ERROR: Email Validation Error.");
}
}
else {
alert($json.error_msg);
}
},
error: function($json)
{
ajaxloader(true);
$(activatedelement).removeClass('dim__X__123');
$('#access').html("ACCESS ERROR: Please, Try Again.");
}
});
}
};
var $generate_client = function ($dob, $opt, $id){
//Check button state
var activatedelement = $('#' + $id);
var currentClassName = $(activatedelement).attr('class');
//retrive cal_location (where the calculation is coming from (from ies console interface iesclient.php));
if(typeof generate_quote_from_console == "undefined" ) {
generate_quote_from_console=false;
}
if(typeof login_det == "undefined" ) {
login_det ='';
}
//define which proposal method we are using
create_proposal_method = "DIRECT"; //set direct as default(generating directly)
if(generate_quote_from_console == true) { //generating of proposals from console
create_proposal_method = "FROMCONSOLE";
}
else if(login_det != '') { //generating proposal from already existing client
create_proposal_method = "ALREADYEXISTINGCLIENT";
}
if (currentClassName.indexOf('dim__X__123') == -1){
$(activatedelement).addClass('dim__X__123');
if($dob != "" || $dob.replace(/\s+/g, ' ') == ' '){
var url = "prelogin_utils/generateuser.php";
ajaxloader(false);
$.ajax({
url: url,
type: "GET",
data: { 'gen':'1', 'dbirth': $dob, 'opt' : $opt, 'create_proposal_method' : create_proposal_method },
dataType: "html",
success: function(html)
{
ajaxloader(true);
//On success
if(ajaxerrorHandler(html) == ''){ //no errors
if(generate_quote_from_console == true) {
ajaxloader(true);
url = iesurl + "iesmain.php?targ=login&op=&act=";
param = {'generate_quote_from_console' : generate_quote_from_console };
proc_console(url, param);
}
else if(login_det != ''){
url1 = iesurl + "iestasks_payment.php?op=C&act=payform";
url2 = iesurl + "iesmain.php?targ=login&op=&act=";
//
//alert(url1);
logindata = {'loginid':login_det.cltcode_already_exist, 'loginpass':login_det.pass_already_exist, 'generate_quote_from_console':true }
$.post(url2, logindata, function(data) { proc_console(url1, ''); });
}
else {
successful_client();
}
}
else if(ajaxerrorHandler(html) != '') { //error exist
alert(ajaxerrorHandler(html));
$(activatedelement).removeClass('dim__X__123');
}
},
error: function(request, status, error)
{
//On Error
alert("Error: File Not Found Or Connection Error");
$(activatedelement).removeClass('dim__X__123');
ajaxloader(true);
}
});
}
}
return false;
}
$client_redirect_login = function($userid, $password)
{
// Init.
var $id = $userid,
$pass = $password;
if ($id != "")
{
if ($pass != "")
{
ajaxloader(false);
$.ajax({
url: iesurl + "iesmain.php?targ=login&op=&act=",
type: "POST",
data: {'loginid':$id,'loginpass':$pass},
dataType: "html",
success: function(html)
{
ajaxloader(true);
var redirect = iesurl + "iesmain.php?targ=login&op=&act=&status=new";
$(location).attr('href',redirect);
},
error: function(request, status, error)
{
ajaxloader(true);
alert('redirection error');
}
})
}
}
}
buy_new_plan = function ($title,$file)
{
//$ui_engine.block({title:$title.toUpperCase() + ' CALCULATOR ',file:$file,width:'200',height:'550',buttons:'NNY'});
$ui_engine.block({title:$title.toUpperCase() + ' ',file:$file,width:'200',height:'180',buttons:'NNY'});
};
display_payment_resp = function ($title,$file,$status)
{
setquerystring = jQuery.param( {'status' : $status} );
$ui_engine.block({title:$title.toUpperCase() + ' ',file:$file,width:'900',height:'500',buttons:'NNY',querystring:setquerystring});
};
cal_new_plan = function ($title,$file,setquerystring)
{
$ui_engine.block({title:$title.toUpperCase() + ' CALCULATOR ',file:$file,width:'1000',height:'550',buttons:'NNY',querystring:setquerystring});
};
function proc_console(path, parameters) {
var form = $('');
form.attr("method", "post");
form.attr("action", path);
$.each(parameters, function(key, value) {
var field = $('');
field.attr("type", "hidden");
field.attr("name", key);
field.attr("value", value);
form.append(field);
});
// The form needs to be a part of the document in
// order for us to be able to submit it.
$(document.body).append(form);
form.submit();
}
function addCssRule(rule, css) {
css = JSON.stringify(css).replace(/"/g, "").replace(/,/g, ";");
$("