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('');
} else {
$('#headshot').cycle({
fx: 'fade',
timeout: 15000,
random: 1
});
}
if (jQuery.browser.msie && jQuery.browser.version.substr(0,1)<=7) $('#headshot').append('');
//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 + '