var galleryItem;
var backoffice = false
$(document).ready(function()
{
if ($('div.controlBorder').length > 0)
{
backoffice = true;
}
// Add css to checkoutsteps
$('div#CheckoutSteps').addClass('block round noPadding');
$('div#CheckoutSteps li a, div#CheckoutSteps li span').append('');
$('div#CheckoutSteps li').hover(function(){$(this).addClass('hover')}, function(){$(this).removeClass('hover')});
var test = $('div#CheckoutSteps li').length;
$('div#CheckoutSteps li').each(function(index)
{
$(this).css('z-index', test - index);
});
// Add link Glasses to menu
var acc = $('div#Categories a[href="http://www.lensexpress.nl/accessoires"]').parent();
$('
Brillen').insertAfter(acc);
//Fixes for module
//$('div#Register div.Country, div#Register div.dateOfBirth').addClass('customForm_Row');
//$('div.LoginUserControl').prepend('');
//$('div#Column2 div#Register, div#Column2 div.LoginUserControl, div#Column2 div#PaymentMethods, div#Column2 div#contentBox, div#Column2 div.contentBox').addClass('block round');
$('div#Column2 div#Register, div#Column2 div.LoginUserControl, div#Column2 div#contentBox, div#Column2 div.contentBox').addClass('block round');
//$('div#contentBox div.title').addClass('header');
$('div#contentBox h1').wrap('');
$('div#Register, div#NewAddress, div#PaymentMethods, div#Register div.deliveryAddress').append('
');
$('div#Register div.Country div.error span').css('display', 'none');
$('div#Register div.selectOtherDeliveryAddress, div#Register div.password, div#Register div.repeatPassword, div#Register div.nationalIdentificationNumber').addClass('customForm_FullRow');
$('div#Column2 div.CheckboxInsurance, div#Register div.selectOtherDeliveryAddress').addClass('customForm_RowCheck');
$('div#contentBox div.addressContainer div.firstline').addClass('addressLabel');
$('div#Column2 div#contentBox div.prevStep, div#Column2 div#contentBox div.nextStep, div#PaymentMethods div.prevStep, div#PaymentMethods div.nextStep').addClass('customForm_Button');
$('input[type=text]').addClass('textbox');
$('div.specialButton a').prepend(' ');
$('div.customForm').each(function()
{
//$(this).find('div.customForm_Row:even').addClass('even');
//$('div#Register div.phoneNr').addClass('odd');
//$(this).find('div.customForm_Row:odd').addClass('odd');
});
//Breadcrumbs fix Home
$('div#Breadcrumbs a:first').attr('href', subsiteUrl);
$('div#Breadcrumbs a:first').text('Home');
//Error messages fix
$('div.error span').not('div.customForm_Error span').text('');
//End Fixes
//First last
$('ul').each(function()
{
$(this).find('li:first').addClass('first');
$(this).find('li:last').addClass('last');
});
//Rounded blocks
$('div.round').each(function()
{
if ($(this).find('div.contents').length > 0)
{
$(this).find('div.contents').children(':first').unwrap();
}
$(this).wrapInner('');
//Check for headers
var header = $(this).find('div.header');
if (header.length > 0)
{
var headerContent = header.html();
header.remove();
$(this).find('div.contents:first').before('');
}
$(this).prepend('
');
$(this).prepend('
');
$(this).prepend('
');
$(this).prepend('
');
$(this).prepend('
');
$(this).append('
');
});
$('div.roundTop').each(function()
{
$(this).wrapInner('');
$(this).prepend('
');
$(this).prepend('
');
});
//Brands
$('div.block div.brands a').each(function()
{
$(this).mouseenter(function()
{
var image = $(this).find('img');
image.stop();
image.animate({ left: -110}, 400);
});
$(this).mouseleave(function()
{
var image = $(this).find('img');
image.stop();
image.animate({ left: 0}, 400);
});
});
//Gallery
if (backoffice == false)
{
cmsRewrite();
}
var items = $('div#Gallery div#ScrollArea ul li');
items.click(function()
{
var location = $(this).find('a:first').attr('href');
if (location)
{
window.location = location;
}
});
galleryItem = 106;
$('div#Gallery div#ScrollArea ul').attr('moveTo', 0);
$('div#Gallery div#ScrollArea ul').css('width', galleryItem * items.length);
checkGallery();
$('div#Gallery div.scrollLeft').click(function()
{
scrollGallery(1);
return false;
});
$('div#Gallery div.scrollRight').click(function()
{
scrollGallery(-1);
return false;
});
//Blocks
var blocks = $('div.block');
blocks.each(function(index)
{
$(this).css('z-index', 20 + (blocks.length - index));
});
//Checkboxes & Pricing
$('div#Products div.product').each(function()
{
$(this).find('div.text div.details div.eye input[type=checkbox]').ezMark();
$(this).find('div.text div.details div.eye input.ez-hide').click(function(event)
{
var checked = $(this).parents('div.details').find('input.ez-hide:checked').length;
if (checked == 0)
{
alert('U dient tenminste 1 type (links/rechts) te selecteren');
$(this).parent().addClass('ez-checked'); //IE LOL Fix
return false;
}
else
{
amountToPrice($(this).parents('div.product'));
}
});
function amountToPrice(product)
{
if (product.find('div.imageAndPrice div.price input').length < 1 || product.find('div.details input.ez-hide:checked').length < 1 || product.find('div.imageAndPrice div.price span').length < 1)
{
return false;
}
var row = product.find('div.details div.row:first');
if (row.find('select.amount').length > 0)
{
var index = row.find('select.amount :selected').index();
if (index < 0)
{
index = 0;
}
}
else
{
var index = 0;
}
var price = product.find('div.imageAndPrice div.price input').val();
price = price.split(';');
var checked = product.find('div.details input.ez-hide:checked').length;
var span = product.find('div.imageAndPrice div.price span');
var splitData = price[index].split('|');
if (product.find('div.price div.month').length > 0)
{
var amount = (parseFloat(splitData[1]) * checked).toFixed(2).split('.').join(',');
var monthly = (parseFloat(amount.replace(',', '.')) / parseFloat(splitData[0])).toFixed(2).split('.').join(',');
var newPrice = '€ ' + amount + '' + '€ ' + monthly + ' p/m';
}
else if (product.find('div.price div.unit').length > 0)
{
var amount = (parseFloat(splitData[1])).toFixed(2).split('.').join(',');
var monthly = (parseFloat(splitData[1]) / parseFloat(splitData[0])).toFixed(2).split('.').join(',');
var newPrice = '€ ' + amount + '' + '€ ' + monthly + ' p/s';
}
span.html(newPrice);
Cufon.replace(span);
}
$(this).find('div.details select.amount').change(function()
{
amountToPrice($(this).parents('div.product'));
});
/*if ($(this).find('div.details select.amount').length > 0)
{
amountToPrice($(this));
}*/
amountToPrice($(this));
});
if ($('div#Products div.order div.text div.details div.eye').length > 0)
{
$('div#Products div.order div.text div.details div.eye div.input div.column:nth-child(1)').addClass('noClear');
$('div#Products div.order div.text div.details div.eye div.input div.column:nth-child(2n)').addClass('oddColumn');
}
//Regular font
Cufon.replace('div#Menu ul li a', {hover: true});
Cufon.replace('div#Content h1, div#Content h2, div#Content h3:not(div.elFBWebshopNav h3), div#Footer h2');
Cufon.replace('div#Content div#MoreShopping div.text');
//Bold font
Cufon.replace('div#Content div#Categories ul li a', {hover: true});
Cufon.replace('div#Content div#Products div.price');
$('div#SiteContainer').show();
if ($('div.splitIn2 div.block').length > 0)
{
$('div.splitIn2').each(function()
{
resizeBlocks($(this));
});
}
//shop voucher error fix (adding display:none; to spans with visibility:hidden)
$("div#PaymentMethods div.paymentMethod div.Voucher div.details div.customForm_Error span").each(function()
{
if ($(this).css('visibility') == 'hidden')
{
$(this).hide();
}
});
});
function scrollGallery(direction)
{
var gallery = $('div#Gallery div#ScrollArea ul');
gallery.attr('moveTo', parseInt(gallery.attr('moveTo')) + (direction * galleryItem));
gallery.stop();
gallery.animate({left: gallery.attr('moveTo') }, 400);
checkGallery();
}
function checkGallery()
{
var gallery = $('div#Gallery div#ScrollArea ul');
if (gallery.attr('moveTo') == 0)
{
$('div#Gallery div.scrollLeft').hide();
}
else
{
$('div#Gallery div.scrollLeft').show();
}
var correct = parseInt(gallery.attr('moveTo')) + parseInt(gallery.css('width'));
if (correct - galleryItem < parseInt(gallery.parent().css('width')))
{
$('div#Gallery div.scrollRight').hide();
}
else
{
$('div#Gallery div.scrollRight').show();
}
}
function cmsRewrite()
{
var html = '';
var items = $('div#Gallery div#ScrollArea a');
items.each(function()
{
var image = $(this).find('img');
html += '';
html += '
';
html += '';
html += '
';
html += '';
html += ' + ') | ';
html += '
';
html += '
';
html += '
';
html += '' + image.attr('alt') + '
';
html += '' + image.attr('longdesc') + '
';
html += 'Link';
html += '';
});
if (html)
{
$('div#Gallery div#ScrollArea').html('');
}
}
function resizeBlocks(target)
{
var newHeight = 0;
target.find('div.block div.contents').each(function()
{
var height = $(this).height();
if (height > newHeight)
{
newHeight = $(this).height();
}
});
target.find('div.block div.contents').height(newHeight);
}