//AJAX WAITING LOADER ADDED function ajaxloader(success) { if (success != true) { $(document.body).append(''); $( "#loader_bg" ).show(); $( "#loader" ).fadeIn('fast'); } else { $( "#loader_bg" ).hide(); } } function forceNumberPress (ID) { if(ID != '' && typeof(ID) !== 'undefined') { var id = "#"+ID; $(id).keydown(function(event) { // Allow: backspace, delete, tab, escape, and enter if ( event.keyCode == 46 || event.keyCode == 8 || event.keyCode == 9 || event.keyCode == 27 || event.keyCode == 13 || // Allow: Ctrl+A (event.keyCode == 65 && event.ctrlKey === true) || // Allow: Ctrl+C (event.keyCode == 67 && event.ctrlKey === true) || // Allow: Ctrl+V (event.keyCode == 86 && event.ctrlKey === true) || // Allow: home, end, left, right (event.keyCode >= 35 && event.keyCode <= 39)) { // let it happen, don't do anything return; } else { // Ensure that it is a number and stop the keypress if (event.shiftKey || (event.keyCode < 48 || event.keyCode > 57) && (event.keyCode < 96 || event.keyCode > 105 )) { event.preventDefault(); } } }); $(id).on('blur', function() { var $this = $(this); if ((isNaN($this.val())) && ($this.val() != '')) { $this.val(''); $this.focus(); } }); } } 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('+'); }); } }); /////date validation on registration interface $('#dd_coverprdstart').on('change', function(){ var $incoming = $(this), $incoming_date = $incoming.val(), $current_date = get_date(); //set date to current date if a date backwards was selected if ($incoming_date < $current_date) $incoming.val($current_date); ///STRICT VALIDATION CHECK if (($('#dd_coverprdstart').val() >= $('#dd_coverprdend').val()) && $('#dd_coverprdend').val() != '' && $('#dd_coverprdstart').val() != '') { $('#car_information_msg').html("ERROR: Start Date Cant be greater than End date"); $('#dd_coverprdstart').val(''); $('#dd_coverprdend').val(''); $('#term').val(''); } else{ $('#car_information_msg').html(""); } if($('#dd_coverprdstart').val() != '' && $('#dd_coverprdend').val() != '') { //get the diffrence between two dates in javascript var startdate = $('#dd_coverprdstart').datepicker('getDate'); var enddate = $('#dd_coverprdend').datepicker('getDate'); var term = (enddate - startdate)/1000/60/60/24; $('#term').val(term); } }); $('#dd_coverprdend').on('change', function(){ var $incoming = $(this), $incoming_date = $incoming.val(), $current_date = get_date(); //set date to current date if a date backwards was selected if ($incoming_date < $current_date) $incoming.val($current_date); ///STRICT VALIDATION CHECK if (($('#dd_coverprdstart').val() >= $('#dd_coverprdend').val()) && $('#dd_coverprdend').val() != '' && $('#dd_coverprdstart').val() != '') { $('#car_information_msg').html("ERROR: Start Date Cant be greater than or Equal To End date"); $('#dd_coverprdend').val(''); $('#dd_coverprdstart').val(''); $('#term').val(''); } else{ $('#car_information_msg').html(""); } if($('#dd_coverprdstart').val() != '' && $('#dd_coverprdend').val() != '') { //get the diffrence between two dates in javascript var startdate = $('#dd_coverprdstart').datepicker('getDate'); var enddate = $('#dd_coverprdend').datepicker('getDate'); var term = (enddate - startdate)/1000/60/60/24; $('#term').val(term); } }); //SET DATE IF TERM IS SELECTED $('#term').on('keyup', function (){ var term = $('#term').val(); $current_date_obj = get_date(); $current_date = $current_date_obj.toString(); $('#dd_coverprdstart').val($current_date); endDate = new Date($current_date); endDate = new Date(endDate.getTime() + term*24*60*60*1000); endDate = $.datepicker.formatDate('yy-mm-dd', new Date(endDate)); $('#dd_coverprdend').val(endDate); }); //GET DATE COPIED HERE var get_date = function() { var currentDate = new Date(), day = currentDate.getDate(), month = currentDate.getMonth() + 1, year = currentDate.getFullYear(), date = ''; // Padding Day and Month if ((month > 9) && (day < 10)) { date = year + "-" + month + "-0" + day; } else if ((month < 10) && (day > 9)) { date = year + "-0" + month + "-" + day; } else if ((month < 10) && (day < 10)) { date = year + "-0" + month + "-0" + day; } else { date = year + "-" + month + "-" + day; } return date; }; // getter and setter $( "#dd_dbirth" ).datepicker({ dateFormat: "yy-mm-dd", changeMonth: true, changeYear: true, yearRange: "-80:+2" }); $( "#dd_coverprdstart" ).datepicker({ dateFormat: "yy-mm-dd", changeMonth: true, changeYear: true, yearRange : "-1:+100" }); $( "#dd_coverprdend" ).datepicker({ dateFormat: "yy-mm-dd", changeMonth: true, changeYear: true, yearRange: "-1:+100" }); //forceNumberPress('regnumb'); forceNumberPress('lphone'); forceNumberPress('gsm'); forceNumberPress('insureval'); forceNumberPress('yearofmake'); forceNumberPress('term'); //forceNumberPress('chassisnumb'); ///AJAX IMAGE UPLOAD////////////// $("#uploadimagebtn").on('click',(function(e) { e.preventDefault(); var obj = $("#fileimage").get(0).files[0]; 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("ERROR:Invalid Image Type"); } } else {$('#personal_details_msg').html("ERROR:Invalid Image Size"); } } else {$('#personal_details_msg').html("ERROR: No Image Selected"); } })); ////FOR IMAGE delete $("#deleteimagebtn").on('click',(function(e) { e.preventDefault(); //iesmain.php?targ=login&op=&act=(removed) $.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()); }); })); ////FOR FILE delete $("#deletefilebtn").on('click',(function(e) { e.preventDefault(); //"iesmain.php?targ=login&op=&act=" $.post( window.location.href, {deleteimage:true, type:'file'}, function( data ) { //var delete_status = $($.parseHTML(data)).find('#delete_status'); var parse = $($.parseHTML(data)).find('#docviewnode'); //$('#personal_details_msg').html(delete_status.html()); $('#docview').replaceWith(parse.html()); }); })); // DOC VIEWER $(document).on('click', '.viewer',(function(e) { e.preventDefault(); var imagelink = $(".viewer").attr('href'); var timestamp = new Date().toString(); $(".viewer").attr('href', imagelink+'?t='+timestamp); //alert(timestamp); })); $(".viewer").fancybox(); // IMAGE VIEWER $(document).on('click', '#docview',(function(e) { e.preventDefault(); var imagelink = $("#docview").attr('href'); var timestamp = new Date().toString(); $("#docview").attr('href', imagelink+'?t='+timestamp); })); $("#docview").fancybox(); //selection box effect(THIS GETS THE SELECTED CAR MAKE AND RETURNS AND RUNS THE SCRIPT TO GET RESPECTIVE CAR MODEL) $('#maketype').change(function(){ var maketype = $('#maketype').val(); var querystring = {'maketype':maketype}; ajaxloader(false); //thanks to jquery :) $('#model').load('motor.php #model > *', querystring, function() { ajaxloader(true); }); }) ///// // $('#polclass').change(function(){ // // var polclass = $('#polclass').val(); // var querystring = {'polclass':polclass}; // ajaxloader(false); // //thanks to jquery :) // $('#risktype').load('products.php #risktype > *', querystring, function() { // ajaxloader(true); // }); // // // }) // // // $('#submit_risktype').click(function(){ // if($('#risktype').val() != ''){ // var risktype = $('#risktype').val(); // var title = $("#risktype option:selected").text(); // quicksignup_blocker(title,risktype); // } // // }); //Personal Details Validation $('#save_personal_details').click(function(){ $("#regstatus").removeAttr("name"); $('#btnstatus').val('Personal Details'); 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(lname, 'lname', '', '', '', '')){ $('#personal_details_msg').html("ERROR: Please, type your last name."); }else if(required(fname, 'fname', '', '', '', '')){ $('#personal_details_msg').html("ERROR: Please, type your other name."); }else if(required(dd_dbirth, 'dd_dbirth', '', '', '', '')){ $('#personal_details_msg').html("ERROR: Please, type your date of birth."); }else if(required(dd_occupa, 'dd_occupa', '', '', '', '')){ $('#personal_details_msg').html("ERROR: Please, select your occupation."); }else if(!dd_gender){ $('#personal_details_msg').html("ERROR: Please, select your gender."); }else if(!dd_mstatus1){ $('#personal_details_msg').html("ERROR: Please, select marital status."); }else{ document.forms.frm_quote.submit(); } //End Personal Details Validation /// /// }); //Contact Details Validation ///////////////////////////// $('#save_contact_details').click(function(){ $("#regstatus").removeAttr("name"); $('#btnstatus').val('Contact Details'); var lphone = $('#lphone').val(); var gsm = $('#gsm').val(); var femail = $('#email').val(); var address1 = $('#address1').val(); // checking this later //if(required(lphone, 'lphone', '', '', '', '')){ // $('#contact_details_msg').html("ERROR: Type your home number"); // } // else if(plainNumber(lphone, 'lphone', '', '', '', '')){ $('#contact_details_msg').html("ERROR: Type a valid home number"); } else if(required(gsm, 'gsm', '', '', '', '')){ $('#contact_details_msg').html("ERROR: Type your gsm number"); } else if(plainNumber(gsm, 'gsm', '', '', '', '')){ $('#contact_details_msg').html("ERROR: Type a valid gsm number"); } else if(required(femail, 'femail', '', '', '', '')){ $('#contact_details_msg').html("ERROR: Type your email address"); } else if(emailChecks(femail, 'femail', '', '', '', '')){ $('#contact_details_msg').html("ERROR: Type a valid email address"); } else if(required(address1, 'address1', '', '', '', '')){ $('#contact_details_msg').html("ERROR: Type your current address"); } else{ $('#contact_details_msg').html(""); //todo on valid form document.forms.frm_quote.submit(); } }); //End Contact Details Validation //Car information Validation ///////////////////////////// $('#carinformation').click(function(){ $("#regstatus").removeAttr("name"); var model = $('#model').val(); var regnumb = $('#regnumb').val(); var enginenumb = $('#enginenumb').val(); var chassisnumb = $('#chassisnumb').val(); var insureval = $('#insureval').val(); var maketype = $('#maketype').val(); var yearofmake = $('#yearofmake').val(); var seats = $('input[name=seats]:checked', '#frm_quote').val(); var covertype = $('#dd_covertype').val(); // var doc = $("#filedoc").get(0).files[0]; if( covertype == '00377' || covertype == '00378' || covertype == '00365' || covertype == '00380'){ var mode_dec = "Type Situation of Risk"; var biztypes = "Type Business Type"; var locatn = "Type your location"; var decrtn = "Type your Description"; var risktype = "Select Your Risk type"; $('#btnstatus').val(' Red Card Information'); }else { var mode_dec = "Type your model number"; var biztypes = "Type your regnumb number"; var locatn = "Type your enginenumb number"; var decrtn = "Type your chassisnumb number"; var risktype = "Type your car make type"; $('#btnstatus').val('Car Information'); } if(required(model, 'model', '', '', '', '')){ // $('#car_information_msg').html("ERROR: Type your model number"); $('#car_information_msg').html(""+ mode_dec + ""); } else if(required(regnumb, 'regnumb', '', '', '', '')){ $('#car_information_msg').html(""+ biztypes + ""); } else if(required(enginenumb, 'enginenumb', '', '', '', '')){ $('#car_information_msg').html(""+ locatn + ""); } else if(required(chassisnumb, 'chassisnumb', '', '', '', '')){ $('#car_information_msg').html(""+ locatn + ""); } else if(required(insureval, 'insureval', '', '', '', '')){ $('#car_information_msg').html("ERROR: Type your insure value"); } else if(required(maketype, 'maketype', '', '', '', '')){ $('#car_information_msg').html(""+ risktype + ""); } // else if(required(yearofmake, 'yearofmake', '', '', '', '')){ // $('#car_information_msg').html("ERROR: Type your year of make"); // } // else if(required(seats, 'seats', '', '', '', '')){ // $('#car_information_msg').html("ERROR: Select the number of seats"); // } else if( $('.docview').attr('href') == ''){ alert($('.docview').attr('href')); $('#car_information_msg').html("ERROR: Please Select Doc To Upload"); } else { $('#filetype').val('filedoc'); //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 lname = $('#lname').val(); var fname = $('#fname').val(); var dd_dbirth = $('#dd_dbirth').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 address1 = $('#address1').val(); var model = $('#model').val(); var regnumb = $('#regnumb').val(); var enginenumb = $('#enginenumb').val(); var chassisnumb = $('#chassisnumb').val(); var insureval = $('#insureval').val(); var maketype = $('#maketype').val(); var yearofmake = $('#yearofmake').val(); var seats = $('#seats').val(); var dd_drivercount = $('#dd_drivercount').val(); var dd_covertype = $('#dd_covertype').val(); //todo check all required credentials are set var confirmation = confirm('are you sure you want to update your process details info? if not click cancel'); if (confirmation) { if (dd_title != '' && lname != '' && fname != '' && // dd_dbirth != '' && // dd_occupa != '' && // dd_gender != '' && // dd_mstatus1 != '' && // lphone != '' && gsm != '' && // model != '' && regnumb != '' && // enginenumb != '' && // chassisnumb != '' && insureval != '' //&& // maketype != '' && // yearofmake != '' && // dd_drivercount != '' && // dd_covertype != '' && // seats != '' // // ) { var querystring = $('#frm_quote').serialize(); quote_calculator(querystring); //document.forms.frm_quote.submit(); } else { alert('Some required fields are not entered'); } } } else { $('#declaration_msg').html("ERROR:Please select checkbox to accept declaration"); } }); //declaration //Coverage Details Validation ///////////////////////////////// $('#save_coverage_details').click(function(){ document.frm_quote.regstatus.value = 'N'; var sumass = $('input[name=sumass]:checked', '#frm_quote').val(); var sumass2 = $('#sumass2').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 paymode = $('input[name=paymode]:checked', '#frm_quote').val(); var paymode_b = $('#paymode_b').val(); var init_contrib = $('#init_contrib').val(); // // if((sumass == '__o__') && (required(sumass2, 'sumass2', '', '', '', ''))){ // $('#coverage_details_msg').html("ERROR: Type sum assured"); // return; // } // // // if((plainRawNumber(sumass2, 'sumass2', '', '', '', ''))){ // $('#coverage_details_msg').html("ERROR: Type valid sum assured"); // return; // } // // if(!esc){ // $('#coverage_details_msg').html("ERROR: Choose Sum Assured Escalation"); // return; // } // // if((qterm_a == '__o__') && (required(qterm_b, 'qterm_b', '', '', '', ''))){ // $('#coverage_details_msg').html("ERROR: Type Proposed Tenure"); // return; // } // // // if((plainRawNumber(qterm_b, 'qterm_b', '', '', '', ''))){ // $('#coverage_details_msg').html("ERROR: Type Valid Proposed Tenure"); // return; // } // // // if((annual_prem_a == '__o__') && (required(annual_prem_b, 'annual_prem_b', '', '', '', ''))){ // $('#coverage_details_msg').html("ERROR: Type Annual Contribution"); // return; // } // // // if((plainRawNumber(annual_prem_b, 'annual_prem_b', '', '', '', ''))){ // $('#coverage_details_msg').html("ERROR: Type Valid Annual Contribution"); // return; // } // // // if(!dd_premfrq_a){ // $('#coverage_details_msg').html("ERROR: Choose Contribution Payment Pattern"); // return; // } // // // if((annual_prem_a == '__o__') && (required(annual_prem_b, 'annual_prem_b', '', '', '', ''))){ // $('#coverage_details_msg').html("ERROR: Type Annual Contribution"); // return; // } // // // if((plainRawNumber(annual_prem_b, 'annual_prem_b', '', '', '', ''))){ // $('#coverage_details_msg').html("ERROR: Type Valid Annual Contribution"); // return; // } // // // if((paymode == '__o__') && (required(paymode_b, 'paymode_b', '', '', '', ''))){ // $('#coverage_details_msg').html("ERROR: Type Contribution Payment"); // return; // } // // // if((required(init_contrib, 'init_contrib', '', '', '', ''))){ // $('#coverage_details_msg').html("ERROR: Type Initial Contribution"); // return; // } // // // if((plainRawNumber(init_contrib, 'init_contrib', '', '', '', ''))){ // $('#coverage_details_msg').html("ERROR: Type Valid Initial Contribution"); // return; // } // $('#coverage_details_msg').html(""); //todo on valid form document.forms.frm_quote.submit(); }); //End Coverage Details Validation ////////// /* 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') { // Reposit$ui_engineion 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 = $form.loginid.value, $pass = $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: "GET", data: {'opt':'auth','id':$id,'pass':$pass}, dataType: "json", success: function($json) { 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(); } }, 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(); */ } /* if($json.status == "true") { $('#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: Uable to generate Security Question."); $form.loginid.focus(); } }, $chg_password = function($form){ var oldpass = $form.oldpassword.value, newpass = $form.newpassword.value, confirmpass= $form.confirmpass.value, $url = "change_pass.php"; 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, 'ajaxRec' : "true" }, dataType: "json", success: function($json) { if($json.status == "true") { //$('#login_msg').html("" + $json.msg + ""); alert($json.msg); login_blocker(); } else{ $('#password_msg').html("" + $json.msg + ""); } }, error: function(request, status, error) { $('#password_msg').html("" + error+ ""); } }); } } $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"; // 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; } else if(emailChecks($cemail, 'cemail', '', '', '', '')) { $('#access_msg').html("ERROR: Please, A Valid 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; } // Phone (Must be a greater than or equal to 13digits) else if(plainNumber($cgsm, 'cgsm', '', '', '', '')){ $('#access_msg').html("ERROR: Type a valid home number"); $form.cgsm.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 == ''; $url = "prelogin_utils/quicklogin_processor.php"; $act = 'testrequest' } //shows loading icon 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, 'cgsm' : $cgsm, 'requestid' : '', 'txt_message' : 'Save my details', 'subjectm' : '' }, dataType: "json", success: function($json) { if($json.email_return == false) { console.log($json.email_return); //todo code on success: $(activatedelement).removeClass('dim__X__123'); product_blocker(blocker_title,blocker_calculatorfile); } else { $('#access_msg').html("ACCESS ERROR: Your are already a client, kindly login in with the username and password sent to you."); $(activatedelement).removeClass('dim__X__123'); } //removes loading icon ajaxloader(true); }, error: function(request, status, error) { //removes loading icon ajaxloader(true); $(activatedelement).removeClass('dim__X__123'); $('#access').html("ACCESS ERROR: Please, Try Again."); } }); } }; $submit_access = function($form, $mode) { // Init. 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': '', $csurname = $form.csurname.value, $cothname = $form.cothname.value, $ccompany = $form.ccompany.value, $cemail = $form.cemail.value, $cgsm = $form.cgsm.value; $.ajax({ url: "prelogin_utils/switch.php", type: "GET", data: { 'opt': 'access', 'access_opt': $mode, 'chk_agtbro': $chk_agtbro, 'chk_staff': '', 'chk_client': $chk_client, 'chk_mgt': '', 'csurname': $csurname, 'cothname': $cothname, 'ccompany': $ccompany, 'cemail': $cemail, 'cgsm': $cgsm }, dataType: "html", success: function($html) { alert($html); login_blocker(); }, error: function(request, status, error) { //alert(request.responseText); $('#access').html("ACCESS ERROR: Please, Try Again."); } }) }; var $generate_client = function ($opt, $id){ //Check button state var activatedelement = $('#' + $id); var currentClassName = $(activatedelement).attr('class'); if (currentClassName.indexOf('dim__X__123') == -1){ $(activatedelement).addClass('dim__X__123'); var url = "prelogin_utils/generateuser.php"; //loading symbol ajaxloader(false); $.ajax({ url: url, type: "GET", data: { 'gen':'1','opt' : $opt }, dataType: "json", success: function(data) { ajaxloader(true); if(data.length > 0){ let userid = data[0]; let password = data[1]; $client_redirect_login(userid, password); console.log(data); } else{ successful_client(); } }, error: function(request, status, error) { //On Error ajaxloader(true); } }); } return false; } $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; // alert(email); 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 + ""); } }); } } $client_redirect_login = function($userid, $password) { // Init. var $id = $userid, $pass = $password; if ($id != "") { if ($pass != "") { //loading symbol 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) { console.log(`Error ${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}); };