
wffBasket = { updatingPostcode: false, formWaiting: null };
function basketPost(formData, productTitle, prefix, productId, postQuantity, item, image) {
this.formData = formData;
this.productTitle = productTitle;
this.prefix = prefix;
this.productId = productId;
this.postQuantity = postQuantity;
this.item = item;
this.image = image;
var me = this;
this.submit = function() {
jQuery.post('/basket/add', this.formData, function(data) {
jQuery('#basketCount').text(data.intProdCount + ' item' + (data.intProdCount != 1 ? 's' : ''));
jQuery('#basketPrice').text(data.mnyTotal);
if (data.strLineName.length > 0) me.productTitle = data.strLineName;
var bsktText = 'your basket has been updated.<br/><strong>' + data.intLineQty + '</strong>' + (data.intLineQty == 1 ? ' is ' : ' are ') + 'now in your basket';
if (data.intLineQty == '0' && postQuantity != '0') {
if (me.productTitle == undefined) {
me.productTitle = 'Sorry, the item couldn\'t be found';
bsktText = '';
}
else {
bsktText = 'couldn\'t be added to your basket';
}
}
else if (data.intLineQty == '0') {
bsktText = 'have all been removed from your basket';
}
queueBasketMessage(me.productTitle, data.mnyLineTotal, bsktText, false, me.image);
this.item = me.item.add(jQuery('.' + me.prefix + '-' + me.productId));
this.item.find('input[type=submit]').val(data.intLineQty == 0 ? 'Add to basket' : 'Add another');
this.item.find('input[name=qty][type=hidden]').val(data.intLineQty + 1); //hidden qty fields for add-another
this.item.find('.basketCount').text(data.intLineQty + ' in basket');
jQuery('#warningMessage ul li:not(.minOrderAmtWarning)').remove();
jQuery('.minOrderAmtWarning').hide();
if (data.strError != '') {
jQuery('#warningMessage p').html(data.strError);
jQuery('#warningMessage').show();
jQuery('.checkoutColumn .submitRow a.popuptrigger').removeClass('popuptrigger');
}
else if (jQuery('.minOrderAmtWarning').length > 0 && convertToNumber(data.mnyTotal) < convertToNumber(data.mnyMinOrderValue)) {
jQuery('.minOrderAmtWarning').show();
jQuery('#warningMessage:has(.minOrderAmtWarning)').show();
jQuery('.checkoutColumn .submitRow a.popuptrigger').removeClass('popuptrigger');
}
else {
jQuery('#warningMessage').hide();
jQuery('.checkoutColumn .submitRow a.popuptrigger').addClass('popuptrigger');
}
if (data.intLineQty == 0) {
jQuery('.' + me.prefix + '-' + me.productId).removeClass('productListingInBasket');
}
else {
jQuery('.' + me.prefix + '-' + me.productId).addClass('productListingInBasket');
}
}, 'json');
}
}
function basketInit(s) {
s = s == undefined ? '.productForm' : s;
jQuery(s).unbind('submit').submit(function() {
if (wffBasket.updatingPostcode)
return false;
if (!headscapeDOM.getSubCookie("WFF", "F")) {
wffBasket.formWaiting = jQuery(this).attr('id');
var basket = jQuery(this).find('input[name=pid],input[name=mid],input[name=qty]').serialize();
clickFire('/franchise/change?a=addproduct', function(f) {
f.find('form').attr('action', '/basket/add?' + basket);
});
}
else {
var p = new basketPost();
p.item = jQuery(this).parents('li,.prodDetails_intro,.mealBox,tr').eq(0);
var fImg = p.item.find('img:first');
p.image = fImg.clone();
if (p.image.attr('src') != undefined)
p.image.attr('src', p.image.attr('src').replace(/&t=[0-9]+x[0-9]+$/, '&t=222x222'));
p.image.appendTo('#tools')
.removeClass('prodImg')
.css({ left: (fImg.offset().left - jQuery('#tools').offset().left) - p.image.width(),
top: (fImg.offset().top - jQuery('#tools').offset().top),
position: 'absolute',
width: '222px',
height: '222px'
})
.animate({ left: 20, top: 150, opacity: 0, width: 10, height: 10 }, 800, function() { jQuery(this).remove(); });
p.formData = jQuery(this).serialize();
p.prefix = (p.item.find('input[name=pid]').length > 0) ? 'pid' : 'mid';
p.productId = p.item.find('input[name=' + p.prefix + ']').val();
p.postQuantity = p.item.find('input[name=qty]').val() * 1;
if (p.postQuantity > 0) p.item.find('input[type=hidden][name=qty]').val(p.postQuantity + 1); //increment pre-emptive of multiple clicks
p.submit();
}
return false;
});
if (wffBasket.formWaiting != null) {
if (jQuery('#' + wffBasket.formWaiting).length == 0) {
queueBasketMessage('', '', 'Sorry, the product you tried to add is unavailable for this franchise.', false, null)
}
else {
jQuery('#' + wffBasket.formWaiting).submit();
}
wffBasket.formWaiting = null;
}
jQuery('.basketForm').submit(function() {
jQuery.post('?request=partial', jQuery(this).serialize(), function(data) {
for (line in data.items) {
if (line.quantity == 0) {
jQuery('tr#basketLine' + data.items[line].id).fadeOut();
}
else {
var row = jQuery('tr#basketLine' + data.items[line].id);
if (jQuery.trim(row.find('.lineTotal').text()) != jQuery.trim(data.items[line].subtotal)) {
row.find('input.quantity').val(data.items[line].quantity).end()
.find('.lineTotal').text(data.items[line].subtotal).flash().end();
}
}
}
jQuery('.basketItems tr:has(input.quantity[value=0])').fadeOut();
if (data.items.length == 0) {
jQuery('.basketItems th').hide();
jQuery('tr.emptyBasket').show();
jQuery('.checkoutButton').css({ visibility: 'hidden' });
}
jQuery('.basketTotalPrice').text(data.total).flash();
}, 'json');
return false;
}).find('input.quantity').bind('blur', function() {
var qty = jQuery(this).val();
if (qty=='' || isNaN(qty)) jQuery(this).val('0');
jQuery(this).parents('form').submit();
}).end().find('input.remove').bind('click', function() {
jQuery(this).parents('tr').find('input.quantity').val('0').parents('form').submit();
return false;
});
}
function queueBasketMessage(product, price, text, temp, img) {
if (product == undefined) product = '';
if (jQuery('#toolsOuterContainer').css('position') == 'static') return false;
if (temp && jQuery('#basketLatest').queue().length > 0) return; // ignore temp messages if we have a current one displaying
jQuery('#tools').addClass('active');
jQuery('#toolsContainer').animate({ backgroundColor: '#fff469' }, 500)
.animate({ backgroundColor: '#fff469' }, 1000)
.animate({ backgroundColor: '#eeeeee' }, 500);
jQuery('#toolsAdded').queue(function() { jQuery(this).find('.mealName').text(product); $(this).dequeue(); })
.queue(function() { jQuery(this).find('.mealPrice').text((+price > 0) ? ' (£' + price + ')' : ''); $(this).dequeue(); })
.queue(function() { jQuery(this).find('.addedConfirm').html(text); $(this).dequeue(); })
.queue(function() { jQuery(this).find('dt').html(img != null ? img.clone().css({ position: 'static', left: 0, top: 0, opacity: 1, width: 70, height: 70 }).addClass('toolsAddedImg') : ''); $(this).dequeue(); })
.slideDown(250)
.animate({ opacity: '1' }, 1000)
.slideUp(250, function() { jQuery('#tools').removeClass('active'); });
}
jQuery.fn.extend({
flash: function() {
return this.each(function() {
jQuery(this).css({ backgroundColor: '#F4E400' }).animate({ backgroundColor: '#ffffff' }, 1000);
});
}
});
jQuery(function() {
jQuery('.password dt a').click(function() {
var fld = jQuery(this).parents('dl').find('input');
if (fld.attr('type') == 'text') {
fld.after('<input type="password" name="' + fld.attr('name') + '" value="' + fld.val() + '" class="field" />').remove();
jQuery(this).text('Show my password');
}
else {
fld.after('<input type="text" name="' + fld.attr('name') + '" value="' + fld.val() + '" class="field" />').remove();
jQuery(this).text('Hide my password');
}
bindValidationRules(jQuery(this).parents('dl'));
return false;
});
jQuery('.haveDeliveryDates').click(function() {
clickFire('/checkout_3_date.asp', function(p) {
p.find('#deliveryDateList .more').hide();
p.find('.moreDates').click(function() {
jQuery('#deliveryDateList .more').show();
jQuery(this).hide();
return false;
});
});
return false;
});
jQuery('#cBillingAddress').click(function() {
if (jQuery(this).filter(':checked').length > 0) {
jQuery('#co_billing').slideUp('slow');
} else {
jQuery('#co_billing').slideDown('slow');
}
});
if (jQuery('#cBillingAddress:checked').length > 0) {
jQuery('#co_billing').hide();
}
jQuery('.checkoutSectionShowHide').text('hide');
jQuery('.checkoutSectionShowHideBlock.hideDefault').hide().parent().find('.checkoutSectionShowHide').text('show');
jQuery('.checkoutSectionShowHide').click(function() {
var block = jQuery(this).parent().siblings('.checkoutSectionShowHideBlock');
block.toggle();
jQuery(this).text(block.is(':visible') ? 'hide' : 'show');
return false;
});
jQuery('input[name=placeOrder]').click(function(e) {
if (jQuery('.popupIfEmpty input').val() == '') {
clickFire(jQuery('.popupIfEmpty').clone().wrap('<form id="cv2form"/>').parent().append('<h1>Please enter your security number</h1><input type="submit" class="button09" value="Place your order"/>'), function(box) {
jQuery(box).find('form').submit(function() {
var field = jQuery(this).find('input[type=text]');
if (field.val().length < 3) {
field.focus();
return false;
}
jQuery('input[name=' + field.attr('name') + ']').val(field.val());
closePop();
jQuery('input[name=placeOrder]').click();
return false;
});
});
e.stopImmediatePropagation();
return false;
}
return true;
});
jQuery('.checkoutPopup').click(function() {
jQuery('#popup').show();
});
jQuery('.extraLines').hide();
jQuery('.showAnotherLine').show().click(function() {
jQuery(this).remove();
jQuery('.extraLines:first').removeClass('extraLines').show();
return false;
});
});

