var uinfo = new Array(); $(document).ready(function(){ //run elements //gets the page were on var filename = (window.location.pathname.split("/")); var page=new Array(); //default is 6 page['services.php']=1; page['examples.php']=2; page['benefits.php']=3; page['essayclass.php']=4; page['submit.php']=5; var floaterStation = (page[filename[1]] == null) ? 6 : page[filename[1]]; //payment system constant variables var paymentURL = 'https://secure.wp3.rbsworldpay.com/wcc/purchase'; var paymentParams = { "instId" : "239804", "cartId" : "abc123", "testMode" : "0", "currency" : "CAD" }; //MENU JS var start_offset = $('#m'+floaterStation).offset(); var mainNavOffset = $('#mainNav').offset(); $('#floater').width($('#m'+floaterStation).width()+36).css('left',start_offset.left-mainNavOffset.left+'px').fadeTo("fast", 0.4); $('#m'+floaterStation).addClass("active"); $("#mainNav ul li a").hover( function () { var offset = $(this).offset(); var mainNavOffset = $('#mainNav').offset(); $('#floater') .animate( { width:$(this).width()+36+"px" }, { queue:false, duration:600 } ) .animate( { left:offset.left-mainNavOffset.left+"px" }, { queue:false, duration:600 } ); $(this).addClass("white"); }, function () { var offset = $('#m'+floaterStation).offset(); var mainNavOffset = $('#mainNav').offset(); $('#floater') .stop() .animate( { width:$('#m'+floaterStation).width()+36+"px" }, { queue:false, duration:300 } ) .animate( { left:offset.left-mainNavOffset.left+"px" }, { queue:false, duration:300 } ); //.animate( { width:"1px" }, { queue:false, duration:300 } ) //.animate( { left:"1px" }, { queue:false, duration:300 } ); $(this).removeClass("white"); } ).click( function () { $("#mainNav ul li a").unbind('hover'); } ); //page specific JS if ($('#submitDOTphp').length) {//submit.php $.post("db.php", { action: "acc_management_get", username: $('#user_name').val(), password: $('#password').val() }, function(data){ if (data.redirect) { alert('Before submitting a paper you must create an account, you will be automatically redirected'); window.location = "signup.php"; } else { if (data.sign_essayclass == "0") $('#advert15').removeClass('hideMe'); else $('#discountNote').removeClass('hideMe'); uinfo["email"] = data.sign_email; uinfo["first"] = data.sign_first; uinfo["essayclass"] = data.sign_essayclass; uinfo["stamp"] = data.sign_stamp; } },"json"); } else if ($('#accountmgtDOTphp').length) {//accountmgt.php $.post("db.php", { action: "acc_management_get", username: $('#user_name').val(), password: $('#password').val() }, function(data){ if (data.redirect) { window.location = "signup.php"; } else { //creating the floating error box dynamicaly, so that code can stay shared b/w both forms $("#b3wrapper").append("
"); $('#newCCfloater').width($("#b3wrapper").width()).height($("#b3wrapper").height()).fadeTo("normal", 0.5); $('#newCCfloaterTXT').width($("#b3wrapper").width()).fadeTo("fast", 0); //disabling all cc fields //$('#sign_username, #sign_ccnum, #sign_cc_cvv, #sing_visa , #sing_mc , #sing_am, #sign_cc_month, #sign_cc_year, #sign_cc_address, #sign_cc_city, #sign_cc_province, #sign_cc_country').attr('disabled','disabled'); $('#sign_username').attr('disabled','disabled'); //assigning value to each field $('#sign_username').val(data.sign_username); $('#sign_password').val(data.sign_password); $('#sign_first').val(data.sign_first); $('#sign_last').val(data.sign_last); $('#sign_phone').val(data.sign_phone); $('#sign_email').val(data.sign_email); if (data.sign_essayclass != '0') { uinfo["essayclass"] = data.sign_essayclass; $('#essay_class').attr('checked','checked'); if (data.sign_essayclass =='Beginner' || data.sign_essayclass =='Intermediate' || data.sign_essayclass =='Advanced') {//this means is any of the intense classes were chosen we have to move the radio button $("#diff_intensive").attr('checked','checked'); } $("input[name='diff']").change(); $('#sign_essayclass').val(data.sign_essayclass); $('#essay_class_fields').animate( { height:"80px" }, { queue:false, duration:600 } ); $('#essay_class, #diff_eassy, #diff_intensive, #sign_essayclass').attr('disabled','disabled'); $('#current_compleated').removeClass('hideMe').children('span').html(data.sign_essayNum); } } },"json"); } else if ($('#signupDOTphp').length) { if (uinfo['username'] != null) window.location = "accountmgt.php"; } //input field JS $("input[type='text'], input[type='password']") .addClass("idle") .focus(function(){ $(this).addClass("activeField").removeClass("idle"); }).blur(function(){ $(this).removeClass("activeField").addClass("idle"); }); //userLogin $("#logIn").click( function () { loginCheck(); } ); //logout Function $('#logOut').click ( function () { $.post("db.php", { action: "logout", sid: ses }); $.cookie('first_name', null); $.cookie('user_name', null); $.cookie('password', null); $('#loggedIn').addClass('hideMe'); $('#user_name').val(''); $('#password').val(''); $('#anonymous').removeClass('hideMe'); } ); //forgotpass submit $("#forgotSubmit").click( function () { $('#forgotPass').addClass('hideMe'); $('#loading').removeClass('hideMe'); $.post("db.php", { action: "forgot", userORemail: $('#forgot_user').val()}, function(data){ if (data.error) { loginError (data.error); } else { loginError (data.success) } }, "json"); } ); //new signup submit $("#newaccountSub, #acc_mgt_change").click( function () { $('#coverFloater').removeClass('hideMe'); $('#coverFloater tr td').width($("#singupCont").width()).height($("#singupCont").height()); $(".signupform").fadeTo("normal", 0.33); if ($('#essay_class').attr('checked')) $('#essay_class').val($('#sign_essayclass').val()); var runEssayClass = 'true';//boolean was not working correctly because i think variable once passed was a string? if ( uinfo["essayclass"] == null && $('#essay_class').val() != '0' ) runEssayClass = 'false';//this is basicaly saying if there was no trace of the user being in the essay class (new or old) and now the essay class is chosen, we have the charge them $.post("db.php", { action: $(this).attr('name') , username: $('#sign_username').val(), runEssayClass: runEssayClass , password : $('#sign_password').val() , first : $('#sign_first').val() , last : $('#sign_last').val() , phone : $('#sign_phone').val() , email : $('#sign_email').val() , essayclass : $('#essay_class').val() }, function(data){ $('#coverFloater tr td').css('background-image','url(../images/iebg.gif)'); if (data.error) { if (data.location=='username' || data.location=='password') { $('#b1').addClass('bgred'); } else if (data.location=='first' || data.location=='last' || data.location=='email') { $('#b2').addClass('bgred'); } else if (data.location=='ccnum' || data.location=='cc_cvv' || data.location=='cc_address' || data.location=='cc_city' || data.location=='cc_province') { $('#b3').addClass('bgred'); } $('#coverFloater tr td').html(data.error + '

'); //error continue click $(".err_signup").bind("click", function(){ $(".signupform").fadeTo("normal", 1); $('#coverFloater').addClass('hideMe'); $('#coverFloater tr td').html('').css('background-image','url(../images/ajax-loader.gif)'); }); } else { $('#user_name').val(data.username); $('#password').val(data.password); loginCheck(); if (runEssayClass == 'false') {//this means we must proccess them through billing $('#createHead').html('Payment'); $('#accountSub').slideToggle('slow', function () { var classLevel = new Array(); classLevel['Beginner I'] = 110; classLevel['Beginner II'] = 110; classLevel['Intermediate I'] = 150; classLevel['Intermediate II'] = 150; classLevel['Advanced I'] = 190; classLevel['Advanced II'] = 190; classLevel['Beginner'] = 90; classLevel['Intermediate'] = 120; classLevel['Advanced'] = 150; paymentParams['M_act'] = $('#user_name').val(); paymentParams['amount'] = classLevel[$('#essay_class').val()]; paymentParams['desc'] = "eslpaperchecker.com Essay class registration"; for ( var key in paymentParams ) { if (paymentURL.length<=52) paymentURL += "?"; else paymentURL += "&"; paymentURL += key+'='+paymentParams[key]; } $('#coverFloater tr td').height($("#singupCont").height()-26); $(this).html($('#specialPayCont').html()+'').slideToggle('slow', function () { $(this).children('#paymentLoader') .width($(this).width()) .height($(this).height()-25); $(this).children('#payWindow').attr('src',paymentURL); } ); $('#payWindow').load( function() { $('#paymentLoader').addClass('hideMe'); } ); $('#specialStep.signupform').fadeTo("normal", 1); check4changeEssayClass( data.username , data.password ); } ); } else {// treat is like normal, no need for billing no changes were made to essay class OR essay class was not signed up for $('#coverFloater tr td').html(data.success); } } }, "json"); } ); //mimik enter button on loging form, some users hit enter to submit on a form $('#user_name, #password').keydown(function(event){ if (event.keyCode == 13) { $('#logIn').click(); } }); //forgotPass click event $('#forgotLink').click ( function () { forgotInfo (); } ); //essay class check box enable click $('#essay_class').click ( function () { if($(this).attr('checked')) { $('#essay_class_fields') .animate( { height:"80px" }, { queue:false, duration:600 } ); $(".essay_difficulty").change(); } else { $('#essay_class_fields') .animate( { height:"0px" }, { queue:false, duration:600 } ) } } ); //error focus return click event $('#b1, #b2, #b3').click ( function () { $(this).removeClass('bgred'); } ); //anonymous email click event $('#anonymousemail').click ( function () { $('#coverFloater').removeClass('hideMe'); $('#coverFloater tr td').width($(".anrte").width()).height($(".anrte").height()); $(".anrte").fadeTo("normal", 0.33); $.post("db.php", { action: "anonymous_email", emailtype: $('#emailtype').val(), full_name: $('#full_name').val(), email: $('#email').val(), content: $("#freeSentence").length ? $("#freeSentence").val() : $("iframe.rte-zone").contents().find(".frameBody").html()}, function(data){ $('#coverFloater tr td').css('background-image','url(../images/iebg.gif)'); if (data.error) { $('#coverFloater tr td').html(data.error + '

'); //error continue click $(".err_anonymousemail").bind("click", function(){ $(".anrte").fadeTo("normal", 1); $('#coverFloater').addClass('hideMe'); $('#coverFloater tr td').html('').css('background-image','url(../images/ajax-loader.gif)'); }); } else { $('#coverFloater tr td').html(data.success); $('#anonymousemail').unbind( "click" ); } }, "json"); } ); //rounded corener boxes if (jQuery.browser.msie && jQuery.browser.version.substr(0,1)<=7) { $('.signupform label, .submitform label').before(""); //IE is dogshit... } else { $('.roundedOut').corner("round 10px"); $('.roundedIn').corner("round 8px"); if (jQuery.browser.msie) {//IE BROWSERS ONLY //IE7 fix for lables not being able to clear:left $('.signupform label').before(""); } else {//this is done beacuse IE cant fade the rounded corener boxes... $('.roundedOutFade').corner("round 10px"); $('.roundedInFade').corner("round 8px"); } } //left Ad click effect *** TAKEN OUT BEACUSE IT WAS CAUSING PROBLEMS WITH STYLES IN FIREFOX /*$('#leftAd a.packages').mousedown(function(){ $(this).css('border-style','inset'); }).mouseup(function(){ $(this).css('border-style','outset'); }).bind("mouseenter",function(){ $(this).css('border-style','outset') .css('border-color','#65859F'); }).bind("mouseleave",function(){ $(this).css('border-style','solid') .css('border-color','#739BB8'); });*/ //JS rich text boxes $(".rte-zone").rte({ content_css_url: "assets/css/rte.css", media_url: "assets/rte/" }); //account management cc lock /*$("#b3wrapper").mouseenter(function(){ $('#newCCfloaterTXT').removeClass('hideMe'); $('#newCCfloaterTXT').stop().fadeTo("normal", 1); }).mouseleave(function(){ $('#newCCfloaterTXT').stop().fadeTo("normal", 0); });*/ //bringing the tables in 10px, aproved design effect $('table.tablestyle').wrap("
"); //applying the button class to all buttons $("input[type='button']").addClass('btn'); //class level dificulty //first BEACUSE OF IE7 we create an array to hold all the options in the select list. var diff_dropdown = new Array(); $.each($("#sign_essayclass option"), function() { diff_dropdown[$(this).attr('title')]=$(this); }); $(".essay_difficulty").change(function(){ if ($(this).attr('checked')) { $('#sign_essayclass').html(''); if ($(this).val() == 'eassy') for (i=1;i<=6;i++) $('#sign_essayclass').append(diff_dropdown[i]);//this is basic else for (i=7;i<=9;i++) $('#sign_essayclass').append(diff_dropdown[i]);//this is intenseive $(".startSpot").attr('selected','selected'); } }); //roatating front banner images if($('#ceostatmentDOTphp').length) { $('#headshot').html("").append('ESLpaperChecker'); } else { $('#headshot').cycle({ fx: 'fade', timeout: 15000, random: 1 }); } if (jQuery.browser.msie && jQuery.browser.version.substr(0,1)<=7) $('#headshot').append('ESLpaperChecker'); //price drop down based on native or basic service //first BEACUSE OF IE7 we create an array to hold all the options in the select list. var speedDropDown = new Array(); $.each($("#submit_duration option"), function() { //speedDropDown[$(this).attr('title')]=''; speedDropDown[$(this).attr('title')]=$(this); }); $("#submit_service").change(function(){ $('#submit_duration').html(''); if ($(this).val() == 'Basic Essay Correction') for (i=1;i<=3;i++) $('#submit_duration').append(speedDropDown[i]);//this is basic else for (i=4;i<=6;i++) $('#submit_duration').append(speedDropDown[i]);//this is intenseive $(".startSpot").attr('selected','selected'); }).change(); //updates the amount the user owes $('#calculate').click( function () { //var remainder = ($('#typeCounter').html()%500 >= 1) ? 1 : 0; // removed beacuse all this does is account for the exact 500'th word var numberofPages = Math.floor($('#typeCounter').html()/500)+1; var freePapers = Math.floor(((uinfo["stamp"]/1)+numberofPages)/7); if ( freePapers > 0 ) $('#freepaperStamp').fadeIn('slow'); //uinfo["stamp"] = ((uinfo["stamp"]/1)+numberofPages)%7; var amount = (numberofPages-freePapers)*$('#submit_duration').val(); if (uinfo['essayclass'] != "0") amount = Math.round((amount-(amount*0.15))*100)/100; $('#cost').html('$ '+amount); uinfo["new_stamp"] = ((uinfo["stamp"]/1)+numberofPages)%7; uinfo['amount'] = amount; //this updates the convertion link $('#pricecovert').attr('href',$('#pricecovert').attr('name')+'&Amount='+amount).attr('target','blank'); } ); //essasy submit, logged in user submits and essay $('#essay_submit').click( function () { $('#coverFloater').removeClass('hideMe'); $('#coverFloater tr td').width($("#singupCont").width()).height($("#singupCont").height()); $(".submitform").fadeTo("normal", 0.33); $('#calculate').click(); $.post("db.php", { action: "essay_submit_start", amount: uinfo['amount'], content: $("iframe.rte-zone").contents().find(".frameBody").html() }, function(data){ $('#coverFloater tr td').css('background-image','url(../images/iebg.gif)'); if (data.error) { $('#coverFloater tr td').html(data.error + '

'); //error continue click $(".err_signup").bind("click", function(){ $(".submitform").fadeTo("normal", 1); $('#coverFloater').addClass('hideMe'); $('#coverFloater tr td').html('').css('background-image','url(../images/ajax-loader.gif)'); }); } else { $('.essay_submitContain').slideToggle('slow', function () { paymentParams['M_act'] = $('#user_name').val(); paymentParams['amount'] = uinfo['amount']; paymentParams['desc'] = "eslpaperchecker.com Essay Submission"; for ( var key in paymentParams ) { if (paymentURL.length<=52) paymentURL += "?"; else paymentURL += "&"; paymentURL += key+'='+paymentParams[key]; } $('#coverFloater tr td').height($("#singupCont").height()-26); /*$(this).html('') .slideToggle('slow');*/ $(this).html($('#specialPayCont').html()+'').slideToggle('slow', function () { $(this).children('#paymentLoader') .width($(this).width()) .height($(this).height()-25); $(this).children('#payWindow').attr('src',paymentURL); } ); $('#payWindow').load( function() { $('#paymentLoader').addClass('hideMe'); } ); $('#specialStep.submitform').fadeTo("normal", 1); check4change( $('#user_name').val() , $('#password').val() , uinfo['amount'] ); } ); } },"json"); } ); //free sentance check JS $("#freeSentence").hover( function () { $(this).addClass('bgOrange'); }, function () { $(this).removeClass('bgOrange'); } ).focus( function () { $(this).addClass('forcedWhite'); } ) .maxLength($("#freeSentence").attr('name')); $('#textCounter').html($("#freeSentence").attr('name')); $("#email, #full_name").focus( function () { if ( $(this).val() == 'Name' || $(this).val() == "Email" ) { $(this).val('').css('color','#000'); } } ); //click event for essayClass tables $('.esIntensive').click ( function () { window.location = "tenscurriculum.php"; } ); $('.esNormal').click ( function () { window.location = "curriculum.php"; } ); //stamp card sliding effect $('#clickArrow').click ( function () { if ($("#shiftContain").css('right')=='-25px') { $('.stampCard.small').removeClass('hideMe'); $("#shiftContain").animate({right:-285},1000, function(){ $(this).children('#clickArrow').css('background-position','center bottom'); }); } else { $("#shiftContain").animate({right:-25},1000, function(){ $(this).children('#clickArrow').css('background-position','center top'); //$('.stampCard.small').addClass('hideMe'); }); } } ); //comment spacer }); //functions function trueCharCounter (mixedHTML) { $('#typeCounter').html(ReplaceTags(mixedHTML).split(/[\s\.\?]+/).length); } function ReplaceTags(xStr){ var regExp = /<\/?[^>]+>/gi; xStr = xStr.replace(regExp,""); return xStr; } function loginCheck () { $('#anonymous, #loggedIn').addClass('hideMe'); $('#loading').removeClass('hideMe'); $.post("db.php", { user_name: $('#user_name').val(), password: $('#password').val(), action: "login", sid: ses }, function(data){ if (data.error) { loginError (data.error); } else { $.cookie('user_name', data.user_name, { expires: 7 }); $.cookie('password', data.password, { expires: 7 }); loggedIn(data.first_name, data.stamp); } }, "json"); } function selectedRadioButton () { if ($("#sing_visa:checked").val() != null) return $("#sing_visa:checked").val(); if ($("#sing_mc:checked").val() != null) return $("#sing_mc:checked").val(); if ($("#sing_am:checked").val() != null) return $("#sing_am:checked").val(); } function loginError (errorMSG) { $('#loading').addClass('hideMe'); $('#logError').html(errorMSG + '

').removeClass('hideMe'); //error continue click $(".err_login_head").bind("click", function(){ $('#logError').addClass('hideMe'); $('#anonymous').removeClass('hideMe'); }); } function loggedIn (user_name, stamp){ uinfo["username"] = user_name; $('#loading').addClass('hideMe'); $('#loggedIn').removeClass('hideMe').children('span').html(user_name); stampCard (stamp); $('#shiftContain').removeClass('hideMe'); } function stampCard (numberOfStamps) { $('.stampCard').each(function(){ var counter = numberOfStamps; $(this).children('a').each(function(){ if (counter >= 1) $(this).addClass("show"); counter = counter-1; }); }); } function anonymous () { $('#anonymous').removeClass('hideMe'); } function forgotInfo () { $('#anonymous').addClass('hideMe'); $('#forgotPass').removeClass('hideMe') } function str_split ( f_string, f_split_length){ // http://kevin.vanzonneveld.net // + original by: Martijn Wieringa // + improved by: Brett Zamir (http://brett-zamir.me) // + bugfixed by: Onno Marsman // * example 1: str_split('Hello Friend', 3); // * returns 1: ['Hel', 'lo ', 'Fri', 'end'] f_string += ''; if (f_split_length == undefined) { f_split_length = 1; } if(f_split_length > 0){ var result = []; while(f_string.length > f_split_length) { result[result.length] = f_string.substring(0, f_split_length); f_string = f_string.substring(f_split_length); } result[result.length] = f_string; return result; } return false; } jQuery.fn.maxLength = function(max){ this.each(function(){ //Get the type of the matched element var type = this.tagName.toLowerCase(); //If the type property exists, save it in lower case var inputType = this.type? this.type.toLowerCase() : null; //Check if is a input type=text OR type=password if(type == "input" && inputType == "text" || inputType == "password"){ //Apply the standard maxLength this.maxLength = max; } //Check if the element is a textarea else if(type == "textarea"){ //Add the key press event this.onkeypress = function(e){ //Get the event object (for IE) var ob = e || event; //Get the code of key pressed var keyCode = ob.keyCode; //Check if it has a selected text var hasSelection = document.selection? document.selection.createRange().text.length > 0 : this.selectionStart != this.selectionEnd; //return false if can't write more return !(this.value.length >= max && (keyCode > 50 || keyCode == 32 || keyCode == 0 || keyCode == 13) && !ob.ctrlKey && !ob.altKey && !hasSelection); }; //Add the key up event this.onkeyup = function(){ //If the keypress fail and allow write more text that required, this event will remove it if(this.value.length > max){ this.value = this.value.substring(0,max); } $('#textCounter').html(max-this.value.length); }; } }); }; function check4change ( usr , pss , amount) { $.post("db.php", { action: "acc_management_get", username: usr, password: pss }, function(data){ if (data.redirect) { window.location = "signup.php"; } else if (data.sign_paymentTag=='1' || amount=='0' ) { $(".essay_submitContain").fadeTo("slow", 0.1, function () { var tempHeight = $(this).height(); $(this).height(tempHeight); $(this).html(''); $(this).fadeTo("slow",1, function () { $(this).slideToggle('slow', function () { $('#calculate').click(); $.post("db.php", { action: "essay_submit_aproved", username: usr, firstname: uinfo['first'] , email: uinfo['email'] , dialect: $('#submit_dialect').val() , service: $('#submit_service').val() , cost: uinfo['amount'] , duration: $('#submit_duration option:selected').text().substring(0,14) , style: $('#submit_style').val() , other: $('#otherInfo').val() , purpose: $('#submit_purpose').val() , content: $("iframe.rte-zone").contents().find(".frameBody").html(), stamp: uinfo["new_stamp"] }, function(data){ $('#coverFloater tr td').height($("#singupCont").height()); $('#specialStep.submitform').fadeTo("normal", 0.33); if (data.error) $('#coverFloater tr td').html(data.error); else $('#coverFloater tr td').html(data.success); },"json"); }); }); }); } else { setTimeout("check4change('"+usr+"','"+pss+"')",3000); } },"json"); } function check4changeEssayClass ( usr , pss ) { $.post("db.php", { action: "acc_management_get", username: usr , password: pss }, function(data){ if (data.sign_paymentTag=='1') { $("#accountSub").fadeTo("slow", 0.1, function () { var tempHeight = $(this).height(); $(this).height(tempHeight); $(this).html(''); $(this).fadeTo("slow",1, function () { $(this).slideToggle('slow', function () { $.post("db.php", { action: "essay_class_pay_rec", username: usr , essayclass: $('#essay_class').val() }, function(data_essay){ $('#coverFloater tr td').height($("#singupCont").height()); $('#specialStep.signupform').fadeTo("normal", 0.33); $('#coverFloater tr td').html(data_essay.success); }, "json"); }); }); }); } else { setTimeout("check4changeEssayClass('"+usr+"' , '"+pss+"')",3000); } },"json"); }