﻿// JScript File

<!--

$(document).ready(function() {

	// input field hints
	$('input[title!=""]').inputHint(); 

	// set padding on oversized text inputs for IE browsers
	if ($.browser.msie) {
		$('#rhn .module.newsletter input#rhn_nl_email').css({
			paddingTop : '4px',
			height : '21px'
		});
		$('#footer .newsletter .content input#promo_nl_email').css({
			paddingTop : '3px',
			height : '20px'
		});
	}

	// scrolling our brands panel
	// brand logos should be 130x50
    $(".jCarouselLite").jCarouselLite({
        btnNext : ".next",
        btnPrev : ".prev",
        visible : 7
    });

	// main drop down menus
	$("ul.sf-menu").superfish({
		hoverClass : 'current',
		autoArrows : false,
		dropShadows : false,
		speed : 'fast'
	});

	// setup the sliders for product search filtering
	var filterSlidersConf = [{
		base : '#lhn_filter_form .price-filter',
		valueDisplay : ['.slider-value-1-2', '.slider-value-2-2'],
		valueFields : ['#price_from input', '#price_to input'],
		type : 'dollar'
	}, 
    {
		base : '#lhn_filter_form .screen-size-inches',
		valueDisplay : ['.slider-value-1-2', '.slider-value-2-2'],
		valueFields : ['#screen-size-inches_from input', '#screen-size-inches_to input'],
		type : 'inch/cm'
	},    
    {
		base : '#lhn_filter_form .depth-cm',
		valueDisplay : ['.slider-value-1-2', '.slider-value-2-2'],
		valueFields : ['#depth-cm_from input', '#depth-cm_to input'],
		type : 'cm'
	},
    {
		base : '#lhn_filter_form .width-cm',
		valueDisplay : ['.slider-value-1-2', '.slider-value-2-2'],
		valueFields : ['#width-cm_from input', '#width-cm_to input'],
		type : 'cm'
	},
    {
		base : '#lhn_filter_form .height-cm',
		valueDisplay : ['.slider-value-1-2', '.slider-value-2-2'],
		valueFields : ['#height-cm_from input', '#height-cm_to input'],
		type : 'cm'
	},
    {
		base : '#lhn_filter_form .energy-rating',
		valueDisplay : ['.slider-value-1-2', '.slider-value-2-2'],
		valueFields : ['#energy-rating_from input', '#energy-rating_to input'],
		type : 'rating'
	}, 
    {
		base : '#lhn_filter_form .water-rating',
		valueDisplay : ['.slider-value-1-2', '.slider-value-2-2'],
		valueFields : ['#water-rating_from input', '#water-rating_to input'],
		type : 'rating'
	}, 
    {
		base : '#lhn_filter_form .number-of-tuners',
		valueDisplay : ['.slider-value-1-2', '.slider-value-2-2'],
		valueFields : ['#number-of-tuners_from input', '#number-of-tuners_to input'],
		type : 'tuners'
	}, 
    {
		base : '#lhn_filter_form .capacity-gb',
		valueDisplay : ['.slider-value-1-2', '.slider-value-2-2'],
		valueFields : ['#capacity-gb_from input', '#capacity-gb_to input'],
		type : 'gb'
	}, 
    {
		base : '#lhn_filter_form .hdd-size-gb',
		valueDisplay : ['.slider-value-1-2', '.slider-value-2-2'],
		valueFields : ['#hdd-size-gb_from input', '#hdd-size-gb_to input'],
		type : 'gb'
	},
    {
		base : '#lhn_filter_form .megapixels-mp',
		valueDisplay : ['.slider-value-1-2', '.slider-value-2-2'],
		valueFields : ['#megapixels-mp_from input', '#megapixels-mp_to input'],
		type : 'mp'
	},
    {
		base : '#lhn_filter_form .zoom-optical',
		valueDisplay : ['.slider-value-1-2', '.slider-value-2-2'],
		valueFields : ['#zoom-optical_from input', '#zoom-optical_to input'],
		type : 'zoom'
	},
    {
		base : '#lhn_filter_form .capacity-ltrs',
		valueDisplay : ['.slider-value-1-2', '.slider-value-2-2'],
		valueFields : ['#capacity-ltrs_from input', '#capacity-ltrs_to input'],
		type : 'ltrs'
	},
    {
		base : '#lhn_filter_form .capacity-bottles',
		valueDisplay : ['.slider-value-1-2', '.slider-value-2-2'],
		valueFields : ['#capacity-bottles_from input', '#capacity-bottles_to input'],
		type : 'bottles'
	},
    {
		base : '#lhn_filter_form .capacity-kgs',
		valueDisplay : ['.slider-value-1-2', '.slider-value-2-2'],
		valueFields : ['#capacity-kgs_from input', '#capacity-kgs_to input'],
		type : 'kg'
	},
    {
		base : '#lhn_filter_form .cooling-capacity-kw',
		valueDisplay : ['.slider-value-1-2', '.slider-value-2-2'],
		valueFields : ['#cooling-capacity-kw_from input', '#cooling-capacity-kw_to input'],
		type : 'kw'
	},
    {
		base : '#lhn_filter_form .heating-capacity-kw',
		valueDisplay : ['.slider-value-1-2', '.slider-value-2-2'],
		valueFields : ['#heating-capacity-kw_from input', '#heating-capacity-kw_to input'],
		type : 'kw'
	}];

	$.each(filterSlidersConf, function(i, item) {
		setupFilterSlider(item);
	});

	// set up qty adjust behaviours
	$('.qty .buttons').each(function(i0, item0) {
		var $inp = $('input#qty', item0);
		$('a', item0).each(function(i, item) {
			$.data(item, 'qty_incr', ((i * 2) - 1) * -1);
			$(item)
			.mousedown(function(e) { clearInterval($.data(item, 'qty_intID')); $.data(item, 'qty_intID', setInterval(function(){ $(item).trigger('click'); }, 150)); return false; })
	  	.mouseup(function(e) { clearInterval($.data(item, 'qty_intID')); return false; })
	  	.mouseout(function(e) { clearInterval($.data(item, 'qty_intID')); return false; })
	  	.click(function(e) { incrQty($inp, $.data(this, 'qty_incr')); return false; });
	  	$inp.focusout(function(e) { incrQty($inp, 0); return false; })
	  	.blur(function(e) { incrQty($inp, 0); return false; });
		});
	});

	// set padding on oversized text inputs for IE browsers
	if ($.browser.msie) {
		$('#topNav .nav_level_1 .search #keyword').css({
			paddingTop : '3px',
			height : '19px'
		});
	}

    // search results last row
    $('.search-results #prod-list-container div.result-row:last').addClass("last");

	// round corners
	var corners = [
		{ img : 'lightblue.gif', obj : [
				{ tid : '#pageHead', force : true, pos : 'tl tr' }
			]
		}, { img : 'lightblue.gif', obj : [
				{ tid : '#pageContent', force : true, pos : 'bl br' }
			]
		}, { img : 'top_nav.gif', obj : [
				{ tid : '#topNav', force : true, pos : 'tl tr bl br' }
			]
		}, { img : 'grey_border_subcat.gif', obj : [
				{ tid : '#main .content .subcat_container.first', force : true, lx : -1, ty : -1, by : -1, pos : 'tl bl' },
				{ tid : '#main .content .subcat_container.last', force : true, rx : -1, ty : -1, by : -1, pos : 'tr br' }
			]
		}, { img : 'grey_border.gif', obj : [
				{ tid : '#lhn .recently-viewed .head, #lhn .side-filter > .head', force : true, lx : -1, rx : -1, ty : -1, pos : 'tl tr' },
				{ tid : '#product-detail #detail-tabs > ul li:first', force : true, lx : -1, rx : -1, ty : -1, pos : 'tl tr' },
				{ tid : '#product-detail #detail-tabs > div', force : true, lx : -1, rx : -1, ty : -1, by : -1, pos : 'tr bl br' },
				{ tid : '#prod-details-container', force : true, pos : 'tl tr bl br' },
				{ tid : '#footer .foot_spotlight .about-us', force : true, pos : 'tl tr bl br' },
				{ tid : '#footer .foot_spotlight .customer', force : true, pos : 'tl tr bl br' },
				{ tid : '#footer .foot_spotlight .newsletter', force : true, pos : 'tl tr bl br' },
				{ tid : '#footer .product_cats', force : true, pos : 'tl tr bl br' },
				{ tid : '#rhn .module.blog', force : true, pos : 'bl br' },
				{ tid : '#featured_products', force : true, pos : 'tl tr bl br' },
				{ tid : '#main .content .cat_grp_container', force : true, pos : 'tl tr bl br' },
				{ tid : '#main .pagination-container', force : true, pos : 'tl tr bl br' },
				{ tid : '#prod-list-container .result-row', force : true, pos : 'tl tr bl br' },
				{ tid : '#catalogue-search-container', force : true, pos : 'tl tr bl br' },
				{ tid : '#lhn .module.advanced-search', force : true, pos : 'tl tr bl br' },
				{ tid : '#brand-list-container', force : true, pos : 'tl tr bl br' },
				{ tid : '#billing-container #address-container', force : true, pos : 'tl tr bl br' },
				{ tid : '.cart-list-container', force : true, pos : 'tl tr' },
				{ tid : '#billing-container .order-contents-container', force : true, pos : 'tl tr bl br' },
				{ tid : '#billing-container .order-contents', force : true, pos : 'tl tr bl br' },
				{ tid : '#completed-order div.tlbr-border', force : true, pos : 'tl tr bl br' },
				{ tid : '#payment div.tlbr-border', force : true, pos : 'tl tr bl br' },
				{ tid : '#view-order div.tlbr-border', force : true, pos : 'tl tr bl br' },
				{ tid : '#print-invoice div.tlbr-border', force : true, pos : 'tl tr bl br' },
				{ tid : '#order-history div.tlbr-border', force : true, pos : 'tl tr bl br' },
				{ tid : '#contact-us div.tlbr-border', force : true, pos : 'tl tr bl br' },
				{ tid : '#login div.tlbr-border', force : true, pos : 'tl tr bl br' },
				{ tid : '#my-account div.tlbr-border', force : true, pos : 'tl tr bl br' },
				{ tid : '#my-account-prod-reviews div.tlbr-border', force : true, pos : 'tl tr bl br' },
				{ tid : '#my-account-update div.tlbr-border', force : true, pos : 'tl tr bl br' },
				{ tid : '.content .wishlist .email-container .form-content', force : true, pos : 'tl tr bl br' }
			]
		}, { img : 'white_bg.png', obj : [
				{ tid : '#product-detail #detail-tabs > ul li:not(:first)', force : true, lx : -1, rx : -1, ty : -1, pos : 'tl tr' },
				{ tid : '#rhn .related-products .head', force : true, pos : 'tl tr' },
				{ tid : '#rhn .module.shipping-estimator', force : true, pos : 'tl tr' },
				{ tid : '#rhn .module.wishlist-password', force : true, pos : 'tl tr' },
				{ tid : '#rhn .module.order-summary', force : true, pos : 'tl tr' },
				{ tid : '#rhn .module.coupon-code', force : true, pos : 'tl tr' },
				{ tid : '#slider-nav', force : true, pos : 'bl br' }
			]
		}
	];

	if (!$.browser.msie || ($.browser.msie && $.browser.version > 6)) { addCorners(corners, 'common'); }
	$(':not(.noPngFix)').pngFix({ blankgif:'/images/blank.gif' });
		
	$('.href-onclick').click(function() {
		if ($(this).attr('href'))
			document.location.href = $(this).attr('href');
	});

	$('#payment-option .col .head input').click(function() {
		var self = this;
		$('#payment-option .col .head input').each(function() {
			if (this.className != self.className) { $('#payment').removeClass(this.className); }
		});
		$('#payment').addClass(self.className);
	});

});