jQuery(function() {
if (jQuery('#dietSearchForm input.dsFilter:checked').length == 0)
jQuery('#dietSearchForm .dsBoxInner').hide();
jQuery('#dietSearchForm .dsTitle').click(function() {
var inner = jQuery(this).siblings('.dsInner,.dsBoxInner');
if (inner.is(':visible'))
inner.slideUp();
else
inner.slideDown();
return false;
});
jQuery('.dsOptions label').hide();
jQuery('.dsOptions li>a').css({ display: 'block' }).click(function() {
var chkBox = jQuery(this).parent().find('input[type=checkbox]');
chkBox.attr('checked', !chkBox.attr('checked')).triggerHandler('click');
return false;
});
if (typeof (productNutrition) == undefined) return;
jQuery('#filterButton').hide();
jQuery('#dietSearchForm input.dsFilter').click(function() {
var isChecked = jQuery(this).attr('checked');
jQuery('.productList > li.productListing:' + (isChecked ? 'visible' : 'hidden')).each(function() {
var id = jQuery(this).find('input[name=pid]').val();
var hide = false;
jQuery('#dietSearchForm input.dsFilter').each(function() {
if (jQuery(this).attr('checked')) {
if (!eval('productNutrition[id].' + jQuery(this).attr('name')))
hide = true;
}
});
jQuery(this).toggleClass('filtered', hide);
});
if (jQuery('.productList > li.productListing:visible').length == 0) {
jQuery('#nodietresults').show();
}
else {
jQuery('#nodietresults').hide();
}
headscapeDOM.setCookie('dietFilter', jQuery('#dietSearchForm').serialize(), 30);
var i = 0;
jQuery('.productList > li.productListing:visible').each(function() {
jQuery(this).toggleClass('clear', ((i++ % 3) == 0));
if (jQuery(this).hasClass('featuredListing')) i++;
});
jQuery(this).closest('li').toggleClass('dsItemSelect', isChecked).toggleClass('dsItem', !isChecked);
});
});

