$(function(){
// var img_count = 0;
// var length = $("img").length;
// var k = 0;
// $("img").each(function(i,v){
// $(v).on("load",function(){
// $(".loader-bar .bars").css({
// 'width' : img_count + "%"
// });
// img_count = (Math.round((k / length)) * 100);
// k += 1;
// });
// });
// $('html,body').stop().animate({
// 'scrollTop': 0
// }, 800, 'swing');
$.fn.swiperNoSwiping();
if(!Modernizr.touch)
{
$(".ajaxmodal").hide();
}else{
//$("ul li a.plans-link,ul li a.sidr-class-plans-link,a.gotolink").attr("href",plan_link);
// if(typeof plan_link_unlimited !== undefined)
// {
// $("a.buildUnlimited").attr("href",plan_link_unlimited);
// }
// $("a.buildPersonalised").attr("href",plan_link);
}
if(Modernizr.touch && $(location).attr("href").indexOf("swipePlans") !== - 1 && screen.width <= 768) {
//$('body').prepend("");
var plansPages = ['div#personalised','div#payasyougo','div#unlimited'];
var measures = new Array();
var viewPortWidth = screen.width;
var initOffSetLeft = 0;
var j = 1;
$.each(plansPages,function(i,v){
$(v).css({
'position' : 'absolute',
'top' : $("section.planinfo div.pricing-tabs").outerHeight(true),
'left' : initOffSetLeft,
'float' : 'left',
'width' : '100%'
});
measures[j] = initOffSetLeft;
j+=1;
initOffSetLeft += viewPortWidth;
});
$("section#pricing").css({
'height' : $("div#personalised").outerHeight(true) + 81
});
// $("footer.footer-pages").css({
// 'top' : 150 + $("section#pricing").outerHeight(true) + $("section.plans").outerHeight(true)
// });
if($(location).attr("href").indexOf("swipePlans#unlimited") === - 1)
{
window.history.pushState(null,null,"personalised");
}
}
// }else{
// window.location.href= "personalised";
// }
var plansPages = [];
plansPages[1] = 'div#personalised';
plansPages[2] = 'div#payasyougo';
plansPages[3] = 'div#unlimited';
//plansPages[4] = 'div#dataonly';
var banners = [];
banners[0] = 'section.banner_personalised.plans';
banners[1] = 'section.banner_payg.plans';
banners[2] = 'section.banner_unli.plans';
//banners[3] = 'section.banner_dataonly.plans';
var previous_plan = $("input#plans-pricing-previous").val();
var current_plan = $("input#plans-pricing-active").val();
var next_plan = $("input#plans-pricing-next").val();
$("ul.pricing-nav-mobile li a").each(function(j,k){ //@TODO
$(this).on("click",function(){
$.each(banners,function(i,v){
$(v).hide();
});
$("style[data-name='plans-page']").remove();
var el_index = $(this).index("ul.pricing-nav-mobile li a");
$(banners[el_index]).show();
//$('body').prepend("");
var id_target = $(this).attr("id");
$("ul.pricing-nav li a").removeClass("active");
$(this).addClass("active");
$("section#pricing .tab-contenttt").each(function(i,v){
//$("section#pricing .tab-contenttt")
var index = $.inArray("div#"+$(v).attr("id"),plansPages);
if(id_target == "personalised"){
//alert(measures[index]);
$(v).css({
'left' : measures[index]
}).hide();
if($(v).attr('id') == "personalised")
{
$(v).show();
}
window.history.pushState(null,null,"personalised");
//$("section#pricing div#personalised" + ".tab-contenttt").animate({'left' : 0},'fast');
}else{
// $(v).animate({
// //'left' : measures[index] - screen.width
// 'left' : parseInt($(v).css('left')) - screen.width
// },'fast');
$("section#pricing .tab-contenttt").hide();
$("section#pricing div#" + id_target + ".tab-contenttt").css({'left' : 0}).show();
window.history.pushState(null,null,id_target);
}
$("input#plans-pricing-previous").val(plansPages[$.inArray("div#" + id_target,plansPages) - 1]);
$("input#plans-pricing-active").val("div#" + id_target);
$("input#plans-pricing-next").val(plansPages[$.inArray("div#" + id_target,plansPages) + 1]);
});
//$("section#pricing div#" + id_target + ".tab-contenttt").animate({'left' : 0},'fast');
});
});
var ddDOB = $("#contact-details select");
var dobd = $(ddDOB[0]);
var dobm = $(ddDOB[1]);
var doby = $(ddDOB[2]);
var ddPDOB = $("#if_postpaid select");
var pdobd = $(ddPDOB[0]);
var pdobm = $(ddPDOB[1]);
var pdoby = $(ddPDOB[2]);
var thisDate = new Date();
var thisYear = thisDate.getFullYear();
function leapYearCheck(year,month,day)
{
//day.find("option[value='29'],option[value='30'],option[value='31']").remove();
if(year.val() % 4 === 0)
{
if(month.val() == '02')
{
day.find("option[value='29'],option[value='30'],option[value='31']").remove();
day.append("");
}else{
day.find("option[value='29'],option[value='30'],option[value='31']").remove();
var no_of_days = new Date(year.val(),month.val(),0).getDate();
for (var i = 29; i <= no_of_days ; i++) {
day.append("");
};
}
}else{
if(month.val() == '02')
{
day.find("option[value='29'],option[value='30'],option[value='31']").remove();
}else{
day.find("option[value='29'],option[value='30'],option[value='31']").remove();
var no_of_days = new Date(year.val(),month.val(),0).getDate();
for (var i = 29; i <= no_of_days ; i++) {
day.append("");
};
}
}
}
$("#contact-details").on("change","select", function(){
/*if(!$(this).hasClass("dobd"))
{
leapYearCheck(doby,dobm,dobd);
}*/
$("input#dob").val(dobd.val() + "/" + dobm.val() + "/" + doby.val());
});
$("#if_postpaid").on("change","select",function(){
/*if(!$(this).hasClass("ported_dobd"))
{
leapYearCheck(pdoby,pdobm,pdobd);
}*/
$("input#ported_phone_dob").val(pdobd.val() + "/" + pdobm.val() + "/" + pdoby.val());
});
var screenHeight = $(window).outerHeight(true);
//var cachedHeight = 1779;
// if(screen.width > 768)
// {
// if($(window).outerHeight(true) <= screenHeight)
// {
// $("footer#contact-page-single").css({
// 'position' : 'fixed',
// 'left' : 0,
// 'bottom' : 0
// });
// }else{
// $("footer#contact-page-single").css({
// 'position' : 'initial',
// 'left' : 'initial',
// 'bottom' : 'initial',
// 'margin' : '15px 0 0 0',
// 'float' : 'left'
// });
// }
// }
// }else{
// var osh = $(".options-selections").outerHeight(true);
// var osw = $(".options-selections").outerWidth(true);
// var winheight = $(window).outerHeight(true) + 150;
// var winwidth = screen.width;
// $(".options-selections").css({
// 'top' : (winheight / 2) - (osh / 2),
// 'left' : (winwidth / 2) - (osw / 2)
// });
// $(".dd,.options-selections span").on("click",function(e){
// if($(this).attr("class") == undefined)
// {
// if($(this).attr('data-value') != "n/a")
// {
// $(this).parents(".select-container").find(".options-wrap").fadeOut();
// $(this).parent().find(" span").css({ 'background-color' : '#FFF' , 'color' : '#000', 'font-weight' : 400 });
// $(this).css({ 'background-color' : '#ff4505' , 'color' : '#FFF', 'font-weight' : 700 });
// }
// }
// $(this).parents(".select-container").find(".options-wrap").fadeIn('fast');
// e.stopPropagation();
// });
// }
// if(screen.width > 768)
// {
// if( ( $("html").outerHeight(true) + $("footer#contact-page-single").outerHeight(true) ) <= screen.height)
// {
// $("footer#contact-page-single").css({
// 'position' : 'initial',
// 'left' : 0,
// 'bottom' : 0,
// 'margin' : 'initial',
// 'float' : 'initial',
// 'top' : 'initial'
// });
// }else{
// $("footer#contact-page-single").css({
// 'position' : 'initial',
// 'left' : 'initial',
// 'bottom' : 'initial',
// 'margin' : '15px 0 0 0',
// 'float' : 'left'
// });
// }
// }else{
// $("footer#contact-page-single").css({
// 'position' : 'absolute',
// 'left' : 'initial',
// 'bottom' : 'initial',
// 'margin' : '15px 0 0 0',
// 'float' : 'left'
// });
// }
$(window).on("resize",function(){
$("#ajax-loading").css({
'height' : $("#login-form-wrapper").outerHeight(true) - 50
});
// setTimeout(function(){
// if($(window).outerWidth(true) > 768)
// {
// if( ( $("html").outerHeight(true) + $("footer#contact-page-single").outerHeight(true) ) <= screen.height)
// {
// $("footer#contact-page-single").css({
// 'position' : 'fixed',
// 'left' : 0,
// 'bottom' : 0,
// 'margin' : 'initial',
// 'float' : 'initial',
// 'top' : 'initial'
// });
// }else{
// $("footer#contact-page-single").css({
// 'position' : 'initial',
// 'left' : 'initial',
// 'bottom' : 'initial',
// 'margin' : '15px 0 0 0',
// 'float' : 'left'
// });
// }
// }else{
// $("footer#contact-page-single").css({
// 'position' : 'absolute',
// 'left' : 'initial',
// 'bottom' : 'initial',
// 'margin' : '15px 0 0 0',
// 'float' : 'left'
// });
// }
// },300);
if($(window).outerHeight(true) != document_width)
{
if(screen.width > 751)
{
$(window).swipe("disable");
}
if($(window).height() >= 900)
{
$("header#homepage").css({
'width' : '100%'
});
// $("div#banner").css({
// 'height' : ($(window).height() - $("#logo-nav").height()) + 42
// });
}
}
// if(screen.width <= 768) /*** multiple images on plans on resize ***/
// {
// // $("html,body").scrollTop(0);
// $("section#plans-tabs").find(".top-left-image").detach().insertAfter("ul.tab-links li.active a");
// var targ = $("ul.tab-links").find("li.active a").attr("data-target");
// $("ul.tab-links").find("li.active").append($("section#plans-tabs").find(targ).detach());
// $("ul.tab-links").find("li.active").append($("section#plans-tabs").find(".bottom-right-image").detach());
// //$("ul.tab-links").find("li.active").append($("section#plans-tabs").find(".bottom-right-image").detach());
// // if($(this).parent().hasClass("payg-tab"))
// // {
// // $("section#plans-tabs").find(".top-left-image").detach().insertAfter($(this).parent().find("a.visible-xs"));
// // }else{
// // $("section#plans-tabs").find(".top-left-image").detach().insertAfter($(this));
// // }
// //$(this).parent().append($("section#plans-tabs").find(".bottom-right-image").detach().css({'display' : 'block'}));
// }
});
if($("header.ty-page").length)
{
if(( $("html").outerHeight(true) + $("footer#contact-page-single").outerHeight(true) ) <= screen.height)
{
$("footer#contact-page-single").css({
'position' : 'fixed',
'left' : 0,
'bottom' : 0,
'margin' : 'initial',
'float' : 'initial',
'top' : 'initial'
});
}else{
$("footer#contact-page-single").css({
'position' : 'initial',
'left' : 'initial',
'bottom' : 'initial',
'margin' : '15px 0 0 0',
'float' : 'left'
});
}
}
/*mobile menu*/
document_width= $(document).width();
document_height=$(document).height();
var ww = screen.width;
var wh = $(window).height();
var resizeTimer;
var tabLinks = $("ul.tab-links");
var tabLinksClone = tabLinks.clone();
// if($(window).height() >= 900 && $(window).outerWidth() > 768)
// {
// $("div#banner").css({
// 'height' : ($(window).height() - $("#logo-nav").height()) + 100
// });
// }
// if(screen.width > 768 && $(window).outerHeight(true) < 980)
// {
// $("div#banner .banner-title-wrap").css({
// 'height' : $(window).outerHeight(true) - 50
// });
// $("div#banner .personalised-div").css({
// 'padding' : '0 0 10px'
// });
// $("div#banner .unlimited-div").css({
// 'margin' : '10px 0 0'
// });
// }
$("#plans-tabs #unlimited").addClass("active");
$("#plans-tabs img.bottom-right-image").attr("src","assets/img/unlimited-bottom-right.png");
$("#plans-tabs img.top-left-image").attr("data-target", "#unlimited").attr("src","assets/img/unlimited-top-left.png");
$("#plans-tabs .plan-link a").attr("href", window.location.pathname + "mobile-plans/unlimited-talk-text/?qs=0|0");
$("#plans-tabs ul.tab-links li a").each(function(){
var dis = $(this);
if($(this).parent().attr("class").indexOf('active') !== -1 && $(window).outerWidth(true) <= 768)
{
var current_active_target = $($(this).attr("data-target"));
$(this).parent().append(current_active_target);
//alert($(this).parent().attr("class"));
}
//resize event
$(window).on("resize",function(){
if(dis.parent().attr("class").indexOf('active') !== -1 && $(window).outerWidth(true) <= 768)
{
var current_active_target = $(dis.attr("data-target"));
dis.parent().append(current_active_target);
}else{
// if(dis.parent().attr("class").indexOf('active') !== -1 && $(window).outerWidth(true) > 768)
// {
// $(".top-left-image").show();
// $(dis.attr("data-target")).detach().insertAfter("ul.tab-links");
// }
$(".top-left-image").detach().insertBefore("ul.tab-links").show();
$(dis.attr("data-target")).detach().insertAfter("ul.tab-links");
}
});
//accordion click event
$(this).on("click",function(){
if(Modernizr.touch && screen.width <= 768)
{
$("style[data-name='plans-page']").remove();
//$("body").prepend("");
}else{
$(".top-left-image").show();
}
var tab_link_height = 0;
if($(window).outerWidth(true) <= 768) //mobile
{
if($(this).parent().hasClass("payg-tab"))
{
$("section#plans-tabs").find(".top-left-image").detach().insertAfter($(this).parent().find("a.visible-xs"));
}else{
$("section#plans-tabs").find(".top-left-image").detach().insertAfter($(this));
}
var targ = $(this).attr("data-target");
var div = $("section#plans-tabs").find(targ).detach();
$(this).parent().append(div);
$(this).parent().append($("section#plans-tabs").find(".bottom-right-image").detach().css({'display' : 'block'}));
}
//MOBILE CLICK EVENT
var targ = $(this).attr("data-target");
if( $(this).parent().hasClass("active") && screen.width <= 768 )
{
//accordion
$("section#plans-tabs ul.tab-links li .top-left-image,section#plans-tabs ul.tab-links li .bottom-right-image").addClass("hidden");
$(".arrow_indicator").attr("src", "assets/img/right-arrrow.png").css({
'height' : '14px',
'width' : '7px'
});
$(this).parent().removeClass("active");
$(this).parent().find(targ).slideUp(100).addClass("inactive").removeClass("active");
setTimeout(function(){
$("footer#contact-us").css({
'top' : $("header#homepage").outerHeight(true) + $("section#plans-tabs").outerHeight(true)
},100);
},100)
return;
}
$(".arrow_indicator").attr("src", "assets/img/right-arrrow.png").css({
'height' : '14px',
'width' : '7px'
});
if(!$(this).parent().hasClass("active"))
{
$("section#plans-tabs ul.tab-links li .top-left-image,section#plans-tabs ul.tab-links li .bottom-right-image").hide();
$(this).addClass("inactive").removeClass("active");
$(this).parent().find(".top-left-image,.bottom-right-image").removeClass("hidden");
$(this).parent().find(".arrow_indicator").attr("src", "assets/img/down-arrrow.png").css({
'height' : '7px',
'width' : '14px'
});
$(this).parent().find(targ).slideDown(100).addClass("inactive").removeClass("active");
setTimeout(function(){
$("footer#contact-us").css({'top' : $("header#homepage").outerHeight(true) + $("section#plans-tabs").outerHeight(true)})
},100);
}
var targ = $(this).attr("data-target");
$(this).parents("#plans-tabs").find("img.top-left-image").attr("src", "assets/img/" + targ.replace("#","") + "-top-left.png").attr("data-target",targ);
if(targ != "#mobilebroadband")
{
if(targ == "#unlimited")
{
$(this).parents("#plans-tabs").find("img.top-left-image").attr("src", "assets/img/" + targ.replace("#unlimited","unlimited") + "-top-left.png").attr("data-target",targ);
}
$(this).parents("#plans-tabs").find("img.bottom-right-image").show().attr("src", "assets/img/" + targ.replace("#","") + "-bottom-right.png").attr("data-target",targ);
if(targ == "#unlimited-talk-text")
{
$(this).parents("#plans-tabs").find("img.bottom-right-image").show().attr("src", "assets/img/" + targ.replace("#unlimited-talk-text","unlimited") + "-bottom-right.png").attr("data-target",targ);
}
}else{
$(this).parents("#plans-tabs").find("img.top-left-image").attr("src", "assets/img/" + targ.replace("#","") + "-top-left.png").attr("data-target",targ);
$(this).parents("#plans-tabs").find("img.bottom-right-image").hide();
}
$("#plans-tabs ul.tab-links li").removeClass("active");
$(this).parent().addClass("active");
$(".tab-content").hide();
$(targ).show();
var link = targ.replace("#","");
if(targ == "#mobilebroadband")
{
link = targ.replace("#mobilebroadband","mobile-broadband");
}else{
if(targ == "#unlimited")
{
link = targ.replace("#unlimited", "unlimited-talk-text");
}
}
$(".plan-link a").attr("href","mobile-plans/" + link + "/");
});
});
$("#personalised,#pay-as-you-go,#unlimited,#data-only,img.bottom-right-image,img.top-left-image").on("click",function(){
var targ = $(this).attr("data-target");
if(typeof targ !== "undefined")
{
var link = targ.replace("#","");
if(targ == "#unlimited")
{
link = targ.replace("#","") + "-talk-text";
}
window.location.href = "mobile-plans/" + link + "/";
}
// }else{
// window.location.href = "mobile-plans/unlimited-talk-text/";
// }
});
// $("html,body").on("scroll",function(){
// var top = $(window).scrollTop();
// });
/*home page slide circle*/
$('a.circles-btn').click(function(e) {
var hash = $(this).attr("href");
if($("#desktop-menu").hasClass("scrolling"))
{
scrollvalue = $(hash).offset().top;
}else{
scrollvalue = $(hash).offset().top - 130;
}
$("html,body").animate({
scrollTop : scrollvalue
});
});
//validate phone number new method
$.validator.addMethod("phone", function(phone_number, element) {
phone_number = phone_number.replace(/\s+/g, "");
return this.optional(element) || phone_number.length >= 7 &&
phone_number.match(/^((\+[1-9]{1,4}[ \-]*)|(\([0-9]{2,3}\)[ \-]*)|([0-9]{2,4})[ \-]*)*?[0-9]{3,4}?[ \-]*[0-9]{3,4}?$/);
}, "Please specify a valid phone number");
//validate digit
$.validator.addMethod("pwcheckdigit", function(value) {
return /\d/.test(value) // has a digit
});
//validate letter
$.validator.addMethod("pwcheckletter", function(value) {
return /[a-z,A-Z]/.test(value) // has a lowercase letter
});
//validate ageplans-tabs
$.validator.addMethod("check_age", function(value, element) {
var day = $("input[name='day']").val();
var month = $("input[name='month']").val();
var year = $("input[name='year']").val();
var age = 12;
var mydate = new Date();
mydate.setFullYear(year, month-1, day);
var currdate = new Date();
currdate.setFullYear(currdate.getFullYear() - age);
return currdate > mydate;
}, "You must be at least 12 years of age.");
//validate age
$.validator.addMethod("check_age_dob", function(value, element) {
var dateEntered = $("#dob").val();
// var day = dateEntered.substring(0, 2);
// var month = dateEntered.substring(3, 5);
// var year = dateEntered.substring(6, 10);
// var age = 11;
// var mydate = new Date();
// mydate.setFullYear(year, month-1, day);
// var currdate = new Date();
// currdate.setFullYear(currdate.getFullYear() - age);
// return currdate > mydate;
var age = getAge(dateEntered)
if (age<12) {
return false
}
return true
});
$.validator.addMethod("check_ported_dob_format", function(value, element) {
if($("input[name='port_number']:checked").val() == 'yes')
{
var dateEntered = $(element).val();
if($.isNumeric(dateEntered.substring(0, 2)))
{
var day = dateEntered.substring(0, 2);
}else{
return false;
}
if($.isNumeric(dateEntered.substring(3, 5))){
var month = dateEntered.substring(3, 5);
}else{
return false;
}
if($.isNumeric(dateEntered.substring(6, 10))){
var year = dateEntered.substring(6,10);
}else{
return false;
}
return true;
}else{
return true;
}
});
//date format
$.validator.addMethod("check_dob_format", function(value, element) {
var dateEntered = $(element).val();
//console.log(element);
if($.isNumeric(dateEntered.substring(0, 1)))
{
var day = dateEntered.substring(0, 1);
}else{
return false;
}
if($.isNumeric(dateEntered.substring(3, 4))){
var month = dateEntered.substring(3, 4);
}else{
return false;
}
if($.isNumeric(dateEntered.substring(6, 9))){
var year = dateEntered.substring(6,9);
}else{
return false;
}
return true;
});
// validate age for sign up page
// added Dec16,2015 by jobs
$.validator.addMethod("check_age_signup", function(value, element) {
var dateEntered = $("#dob").val();
var date = dateEntered.substring(0, 2);
var month = dateEntered.substring(3, 5);
var year = dateEntered.substring(6, 10);
var dateToCompare = new Date(year, month - 1, date);
var currentDate = new Date();
if(dateToCompare > currentDate){
return false;
}else{
return true;
}
});
/*==============================
TOOLTIP
==============================*/
$('.tool-tip').tipso({
speed: 400,
background: '#f1f1f1',
titleBackground: '#f1f1f1',
color: '#777',
titleColor: '#777',
showArrow : true,
width: 350,
maxWidth: '100%',
position : 'right'
});
$('.tool-tip-pricing').tipso({
speed: 400,
background: '#FFF',
titleBackground: '#777',
color: '#000',
titleColor: '#FFF',
showArrow : true,
width: 350,
maxWidth: '100%',
position : 'right'
})
/*=============================
LOGIN VALIDATION
=============================*/
$('#login-form').validate({
rules: {
emailun: "required",
username: "required",
password: "required",
customer_email: {
required: true,
checkemailaddress: true
},
email: {
required: true,
email: true
},
password: {
required: true
}
},
messages: {
emailun: {
required: "Enter an email",
email: "Invalid email"
},
customer_email: {
required: "Enter an email",
checkemailaddress: "Invalid email"
},
username: {
required: "Enter a username"
},
password: {
required: "Enter a password"
}
},
submitHandler: function(form) {
//your callback here
//console.log('confirmed');
/*$('#ajax-loading').show().delay(3000).hide();*/
$('#ajax-loading').slideUp( 300 ).delay( 800 ).fadeIn( 400 );
/*$('#ajax-loading').show(0).delay(5000);*/
$('.login').prop('disabled',true);
document.getElementById('login-form').submit();
//alert('xxx');
/*$('#ajax-loading').show();*/
$('#ajax-loading').hide();
},
focusInvalid: false,
invalidHandler : function(event,validator){
setTimeout(function(){
$("section.plans").css({
'top' : $("header.menuplans").outerHeight(true) - 1
});
$("section#pricing").css({
'top' : $("header.menuplans").outerHeight(true) + $("section.plans").outerHeight(true)
});
$("section#banner_pages").css({
'top' : $("header.menuplans,header.page-banner,header#ty-page").outerHeight(true)
})
$("section#banner_activate").css({
'top' : $("header.page-banner").outerHeight(true)
});
$("section.content").css({
'top' : $("section#banner_activate,section#banner_pages").outerHeight(true) + $("header.page-banner").outerHeight(true)
});
$("#banner-contact-us").css({
'top' : $("header.page-banner").outerHeight(true)
})
$("section#contact-page").css({
'top' : $("#banner-contact-us").outerHeight(true) + $("header.page-banner #logo-nav").outerHeight(true)
})
//footer padding
//$("footer.footer-pages").css({ 'top' : $("section#banner_activate,section.plans").outerHeight(true) + $("header.page-banner #logo-nav,header.menuplans").outerHeight(true) + $("section.content,section#pricing").outerHeight(true) });
//footer padding
$("footer#contact-page-single").css({
'top' : $("#banner-contact-us,section#banner_pages.banner_unli.plans.ty").outerHeight(true) + $("header.page-banner #logo-nav,header#ty-page").outerHeight(true) + $("section#contact-page").outerHeight(true)
});
$("input.error:first").focus();
},100);
}
});
$.validator.addMethod("checkemailaddress", function(email, element) {
var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
return re.test(email);
}, "Please enter a valid email email");
$.validator.addMethod("phone", function(phone_number, element) {
phone_number = phone_number.replace(/\s+/g, "");
return this.optional(element) || phone_number.length >= 7 &&
phone_number.match(/^((\+[1-9]{1,4}[ \-]*)|(\([0-9]{2,3}\)[ \-]*)|([0-9]{2,4})[ \-]*)*?[0-9]{3,4}?[ \-]*[0-9]{3,4}?$/);
}, "Please specify a valid phone number");
// $.validator.addMethod("checkphone_cnt", function(phone, element) {
// phone = phone.length;
// console.log(phone);
// if(phone < 10){
// return false;
// }else{
// return true;
// }
// }, "Please enter a valid number format");
$.validator.addMethod("checkphone_cnt", function(phone, element) {
phone = phone.length;
console.log(phone);
if(phone > 10){
return false;
}else{
return true;
}
}, "Please enter a valid number format");
$.validator.addMethod("checkphoneformat", function(phone, element) {
firstno = phone.charAt(0);
if(firstno != '0'){
return false;
}else{
return true;
}
}, "Please enter a valid number format");
// $.validator.addMethod("checkphoneformat2nd", function(phone, element) {
// secondno = phone.charAt(1);
// if(secondno != '4'){
// return false;
// }else{
// return true;
// }
// }, "Please enter a valid number format");
$("#contact-form-page").validate({
rules: {
email: {
checkemailaddress: true
},
mobile:{
phone: true,
checkphone_cnt: true,
checkphoneformat: true,
checkphoneformat2nd: false
}
},
messages: {
email: {
checkemailaddress: "Please enter a valid email address"
},
mobile:{
phone: "Please enter a valid number",
checkphone_cnt: "Incomplete phone number",
checkphoneformat: "Format should be 0xxxxxxxxx",
checkphoneformat2nd: "Format should be 0xxxxxxxxx"
}
},
focusInvalid: false,
submitHandler: function(form) { return true; }
});
$("#verify-phone-lp").validate();
/*=============================
ACTIVATE SIM
=============================*/
$('#build-plan-form').validate({
rules: {
auto_topup: "required",
iccid_prepaid: {
required: true,
digits: true
},
iccid_postpaid: {
required: true,
digits: true
}
},
messages: {
iccid_prepaid: {
required: "Please enter your SIM ICCID Number.",
digits: "ICCID must be numeric.",
auto_topup: "Please select an amount."
},
iccid_postpaid: {
required: "Please enter your SIM ICCID Number.",
digits: "ICCID must be numeric."
}
},
submitHandler: function(form) {
//your callback here
console.log('confirmed');
},
invalidHandler : function(event,validator){
setTimeout(function(){
$("section.plans").css({
'top' : $("header.menuplans").outerHeight(true) - 1
});
$("section#pricing").css({
'top' : $("header.menuplans").outerHeight(true) + $("section.plans").outerHeight(true)
});
$("section#banner_pages").css({
'top' : $("header.menuplans,header.page-banner,header#ty-page").outerHeight(true)
})
$("section#banner_activate").css({
'top' : $("header.page-banner").outerHeight(true)
});
$("section.content").css({
'top' : $("section#banner_activate,section#banner_pages").outerHeight(true) + $("header.page-banner").outerHeight(true)
});
$("#banner-contact-us").css({
'top' : $("header.page-banner").outerHeight(true)
})
$("section#contact-page").css({
'top' : $("#banner-contact-us").outerHeight(true) + $("header.page-banner #logo-nav").outerHeight(true)
})
//footer padding
//$("footer.footer-pages").css({ 'top' : $("section#banner_activate,section.plans").outerHeight(true) + $("header.page-banner #logo-nav,header.menuplans").outerHeight(true) + $("section.content,section#pricing").outerHeight(true) });
//footer padding
$("footer#contact-page-single").css({
'top' : $("#banner-contact-us,section#banner_pages.banner_unli.plans.ty").outerHeight(true) + $("header.page-banner #logo-nav,header#ty-page").outerHeight(true) + $("section#contact-page").outerHeight(true)
});
},100);
}
});
/*=============================
MOBILE NUMBER
=============================*/
$('#verify-phone-login').validate({
rules: {
mobile: {
required: true,
phone: true
}
},
messages: {
mobile: {
required: "Please enter a valid number.",
phone: "Please enter a valid number."
},
},
submitHandler: function(form) {
//your callback here
// console.log('confirmed');
document.getElementById('verify-phone-login').submit();
},
invalidHandler : function(event,validator){
setTimeout(function(){
$("section.plans").css({
'top' : $("header.menuplans").outerHeight(true) - 1
});
$("section#pricing").css({
'top' : $("header.menuplans").outerHeight(true) + $("section.plans").outerHeight(true)
});
$("section#banner_pages").css({
'top' : $("header.menuplans,header.page-banner,header#ty-page").outerHeight(true)
})
$("section#banner_activate").css({
'top' : $("header.page-banner").outerHeight(true)
});
$("section.content").css({
'top' : $("section#banner_activate,section#banner_pages").outerHeight(true) + $("header.page-banner").outerHeight(true)
});
$("#banner-contact-us").css({
'top' : $("header.page-banner").outerHeight(true)
})
$("section#contact-page").css({
'top' : $("#banner-contact-us").outerHeight(true) + $("header.page-banner #logo-nav").outerHeight(true)
})
//footer padding
//$("footer.footer-pages").css({ 'top' : $("section#banner_activate,section.plans").outerHeight(true) + $("header.page-banner #logo-nav,header.menuplans").outerHeight(true) + $("section.content,section#pricing").outerHeight(true) });
//footer padding
$("footer#contact-page-single").css({
'top' : $("#banner-contact-us,section#banner_pages.banner_unli.plans.ty").outerHeight(true) + $("header.page-banner #logo-nav,header#ty-page").outerHeight(true) + $("section#contact-page").outerHeight(true)
});
},100);
}
});
/*=============================
ACTIVATE SIM SIGNUP
=============================*/
$('#signup-activate-form').validate({
ignore: [],
rules: {
device: "required",
year: {
required: true,
check_age: true
},
gender: "required",
fname: {
required: true,
pwcheckletter: true
},
lname: {
required: true,
pwcheckletter: true
},
email: {
required: true,
email: true
},
email_verify: {
required: true,
equalTo: "#email"
},
contact: {
required: true,
phone: true
},
pw: {
required: true,
pwcheckdigit: true,
pwcheckletter: true,
rangelength: [8, 32],
},
verifypw: {
required: true,
equalTo: '#pw'
},
delivery: "required",
residential: "required",
terms: "required",
iccid: "required"
},
groups: {
birthday: "day month year"
},
messages: {
device: "You must select the type of device you will be using your SIM card in.",
month: "Please complete your date of birth.",
day: "Please complete your date of birth.",
year: {
required: "Please complete your date of birth.",
check_age: "Invalid age."
},
gender: "Please select your gender.",
fname: {
required: "Please fill in your first name.",
pwcheckletter: "Please use only alphabetic characters."
},
lname: {
required: "Please fill in your last name.",
pwcheckletter: "Please use only alphabetic characters."
},
email: {
required: "You must enter an email address.",
email: "Please enter a valid email address."
},
email_verify: {
required: "Please confirm your email.",
equalTo: "Your email do not match."
},
contact: {
required: "Please enter a valid number.",
phone: "Please enter a valid number."
},
pw: {
required: "Please enter a password.",
pwcheckdigit: "Password must contain atleast one number - (0-9)",
pwcheckletter: "Your password must contain at least one letter - (a-z, A-Z)",
rangelength: "Your password must be between 8 and 32 characters and use only valid characters."
},
verifypw: {
required: "Please confirm your password.",
equalTo: "Your passwords do not match."
},
residential: {
required: "Please enter your address."
},
delivery: {
required: "Please enter your delivery address."
},
terms: {
required: "You must agree before proceeding."
},
iccid: {
required: "Please enter your SIM ICCID Number."
}
},
errorPlacement: function(error, element) {
var name = element.prop("name");
if(name === "month" || name==="day" || name==="year") {
error.insertAfter("select[name='year']");
} else {
error.insertAfter(element);
}
if(element.attr("name") == "terms") {
error.appendTo("#error-terms");
} else {
error.insertAfter(element);
}
},
submitHandler: function(form) {
//your callback here
console.log('confirmed');
},
invalidHandler : function(event,validator){
setTimeout(function(){
$("section.plans").css({
'top' : $("header.menuplans").outerHeight(true) - 1
});
$("section#pricing").css({
'top' : $("header.menuplans").outerHeight(true) + $("section.plans").outerHeight(true)
});
$("section#banner_pages").css({
'top' : $("header.menuplans,header.page-banner,header#ty-page").outerHeight(true)
})
$("section#banner_activate").css({
'top' : $("header.page-banner").outerHeight(true)
});
$("section.content").css({
'top' : $("section#banner_activate,section#banner_pages").outerHeight(true) + $("header.page-banner").outerHeight(true)
});
$("#banner-contact-us").css({
'top' : $("header.page-banner").outerHeight(true)
})
$("section#contact-page").css({
'top' : $("#banner-contact-us").outerHeight(true) + $("header.page-banner #logo-nav").outerHeight(true)
})
//footer padding
//$("footer.footer-pages").css({ 'top' : $("section#banner_activate,section.plans").outerHeight(true) + $("header.page-banner #logo-nav,header.menuplans").outerHeight(true) + $("section.content,section#pricing").outerHeight(true) });
//footer padding
$("footer#contact-page-single").css({
'top' : $("#banner-contact-us,section#banner_pages.banner_unli.plans.ty").outerHeight(true) + $("header.page-banner #logo-nav,header#ty-page").outerHeight(true) + $("section#contact-page").outerHeight(true)
});
},100);
}
});
/*=============================
UPDATE PASSWORD VALIDATION
=============================*/
/*$('form#updatepwd-form').validate({
ignore: [],
onkeyup: true,
rules: {
new_password: {
required: true,
pwcheckdigit: true,
pwcheckletter: true,
rangelength: [8, 32],
},
confirm_password: {
required: true,
equalTo: '#new_password'
}
},
messages: {
new_password: {
required: "Please enter a password.",
pwcheckdigit: "Password must contain atleast one number - (0-9)",
pwcheckletter: "Your password must contain at least one letter - (a-z, A-Z)",
rangelength: "Your password must be between 8 and 32 characters and use only valid characters."
},
confirm_password: {
required: "Please confirm your password.",
equalTo: "Your passwords do not match."
}
},
submitHandler: function(form) {
//your callback here
document.getElementById('updatepwd-form').submit();
}
});*/
/*=============================
NEW PASSWORD AFTER RESET VALIDATION
=============================*/
/*$('form#setpassword-form').validate({
ignore: [],
onkeyup: true,
rules: {
newpassword: {
required: true,
pwcheckdigit: true,
pwcheckletter: true,
rangelength: [8, 32]
},
confirmnewpassword: {
required: true,
equalTo: '#newpassword'
},
},
messages: {
newpassword: {
required: "Please enter a password.",
pwcheckdigit: "Password must contain atleast one number - (0-9)",
pwcheckletter: "Your password must contain at least one letter - (a-z, A-Z)",
rangelength: "Your password must be between 8 and 32 characters and use only valid characters."
},
confirmnewpassword: {
required: "Please confirm your password.",
equalTo: "Your passwords do not match."
}
},
submitHandler: function(form) {
//your callback here
document.getElementById('setpassword-form').submit();
}
});*/
/*=============================
RESET PASSWORD VALIDATION
=============================*/
$('form#forgot-form').validate({
rules: {
emailforgot: "required",
email: {
required: true,
email: true
}
},
messages: {
emailforgot: {
required: "Enter an email",
email: "Invalid email"
},
},
submitHandler: function(form) {
//your callback here
document.getElementById('forgot-form').submit();
},
invalidHandler : function(event,validator){
setTimeout(function(){
$("section.plans").css({
'top' : $("header.menuplans").outerHeight(true) - 1
});
$("section#pricing").css({
'top' : $("header.menuplans").outerHeight(true) + $("section.plans").outerHeight(true)
});
$("section#banner_pages").css({
'top' : $("header.menuplans,header.page-banner,header#ty-page").outerHeight(true)
})
$("section#banner_activate").css({
'top' : $("header.page-banner").outerHeight(true)
});
$("section.content").css({
'top' : $("section#banner_activate,section#banner_pages").outerHeight(true) + $("header.page-banner").outerHeight(true)
});
$("#banner-contact-us").css({
'top' : $("header.page-banner").outerHeight(true)
})
$("section#contact-page").css({
'top' : $("#banner-contact-us").outerHeight(true) + $("header.page-banner #logo-nav").outerHeight(true)
})
//footer padding
//$("footer.footer-pages").css({ 'top' : $("section#banner_activate,section.plans").outerHeight(true) + $("header.page-banner #logo-nav,header.menuplans").outerHeight(true) + $("section.content,section#pricing").outerHeight(true) });
//footer padding
$("footer#contact-page-single").css({
'top' : $("#banner-contact-us,section#banner_pages.banner_unli.plans.ty").outerHeight(true) + $("header.page-banner #logo-nav,header#ty-page").outerHeight(true) + $("section#contact-page").outerHeight(true)
});
},100);
}
});
$('#ajax-loading').hide();
$("#ajax-loading").css({
'height' : $("#login-form-wrapper").outerHeight(true) - 50
});
/*forgort form*/
$("#forgot").on('click', function() {
$('#ajax-loading').show();
$('#first-form').hide(function() {
$('#social-login-wrap').hide();
$('#second-form form').show();
$('#ajax-loading').hide();
});
});
/*login form*/
$("#backLogin").on('click', function() {
$('#ajax-loading').show();
$('#second-form form').hide(function() {
$('#social-login-wrap').show();
$('#first-form').show();
$('#ajax-loading').hide();
});
});
/*sign up form*/
$("#signup").on('click', function() {
$('#ajax-loading').show();
$('#first-form').hide(function() {
$('#signup-details').show();
$('#ajax-loading').hide();
$('#second-form form, #social-login-wrap').hide();
$('#login-details').hide();
});
$(this).hide();
//$('#login-details').hide();
});
/*$("input#residential").on('keyup focusout blur change click',function(){
if($(this).val().length > 0)
{
$('#delivery_preview').text($(this).val());
$('input#delivery').val($(this).val());
}else{
$("#delivery_preview").text("Enter residential address");
}
});*/
$('#signup-second-step-btn').on("click", function(e) {
$('#dob').val($('.dobd').val()+'/'+$('.dobm').val()+'/'+$('.doby').val());
$('#ported_phone_dob').val($('.ported_dobd').val()+'/'+$('.ported_dobm').val()+'/'+$('.ported_doby').val());
validate_email();
var signupForm = $('#sign-up-form');
/*sign up form validate*/
if($('#retail_checker').val() == 0){
if(document.getElementById('nano').checked == true) {
$('#hdnsim').val("nano");
} else {
$('#hdnsim').val("regular");
}
}
if(document.getElementById('delivery-add').style.display == "none") {
$('#delivery').val($('#residential').val());
$('#hdnsameadd').val("Y");
} else {
$('#hdnsameadd').val("N");
}
$('#hdnfname').val($('#fname').val());
$('#hdnlname').val($('#lname').val());
$('#hdnemail').val($('#email').val());
$('#hdncontact').val($('#contact').val());
$('#hdnpassword').val($('#pw').val());
$('#spanname').html($('#fname').val()+' '+$('#lname').val());
$('#spanemail').html($('#email').val());
$('#spanaddress').html($('#residential').val());
$('#spandelivery').html($('#delivery').val());
if($('#retail_checker').val() == 0){
var ref_contact = $('#referral_contact').val();
res = ref_contact.split(' ').join('');
$('#hdnreferralcontact').val(res);
}
//>>> checker if sign up with facebook
if ($('#hdnisfacebook').val() == 1) {
var fbpassword = $('#pw').val()
fbpassword = fbpassword.substr(2, fbpassword.length)
$('#hdnpassword').val(fbpassword);
}
//<<< checker if sign up with facebook
/*var d = new Date($('#dob').val())
var year = d.getYear()
var m = d.getMonth() + 1
var d = d.getDate()
var final_dob = d+"/"+m+"/"+year;
var d_phone = new Date($('#ported_phone_dob').val())
var year_phone = d_phone.getYear()
var m_phone = d_phone.getMonth() + 1
var d_phone = d_phone.getDate()
var final_dob_phone = d_phone+"/"+m_phone+"/"+year_phone;*/
$('#hdndob').val($('#dob').val());
$('#hdnported').val($("input[name='port_number']:checked").val());
$('#hdnretailchecker').val($('#retail_checker').val());
if($('#retail_checker').val() == 1){
$('#hdniccidno').val($('#iccid').val());
}
if($("input[name='port_number']:checked").val() == 'yes'){
$('#hdnportedno').val($('#ported_phone_no').val());
$('#hdnsubscription').val($("input[name='subscription']:checked").val());
$('#hdnserviceprovider').val($('#service_provider').val());
$('#hdnphonedbo').val($('#ported_phone_dob').val());
$('#hdnaccountno').val($('#ported_account_no').val());
}else{
$('#hdnportedno').val('');
$('#hdnsubscription').val('');
$('#hdnserviceprovider').val('');
$('#hdnphonedbo').val('');
$('#hdnaccountno').val('');
}
$.validator.addMethod("pwcheckportedphoneno", function() {
if($("input[name='port_number']:checked").val() == 'yes' && $('#ported_phone_no').val() == ''){
return false;
}else{
return true;
}
});
$.validator.addMethod("pwcheckportedphoneno_cnt", function() {
portedno = $('#ported_phone_no').val();
pno_cnt = portedno.length;
if($("input[name='port_number']:checked").val() == 'yes' && pno_cnt < 10){
return false;
}else{
return true;
}
});
$.validator.addMethod("pwcheckportednoformat", function() {
portedno = $('#ported_phone_no').val();
firstno = portedno.charAt(0);
if($("input[name='port_number']:checked").val() == 'yes' && firstno != '0'){
return false;
}else{
return true;
}
});
$.validator.addMethod("pwcheckportednoformat2nd", function() {
portedno = $('#ported_phone_no').val();
secondno = portedno.charAt(1);
if($("input[name='port_number']:checked").val() == 'yes' && secondno != '4'){
return false;
}else{
return true;
}
});
$.validator.addMethod("checkrefcontact_cnt", function() {
ref_contact = $('#referral_contact').val();
res = ref_contact.split(' ').join('');
referral_contact_cnt = res.length;
if($("#referral_contact").val() != '' && referral_contact_cnt < 10){
return false;
}else{
return true;
}
});
$.validator.addMethod("checkrefcontact2_cnt", function() {
ref_contact = $('#referral_contact').val();
res = ref_contact.split(' ').join('');
referral_contact_cnt = res.length;
if($("#referral_contact").val() != '' && referral_contact_cnt > 10){
return false;
}else{
return true;
}
});
$.validator.addMethod("checkrefcontactformat", function() {
referral_contact = $('#referral_contact').val();
firstno = referral_contact.charAt(0);
if($("#referral_contact").val() != '' && firstno != '0'){
return false;
}else{
return true;
}
});
$.validator.addMethod("checkrefcontactformat2nd", function() {
referral_contact = $('#referral_contact').val();
secondno = referral_contact.charAt(1);
if($("#referral_contact").val() != '' && secondno != '4'){
return false;
}else{
return true;
}
});
$.validator.addMethod("checkportterms", function() {
if($("input[name='port_number']:checked").val() == 'yes' && !$("input[name='portterms']").is(":checked")){
return false;
}else{
return true;
}
});
$.validator.addMethod("pwcheckportedphonedob", function() {
if($("input[name='port_number']:checked").val() == 'yes' && $('#ported_phone_dob').val() == '' && $("input[name='subscription']:checked").val() == 'prepaid'){
return false;
}else{
return true;
}
});
$.validator.addMethod("pwcheckportedphoneacct", function() {
if($("input[name='port_number']:checked").val() == 'yes' && $('#ported_account_no').val() == '' && $("input[name='subscription']:checked").val() == 'postpaid'){
return false;
}else{
return true;
}
});
$.validator.addMethod("checkserviceprovider", function() {
if($("input[name='port_number']:checked").val() == 'yes' && $('#service_provider').val() == ''){
return false;
}else{
return true;
}
});
$.validator.addMethod("checkvaliddate", function() {
var s = $('#dob').val();
var bits = s.split('/');
var d = new Date(bits[2], bits[1] - 1, bits[0]);
return d && (d.getMonth() + 1) == bits[1] && d.getDate() == Number(bits[0]);
});
/*$.validator.addMethod("checkvaliddateported", function() {
var s = $('#ported_phone_dob').val();
var bits = s.split('/');
var d = new Date(bits[2], bits[1] - 1, bits[0]);
return d && (d.getMonth() + 1) == bits[1] && d.getDate() == Number(bits[0]);
});*/
$.validator.addMethod("checkvaliddateported", function() {
if($("input[name='port_number']:checked").val() == 'yes' && $("input[name='subscription']:checked").val() == 'prepaid'){
var s = $('#ported_phone_dob').val();
var bits = s.split('/');
var d = new Date(bits[2], bits[1] - 1, bits[0]);
return d && (d.getMonth() + 1) == bits[1] && d.getDate() == Number(bits[0]);
}else{
return true;
}
});
$.validator.addMethod("checklnamespace", function() {
var lname = $('#lname').val();
if(lname.trim().length == 0){
return false;
}else{
return true;
}
});
$.validator.addMethod("checkfnamespace", function() {
var fname = $('#fname').val();
if(fname.trim().length == 0){
return false;
}else{
return true;
}
});
$.validator.addMethod("checklnamespecialchar", function() {
var lname = $('#lname').val();
if(/^[a-zA-Z0-9- ]*$/.test(lname) == false){
return false;
}else{
return true;
}
});
$.validator.addMethod("checkfnamespecialchar", function() {
var fname = $('#fname').val();
if(/^[a-zA-Z0-9- ]*$/.test(fname) == false){
return false;
}else{
return true;
}
});
$.validator.addMethod("checkemail", function() {
var emailvalid = $('#emailvalid').val();
if(emailvalid == 1){
return false;
}else{
return true;
}
});
$.validator.addMethod("checkportedphonenospace", function() {
var ported_phone_no = $('#ported_phone_no').val();
if(ported_phone_no.trim().length == 0 && $("input[name='port_number']:checked").val() == 'yes'){
return false;
}else{
return true;
}
});
$.validator.addMethod("checkportednonumeric", function() {
var ported_phone_no = $('#ported_phone_no').val();
if(/^\d+$/.test(ported_phone_no) == false && $("input[name='port_number']:checked").val() == 'yes'){
return false;
}else{
return true;
}
});
$.validator.addMethod("checkportednodob", function() {
var dateEntered = $("#ported_phone_dob").val();
var date = dateEntered.substring(0, 2);
var month = dateEntered.substring(3, 5);
var year = dateEntered.substring(6, 10);
var dateToCompare = new Date(year, month - 1, date);
var currentDate = new Date();
if(dateToCompare > currentDate && $("input[name='port_number']:checked").val() == 'yes'){
return false;
}else{
return true;
}
});
if($('#retail_checker').val() == 0){
signupForm.validate({
ignore: [],
onkeyup: false,
rules: {
fname: {
required: true,
checkfnamespace:true,
checkfnamespecialchar:true
},
lname: {
required: true,
checklnamespace:true,
checklnamespecialchar: true,
minlength:2
},
// dob: "required", -- old version
dob: {
required: true,
checkvaliddate: true,
check_age_signup: true,
check_age_dob: true,
check_dob_format : true
},
email: {
required: true,
email: true
},
email_verify: {
required: true,
equalTo: "#email"
},
contact: {
required: true,
phone: true
},
pw: {
required: true,
pwcheckdigit: true,
pwcheckletter: true,
rangelength: [8, 32],
},
verifypw: {
required: true,
equalTo: '#pw'
},
delivery: "required",
residential: "required",
terms: "required",
portterms: {
checkportterms: true
},
ported_phone_no: {
pwcheckportedphoneno: true,
checkportedphonenospace: true,
checkportednonumeric: true,
pwcheckportednoformat: true,
pwcheckportednoformat2nd: true,
pwcheckportedphoneno_cnt: true
},
referral_contact: {
checkrefcontact_cnt: true,
checkrefcontact2_cnt: true,
checkrefcontactformat: true,
checkrefcontactformat2nd: true
},
ported_phone_dob: {
pwcheckportedphonedob: true,
checkvaliddateported: true,
checkportednodob: true,
check_ported_dob_format : true
},
ported_account_no: {
pwcheckportedphoneacct: true
},
service_provider: {
checkserviceprovider: true
}
},
messages: {
ported_phone_no:{
pwcheckportedphoneno: "Please enter ported phone number",
checkportedphonenospace: "Please enter ported phone number",
checkportednonumeric: "Please use numeric characters.",
pwcheckportednoformat: "Format should be 04xxxxxxxx",
pwcheckportednoformat2nd: "Format should be 04xxxxxxxx",
pwcheckportedphoneno_cnt: "Incomplete ported number"
},
referral_contact:{
checkrefcontact_cnt: "Incomplete phone number",
checkrefcontact2_cnt: "Invalid phone number",
checkrefcontactformat: "Format should be 04xxxxxxxx",
checkrefcontactformat2nd: "Format should be 04xxxxxxxx"
},
ported_phone_dob:{
pwcheckportedphonedob: "Please enter date of birth provided to previous carrier",
checkvaliddateported: "Please enter valid date of birth provided to previous carrier",
checkportednodob: "Entered date is greater than today's date",
check_ported_dob_format: "Please check date of birth format dd/mm/yyyy"
},
ported_account_no:{
pwcheckportedphoneacct: "Please enter account number"
},
fname:{
required: "Enter your first name.",
checkfnamespace: "Enter your first name.",
checkfnamespecialchar: "Please use alphabetic characters."
},
lname:{
required: "Enter your last name.",
checklnamespace: "Enter your last name.",
checklnamespecialchar: "Please use alphabetic characters.",
minlength: "Minimum of two letters required."
},
dob: {
required: "Please enter date of birth",
checkvaliddate: "Please enter valid date of birth",
check_age_signup: "Entered date is greater than today's date",
check_age_dob: "You must be atleast 12 years old and above",
check_dob_format: "Please check date of birth format dd/mm/yyyy"
},
email: {
required: "You must enter an email address.",
email: "Please enter a valid email address."
},
email_verify: {
required: "Please confirm your email.",
equalTo: "Your email do not match."
},
contact: {
required: "Please enter a valid number.",
phone: "Please enter a valid number."
},
pw: {
required: "Please enter a password.",
pwcheckdigit: "Password must contain atleast one number - (0-9)",
pwcheckletter: "Your password must contain at least one letter - (a-z, A-Z)",
rangelength: "Your password must be between 8 and 32 characters and use only valid characters."
},
verifypw: {
required: "Please confirm your password.",
equalTo: "Your passwords do not match."
},
residential: {
required: "Please enter your address."
},
delivery: {
required: "Please enter your delivery address."
},
terms: {
required: "You must agree before proceeding."
},
portterms: {
checkportterms: "You must agree before proceeding."
},
service_provider: {
checkserviceprovider: "Please select service provider."
}
},
error: function(e) {
console.log(e);
},
errorPlacement: function(error, element) {
// $("footer.footer-pages").css({
// 'top' : $("section.content").outerHeight(true) + $("section#banner_pages").outerHeight(true) + $("header.page-banner").outerHeight(true)
// })
if(element.attr("name") == "terms") {
error.appendTo("#error-terms");
}
else if(element.attr("name") == "portterms") {
error.appendTo("#error-port-terms");
}
else {
error.insertAfter(element);
}
},
success : function(label)
{
// $("footer.footer-pages").css({
// 'top' : $("section.content").outerHeight(true) + $("section#banner_pages").outerHeight(true) + $("header.page-banner").outerHeight(true)
// })
},invalidHandler : function(event,validator){
setTimeout(function(){
$("section.plans").css({
'top' : $("header.menuplans").outerHeight(true) - 1
});
$("section#pricing").css({
'top' : $("header.menuplans").outerHeight(true) + $("section.plans").outerHeight(true)
});
$("section#banner_pages").css({
'top' : $("header.menuplans,header.page-banner,header#ty-page").outerHeight(true)
})
$("section#banner_activate").css({
'top' : $("header.page-banner").outerHeight(true)
});
$("section.content").css({
'top' : $("section#banner_activate,section#banner_pages").outerHeight(true) + $("header.page-banner").outerHeight(true)
});
$("#banner-contact-us").css({
'top' : $("header.page-banner").outerHeight(true)
})
$("section#contact-page").css({
'top' : $("#banner-contact-us").outerHeight(true) + $("header.page-banner #logo-nav").outerHeight(true)
})
//footer padding
//$("footer.footer-pages").css({ 'top' : $("section#banner_activate,section.plans").outerHeight(true) + $("header.page-banner #logo-nav,header.menuplans").outerHeight(true) + $("section.content,section#pricing").outerHeight(true) });
//footer padding
$("footer#contact-page-single").css({
'top' : $("#banner-contact-us,section#banner_pages.banner_unli.plans.ty").outerHeight(true) + $("header.page-banner #logo-nav,header#ty-page").outerHeight(true) + $("section#contact-page").outerHeight(true)
});
},100);
}
});
}
if($('#retail_checker').val() == 1){
$.validator.addMethod("checkphone_cnt", function() {
var phone = $('#contact').val();
phonelen = phone.length;
if(phonelen < 10){
return false;
}else{
return true;
}
});
$.validator.addMethod("checkphoneformat", function() {
var phone = $('#contact').val();
firstno = phone.charAt(0);
if(firstno != '0'){
return false;
}else{
return true;
}
});
$.validator.addMethod("checkphoneformat2nd", function() {
var phone = $('#contact').val();
secondno = phone.charAt(1);
if(secondno != '4'){
return false;
}else{
return true;
}
});
signupForm.validate({
ignore: [],
onkeyup: false,
rules: {
fname: {
required: true,
checkfnamespace:true,
checkfnamespecialchar:true
},
lname: {
required: true,
checklnamespace:true,
checklnamespecialchar:true,
minlength:2
},
// dob: "required", -- old version
dob: {
required: true,
checkvaliddate: true,
check_age_signup: true,
check_age_dob: true,
check_dob_format : true
},
iccid: "required",
email: {
required: true,
email: true,
checkemail: true
},
email_verify: {
required: true,
equalTo: "#email"
},
contact: {
required: true,
phone: true,
checkphone_cnt: true,
checkphoneformat: true,
checkphoneformat2nd: true
},
pw: {
required: true,
pwcheckdigit: true,
pwcheckletter: true,
rangelength: [8, 32],
},
verifypw: {
required: true,
equalTo: '#pw'
},
delivery: "required",
residential: "required",
terms: "required",
portterms: {
checkportterms: true
},
ported_phone_no: {
pwcheckportedphoneno: true,
checkportedphonenospace: true,
checkportednonumeric: true,
pwcheckportednoformat: true,
pwcheckportednoformat2nd: true,
pwcheckportedphoneno_cnt: true
},
ported_phone_dob: {
pwcheckportedphonedob: true,
checkvaliddateported: true,
checkportednodob: true,
check_ported_dob_format : true
},
ported_account_no: {
pwcheckportedphoneacct: true
},
service_provider: {
checkserviceprovider: true
}
},
messages: {
ported_phone_no:{
pwcheckportedphoneno: "Please enter ported phone number",
checkportedphonenospace: "Please enter ported phone number",
checkportednonumeric: "Please use numeric characters.",
pwcheckportednoformat: "Format should be 04xxxxxxxx",
pwcheckportednoformat2nd: "Format should be 04xxxxxxxx",
pwcheckportedphoneno_cnt: "Incomplete ported number"
},
ported_phone_dob:{
pwcheckportedphonedob: "Please enter date of birth provided to previous carrier",
checkvaliddateported: "Please enter valid date of birth provided to previous carrier",
checkportednodob: "Entered date is greater than today's date",
check_ported_dob_format: "Please check date of birth format dd/mm/yyyy"
},
ported_account_no:{
pwcheckportedphoneacct: "Please enter account number"
},
fname:{
required: "Enter your first name.",
checkfnamespace: "Enter your first name.",
checkfnamespecialchar: "Please use alphabetic characters."
},
lname:{
required: "Enter your last name.",
checklnamespace: "Enter your last name.",
checklnamespecialchar: "Please use alphabetic characters.",
minlength:"Minimum of two letters required."
},
dob: {
required: "Please enter date of birth",
checkvaliddate: "Incomplete birth date provided",
check_age_signup: "Entered date is greater than today's date",
check_age_dob: "You must be atleast 12 years old and above",
check_dob_format : "Please check date of birth format dd/mm/yyyy"
},
iccid: "Please enter ICCID number",
email: {
required: "You must enter an email address.",
email: "Please enter a valid email address.",
checkemail: "This email is already in use.
If you would like to add an extra phone number to your account or you believe this is in error, please contact our support team on 1300 966 656."
},
email_verify: {
required: "Please confirm your email.",
equalTo: "Your email do not match."
},
contact: {
required: "Please enter a valid number.",
phone: "Please enter a valid number.",
checkphone_cnt: "Incomplete phone number",
checkphoneformat: "Format should be 04xxxxxxxx",
checkphoneformat2nd: "Format should be 04xxxxxxxx"
},
pw: {
required: "Please enter your password.",
pwcheckdigit: "Password must contain atleast one number - (0-9)",
pwcheckletter: "Your password must contain at least one letter - (a-z, A-Z)",
rangelength: "Your password must be between 8 and 32 characters and use only valid characters."
},
verifypw: {
required: "Please verify your password.",
equalTo: "Your passwords do not match."
},
residential: {
required: "Please enter your address."
},
delivery: {
required: "Please enter your delivery address."
},
terms: {
required: "You must agree before proceeding."
},
portterms: {
checkportterms: "You must agree before proceeding."
},
service_provider: {
checkserviceprovider: "Please select service provider."
}
},
error: function(e) {
console.log(e);
},
errorPlacement: function(error, element) {
if(element.attr("name") == "terms") {
error.appendTo("#error-terms");
}
else if(element.attr("name") == "portterms") {
error.appendTo("#error-port-terms");
}
else {
error.insertAfter(element);
}
},invalidHandler : function(event,validator){
setTimeout(function(){
$("section.plans").css({
'top' : $("header.menuplans").outerHeight(true) - 1
});
$("section#pricing").css({
'top' : $("header.menuplans").outerHeight(true) + $("section.plans").outerHeight(true)
});
$("section#banner_pages").css({
'top' : $("header.menuplans,header.page-banner,header#ty-page").outerHeight(true)
})
$("section#banner_activate").css({
'top' : $("header.page-banner").outerHeight(true)
});
$("section.content").css({
'top' : $("section#banner_activate,section#banner_pages").outerHeight(true) + $("header.page-banner").outerHeight(true)
});
$("#banner-contact-us").css({
'top' : $("header.page-banner").outerHeight(true)
})
$("section#contact-page").css({
'top' : $("#banner-contact-us").outerHeight(true) + $("header.page-banner #logo-nav").outerHeight(true)
})
//footer padding
//$("footer.footer-pages").css({ 'top' : $("section#banner_activate,section.plans").outerHeight(true) + $("header.page-banner #logo-nav,header.menuplans").outerHeight(true) + $("section.content,section#pricing").outerHeight(true) });
//footer padding
$("footer#contact-page-single").css({
'top' : $("#banner-contact-us,section#banner_pages.banner_unli.plans.ty").outerHeight(true) + $("header.page-banner #logo-nav,header#ty-page").outerHeight(true) + $("section#contact-page").outerHeight(true)
});
},100);
}
});
}
if(signupForm.valid() == true) {
e.preventDefault();
$('#signup-first-step').slideUp("slow", function() {
$('#signup-second-step').slideDown("slow",function(){
// $("footer.footer-pages").css({
// 'top' : $("section#signup-form.content #signup-second-step").outerHeight(true) + $("section#banner_pages").outerHeight(true) + 150 + 80
// });
});
});
}
$('#back-to-signup').on("click", function(e) {
e.preventDefault();
$('#signup-second-step').slideUp("slow", function() {
$('#signup-first-step').slideDown("slow",function(){
// $("footer.footer-pages").css({
// 'top' : $("section#signup-form.content").outerHeight(true) + $("section#banner_pages").outerHeight(true) + 150
// });
});
});
});
});
/*Payment validation*/
$('#payment-finish-btn').on("click", function(e) {
$.validator.addMethod("cardCvvAmex", function() {
var value = $('#card_cvv').val();
if($('#card_type').val() == 'Amex'){
if(value.length == 4){
return true;
}else{
return false;
}
}else{
return true;
}
});
$.validator.addMethod("cardCvvOther", function() {
var value = $('#card_cvv').val();
if($('#card_type').val() == 'Visa' || $('#card_type').val() == 'Mastercard'){
if(value.length == 3){
return true;
}else{
return false;
}
}else{
return true;
}
});
$.validator.addMethod("cardExpiryMonth", function() {
var value = $('#card_expiry').val();
var expiry = value.split("/");
if(expiry[0] > 12 || expiry[0] < 1)
{
return false;
}
return true;
});
$.validator.addMethod("cardExpiryYear", function() {
var value = $('#card_expiry').val();
var expiry = value.split("/");
var d = new Date();
var curMonth = d.getMonth() + 1;
var month = ((expiry[0].substr(0,1) < 1) ? expiry[0].substr(1,1) : expiry[0].substr(0,2) );
if(expiry[1] <= d.getFullYear().toString().substr(2, 2))
{
if(month < curMonth)
{
return false;
}
if(month > curMonth && expiry[1] < d.getFullYear().toString().substr(2, 2))
{
return false;
}
}
return true;
});
$.validator.addMethod("cardExpiryFormat", function() {
var value = $('#card_expiry').val();
var match = /^(0[1-9]|1[0-2])\/\d{2}$/;
return match.test(value)
});
var paymentForm = $('#payment-form');
paymentForm.validate({
ignore: [],
onkeyup: false,
rules: {
card_name: "required",
yomojo_subscription: "required",
card_number: {
required: true,
creditcard: true
},
//card_expiry_month: "required",
//card_expiry_year: "required",
//card_type: "required",
card_cvv: {
required: true,
digits: true,
cardCvvAmex: true,
cardCvvOther: true
},
card_expiry: {
required: true,
cardExpiryMonth : true,
cardExpiryYear : true,
cardExpiryFormat: true
}
},
messages: {
card_name: "Please enter your card name",
yomojo_subscription: "Please select your subscription type.",
card_number: {
required: "Please enter your card number.",
creditcard: "Please enter a valid credit card number."
},
//card_expiry_month: "Please select an expiry month.",
card_cvv: {
required: "Please enter your CVV number.",
digits: "Please enter a valid CVV number.",
cardCvvAmex: "Please enter at least 4 digits.",
cardCvvOther: "Please enter at least 3 digits."
},
//card_expiry_year: "Please select an expiry year.",
card_expiry: {
required : "Please enter your card expiration date",
cardExpiryMonth : "Invalid card expiration date format, please follow: MM/YY format (e.g 03/19)",
cardExpiryYear : "Invalid card expiration date format, please follow: MM/YY format (e.g 03/19)",
cardExpiryFormat: "Invalid card expiration date format, please follow: MM/YY format (e.g 03/19)"
}
//card_type: "Please select card type."
},
errorPlacement: function(error, element) {
if(element.attr("name") == "yomojo_subscription") {
error.appendTo("#error_yomojo_subscription");
} else {
error.insertAfter(element);
}
},
submitHandler: function(form) {
$(".ajaxmodal").css("display", "block");
//alert("ddddd");
return true;
},
invalidHandler : function(event,validator){
setTimeout(function(){
$("section.plans").css({
'top' : $("header.menuplans").outerHeight(true) - 1
});
$("section#pricing").css({
'top' : $("header.menuplans").outerHeight(true) + $("section.plans").outerHeight(true)
});
$("section#banner_pages").css({
'top' : $("header.menuplans,header.page-banner,header#ty-page").outerHeight(true)
})
$("section#banner_activate").css({
'top' : $("header.page-banner").outerHeight(true)
});
$("section.content").css({
'top' : $("section#banner_activate,section#banner_pages").outerHeight(true) + $("header.page-banner").outerHeight(true)
});
$("#banner-contact-us").css({
'top' : $("header.page-banner").outerHeight(true)
})
$("section#contact-page").css({
'top' : $("#banner-contact-us").outerHeight(true) + $("header.page-banner #logo-nav").outerHeight(true)
})
//footer padding
//$("footer.footer-pages").css({ 'top' : $("section#banner_activate,section.plans").outerHeight(true) + $("header.page-banner #logo-nav,header.menuplans").outerHeight(true) + $("section.content,section#pricing").outerHeight(true) });
//footer padding
$("footer#contact-page-single").css({
'top' : $("#banner-contact-us,section#banner_pages.banner_unli.plans.ty").outerHeight(true) + $("header.page-banner #logo-nav,header#ty-page").outerHeight(true) + $("section#contact-page").outerHeight(true)
});
},100);
}
});
});
/*radio and checkbox button click script for signup*/
$("span.input-helper-checkbox").each(function() {
var element = $(this);
if(element.hasClass('dadd')) {
$(this).on("click", function() {
$(this).prev('input[name="same-address"]#same-add-btn').trigger('click');
if($(this).prev('input#same-add-btn').is(':checked')) {
$('#delivery-add').hide();
}
else {
$('#delivery-add').show();
}
// $("footer.footer-pages").css({
// 'top' : $("section#signup-form.content,section#signup-activate").outerHeight(true) + $("section#banner_pages").outerHeight(true) + 150
// });
});
}
if(element.hasClass('terms')) {
$(this).on("click", function() {
$(this).prev().trigger('click');
// $("footer.footer-pages").css({
// 'top' : $("section#signup-form.content").outerHeight(true) + $("section#banner_pages").outerHeight(true) + 150
// });
});
}
if(element.hasClass('sim')) {
$(this).on("click", function() {
$(this).prev().trigger('click');
// $("footer.footer-pages").css({
// 'top' : $("section#signup-form.content").outerHeight(true) + $("section#banner_pages").outerHeight(true) + 150
// });
});
}
});
$('.billing-type-wrapper').each(function() {
var element = $(this);
if(element.hasClass('prepaid')) {
$('#build-plan-prepaid').hide();
if($(this).on("click", function() {
$('#build-plan-prepaid').slideToggle(function(){
// $("footer.footer-pages").css({
// 'top' : $("section.content").outerHeight(true) + $("section#banner_pages").outerHeight(true) + $("header.page-banner").outerHeight(true)
// });
});
$('#build-plan-postpaid').hide();
}));
}
if(element.hasClass('postpaid')) {
$('#build-plan-postpaid').hide();
if($(this).on("click", function() {
$('#build-plan-prepaid').hide();
$('#build-plan-postpaid').slideToggle(function(){
$("footer.footer-pages").css({
'top' : $("section.content").outerHeight(true) + $("section#banner_pages").outerHeight(true) + $("header.page-banner").outerHeight(true)
});
});
}));
}
});
/*slider prepaid plan option*/
var topUpDefaults = ["0","200MB","500MB","1GB","2GB","3GB","5GB","10GB"];
var actualValue = ["0","5","9","11","15","25","39","69"];
$(".slider.slider-top-up").changePlanSlider({
dataValues : topUpDefaults,
valueMappings : actualValue,
indicatorBG : '#d62c63',
totalAmountEl : '.slide-top-up-val .perAmount, .top-up-final-amount .amt-holder',
type : 'top-up-modal',
initialAmount : 0
});
/*drowpdown prepaid plan option*/
$('.option-plan').change(function() {
var val = $(this).val();
if(val) {
$('.option-amount').text('$' + val).slideDown();
$('input.option-total').val(val);
}
});
/*dropdown pricing page*/
var selects = $('#personalised select.s-pricing-option');
selects.change(function(){
var value = 0;
selects.each(function(){ value += +this.value; });
$('.m-price-amount').html('$' + value);
}).trigger('change');
/*unlimited pricing page*/
var unlimited = $('#unlimited select.u-pricing-option');
unlimited.change(function(){
var value = 19.90;
if(unlimited.hasClass("data-pack-mb"))
{
if(this.value > 0)
{
$("span.unlimited_notice").css({ 'visibility' :'hidden'});
}else{
$("span.unlimited_notice").css({ 'visibility' :'visible'});
}
}
unlimited.each(function(){ value += +this.value; });
$('.u-price-amount').html('$' + value.toFixed(2));
}).trigger('change');
/*data pricing page*/
var dataonly = $('#data-only select.u-pricing-option,#dataonly select.u-pricing-option');
dataonly.change(function(){
var value = 0;
dataonly.each(function(){ value += +this.value; });
$('.d-price-amount').html('$' + value);
}).trigger('change');
//SET DEFAULT VALUES ON PLAN DROPDOWNS
//dataonly.val(15).trigger("change");
if(window.location.search == "")
{
selects.each(function(i,v){
switch(i)
{
case 0:
$(this).val(7).trigger('change');
break;
case 1:
$(this).val(9).trigger('change');
break;
case 2:
$(this).val(5).trigger('change');
break;
}
});
}
// ACTIVITY SETTINGS BUTTON SWITCH
var buttonToggler = {
'selector': $(".y-toggle-button"),
clickAction: function(doSomething)
{
buttonToggler.selector.on("click", function()
{
$(this).prop("disabled", true);
var type = $(this).attr("data-action");
$(this).toggleClass("active");
if($(this).hasClass("active"))
{
if(doSomething != false)
{
$(this).prop("disabled", false);
doSomething(type + ": swtiched to ON");
}
}
else
{
$(this).prop("disabled", false);
doSomething(type + ": swtiched to OFF");
}
});
}
}
var doSomething = (function(type)
{
$('#topup-details div.auto-topup').slideToggle("active");
});
buttonToggler.clickAction(doSomething);
// PRICING HOMEPAGE SLIDER
// !TABS
// $(".pricing-tab-links").each(function(){
// $(this).on("click",function(){
// $(".pricing-tab-links").removeClass("active");
// $(this).addClass("active");
// var target = $(this).attr("href");
// $(".tab-content").hide();
// $(target).show();
// return false;
// });
// });
// !PERSONALISED
$(".personal-slider-voice-pack .slider").changePlanSlider({
dataValues : ["0","100","200","400","600","1000"],
valueMappings : [0,7,10,14,17,23],
indicatorBG : '#e1044f',
type : 'personalised',
totalAmountEl : "#personalised .price-amount span",
initialAmount : 0,
indicatorBGHeight : '21px',
decimalPlaces : false
});
$(".personal-slider-sms-pack .slider").changePlanSlider({
dataValues : ["0","100","200","400","600","1000"],
valueMappings : [0,6,9,11,13,17],
indicatorBG : '#FF4505',
type : 'personalised',
totalAmountEl : "#personalised .price-amount span",
initialAmount : 0,
indicatorBGHeight : '21px',
decimalPlaces : false
});
$(".personal-slider-data-pack .slider").changePlanSlider({
dataValues : ["0","200","500","1GB","2GB","3GB","5GB","10GB"],
valueMappings : [0,5,9,11,15,25,39,69],
indicatorBG : '#FF9005',
type : 'personalised',
totalAmountEl : "#personalised .price-amount span",
initialAmount : 0,
indicatorBGHeight : '21px',
decimalPlaces : false
});
$(".personal-slider-intl-pack .slider").changePlanSlider({
dataValues : ["0","50","100","200","300"],
valueMappings : [0,5,10,20,30],
indicatorBG : '#929497',
type : 'personalised',
totalAmountEl : "#personalised .price-amount span",
initialAmount : 0,
indicatorBGHeight : '21px',
decimalPlaces : false
});
// !UNLIMITED
$(".unlimited-slider-data-pack .slider").changePlanSlider({
//dataValues : ["2GB","6GB","9GB","12GB"],
dataValues : ["2GB","6GB","9GB"],
valueMappings : [0,10,20,25],
indicatorBG : '#FF9005',
type : 'unlimited',
totalAmountEl : "#unlimited .price-amount span",
initialAmount : 19.90,
indicatorBGHeight : '21px',
decimalPlaces : true
});
$(".unlimited-slider-intl-pack .slider").changePlanSlider({
dataValues : ["0","50","100","200","300"],
valueMappings : [0,5,10,20,30],
indicatorBG : '#929497',
type : 'unlimited',
totalAmountEl : "#unlimited .price-amount span",
initialAmount : 19.90,
indicatorBGHeight : '21px',
decimalPlaces : true
});
//! DATA ONLY
$(".data-only-slider-data-pack .slider").changePlanSlider({
dataValues : ["3GB","10GB","25GB","40GB"],
valueMappings : [15.90,25.90,45.90,65.90],
indicatorBG : '#FF9005',
type : 'data-only',
totalAmountEl : "#data-only .price-amount span",
initialAmount : 0,
indicatorBGHeight : '21px',
decimalPlaces : false
});
// !FAMILY PLAN
$(".family-slider-pack .slider").changePlanSlider({
dataValues : ["2","3","4","5","6"],
valueMappings : [5.0,7.5,10.0,12.5,15.0],
indicatorBG : '#ff9005',
type : 'family',
totalAmountEl : "#family .family-slider .fam-discount-perc span",
initialAmount : 0,
indicatorBGHeight : '20px',
decimalPlaces : true,
eventChange : function(value){
var savings = [3.50,7.86,13.96,21.80,31.44];
$(".fam.fam-price span.actual-price").text("$" + savings[value].toFixed(2));
}
});
$(".family-slider-pack .slider").slider({ value: 2 });
$("#personalised .personal-slider-voice-pack .slider").slider({ value: 1 });
$("#personalised .personal-slider-sms-pack .slider").slider({ value: 2 });
$("#personalised .personal-slider-sms-pack .slider").slider({ value: 2 });
$(".unlimited-slider-data-pack .slider").slider({ value : 1 });
$(".data-only-slider-data-pack .slider").slider({ value : 4 });
$("#personalised .personal-slider-data-pack .slider").slider({ value: 1 });
$(".data-only .data-only-slider-data-pack .slider").slider({ value: 4 });
// FILTER RATES TABLE
$(".rate-index li a").filterRates();
var hash = window.location.hash;
if(hash != "" && hash.indexOf("#page=") == -1)
{
$("#pricing a.pricing-tab-links").removeClass("active");
$("#pricing a.pricing-tab-links").each(function(){
var dis = $(this);
if(dis.attr("href") == hash)
{
dis.addClass("active");
}
});
$("#pricing .tab-content").hide();
$("#pricing " + hash).show();
if(hash == "#unlimited")
{
$("section#banner_personalised.banner_unli.plans").css({ 'top' : '150px', 'display': 'block'});
$("style[data-name='benefits'],style[data-name='home-hash'],style[data-name='dashboard'],style[data-name='plans-page']").remove();
$("ul.pricing-nav-mobile li.unlimited-tab a").addClass("active");
//$('body').prepend("");
//$('body').prepend("");
$("#plans-pricing-previous").val("div#payasyougo");
$("#plans-pricing-active").val("div#unlimited");
$("#plans-pricing-next").val("div#dataonly");
$("body").css({
'background' : '#FFF'
});
window.history.pushState(null,null,"unlimited");
}
}
});
// Function to check age from the current date
function getAge(dateString) {
var d = new Date();
var userday = dateString.substring(0, 2);
var usermonth = dateString.substring(3, 5);
var useryear = dateString.substring(6, 10);
var curday = d.getDate();
var curmonth = d.getMonth()+1;
var curyear = d.getFullYear();
var age = curyear - useryear;
if((curmonth < usermonth) || ( (curmonth == usermonth) && curday < userday )){
age--;
}
return age;
}
/** FAQ ACCORDION **/
if(window.location.search != "")
{
var faqpath = decodeURI(window.location.search).replace("?path=","");
//if(faqpath.indexOf("|") != -1)
//{
var path = faqpath.split("|");
if(typeof path[0] != 'undefined')
{
var maincategory = $.trim(path[0].replace(/\+/g," "));
}
if(typeof path[1] != 'undefined')
{
var subcategory = $.trim(path[1].replace(/\+/g," "));
}
if(typeof path[2] != 'undefined')
{
var title = $.trim(path[2].replace(/\+/g," "));
}
//console.log(maincategory + "|" + subcategory + "|" + title);
$(".main-category").each(function(){
var _main = $(this);
var maincategorytext = $(this).find("span").text();
//console.log(maincategory + "|" + maincategorytext);
if(maincategorytext.indexOf($.trim(maincategory)) != -1)
{
$(this).addClass('open');
$(this).next().stop().show();
_main.find("span.block-content").stop().show();
$(this).find("i").removeClass('fa-chevron-down').addClass('fa-chevron-up');
setTimeout(function(){
$("html,body").scrollTop(_main.find("span").offset().top-50);
},1000);
}
});
if(typeof subcategory != "undefined")
{
$(".sub-category").each(function(){
var _main = $(this);
var maincategorytext = $(this).find("span").text();
//console.log($.trim(subcategory.toLowerCase()) + "|" + $.trim(maincategorytext.toLowerCase().replace(/\s/g," ")));
if($.trim(maincategorytext.toLowerCase().replace(/\s/g," ")).indexOf($.trim(subcategory.toLowerCase())) != -1)
{
$(this).addClass('open');
$(this).next().stop().show();
$(this).find("i").removeClass('fa-chevron-down').addClass('fa-chevron-up');
setTimeout(function(){
$("html,body").scrollTop(_main.find("span").offset().top-50);
},1000);
}
});
}
if(typeof title != "undefined")
{
$(".sub-article").each(function(){
var _main = $(this);
var subarticletext = $(this).find("span").text();
//console.log(subarticletext.toLowerCase().replace(" "," ") + "|" + $.trim(title.toLowerCase().replace(" "," ")))
//console.log($.trim(subcategory.toLowerCase().replace(" "," ")) + "|" + $.trim(maincategorytext.toLowerCase().replace(" "," ")));
if($.trim(title.toLowerCase()).indexOf($.trim(subarticletext.toLowerCase().replace(" "," "))) != -1)
{
$(this).addClass('open');
$(this).find(".article").stop().show();
$(this).find("i").removeClass('fa-chevron-down').addClass('fa-chevron-up');
setTimeout(function(){
$("html,body").scrollTop(_main.find("span").offset().top-50);
},1000);
}
});
}
//}
}
$(".main-category").each(function(){
var _main = $(this);
_main.on("click",function(e){
e.preventDefault();
//_main.find("span.block-content").stop().slideDown('fast');
$(".sub-category").removeClass('open');
$(".sub-category").find('i').removeClass('fa-chevron-up').addClass('fa-chevron-down');
$(".article-content").stop().slideUp('fast');
$(".sub-article").removeClass('open');
$(".sub-article").find('i').removeClass('fa-chevron-up').addClass('fa-chevron-down');
$(".article").stop().slideUp('fast');
if($(this).hasClass('open'))
{
$(".main-category").removeClass('open');
$(".main-category").find('i').removeClass('fa-chevron-up').addClass('fa-chevron-down');
$(".main-category-categories").stop().stop().slideUp('fast');
$("span.block-content").stop().slideUp('fast');
setTimeout(function(){
var topPX = $("section#faq").outerHeight(true) + $("section.plans").outerHeight(true) + $("header.menuplans").outerHeight(true)
$("footer.footer-pages").css({ position : 'static' });
},250)
}else{
$(".main-category").removeClass('open');
$(".main-category").find('i').removeClass('fa-chevron-up').addClass('fa-chevron-down');
$(".main-category-categories").stop().stop().slideUp('fast');
$("span.block-content").stop().slideUp('fast');
$(this).addClass('open');
$(this).find("i").removeClass('fa-chevron-down').addClass('fa-chevron-up');
$(this).next().stop().stop().slideDown('fast');
_main.find("span.block-content").stop().slideDown('fast');
//footer padding
setTimeout(function(){
var topPX = $("section#faq").outerHeight(true) + $("section.plans").outerHeight(true) + $("header.menuplans").outerHeight(true)
$("footer.footer-pages").css({ position : 'static' });
},250)
}
});
});
$(".sub-category").each(function(){
var _sub = $(this);
_sub.on("click",function(e){
e.preventDefault();
$(".sub-article").removeClass('open');
$(".sub-article").find('i').removeClass('fa-chevron-up').addClass('fa-chevron-down');
$(".article").stop().slideUp('fast');
if($(this).hasClass("open"))
{
$(".sub-category").removeClass("open")
$(".sub-category").find('i').removeClass('fa-chevron-up').addClass('fa-chevron-down');
$(".article-content").stop().slideUp('fast');
setTimeout(function(){
var topPX = $("section#faq").outerHeight(true) + $("section.plans").outerHeight(true) + $("header.menuplans").outerHeight(true)
$("footer.footer-pages").css({ position : 'static' });
},250)
}else{
$(".sub-category").removeClass("open")
$(".sub-category").find('i').removeClass('fa-chevron-up').addClass('fa-chevron-down');
$(".article-content").stop().slideUp('fast');
$(this).addClass("open");
$(this).find("i").removeClass('fa-chevron-down').addClass('fa-chevron-up');
$(this).next().stop().slideDown('fast');
//footer padding
setTimeout(function(){
var topPX = $("section#faq").outerHeight(true) + $("section.plans").outerHeight(true) + $("header.menuplans").outerHeight(true)
$("footer.footer-pages").css({ position : 'static' });
},250)
}
});
});
$(".sub-article").each(function(){
var _sub_article = $(this);
_sub_article.on("click",function(e){
e.stopPropagation();
if($(this).hasClass("open"))
{
$(".sub-article").removeClass("open")
$(".sub-article").find('i').removeClass('fa-chevron-up').addClass('fa-chevron-down');
$(".article").stop().slideUp('fast');
setTimeout(function(){
var topPX = $("section#faq").outerHeight(true) + $("section.plans").outerHeight(true) + $("header.menuplans").outerHeight(true)
$("footer.footer-pages").css({ position : 'static' });
},250)
}else{
$(".sub-article").removeClass("open")
$(".sub-article").find('i').removeClass('fa-chevron-up').addClass('fa-chevron-down');
$(".article").stop().slideUp('fast');
$(this).addClass("open");
$(this).find(".article").stop().slideDown('fast');
$(this).find("i").removeClass('fa-chevron-down').addClass('fa-chevron-up');
//footer padding
setTimeout(function(){
var topPX = $("section#faq").outerHeight(true) + $("section.plans").outerHeight(true) + $("header.menuplans").outerHeight(true)
$("footer.footer-pages").css({ position : 'static' });
},250)
}
});
});
/** END FAQ ACCORDION **/
// var subdir = ( (window.location.pathname.indexOf("frontend") !== -1) ? "/frontend/" : "/" ); //"/frontend/"; /** Leave "/" if prod version **/
// var hostname = window.location.protocol + "//" + window.location.host + subdir;
// $("a").each(function(j,k){
// var _link = $(this);
// var _linkhref = _link.attr("href");
// var _marker = $.trim(_link.text());
// var _linkref = ((typeof _linkhref !== "undefined") ? _linkhref.split("/")[_linkhref.split("/").length-1] : "");
// switch(_linkref)
// {
// case "cis":
// ( ( _link.text() == "Click here" ) ? _link.attr("href","").attr("href", hostname + "cis/") : "");
// break;
// case "pricingtable":
// case "pricingtable#appendix1":
// ( ( _link.text() == "Click here" ) ? _link.attr("href","").attr("href", hostname + "pricing-table/") : "" );
// ( ( _link.text() == "https://yomojo.com.au/home/pricingtable" ) ? _link.attr("href","").attr("href", hostname + "pricing-table/") : "" );
// ( ( _link.text() == "https://yomojo.com.au/home/pricingtable#appendix1" ) ? _link.attr("href","").attr("href", hostname + "pricing-table/#appendix1" ) : "" );
// break;
// }
// switch(_marker)
// {
// case "Log in":
// _link.attr("href","").attr("href", hostname + "login/");
// break;
// case "Activate SIM":
// _link.attr("href","").attr("href", hostname + "activation/");
// break;
// case "Unlimited":
// case "Mobile Plans":
// case "Customise your plan":
// if( _link.attr("href") != "javascript:void(0);" && _link.attr("href") != "javascript: void(0);" )
// _link.attr("href","").attr("href", hostname + "mobile-plans/unlimited-talk-text/");
// break;
// case "Mobile Broadband":
// case "Check our plans":
// if( _link.attr("href") != "javascript:void(0);" && _link.attr("href") != "javascript: void(0);" )
// _link.attr("href","").attr("href", hostname + "mobile-plans/mobile-broadband/");
// break;
// case "Coverage":
// _link.attr("href","").attr("href", hostname + "network-coverage/");
// break;
// case "FAQ":
// _link.attr("href","").attr("href", hostname + "faq/");
// break;
// case "Contact Us":
// case "Contact":
// _link.attr("href","").attr("href", hostname + "contact-us/");
// break;
// case "Terms and Conditions":
// case "Terms & Conditions":
// _link.attr("href","").attr("href", hostname + "terms/");
// break;
// case "Privacy Policy":
// _link.attr("href","").attr("href", hostname + "privacy-policy/");
// break;
// case "Critical Information Summaries":
// _link.attr("href","").attr("href", hostname + "cis/");
// break;
// case "Buy SIM":
// _link.attr("href","").attr("href", hostname + "signup/");
// break;
// case "Buy now":
// //_link.attr("href","").attr("href", hostname + "mobile-plans/unlimited-talk-text/");
// break;
// case "Create your own plan":
// var newlink = _link.attr("href").replace("home","mobile-plans");
// _link.attr("href","").attr("href",newlink);
// break;
// case "":
// if($(_link.html()).hasClass("logo-orange"))
// {
// _link.attr("href", hostname);
// }
// break;
// case "Personalised":
// if( _link.attr("href") != "javascript:void(0);" && _link.attr("href") != "javascript: void(0);" )
// _link.attr("href","").attr("href", hostname + "mobile-plans/personalised/");
// break;
// case "Sign up with Yomojo":
// _link.attr("href","").attr("href", hostname + "signup/");
// break;
// case "Log in to activate":
// _link.attr("href","").attr("href", hostname + "login/");
// break;
// case "SIGN UP TO ACTIVATE":
// _link.attr("href","").attr("href", hostname + "signup/retail/");
// break;
// case "Porting Terms & Conditions":
// _link.attr("href","").attr("href", hostname + "porting/");
// break;
// }
// if(_link.attr("id") == "pay"){
// _link.attr("href","").attr("href", hostname + "mobile-plans/pay-as-you-go/");
// }
// });
var hash = window.location.hash;
if(!Modernizr.touch)
{
var str = window.location.pathname;
var isAccount = str.indexOf("settings");
if(isAccount != -1){
$(window).on("load",function(){
$('html,body').stop().animate({
'scrollTop': $(this).offset().top + 60
}, 800, 'swing');
});
}
}
function footer()
{
var path = window.location.pathname.split("/");
if(path[path.length - 2] == "pay-as-you-go" || path[path.length - 2] == "faq" || path[path.length - 2] == "includedcountries")
{
var headermenu = $("header.menuplans").outerHeight(true);
var banner_personalised = $("section#banner_personalised,section#page-banner").outerHeight(true);
var pricing = $("section#pricing,section#faq").outerHeight(true);
var footer = $("footer.footer-pages").outerHeight(true);
console.log((banner_personalised + pricing + headermenu + footer) + "|" + ($(window).outerHeight(true) - (banner_personalised + pricing + headermenu + footer) ) + "|" + $(window).outerHeight(true));
if((banner_personalised + pricing + headermenu + footer) < $(window).outerHeight(true))
{
$("footer.footer-pages").css({
'position':'absolute',
'bottom' : '0',
'left' : '0'
});
}else{
$("footer.footer-pages").css({
'position':'static',
'bottom' : '0',
'left' : '0'
});
}
}
}
footer();
window.addEventListener('orientationchange',function(){
footer();
});
var ww = $(window).outerWidth(true);
$(window).on("resize",function(){
setTimeout(function(){
if(ww != $(window).outerWidth(true))
{
footer();
}
},300);
});
/** AWARD **/
function award()
{
$currentWindowHeight = screen.height;
if($(window).outerHeight(true) >= 799)
{
$(".pricing-cover").css('margin', 0);
if($currentWindowHeight > 1024)
{
/*$(".pricing-cover").css('margin', '90px 0 0'); */
$(".pricing-cover").css('margin', '30px 0 0');
}
$(".mbb2-boy, .mbb2-girl").css('bottom', "-110px");
$(".mbb2-slider").css('bottom', '-50px');
if(document.documentElement.clientHeight > 916)
{
$(".mbb2-boy, .mbb2-girl").css('bottom', "-90px");
$(".mbb2-slider").css('bottom', '-30px');
}
// if($currentWindowHeight - (125 + $("section#award").outerHeight(true)) < 695)
// {
// $(".mbb2-boy, .mbb2-girl, .mbb2-slider").css('bottom', -225);
// $(".pricing-cover").css('margin', 0);
// }
$(".carousel-inner .item.slide2,.carousel-inner .item.slide1,.carousel-inner .item.slide3,.carousel-inner .item.slide2 .sliders-wrapper,.carousel-inner .item.slide1 .sliders-wrapper,.carousel-inner .item.slide3 .sliders-wrapper").css('min-height', $(window).outerHeight(true) - (125 + $("section#award").outerHeight(true)));
}else{
$(".pricing-cover").css('margin', 0);
}
}
//award();
$(window).on("resize",function(){
//setTimeout(award,1000);
});
//CHANGE DISCOUNT PERCENTAGE WHEN FAMILY DROPDOWN VALUE CHANGES
$("#family-plan-dropdown").on("change",function(){
var percentage = parseFloat($(this).val()).toFixed(1);
var index = $("#family-plan-dropdown option:selected").attr('data-index');
var discount_el = $(".discount-perc span.perc > .figure");
discount_el.text(percentage);
var savings = [3.50,7.86,13.96,21.80,31.44];
$(".fam.fam-price span.actual-price").text("$" + savings[index].toFixed(2));
});
//SELECT INITIAL FAMILY DROPDOWN VALUE TO MAX
$("#family-plan-dropdown").val(10);