function initAjaxProgress()
{
    var pageHeight = (document.documentElement && document.documentElement.scrollHeight) ? document.documentElement.scrollHeight : (document.body.scrollHeight > document.body.offsetHeight) ? document.body.scrollHeight : document.body.offsetHeight;
    //SET HEIGHT OF BACKGROUND
    var bg = document.getElementById('ajaxProgressBg');
    bg.style.height = (pageHeight + 1000) + 'px';
    //POSITION THE PROGRESS INDICATOR ON INITIAL LOAD
    reposAjaxProgress();
    //REPOSITION THE PROGRESS INDICATOR ON SCROLL
    window.onscroll = reposAjaxProgress;
}

function reposAjaxProgress()
{
    var div = document.getElementById('ajaxProgress');
    var st = document.body.scrollTop;
    if (st == 0) {
        if (window.pageYOffset) st = window.pageYOffset;
        else st = (document.body.parentElement) ? document.body.parentElement.scrollTop : 0;
    }
    div.style.top = 150 + st + "px";
}

function initReviewForm()
{
    $('#addReviewPopup tr:first td, #addReviewPopup tr:last td').css({ height: '23px' });
    $('#addReviewPopup tr td:first, #addReviewPopup tr td:last').css({ width: '23px' });
    $('#addReviewPopup tr.top td:first').css({ background: 'url(images/corners/add-review-border-sprite.png) no-repeat scroll left top transparent' });
    $('#addReviewPopup tr.top td.mid').css({ background: 'url(images/corners/add-review-top-bg.png) repeat-x scroll left top transparent' });
    $('#addReviewPopup tr.top td:last').css({ background: 'url(images/corners/add-review-border-sprite.png) no-repeat scroll -23px top transparent' });
    $('#addReviewPopup tr.mid td:first').css({ background: 'url(images/corners/add-review-lef-bg.png) repeat-y scroll left top transparent' });
    $('#addReviewPopup tr.mid td:last').css({ background: 'url(images/corners/add-review-rig-bg.png) repeat-y scroll left top transparent' });
    $('#addReviewPopup tr.bot td:first').css({ background: 'url(images/corners/add-review-border-sprite.png) no-repeat scroll left -23px transparent' });
    $('#addReviewPopup tr.bot td.mid').css({ background: 'url(images/corners/add-review-bot-bg.png) repeat-x scroll left top transparent' });
    $('#addReviewPopup tr.bot td:last').css({ background: 'url(images/corners/add-review-border-sprite.png) no-repeat scroll -23px -23px transparent' });

    $('#addReviewPopup').position({ my:"center", at:"center", of:window });
}

//-->