jQuery(function() {
guide();
newsHome();
deepFooter();
deepFooterLinks();
mealsMenuShowHide();
changePostcode();
faqs();
validation();
formSubmit();
externalLinks();
seo_allProds()
landing_imgs();
notify_fix();
basketInit();
productListing();
initShowMore();
jQuery.ajaxSetup({ timeout: 7000, cache: false });
hideShowPassowrd();
setupCycler('.imagesRotator');
});
function changePostcode() {
jQuery("#homeTextLocation a.changeFranchise").click(function() {
jQuery("#homeTextLocation").removeClass('hasFranchise');
return false
});
jQuery('form.fChangePostcode').submit(updatePostcode);
jQuery('.enterPostcode').click(function() {
clickFire(this, function(f) {
});
return false;
});
}
function updatePostcode() {
headscapeDOM.setCookie('jsCookiesEnabled', 'Yes', 1);
if (headscapeDOM.getCookie('jsCookiesEnabled') != 'Yes') {
location.href = '/cookies.asp';
}
if (jQuery(this).find('input[name=postcode]').val() == '') {
jQuery(this).find('input[name=postcode]').parent()
.animate({ opacity: '.4' }, 200)
.animate({ opacity: '1' }, 100)
.animate({ opacity: '.4' }, 200)
.animate({ opacity: '1' }, 100, function() { jQuery(this).css({ opacity: '' }); });
return false;
}
clickFire(); //shows a loading graphic in the popup
wffBasket.updatingPostcode = true;
jQuery.post('/api/franchise.api.asp', jQuery(this).serialize(), function(jo) {
if (jo.errorText && jo.errorText.length > 0) {
jQuery('#warningMessage .title').text('something has gone wrong');
jQuery('#warningMessage p').html('<ul>' + jo.errorText + '</ul>');
jQuery('#warningMessage').fadeIn();
}
else if (jo.warningText && jo.warningText.length > 0) {
jQuery('#warningMessage .title').text('Please note..');
jQuery('#warningMessage p').html('<ul>' + jo.warningText + '</ul>');
jQuery('#warningMessage').fadeIn();
}
else {
jQuery('#warningMessage').hide();
}
if (+jo.franchiseId > 0) {
jQuery('.basketPostcode').text(jo.basketPostcode);
jQuery('.franchiseName').text(jo.franchiseName);
jQuery('.franchisePostcode').text(jo.franchisePostcode);
jQuery('.franchiseTel').text(jo.franchiseTel);
jQuery('a.franchiseEmail').attr('href', 'jo.franchiseEmail').text(jo.franchiseEmail);
jQuery('.franchiseOpenTimes').text(jo.franchiseOpeningTimes);
jQuery('.franchiseAddr1').text(jo.franchiseAddress1);
jQuery('img.outletPic').attr('src', jo.franchiseImage == '' ? '/images/outletpic.jpg' : '/images/franchise/' + jo.franchiseImage);
jQuery("#toolsOutlet").removeClass('showPostcodeEntry');
jQuery('#homeTextLocation').animate({ opacity: "0" }, 250)
.queue(function() { jQuery(this).addClass('hasFranchise'); jQuery(this).dequeue(); })
.animate({ opacity: "1" }, 250)
.animate({ opacity: "0.8" }, 250)
.animate({ opacity: "1" }, 250);
jQuery.getJSON('/api/basket.api.asp', function(jo) {
if (jo.intProdCount == '') jo.intProdCount = 0;
jQuery('#basketCount').text(jo.intProdCount + ' item' + (jo.intProdCount != 1 ? 's' : ''));
jQuery('#basketPrice').text(jo.mnyTotal);
});
var addr = location.href;
if (addr.indexOf('#') > 0) addr = addr.slice(0, addr.indexOf('#'));
addr += (addr.indexOf('?') > 0 ? '&' : '?') + 'request=partial';
jQuery('#mealsMenu >ul').load(addr + '&onlyshow=mealsmenu #mealsMenu>ul>*', function(responseText, textStatus, XMLHttpRequest) {
if (textStatus == 'success') mealsMenuShowHide();
});
if (jQuery('#prodList,#productList,#prodTypeList,#prodGroupList,#dietDetailsImg,#mainContent').length > 0) {
var id = jQuery('#prodList,#productList,#prodTypeList,#prodGroupList,#dietDetailsImg,#mainContent').attr('id');
jQuery('#' + id + ' form').fadeTo('slow', .2);
jQuery('#productLoader').fadeIn();
jQuery('#' + id).load(addr + ' #' + id + ' >*', function() {
jQuery('#productLoader').fadeOut();
wffBasket.updatingPostcode = false;
basketInit();
closePop(); //close any popups
if (jQuery('#prodList li,#productList li,#prodTypeList li').length == 0)
jQuery('#prodList,#productList li,#prodTypeList').html('<li><h2>Sorry, this franchise doesn\'t stock any products for this category.</h2></li>');
});
}
else {
wffBasket.updatingPostcode = false;
basketInit();
closePop(); //close any popups
}
}
else {
wffBasket.updatingPostcode = false;
closePop(); //close any popups
}
}, 'json');
return false;
}
function deepFooter() {
jQuery("#deepFooter .footerTitle").click(function() {
jQuery("#deepFooter .wrapper").toggleClass('collapse').find('div:not(.footerTitle)').slideToggle(500);
headscapeDOM.setCookie('expandfooter', jQuery("#deepFooter .wrapper").hasClass('collapse'), 1);
return false
});
if (headscapeDOM.getCookie('expandfooter') == 'true') jQuery("#deepFooter .footerTitle").click();
}
function deepFooterLinks() {
jQuery('#deepFooter .moreLinks').hide();
jQuery('.showmore').show().toggle(function() {
jQuery(this).siblings('li.moreLinks').slideDown('slow');
jQuery(this).children('span').html('Show Fewer &uarr;');
}, function() {
jQuery(this).siblings('li.moreLinks').slideUp('slow');
jQuery(this).children('span').html('Show More &darr;');
});
}
function externalLinks() {
jQuery('a.externalLink').each(function() {
var titleStr = jQuery(this).attr("title");
if (titleStr != "" && titleStr != undefined) {
titleStr += " (new window)";
} else {
titleStr = "(new window)";
}
jQuery(this).attr("title", titleStr);
jQuery(this).click(function() {
window.open(this.href);
return false;
});
});
}
var navexpanded = false;
function mealsMenuShowHide() {
jQuery(".mealsMenu ul li:gt(6)").addClass('toggleItems');
jQuery(".mealsMenu .mealsMenu_new").removeClass('toggleItems');
jQuery(".mealsMenu ul").append('<li class="showMore"><a href="#"><em class="more">Show More</em><em style="display:none;" class="fewer">Show Fewer</em></a></li>');
jQuery(".mealsMenu .showMore").click(toggleMenu);
if (headscapeDOM.getCookie('expandnav') == 'true') toggleMenu();
}
function toggleMenu() {
jQuery(".mealsMenu .toggleItems").toggle(500);
jQuery(".mealsMenu .showMore em:eq(0)").toggle(300);
jQuery(".mealsMenu .showMore em:eq(1)").toggle(300);
jQuery(".tHome .brochure").toggle();
navexpanded = !navexpanded;
headscapeDOM.setCookie('expandnav', navexpanded, 1);
return false
}
function notify_fix() {
if (jQuery('#basketLatestIframe').length > 0) {
latestDiv = jQuery('<div id="basketLatest"></div>').append(jQuery('#basketLatest > *'));
jQuery('dd#basketLatest').remove();
jQuery('#basketLatestIframe').after(latestDiv);
}
}
function seo_allProds() {
jQuery('body.tseo table').each(function() {
jQuery(this).hide();
var theTitle = jQuery(this).attr('title');
jQuery(this).before('<p class="hideshow" title="' + theTitle + '"><a href="#">View more ' + theTitle + ' frozen ready meals</a></p>');
});
jQuery('body.tseo .hideshow').click(function() {
if (jQuery(this).siblings('table:hidden').length > 0) {
jQuery(this).siblings('table').slideDown();
this.innerHTML = '<a href="#" class="colapse">Hide all ' + jQuery(this).next().attr('title') + ' frozen ready meals</a>';
}
else {
jQuery(this).siblings('table').slideUp();
jQuery(this).html('<a href="#">View more ' + jQuery(this).next().attr('title') + ' frozen ready meals</a>');
}
return false;
});
}
function faqs() {
jQuery('.lAnswer').hide();
jQuery('.lQuestion').toggle(function() {
jQuery(this).siblings('.lAnswer:hidden').slideDown("fast");
return false;
}, function() {
jQuery(this).siblings('.lAnswer:visible').slideUp("fast");
return false;
});
}
function validation() {
jQuery("#cIssue").bind('keyup', function() {
if (jQuery(this).val().length > 2) {
alert('Please note that the Issue number on maestro cards will be shown on the front of your Maestro card.\r\nYou do not need to enter the digit CV2 security number for your card to place an order with Wiltshire Farm Foods');
}
});
}
function formSubmit() {
jQuery('#specialF,#existCustForm,#feedback,#sendFriend').submit(function() {
if (jQuery(this).data('submitted') == true) {
return false;
}
else {
jQuery(this).data('submitted', true)
return true;
}
});
}
function guide() {
jQuery("#homeGuide .col").click(function() {
jQuery("#homeGuide .wrapper").toggleClass('collapse').find('ol').slideToggle(500);
headscapeDOM.setCookie('homeguide', jQuery("#homeGuide .wrapper").hasClass('collapse'), 1);
return false
});
if (headscapeDOM.getCookie('homeguide') == 'true') jQuery("#homeGuide .col").click();
}
function newsHome() {
jQuery("#newsHome .col").click(function() {
jQuery("#newsHome .wrapper").toggleClass('collapse').find('ol').slideToggle(500);
headscapeDOM.setCookie('homenews', jQuery("#newsHome .wrapper").hasClass('collapse'), 1);
return false
});
jQuery('#newsHome li').click(function() {
location.href = jQuery(this).find('a:eq(0)').attr('href');
});
if (headscapeDOM.getCookie('homenews') != 'false') jQuery("#newsHome .col").click();
}
function landing_imgs() {
jQuery('img.landingImg').each(function() {
var div = jQuery('<div class="' + jQuery(this).attr('class') + '"></div>');
div.css('float', jQuery(this).css('float'));
jQuery(this).wrap(div);
});
}
var wffReview = {
addRating: function(customerId, productId, rating, e) {
jQuery.post('/api/reviews.api.asp', 'a=addrating&c=' + customerId + '&pr=' + productId + '&p=' + rating, wffReview.redrawRatings, 'json');
if (window.event) {
window.event.cancelBubble = true;
window.event.returnValue = false;
}
if (e && e.stopPropagation && e.preventDefault) {
e.stopPropagation();
e.preventDefault();
}
return false;
},
redrawRatings: function(wffAPIResponse) {
if (!wffAPIResponse.Error) {
var oResponse = wffAPIResponse.Value;
if (oResponse.Type == 'Redirect') {
window.location = oResponse.Destination;
}
if (oResponse.Type == 'Rating') {
var totalScore = oResponse.TotalScore;
var totalVotes = oResponse.TotalVotes;
var newScore = oResponse.NewScore;
var newStarWidth = oResponse.NewStarWidth;
var message = oResponse.Message;
var rating = oResponse.Rating;
jQuery('#current-text-rating2').html('&nbsp;&nbsp;(' + newScore + ')');
jQuery('#current-rating2').css({ width: newStarWidth + 'px' });
message = newScore + ' star';
if (newScore != 1) message = message + 's';
message = message + ' based on an average over ' + totalVotes + ' rating';
if (totalVotes != 1) message = message + 's';
message = message + '.';
jQuery('#current-text-rating2-description').html(message);
jQuery('#starrating-1,#starrating-2,#starrating-3,#starrating-4,#starrating-5').css({ visibility: 'hidden' });
message = 'You have rated this product.  Your rating was : <strong>' + rating + ' Star';
if (rating != 1) message = message + 's';
message = message + '.</strong><br /><strong>4 Stars</strong> - Excellent, <strong>4 Stars</strong> - Good, <strong>3 Stars</strong> - Average, <strong>2 Stars</strong> - Below Average, <strong>1 Star</strong> - Poor';
jQuery('#customers-rating').html(message);
}
} else {
alert(wffAPIResponse.Error.Message);
}
},
submitReview: function(customerId, productId, review) {
jQuery.post('/api/reviews.api.asp', 'a=addcomment&c=' + customerId + '&pr=' + productId + '&p=' + escape(review), wffReview.redrawReview, 'json');
},
redrawReview: function(wffAPIResponse) {
if (!wffAPIResponse.Error) {
var oResponse = wffAPIResponse.Value;
if (oResponse.Type == "Redirect") {
window.location = oResponse.Destination;
}
if (oResponse.Type == "Review") {
jQuery('#reviewFormContainer').hide();
jQuery('#reviewFormSent').show();
jQuery('#reviewFormSent').fadeOut();
}
} else {
alert(wffAPIResponse.Error.Message);
}
},
publishReviews: function(strParams) {
jQuery.post('/api/reviews.api.asp', strParams, wffReview.publishComplete, 'json');
},
publishComplete: function(wffAPIResponse) {
if (!wffAPIResponse.Error) {
var oResponse = wffAPIResponse.Value;
if (oResponse.Type == "Redirect") {
window.location = oResponse.Destination;
}
} else {
alert(wffAPIResponse.Error.Message);
}
},
showForm: function() {
jQuery('#reviewForm').show();
}
}
function productListing() {
jQuery('.mainImage img').live('click', function() {
jQuery('.bigImage').css({ zIndex: 100, position: 'absolute', left: jQuery('.prodDetails_img').offset.left, top: jQuery('.prodDetails_img').offset.top }).fadeIn(500);
});
jQuery('.bigImage').live('click', function() {
jQuery('.bigImage').fadeOut(500);
});
jQuery('a.favourite').live('click', function() {
var l = this;
var href = jQuery(this).attr('href');
jQuery.get('/api/favourites.api.asp' + href + '&request=partial', function(msg) {
if (msg.toString().length == 0) {
window.location = href;
} else {
jQuery('.successBox').show().find('p').text(msg);
}
$('a[href=' + $(l).attr('href') + ']').each(function() {
var link = this;
if (msg.indexOf('added to') > 0) {
$(link).text('Remove from favourites').closest('prodDetails_fav').addClass('isFavourite');
if ($(link).closest('table').hasClass('myAccountTable')) {
$('.favouritesList tr:last').after(
$(link).closest('td').removeClass('myAccountTableAdd').addClass('myAccountTableRemove').closest('tr').clone()
);
}
}
else if (msg.indexOf('removed from') > 0) {
if ($(link).closest('table').hasClass('favouritesList')) {
$(link).closest('tr').fadeOut(700);
}
else {
if ($(link).closest('table').hasClass('myAccountTable'))
$(link).closest('td').removeClass('myAccountTableRemove').addClass('myAccountTableAdd');
$(link).text('Add to favourites').closest('prodDetails_fav').removeClass('isFavourite');
}
}
});
});
return false;
});
}
function convertToNumber(str) {
return Number(str.replace(/[^0-9\.]+/g, ""));
}
function initShowMore() {
if ($('.loadMore .next').length > 0) {
$('.loadMore').hide().before('<img class="loadMoreImg" border="0" src="/images/loading.gif" alt=""/>');
var triggerHeight = $('.loadMoreImg').offset().top-100;
var loading = false;
$(window).scroll(function() {
if (!loading && (jQuery(window).scrollTop() + jQuery(window).height()) > triggerHeight) {
loading = true;
$.get($('.loadMore .next').attr('href') + '&request=partial', function(data, textStatus) {
var newProducts = $('#productList > li', data).addClass('justAdded');
$('#productList').append(newProducts);
basketInit('.justAdded form');
newProducts.removeClass('justAdded');
var next = $('.loadMore .next', data);
if (next.length > 0) {
$('.loadMore .next').attr('href', next.attr('href'));
triggerHeight = $('.loadMoreImg').offset().top - 100;
loading = false;
}
else {
$('.loadMoreImg').remove();
}
}, 'html');
}
});
}
}
function hideShowPassowrd() {
jQuery('.textPasswordShow').show();
jQuery('.textPasswordShow').toggle(function() {
jQuery('.pwdObfuscated').hide();
jQuery('.pwdText').show();
jQuery(this).text('Hide this password');
},function() {
jQuery('.pwdText').hide();
jQuery('.pwdObfuscated').show();
jQuery(this).text('Show this password');
});
jQuery('.formPair .fpInput').hide();
jQuery('.formPair .fpText').show();
jQuery('.formPair .editValue').click(function() {
jQuery(this).closest('.fpText').hide().siblings('.fpInput').show().find('input:first').focus();
return false;
});
jQuery('.resetForm').click(function() {
jQuery('.formPair').removeClass('valid').removeClass('invalid');
jQuery('.formPair .fpInput').hide();
jQuery('.formPair .fpText').show();
});
jQuery('.printOrder').show().click(function() {
window.print();
return false;
});
}
function setupCycler(e) {
e = jQuery(e);
setInterval(function() {
var next = e.find('.current').next();
if (next.length == 0) next = e.children().eq(0);
next.addClass('next');
next.fadeIn(1400, function() {
e.find('.current').removeClass('current');
jQuery(this).removeClass('next').addClass('current').css({display:''});
});
}, 5000);
}

