// JavaScript Document
function showReferForm(formLayer) {
var elements = document.getElementsByClassName('referForms');
for (var i = 0, length = elements.length; i < length; i++) {
elements[i].style.display = 'none';
}
document.getElementById(formLayer).style.display = "block";
}
function switchphoto(thisone,pic) {
var elements = document.getElementsByClassName('prodphoto');
for(var i = 0, length = elements.length; i < length; i++) {
elements[i].style.border = '0';
}
document.getElementById(thisone).style.border="2px solid #c00";
document.getElementById('bigProduct').innerHTML="";
}
function showForm(formLayer) {
var elements = document.getElementsByClassName('popLayers');
for (var i = 0, length = elements.length; i < length; i++) {
elements[i].style.display = 'none';
}
document.getElementById(formLayer).style.display = "block";
}
function showPic(formLayer) {
var elements = document.getElementsByClassName('container');
for (var i = 0, length = elements.length; i < length; i++) {
elements[i].style.display = 'none';
}
document.getElementById(formLayer).style.display = "block";
}
function formValidate(formName) {
if (formName == "referralForm2") {
var arr = document.getElementsByClassName('valFormP');
} else if (formName == "referralForm1") {
var arr = document.getElementsByClassName('valForm1');
} else {
var arr = document.getElementsByClassName('valForm');
}
var j = 0;
for (var i = 0; i < arr.length; i++) {
if (arr[i].value == '') {
j++;
}
}
if ((j != 0) || (grecaptcha.getResponse() == "")) {
alert("Please fill this form out completely.");
return false;
} else {
document.getElementById(formName).submit();
return true;
}
}
function signupFormValidate(formName) {
var arr = document.getElementsByClassName('valS');
var j = 0;
for (var i = 0; i < arr.length; i++) {
if (arr[i].value == '') {
j++;
}
var x = document.forms["signupForm"]["Email"].value;
var atpos = x.indexOf("@");
var dotpos = x.lastIndexOf(".");
if (atpos < 1 || dotpos < atpos + 2 || dotpos + 2 >= x.length) {
j = 2;
}
}
if (j == 0) {
document.getElementById(formName).submit();
return true;
} else {
alert("Not a valid e-mail address.");
return false;
}
}
function checkEmail(email) {
var str = new String(email);
var isOK = true;
rExp = /[!"£$%^&*()-+=<>,'#?|¬`/[]]/
if( rExp.test(str) )
isOK = false;
if( str.indexOf('.') == -1 || str.indexOf('@') == -1 )
isOK = false;
if( str.slice(str.lastIndexOf('.')+1,str.length).length < 2 )
isOK = false;
if( str.slice(0,str.indexOf('@')).length < 1 )
isOK = false;
if( str.slice(str.indexOf('@')+1,str.lastIndexOf('.')).length < 1 )
isOK = false;
if( !isOK )
alert( 'Invalid email address' );
return isOK;
}
function sendit() {
var preurl = "includes/checklogin.php?myusername=" + escape(document.submitform.myusername.value) + "&mypassword=" + escape(document.submitform.mypassword.value);
callAjax(preurl);
return false;
}
function loaderDisplayClose() {
document.getElementById('overlay').style.display="none";
var elements = document.getElementsByClassName('popLayers');
for(var i = 0, length = elements.length; i < length; i++) {
elements[i].style.display = 'none';
}
var elements = document.getElementsByClassName('bioFrame');
for(var i = 0, length = elements.length; i < length; i++) {
elements[i].style.display = 'none';
}
var elements = document.getElementsByClassName('container');
for(var i = 0, length = elements.length; i < length; i++) {
elements[i].style.display = 'none';
}
}
function loaderDisplay() {
if ($(window).width() > 568) {
document.getElementById('overlay').style.display="block";
} }
function displayBio(frameid) {
if ($(window).width() > 568) {
var arr = document.getElementsByClassName('bioFrame');
var j = 0;
for (var i = 0; i < arr.length; i++) {
arr[i].style.display = 'none';
}
document.getElementById(frameid).style.display = 'block';
}}
function closeAllBios() {
var arr = document.getElementsByClassName('bioFrame');
var j = 0;
for (var i = 0; i < arr.length; i++) {
arr[i].style.display = 'none';
}
}
// Converts a date into '12-Oct-1984' format
function getDateString(dt) {
return ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12'][dt.getMonth()] + '/' + dt.getDate() +
'/' + dt.getFullYear();
}
// Converts a date into 'July 2010' format
function getMonthYearString(dt) {
return ['January', 'February', 'March', 'April', 'May', 'June', 'July',
'August', 'September', 'October', 'November', 'December'
][dt.getMonth()] +
' ' + dt.getFullYear();
}
// This is the function called when the user clicks any button
function chooseDate(e) {
var targ; // Crossbrowser way to find the target (http://www.quirksmode.org/js/events_properties.html)
if (!e) var e = window.event;
if (e.target) targ = e.target;
else if (e.srcElement) targ = e.srcElement;
if (targ.nodeType == 3) targ = targ.parentNode; // defeat Safari bug
var div = targ.parentNode.parentNode.parentNode.parentNode.parentNode; // Find the div
var idOfTextbox = div.getAttribute('datepickertextbox'); // Get the textbox id which was saved in the div
var textbox = document.getElementById(idOfTextbox); // Find the textbox now
if (targ.value == '<' || targ.value == '>') { // Do they want the change the month?
createCalendar(div, new Date(targ.getAttribute('date')));
return;
}
textbox.value = targ.getAttribute('date'); // Set the selected date
div.parentNode.removeChild(div); // Remove the dropdown box now
}
// Parse a date in d-MMM-yyyy format
function parseMyDate(d) {
if (d == "") return new Date('NotADate'); // For Safari
var a = d.split('-');
if (a.length != 3) return new Date(d); // Missing 2 dashes
var m = -1; // Now find the month
if (a[1] == 'Jan') m = 0;
if (a[1] == 'Feb') m = 1;
if (a[1] == 'Mar') m = 2;
if (a[1] == 'Apr') m = 3;
if (a[1] == 'May') m = 4;
if (a[1] == 'Jun') m = 5;
if (a[1] == 'Jul') m = 6;
if (a[1] == 'Aug') m = 7;
if (a[1] == 'Sep') m = 8;
if (a[1] == 'Oct') m = 9;
if (a[1] == 'Nov') m = 10;
if (a[1] == 'Dec') m = 11;
if (m < 0) return new Date(d); // Couldn't find the month
return new Date(a[2], m, a[0], 0, 0, 0, 0);
}
// This creates the calendar for a given month
function createCalendar(div, month) {
var idOfTextbox = div.getAttribute('datepickertextbox'); // Get the textbox id which was saved in the div
var textbox = document.getElementById(idOfTextbox); // Find the textbox now
var tbl = document.createElement('table');
var topRow = tbl.insertRow(-1);
var td = topRow.insertCell(-1);
var lastMonthBn = document.createElement('input');
lastMonthBn.type = 'button'; // Have to immediately set the type due to IE
td.appendChild(lastMonthBn);
lastMonthBn.value = '<';
lastMonthBn.onclick = chooseDate;
lastMonthBn.setAttribute('date', new Date(month.getFullYear(), month.getMonth() - 1, 1, 0, 0, 0, 0).toString());
var td = topRow.insertCell(-1);
td.colSpan = 5;
var mon = document.createElement('input');
mon.type = 'text';
td.appendChild(mon);
mon.value = getMonthYearString(month);
mon.size = 15;
mon.disabled = 'disabled';
var td = topRow.insertCell(-1);
var nextMonthBn = document.createElement('input');
nextMonthBn.type = 'button';
td.appendChild(nextMonthBn);
nextMonthBn.value = '>';
nextMonthBn.onclick = chooseDate;
nextMonthBn.setAttribute('date', new Date(month.getFullYear(), month.getMonth() + 1, 1, 0, 0, 0, 0).toString());
var daysRow = tbl.insertRow(-1);
daysRow.insertCell(-1).innerHTML = "Mon";
daysRow.insertCell(-1).innerHTML = "Tue";
daysRow.insertCell(-1).innerHTML = "Wed";
daysRow.insertCell(-1).innerHTML = "Thu";
daysRow.insertCell(-1).innerHTML = "Fri";
daysRow.insertCell(-1).innerHTML = "Sat";
daysRow.insertCell(-1).innerHTML = "Sun";
// Make the calendar
var selected = parseMyDate(textbox.value); // Try parsing the date
var today = new Date();
date = new Date(month.getFullYear(), month.getMonth(), 1, 0, 0, 0, 0); // Starting at the 1st of the month
var extras = (date.getDay() + 6) % 7; // How many days of the last month do we need to include?
date.setDate(date.getDate() - extras); // Skip back to the previous monday
while (1) { // Loop for each week
var tr = tbl.insertRow(-1);
for (i = 0; i < 7; i++) { // Loop each day of this week
var td = tr.insertCell(-1);
var inp = document.createElement('input');
inp.type = 'button';
td.appendChild(inp);
inp.value = date.getDate();
inp.onclick = chooseDate;
inp.setAttribute('date', getDateString(date));
if (date.getMonth() != month.getMonth()) {
if (inp.className) inp.className += ' ';
inp.className += 'othermonth';
}
if (date.getDate() == today.getDate() && date.getMonth() == today.getMonth() && date.getFullYear() == today.getFullYear()) {
if (inp.className) inp.className += ' ';
inp.className += 'today';
}
if (!isNaN(selected) && date.getDate() == selected.getDate() && date.getMonth() == selected.getMonth() && date.getFullYear() == selected.getFullYear()) {
if (inp.className) inp.className += ' ';
inp.className += 'selected';
}
date.setDate(date.getDate() + 1); // Increment a day
}
// We are done if we've moved on to the next month
if (date.getMonth() != month.getMonth()) {
break;
}
}
// At the end, we do a quick insert of the newly made table, hopefully to remove any chance of screen flicker
if (div.hasChildNodes()) { // For flicking between months
div.replaceChild(tbl, div.childNodes[0]);
} else { // For creating the calendar when they first click the icon
div.appendChild(tbl);
}
}
// This is called when they click the icon next to the date inputbox
function showDatePicker(idOfTextbox) {
var textbox = document.getElementById(idOfTextbox);
// See if the date picker is already there, if so, remove it
x = textbox.parentNode.getElementsByTagName('div');
for (i = 0; i < x.length; i++) {
if (x[i].getAttribute('class') == 'datepickerdropdown') {
textbox.parentNode.removeChild(x[i]);
return false;
}
}
// Grab the date, or use the current date if not valid
var date = parseMyDate(textbox.value);
if (isNaN(date)) date = new Date();
// Create the box
var div = document.createElement('div');
div.className = 'datepickerdropdown';
div.setAttribute('datepickertextbox', idOfTextbox); // Remember the textbox id in the div
createCalendar(div, date); // Create the calendar
insertAfter(div, textbox); // Add the box to screen just after the textbox
return false;
}
// Adds an item after an existing one
function insertAfter(newItem, existingItem) {
if (existingItem.nextSibling) { // Find the next sibling, and add newItem before it
existingItem.parentNode.insertBefore(newItem, existingItem.nextSibling);
} else { // In case the existingItem has no sibling after itself, append it
existingItem.parentNode.appendChild(newItem);
}
}
// This is called when the page loads, it searches for inputs where the class is 'datepicker'
function datePickerInit() {
// Search for elements by class
var allElements = document.getElementsByTagName("*");
for (i = 0; i < allElements.length; i++) {
var className = allElements[i].className;
if (className == 'datepicker' || className.indexOf('datepicker ') != -1 || className.indexOf(' datepicker') != -1) {
// Found one! Now lets add a datepicker next to it
var a = document.createElement('a');
a.href = '#';
a.className = "datepickershow"
a.setAttribute('onclick', 'return showDatePicker("' + allElements[i].id + '")');
var img = document.createElement('img');
img.src = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAAABGdBTUEAAK/INwWK6QAAABh0RVh0U29mdHdhcmUAUGFpbnQuTkVUIHYzLjM2qefiJQAAAdtJREFUOE+Vj+9PUnEUxvPvar3xja96Q1hGEKG0ubZqbfHCNqIVA4eYLAwFp0LYD4iIJEdeRGGZwDAEcUOn9oNIvPcGgjBQfHE69/YFihe1zs59du7d83nOuR0AcOq/CgEqWbaHDqaD+clF1rLAmija6MsZ5vb0s9nB1xm168s9x67y6Y7q2TaXjo8tVKjUTv7Zt61pAkwt/UA3zFwFuxysV2BKAuYeMAnBcBaGukDdCaozaLg5sUGAiQDLA3IIDIBfAfO34N118PaDRwYvRfBcCMrTaLg2liTAOEW3NjzpBZsMpqUwKQaLCMYvwGMhjArQIDfGCTDqy3EAX47lfVTnCo3qCnOzJ8IpW6pJR2IEGHn7/bBaR5MLO8y8CtPuKO2J0nMfGdKr+5uZ4kVdhAD6N99K1bo7ynB5vHpj3AZ0NxWBbs0KAbTur8VKfTbGeFcbkc1sfnBHuA1CzTIB7js/H5SPffFW3q9sau2PDdLhxkl3X+wiQCVYf4Jt3h1Itmb8iBvEusZJd2a2CuXjxXUWU5dSnAZ5/b0QkOobgMKWzh8eMcXaXr6aYSqfcuXtbAkdbS3RfSD/MGDfvGFO9ZuSfY/ilx/GLumi57Vhgfp9W597ECJA2/a/v/4ENLpYKsDo3kgAAAAASUVORK5CYII=';
img.title = 'Show calendar';
a.appendChild(img);
insertAfter(a, allElements[i]);
}
}
}
// Hook myself into the page load event
if (window.addEventListener) { // W3C standard
window.addEventListener('load', datePickerInit, false);
} else if (window.attachEvent) { // Microsoft
window.attachEvent('onload', datePickerInit);
}
(function($) {
$.fn.easySlider = function(options) {
// default configuration properties
var defaults = {
prevId: 'prevBtn', // id of the element to apply prev rules to
nextId: 'nextBtn', // id of the element to apply next rules to
prevText: 'Previous', // text for autogenerated prev link
nextText: 'Next', // text for autogenerated next link
autogeneratePagination: false, // will automatically generate pagination links
orientation: '', // 'vertical', 'fade', or anything else will assume horizontal
speed: 1000, // duration of a transition
autoplayDuration: 10000, // auto-play if non-zero, this is the time between transitions
restartDuration: 2500, // time to restart autoplay after a user interupts and autoplay
loop: false, // loop around the content
hoverPause: 5000, // when hovering, the time between transitions
hover: false, // on hover instead of onclick
easing: null, // jQuery animation settings 'linear' or 'swing' (default)
pauseable: false, // pause autoplay when hovering the image
pauseButtons: false, // hovering over the cuttons will pause as well
beforeTransition: null, // callback before transitioning
afterTransition: null // callback after transitioning
};
var options = $.extend(defaults, options);
return this.each(function() {
// Setup Measurements and Options
var obj = $(this),
totalSlides = $("li", obj).length,
slideWidth = obj.width(),
slideHeight = obj.height(),
lastSlide = totalSlides - 1,
current = 0;
// States
var vertical = (options.orientation == 'vertical'),
fade = (options.orientation == 'fade'),
horizontal = (!vertical && !fade),
autogen = options.autogeneratePagination,
pauseable = options.pauseable,
loop = options.loop,
speed = options.speed,
easing = options.easing,
hover = options.hover,
hoverPause = options.hoverPause,
buttonsPause = options.pauseButtons,
restartDuration = options.restartDuration,
autoplayDuration = Math.max(options.autoplayDuration, 25) + speed,
autoplay = (options.autoplayDuration > 0),
beforeTransition = options.beforeTransition,
afterTransition = options.afterTransition;
interval = null,
restart = null;
// Autogenerate Pagination
if (autogen) {
$(obj).after('' + options.prevText + ' ' +
'' + options.nextText + '');
}
// Important Elements
var $ul = $("ul", obj),
$next = $("#" + options.nextId),
$prev = $("#" + options.prevId);
// Loop - Duplicate the First Slide onto the end
if (loop) {
$ul.append($("li:first", obj).clone());
totalSlides += 1;
lastSlide += 1;
}
// Horizontal - Make them float left and set the width of the ul (for all slides)
if (horizontal) {
$("li", obj).css('float', 'left');
$ul.css('width', totalSlides * slideWidth);
}
// Fade - Hide all but the first slide so they can fadeIn from nothing
if (fade) {
$ul.find("li:not(:first)").hide();
}
// Reusable Closure to pause the autoplay timer
var pauseFunc = function() {
clearInterval(interval);
clearTimeout(restart);
}
// Reusable Closure to restart the autoplay timers using the restartDuration
var restartFunc = function() {
restart = setTimeout(function() {
interval = setInterval(auto, autoplayDuration);
}, restartDuration);
};
// Pauseable (should be autoplay only, but would have no effect otherwise)
// On Hover: cancel the autoplay timers
// On Leave: restart the autoplay timers
if (pauseable && autoplay) {
$(obj).hover(pauseFunc, restartFunc);
if (buttonsPause) {
$next.hover(pauseFunc, restartFunc);
$prev.hover(pauseFunc, restartFunc);
}
}
// Add Actions to Next and Prev Buttons
// If Not Hover Mode made it click(), if it is Hover Mode, make it hover()
// When in autoplay mode make next/prev reset the autoplay timers
if (!hover) {
$next.click(function() {
if (autoplay) {
pauseFunc();
if (!buttonsPause) {
restartFunc();
}
};
animate("next");
});
$prev.click(function() {
if (autoplay) {
pauseFunc();
if (!buttonsPause) {
restartFunc();
}
};
animate("prev");
});
} else {
var hoverNext = false,
hoverPrev = false,
isAnimating = false;
$next.hover(
function() {
var tfunc = arguments.callee;
hoverNext = true;
if (!isAnimating) {
isAnimating = true;
animate("next", function() {
isAnimating = false;
if (hoverNext) {
tfunc();
}
});
}
},
function() {
hoverNext = false;
}
);
$prev.hover(
function() {
var tfunc = arguments.callee;
hoverPrev = true;
if (!isAnimating) {
isAnimating = true;
animate("prev", function() {
isAnimating = false;
if (hoverPrev) {
tfunc();
}
});
}
},
function() {
hoverPrev = false;
}
);
}
//
// Enclosed Slide Animation
//
// This handles all of the sliding/faiding animation
// @param dir the direction "next" or "prev"
// @param cb the callback function
//
function animate(dir, cb) {
// Before Transition, Guarantee
if (beforeTransition) {
beforeTransition(current, $ul.find('li:eq(' + current + ')'), $ul);
}
// After Transition, Guarantee
// Setup the next have
// NOTE: That current will be the new value when this is called
// due to it being a closure!
var newcb = function() {
if (cb != null) {
(hoverPause == 0) ? cb(): setTimeout(cb, hoverPause);
}
if (afterTransition) {
afterTransition(current, $ul.find('li:eq(' + current + ')'), $ul);
}
}
// cur, nex, and update "current"
// cur is the old current slide, the slide we are currently on
// nex is the new current slide, the slide we are transitioning too
// current is a global value that gets updated right here
var cur = current;
if (loop) {
if (dir == 'next') {
current = (current == lastSlide) ? 1 : current + 1;
} else {
current = (current == 0) ? lastSlide - 1 : current - 1;
}
} else {
if (dir == "next") {
current = (current >= lastSlide) ? lastSlide : current + 1;
} else {
current = (current <= 0) ? 0 : current - 1;
}
}
var nex = current;
// Special Case for looping
// If at the end and going forward, instantaneous jump to the first slide
// If at the start and going backward, instantaneous jump to the last slide
// NOTE: The instantaneous jump is an animate() so jQuery handles it in tune
// with the rest of the animations, and is -1 (not 0) time so its instant.
if (loop) {
if ((dir == "next") && (cur == lastSlide)) {
(vertical) ?
$ul.animate({
marginTop: 0
}, -1):
$ul.animate({
marginLeft: 0
}, -1);
} else if ((dir == "prev") && (cur == 0)) {
(vertical) ?
$ul.animate({
marginTop: (totalSlides - 1) * slideHeight * -1
}, -1):
$ul.animate({
marginLeft: (totalSlides - 1) * slideWidth * -1
}, -1);
}
}
// Dispatch jQuery Animation for the transition
// Slide horizontally, vertically, or fade
if (horizontal) {
$ul.animate({
marginLeft: (nex * slideWidth * -1)
}, speed, easing, newcb);
} else if (vertical) {
$ul.animate({
marginTop: (nex * slideHeight * -1)
}, speed, easing, newcb);
} else {
var curli = 'li:eq(' + cur + ')';
var nexli = 'li:eq(' + nex + ')';
$ul.find(curli).fadeOut("slow", function() {
$ul.find(nexli).fadeIn("slow", newcb);
});
}
// Correctly show the Next/Prev links
// When looping they always show, so we can ignore that
// If at the end, hide the next link
// If at the start, hide the previous link
// Any other case we can show both links
if (!loop) {
if (nex <= 0) {
$prev.fadeOut();
} else if (nex >= lastSlide) {
$next.fadeOut();
} else {
$next.fadeIn();
$prev.fadeIn();
}
}
};
//
// Autoplay
//
// Note that autoplayDuration already has the transitionDuration
// added to it (to prevent doing the addition over and over).
// However that means that the first invokation would take
// autoplayDuration+transitionDuration. We remove that extra
// wait by first doing a single setTimeout with the correct
// time, followed by the correct setInterval.
//
if (autoplay) {
var auto = function() {
animate('next');
if (!loop && current >= lastSlide) {
clearInterval(interval);
}
}
restart = setTimeout(function() {
auto();
interval = setInterval(auto, autoplayDuration);
}, autoplayDuration - speed);
}
// Initially Hide both buttons
$next.hide();
$prev.hide();
// Finally, Display the Next Link if more then one slide
if (totalSlides > 1) {
$next.fadeIn();
if (loop) {
$prev.fadeIn();
}
}
});
};
})(jQuery);
function hideIt() {
var elements = new Array();
if (otbox.checked) {
elements = document.getElementsByClassName('ot');
i = elements.length;
while (i--) {
elements[i].style.display = "block";
}
} else {
elements = document.getElementsByClassName('ot');
i = elements.length;
while (i--) {
elements[i].style.display = "none";
}
}
if (ptbox.checked) {
elements = document.getElementsByClassName('pt');
i = elements.length;
while (i--) {
elements[i].style.display = "block";
}
} else {
elements = document.getElementsByClassName('pt');
i = elements.length;
while (i--) {
elements[i].style.display = "none";
}
}
if (speechbox.checked) {
elements = document.getElementsByClassName('speech');
i = elements.length;
while (i--) {
elements[i].style.display = "block";
}
} else {
elements = document.getElementsByClassName('speech');
i = elements.length;
while (i--) {
elements[i].style.display = "none";
}
}
if (age_birthbox.checked) {
elements = document.getElementsByClassName('age_birth');
i = elements.length;
while (i--) {
elements[i].style.display = "block";
}
} else {
elements = document.getElementsByClassName('age_birth');
i = elements.length;
while (i--) {
elements[i].style.display = "none";
}
}
if (age_threebox.checked) {
elements = document.getElementsByClassName('age_three');
i = elements.length;
while (i--) {
elements[i].style.display = "block";
}
} else {
elements = document.getElementsByClassName('age_three');
i = elements.length;
while (i--) {
elements[i].style.display = "none";
}
}
if (age_sevenbox.checked) {
elements = document.getElementsByClassName('age_seven');
i = elements.length;
while (i--) {
elements[i].style.display = "block";
}
} else {
elements = document.getElementsByClassName('age_seven');
i = elements.length;
while (i--) {
elements[i].style.display = "none";
}
}
}
$(function() {
$('#contact').on('click', function() {
if($(this).hasClass('selected')) {
deselect($(this));
} else {
$(this).addClass('selected');
$('.pop').slideFadeToggle();
}
return false;
});
$('.close').on('click', function() {
deselect($('#contact'));
loaderDisplayClose();
});
});