var headscapeDOM = {
getCookie: function(strName) {
var aryCookies = document.cookie.split(";");
var nameEQ = strName + "=";
for (var i = 0; i < aryCookies.length; i++) {
aryCookies[i] = jQuery.trim(aryCookies[i]);
if (aryCookies[i].indexOf(nameEQ) == 0) return aryCookies[i].substring(nameEQ.length, aryCookies[i].length);
}
return null;
},
getSubCookie: function(strName, strSubName) {
var strReturnValue = null;
var strFullCookie = this.getCookie(strName);
if (strFullCookie) {
var arySubCookies = strFullCookie.split("&");
var nameEQ = strSubName + "=";
for (var i = 0; i < arySubCookies.length; i++) {
arySubCookies[i] = jQuery.trim(arySubCookies[i]);
if (arySubCookies[i].indexOf(nameEQ) == 0) {
strReturnValue = arySubCookies[i].substring(nameEQ.length, arySubCookies[i].length);
break;
}
}
}
return strReturnValue;
},
setCookie: function(strName, strValue, intExpiryDays) {
var aryCookies = document.cookie.split(";");
var nameEQ = strName + "=";
var strNewCookieFull = "";
var intThisCookie = -1;
var strExpires = "";
if (intExpiryDays) {
var date = new Date();
date.setTime(date.getTime() + (intExpiryDays * 24 * 60 * 60 * 1000));
strExpires = "; expires=" + date.toGMTString();
}
strNewCookieFull = nameEQ + strValue + strExpires + "; path=/";
for (var i = 0; i < aryCookies.length; i++) {
aryCookies[i] = jQuery.trim(aryCookies[i]);
if (aryCookies[i].indexOf(nameEQ) == 0) {
intThisCookie = i;
aryCookies[i] = strNewCookieFull;
break;
}
}
if (intThisCookie == -1) {
aryCookies.push(strNewCookieFull);
intThisCookie = aryCookies.length - 1;
}
document.cookie = aryCookies[intThisCookie];
},
setSubCookie: function(strCookieName, strSubCookieName, strValue) {
var strFullCookie = this.getCookie(strCookieName);
if (strFullCookie) {
var arySubCookies = strFullCookie.split("&");
var nameEQ = strSubCookieName + "=";
var strNewCookieFull = nameEQ + strValue;
var intThisSubCookie = -1;
for (var i = 0; i < arySubCookies.length; i++) {
arySubCookies[i] = jQuery.trim(arySubCookies[i]);
if (arySubCookies[i].indexOf(nameEQ) == 0) {
intThisSubCookie = i;
break;
}
}
if (intThisSubCookie == -1) {
arySubCookies.push(strNewCookieFull)
} else {
arySubCookies[intThisSubCookie] = strNewCookieFull;
}
this.setCookie(strCookieName, arySubCookies.join("&"), 365);
}
},
isInteger: function(sInteger) {
if (sInteger == undefined) return false;
var deccount = 0;
var isInt = true;
var inputStr;
inputStr = sInteger.toString(); // in case sInteger is not a string
for (var i = 0; i < inputStr.length; i++) {
var oneChar = inputStr.charAt(i);
if (oneChar < "0" || oneChar > "9" || oneChar == ".") {
isInt = false;
i = inputStr.length;
}
}
return isInt;
}
}


jQuery(function() {
hasJS();
fField();
nav();
navA();
mealsMenu();
highlights();
brochure();
quickOrder();
lists();
scrollMore();
helpHeader();
myAccountHeader();
mealHeader();
helpBoxes();
init_swap_text_boxes();
boxExpand();
nicebuttons(); // ed's nice buttons
nameHLs();
liBkgs();
ltrClick();
formHelp();
formPairWithDetails();
checkoutShowHide();
selectAddress();
basketPositioner();
formPairRequired();
collapseBox();
removeHover();
});
function hasJS() {
jQuery("body").addClass('hasJS');
jQuery("body").addClass("jsenabled");
}
function nicebuttons() {
jQuery(".edsNiceButton").append('<div class="cornerTR"></div><div class="cornerBR"></div><div class="cornerBL"></div>');
}
function basketPositioner() {
}
function fField() {
jQuery(".field").wrap('<div class="fieldWrap"></div>');
jQuery("#allProducts .qtyInput").wrap('<div class="fieldWrap"></div>');
jQuery("#goog-wm-qt").wrap('<div class="textareaWrap"></div>');
jQuery("textarea").wrap('<div class="textareaWrap"></div>');
}
function nav() {
jQuery("#navigation").wrapInner('<div class="inner1"><div class="inner2"><div class="inner3"></div></div></div>');
}
function navA() {
jQuery("#navigation ul a").wrapInner('<div class="inner1"><div class="inner2"><div class="inner3"><span></span></div></div></div>');
jQuery("#navigation ul a,#navigation h1").each(
function() {
var troop = jQuery(this).text();
jQuery(this).prepend("<em></em>");
jQuery(this).find("em").text(troop);
}
)
}
function mealsMenu() {
jQuery(".mealsMenu").append('<div class="corner"></div>');
}
function highlights() {
jQuery("#highlights").wrapInner('<div class="corner"></div>');
}
function helpHeader() {
jQuery("#helpHeader").wrapInner('<div class="inner1"><div class="inner2"><div class="inner3"></div></div></div>');
}
function myAccountHeader() {
jQuery("#myAccountHeader").wrapInner('<div class="inner1"><div class="inner2"><div class="inner3"></div></div></div>');
}
function mealHeader() {
jQuery(".mealHeader").wrapInner('<div class="inner1"><div class="inner2"><div class="inner3"></div></div></div>');
}
function helpBoxes() {
jQuery(".helpRow .helpBox").click(function() { window.location = jQuery(this).find("a").attr("href"); return false; });
jQuery(".helpDetail .helpBox h2 a").parent().parent().parent().hover(
function() { $(this).addClass('helpBoxActive'); },
function() { $(this).removeClass('helpBoxActive'); }
);
}
function boxExpand() {
jQuery(".boxExpand h3 a").live('click', function() { jQuery('.boxExpand .co_inner').toggle(); return false; });
}
function brochure() {
jQuery(".brochure").wrapInner('<div class="inner1"><div class="inner2"><div class="inner3"></div></div></div>');
jQuery(".brochure").live('click', function() { window.location = jQuery(this).find("a").attr("href"); return false; });
}
function quickOrder() {
jQuery(".quickOrder").wrapInner('<div class="inner1"><div class="inner2"><div class="inner3"></div></div></div>');
jQuery(".quickOrder").live('click', function() { window.location = jQuery(this).find("a").attr("href"); return false; });
}
function lists() {
jQuery("ul li:first-child").addClass('firstLi');
jQuery("ul li:last-child").addClass('lastLi');
jQuery("ol li:first-child").addClass('firstLi');
jQuery("ol li:last-child").addClass('lastLi');
}
var swap_text_boxes = [];
function init_swap_text_boxes() {
jQuery('input[type=text][value].swaptextbox').each(function() {
swap_text_boxes[jQuery(this).attr('id')] = jQuery(this).attr('value');
});
jQuery('input[type=text][value].swaptextbox').bind('focus', function() {
if (jQuery(this).val() == swap_text_boxes[jQuery(this).attr('id')]) {
jQuery(this).val('');
}
});
jQuery('input[type=text][value].swaptextbox').bind('blur', function() {
if (jQuery(this).val() == '') {
jQuery(this).val(swap_text_boxes[jQuery(this).attr('id')]);
}
});
}
function scrollMore() {
jQuery("body").prepend('<span id="scrollMore">Scroll for More <em>&darr;</em></span>');
if (jQuery('#scrollMore').css('position') == 'absolute') {
jQuery('#scrollMore').hide();
}
else {
jQuery(window).scroll(function() {
if (jQuery(window).scrollTop() + jQuery(window).height() >= (jQuery(document).height() - 40)) {
jQuery('#scrollMore').fadeOut();
}
else {
jQuery('#scrollMore').fadeIn();
}
}).scroll();
}
}
function smoothAnchorLinks() {
jQuery('a[href^=#]').click(function() {
if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') && location.hostname == this.hostname) {
var jQuerytarget = jQuery(this.hash);
jQuerytarget = jQuerytarget.length && jQuerytarget || jQuery('[name=' + this.hash.slice(1) + ']');
if (jQuerytarget.length) {
var targetOffset = jQuerytarget.offset().top;
jQuery('html,body').animate({ scrollTop: targetOffset }, 1000);
return false;
}
}
});
}
function liBkgs() {
jQuery('#highlights li').prepend('<img class="bkgImg" src="../images/highlightSub.png" />');
}
function nameHLs() {
jQuery('#highlights li').removeClass();
jQuery('#highlights li:first-child').addClass('hl01');
jQuery('#highlights li:first-child + li').addClass('hl02');
jQuery('#highlights li:first-child + li + li').addClass('hl03');
jQuery('#highlights li:first-child + li + li + li').addClass('hl04');
jQuery('#highlights li:last-child').addClass('hl00');
}
function ltrClick() {
jQuery('#highlights li:first-child').bind('click', function() { ltr(); })
}
function ltr() {
jQuery('#highlights li:last-child').remove().prependTo('#highlights');
jQuery('#highlights li:first-child').css({ top: "400px", left: "0" });
jQuery('#highlights li:first-child').animate({
top: "334px",
left: "55px",
width: "191px",
height: "142px",
opacity: 1
}, 1000);
jQuery('#highlights li:first-child + li').animate({
top: "317px",
left: "247px",
width: "225px",
fontSize: "1.1em",
borderWidth: "6px"
}, 1000);
jQuery('#highlights li:first-child + li + li').animate({
top: "334px",
left: "473px",
width: "191px",
fontSize: "13px",
borderWidth: "5px"
}, 1000);
jQuery('#highlights li:first-child + li + li + li').animate({
top: "400px",
left: "717px",
width: "0px",
height: "0px",
fontSize: "0px",
opacity: 0
}, 1000, function() {
nameHLs();
jQuery('#highlights li').attr({ style: "" });
});
}
function formHelp() {
jQuery(".formPairHelp").hover(function() {
$(this).find("em").show();
}, function() {
$(this).find("em").hide();
}
);
}
function formPairWithDetails() {
jQuery(".formPairDetails").parent().parent().addClass('formPairWithDetails');
}
function checkoutShowHide() {
jQuery(".checkoutSectionShowHide").click(function() {
$(this).parent().next().toggleClass("checkoutSectionShowHideClosed");
});
}
function selectAddress() {
jQuery(".selectAddress dd a").hover(
function() {
$(this).parent().parent().css({ 'background-color': '#E9F4DD', 'border-color': '#e4f1d6' });
},
function() {
$(this).parent().parent().css({ 'background-color': '#fff', 'border-color': '#f1f7e9' });
}
);
}
function formPairRequired() {
jQuery(".formPair dd span.required").each(function(){
jQuery(this).css({'float':'none', 'display':'inline'}).appendTo(jQuery(this).parent());
});	
}
function collapseBox() {
jQuery(".collapseBox").addClass('collapseBoxOpen');
jQuery(".collapseBoxOpen + .collapseBoxOpen").toggleClass("collapseBoxClosed");
jQuery(".collapseBoxOpen h3").nextAll().wrap('<div class="collapseBoxInner"></div>');
jQuery(".collapseBoxOpen h3").click(function () {
jQuery(this).parent().toggleClass("collapseBoxClosed");
});	
}
function removeHover(){
jQuery("input.remove").hover(
function () {
$(this).attr("src","/images/removeHover.gif");
}, 
function () {
$(this).attr("src","/images/remove.gif");
}
)
}


String.prototype.linkify = function() {
return this.replace(/[A-Za-z]+:\/\/[A-Za-z0-9-_]+\.[A-Za-z0-9-_:%&\?\/.=]+/, function(m) {
return m.link(m);
});
};
jQuery(function() {
if (jQuery('#tweets').length > 0) {
jQuery.getJSON('http://twitter.com/status/user_timeline/wiltshirefarm.json?count=4&callback=?',
function(data) {
jQuery.each(data, function(i, item) {
jQuery('#tweets').append('<li>' + item.text.linkify() + '</li>');
});
});
}
});
jQuery(function() {
bindValidationRules(document);
});
function bindValidationRules(s) {
rules = [
{ names: ['email', 'fldEmail'], func: validateEmail },
{ names: ['password'], func: validatePassword },
{ names: ['postcode'], func: validatePostcode },
{ names: ['dTel', 'hTel'], func: validatePhone },
{ names: ['cNumber'], func: validateCardNum },
{ names: ['cExpiryMonth', 'cStartMonth'], func: validateMonth },
{ names: ['cExpiryYear', 'cStartYear'], func: validateYear },
{ names: ['cExpiryYear'], func: validateExpiryDate },
{ names: ['cIssue'], func: validatePosInt },
{ names: ['title', 'firstname', 'surname', 'rTitle', 'rFName', 'rLName', 'fldEmail', 'password', 'dAddr1', 'dCity', 'cName', 'hAddr1', 'hCity', 'cExpiryMonth', 'cExpiryYear', 'hPostcode'], func: validateRequired }
];
for (r in rules) {
var str = '';
for (n in rules[r].names) {
str += '*[name=' + rules[r].names[n] + '],';
}
jQuery(s).find(str).focus(clearValidation).blur(rules[r].func).each(function() {
if (jQuery(this).val() != '') {
jQuery(this).triggerHandler('blur');
}
else {
}
});
}
}
function clearValidation() {
var dl = jQuery(this)
.removeClass('invalid').removeClass('valid')
.closest('dl').removeClass('invalid').removeClass('valid')
.find('.required').show();
}
function updateValidation(e, v, event) {
jQuery(e).addClass(v ? 'valid' : 'invalid').removeClass(v ? 'invalid' : 'valid');
var dl = jQuery(e).closest('dl');
if (dl.find('.invalid').length == 0) {
dl.removeClass('invalid').addClass('valid');
dl.find('.required').hide();
}
else {
dl.removeClass('valid').addClass('invalid');
dl.find('.required').show();
event.stopImmediatePropagation();
}
}
function validateRequired(e) {
updateValidation(this, (jQuery(this).val() != ''), e);
}
function validateEmail(e) {
var emailReg = new RegExp(/^((?:(?:(?:[a-zA-Z0-9][\.\-\+_]?)*)))\@((?:(?:(?:[a-zA-Z0-9][\.\-_]?){0,62})[a-zA-Z0-9])+)\.([a-zA-Z0-9]{2,6})$/);
updateValidation(this, emailReg.test(jQuery(this).val()), e);
}
function validatePassword(e) {
updateValidation(this, (jQuery(this).val() && jQuery(this).val().length >= 6), e);
}
function validatePostcode(e) {
var postcodeReg = new RegExp(/^[a-zA-Z][a-zA-Z0-9]{1,3} \d[a-zA-Z]{2}$/);
updateValidation(this, postcodeReg.test(jQuery(this).val()), e);
}
function validatePhone(e) {
var phoneReg = new RegExp(/^[\d\+\(\\)a-zA-Z\s\-\.]{10,30}$/);
updateValidation(this, phoneReg.test(jQuery(this).val()), e);
}
function validateCardNum(e) {
number = jQuery(this).val();
if (number.indexOf('****') >=0) return;
var number = number.replace(/\D/g, '');
var number_length = number.length;
var parity = number_length % 2;
var total = 0;
for (i = 0; i < number_length; i++) {
var digit = number.charAt(i);
if (i % 2 == parity) {
digit = digit * 2;
if (digit > 9) {
digit = digit - 9;
}
}
total = total + parseInt(digit);
}
updateValidation(this, (number.length > 0 && total % 10 == 0), e);
}
function validateMonth(e) {
if(jQuery(this).val()!='') updateValidation(this, (jQuery(this).val() * 1) > 0 && (jQuery(this).val() * 1) <= 12, e);
}
function validateYear(e) {
var yearReg = new RegExp(/^[0-9]{2}$/);
if (jQuery(this).val() != '') updateValidation(this, yearReg.test(jQuery(this).val()), e);
}
function validateExpiryDate(e) {
var d = new Date();
var thisYear = d.getFullYear();
if (jQuery(this).val() != '') updateValidation(this, (!isNaN(jQuery(this).val()) && Number("20" + jQuery(this).val()) >= thisYear), e);
}
function validatePosInt(e) {
if (jQuery(this).val() != '') updateValidation(this, (jQuery(this).val() * 1) > 0, e);
}

jQuery(function() {
jQuery(".popuptrigger a, a.popuptrigger, input.popuptrigger").live('click', function() {    // creates an empty popup when
clickFire(this);
return false;
});
jQuery(".edspopupclose").live('click', closePop); //attaches event to popup close
jQuery(".helpDetail .helpBox, #homeGuide li").click(function() {
rtn = true;
jQuery(this).find('h2 a, a.videoLink').each(function() {
clickFire(this, null, 'popupVid');
rtn = false;
});
return rtn;
});
jQuery('.refreshPage').live('click', function() {
window.location.reload();
return false;
});
});
function positionPopup(box, speed) {
if (speed == null) speed = 0;
iWidth = box.find('.edspopupinner > *:last').outerWidth() +7 //7 is for the margin on the left
iHeight = box.find('.edspopupinner > *:last').outerHeight() +15 // avoid a small scrollbar;
iHeight = Math.min(iHeight, jQuery(window).height()-170);
var iTop = Math.max(Math.round(jQuery(window).scrollTop() + ((jQuery(window).height() / 2) - ((iHeight+50) / 2))), jQuery(window).scrollTop() + 25);
var iLeft = Math.max(Math.round(jQuery(window).scrollLeft() + ((jQuery(window).width() / 2) - ((iWidth+50) / 2))), jQuery(window).scrollLeft() + 10);
box.animate({ top: iTop + 'px', left: iLeft + 'px', width: iWidth+50 + 'px' }, speed);
box.css({margin: '0 auto', position:'absolute', overflow:'visible'});
box.find('.edspopupinner').animate({ width: iWidth + 'px', height: iHeight + 'px' }, speed);
jQuery('#edspopupbkg').css({ height: jQuery(document).height() + 'px' });
}
var popupPanicTimeout;
function clickFire(e, cb, c) {
popupPanicTimeout = setTimeout(function() {
jQuery('.edspopupinner').html('<div><h2>Don\'t panic!</h2><p>This page seems to be taking a long time to load. You may want to <a href="#" class="refreshPage">try refreshing it manually</a>.</p></div>');
complete(true);
}, 8000);
var complete = function(fast) {
clearTimeout(popupPanicTimeout);
var title_text = jQuery('.edspopupinner h1').remove().text();
jQuery('#edspopupbox .title').text(title_text).append('<em>' + title_text + '</em>');
jQuery('.edspopupinner').find('input[type=text]:first').focus();
positionPopup(jQuery('#edspopupbox'), fast ? 0 : 700);
nicebuttons();
if (typeof bindValidationRules == 'function') bindValidationRules('.edspopupinner');
if (typeof cb == 'function') cb(jQuery('.edspopupinner'));
};
if (jQuery('#edspopupbox').length == 0) {
jQuery("body").append('<div id="edspopupbkg"></div><div id="edspopupbkg2"></div><div id="edspopupbox"><div class="cornerTR"><div class="title"></div><div class="cornerBR"><div class="cornerBL"><a href="" class="edspopupclose"><span>Close</span></a><div class="edspopupinner"></div></div></div></div></div>');
}
if (c != null) jQuery('#edspopupbox .edspopupinner').addClass(c);
var addr = '';
var aType = 'GET';
var fData = null;
var div = '';
if (typeof e == 'string') {
addr = e;
}
else if (jQuery(e).is('a')) {
addr = (e.href.replace(/.*\/\/[^\/]+/, '')); // replace everything before the first /
}
else if (jQuery(e).is('input')) {
var f = jQuery(e).parents('form');
addr = f.attr('action');
aType = 'POST';
fData = f.serialize() + '&' + jQuery(e).attr('name') + '=' + jQuery(e).val();
}
else if (typeof e == 'object') {
jQuery('.edspopupinner').append(e);
complete(true);
return false;
}
else {
addr = null;
}
jQuery('.edspopupinner .co_message').remove();
if (jQuery('.edspopupinner .loadingAnim').length == 0) {
jQuery('.edspopupinner').prepend('<p class="loadingAnim"></p>');
}
positionPopup(jQuery('#edspopupbox'));
jQuery('#edspopupbox .loadingAnim').css({ width: jQuery('#edspopupbox .edspopupinner').innerWidth() - 10, height: jQuery('#edspopupbox .edspopupinner').innerHeight() - 10 }).show();
if (addr != null) {
if (addr.indexOf('#') > 0) {
div = addr.substring(addr.indexOf('#'));
addr = addr.substring(0, addr.indexOf('#'));
}
addr += (addr.indexOf('?') == -1 ? '?' : '&') + 'request=partial'
jQuery.ajax({
type: aType,
url: addr,
data: fData,
dataType: 'html',
success: function(data, status) {
try {
var jData = jQuery(data);
}
catch (e) { }
if (jData == undefined) {
location.href = addr.replace('request=partial', '');
return;
}
jQuery('.edspopupinner *:not(.loadingAnim)').remove();
jQuery('.edspopupinner .loadingAnim').fadeOut();
if (jData != undefined && jData.length > 0 && jData.filter('#popupwrapper').length > 0) {
if (div.length > 0 && (jData.filter(div).length > 0 || jData.find(div).length > 0)) {
if (jData.filter(div).length > 0) {
jQuery('.edspopupinner').append(jData.filter(div));
}
else {
jQuery('.edspopupinner').append(jData.find(div));
}
}
else {
jQuery('.edspopupinner').append(jData.html());
}
complete();
}
else {
closePop();
location.href = addr.replace('request=partial', '');
}
},
error: function() {
closePop();
location.href = addr.replace('request=partial', '');
},
timeout: 7000,
cache: false
});
}
return false;
}
function hrefFire(url) {
clickFire(url);
}
function closePop() {
clearTimeout(popupPanicTimeout);
jQuery("#edspopupbkg").remove();
jQuery("#edspopupbkg2").remove();
jQuery("#edspopupbox").remove();
return false;
}
