	/*! http://mths.be/placeholder v1.8.6 by @mathias */
(function(e,g,$){var a='placeholder' in g.createElement('input'),c='placeholder' in g.createElement('textarea'),h=$.fn,i;if(a&&c){i=h.placeholder=function(){return this};i.input=i.textarea=true}else{i=h.placeholder=function(){return this.filter((a?'textarea':':input')+'[placeholder]').not('.placeholder').bind('focus.placeholder',b).bind('blur.placeholder',d).trigger('blur.placeholder').end()};i.input=a;i.textarea=c;$(function(){$('form').bind('submit.placeholder',function(){var j=$('.placeholder',this).each(b);setTimeout(function(){j.each(d)},10)})});$(e).bind('unload.placeholder',function(){$('.placeholder').val('')})}function f(k){var j={},l=/^jQuery\d+$/;$.each(k.attributes,function(n,m){if(m.specified&&!l.test(m.name)){j[m.name]=m.value}});return j}function b(){var j=$(this);if(j.val()===j.attr('placeholder')&&j.hasClass('placeholder')){if(j.data('placeholder-password')){j.hide().next().show().focus().attr('id',j.removeAttr('id').data('placeholder-id'))}else{j.val('').removeClass('placeholder')}}}function d(){var n,m=$(this),j=m,l=this.id;if(m.val()===''){if(m.is(':password')){if(!m.data('placeholder-textinput')){try{n=m.clone().attr({type:'text'})}catch(k){n=$('<input>').attr($.extend(f(this),{type:'text'}))}n.removeAttr('name').data('placeholder-password',true).data('placeholder-id',l).bind('focus.placeholder',b);m.data('placeholder-textinput',n).data('placeholder-id',l).before(n)}m=m.removeAttr('id').hide().prev().attr('id',l).show()}m.addClass('placeholder').val(m.attr('placeholder'))}else{m.removeClass('placeholder')}}}(this,document,jQuery));
	var Site = {
		
		init : function() {
	
		//CUFON
		
		Cufon.replace('.funnel-heading', {
					 textShadow: 'rgba(0,0,0,.4) 2px 2px' 
		}); 
		
		//SHADOWBOX
		
		Shadowbox.init({
			players: ['iframe'],
		    handleOversize:     "drag",
		    handleUnsupported:  "remove",
		    autoplayMovies:     false
		});
		
			//jQuery
			jQuery.noConflict();
			
			(function($) {
				$(document).ready(function(){

				if ($('#catFeatures').text().substring(34,36) === 'ou'){
				
					$('#catFeatures').remove();
				
				}
				//JQUERY CALLS HERE
//				$('img').bind('contextmenu', function(e){
//				    return false;
//				}); //disable right click on images
				window.onload = function (e) {
					var evt = e || window.event,// define event (cross browser)
					imgs, // images collection
					i; // used in local loop
					// if preventDefault exists, then define onmousedown event handlers
					if (evt.preventDefault) { // collect all images on the page
						imgs = document.getElementsByTagName('img'); // loop through fetched images
						for (i = 0; i < imgs.length; i++) { // and define onmousedown event handler
							imgs[i].onmousedown = disableDragging;
						}
					}
				}; // disable image dragging
				
				function disableDragging(e) {
					e.preventDefault();
				};
				if ( $('#catFeatures').text() == 'No items found.' ) {
					$('#catFeatures').text('');
				}
				$('.catalogueList li').each(function(){
				
					var c = $(this).find('.image').children().length;
					var l = $(this).find('h4 a').attr('href');
					if ( c === 0 ) {
					
						$(this).find('.image').append('<a href="' + l + '"><img src="/images/layout/no_picture_available-220x198.jpg" alt="" /></a>');
					
					}
				
				});
				
				$('div.breadcrumbs').contents().each(function(){
					if (this.nodeType === 3) {
						$(this).remove();
					}
					
				}).end()
					.find('a:first').remove().end()
					.find('a:last').remove().end()
					.find('a').each(function(){

					$(this).text('Back to ' + $(this).text());
				
				});	


$('.currentPromotionDetail')
	//.find('li:first h4 a').text('Collection').end()
	.find('li h4 a[href*="index"]').text('Catalogue');

//Warranties page

$('#productSelection').change(function(){
	$('#rangeSelection').attr('class', '');
	var p = $(this).find('option:selected').val();
	$('#rangeSelection').addClass(p);

});
$('#rangeSelection').change(function(){

	var l = $(this).find('option:selected').val();
	$(this).next('a.button').attr('href', '/warranty?CategoryId=' + l); 
	
});

$('#gotquestion-side').find('a').attr('rel','shadowbox;width=320;height=530');
Shadowbox.setup();







					//SLIDER	
					$("#slider").easySlider({
						numeric: true,
						auto: true,
						pause: 5000,
						continuous: true
					});
					//END SLIDER
					
					//INNERFADE
					$('ul#fader').innerfade({
						speed: 2000,
						timeout: 4000,
						type: 'sequence',
						containerheight: '309px',
						containerwidth: '96em'
					});
					//END INNERFADE
$('input, textarea').placeholder();
					
					

				

										
				}); //END JQUERY
			})(jQuery);
		}, shopScripts : function(){
		
				//jQuery
			jQuery.noConflict();
			
			(function($) {
				$(document).ready(function(){
			//Catalogue
				var pFirstImg, pFirstName, largeImage, largeName, pFirstLink, largeLink, lpv;
	
	lpv = $('#catProducts ul li .image').length;
	
	if ( lpv > 0 ) {			
				pFirstImg = $('#catProducts').find('ul li:first .image img').attr('src').split('.')[0];
				pFirstName = $('#catProducts').find('ul li:first .tooltip').text();
				pFirstLink = $('#catProducts').find('ul li:first .image a').attr('data-lpv');

				largeImage = $('#largeImageMask').find('#largeImage');
				largeName = $('#largeImageMask').find('#largeName');
				largeLink = $('#largeImageMask').find('#largeLink');
				largeImage.attr('src', pFirstImg + '-large.jpg');
				largeName.text(pFirstName);
				largeLink.attr('href', pFirstLink);
				
				$('.buyButton').attr('href',pFirstLink);
				$('.productSmall li').click(function(){
				$('#largeImage').remove();
				$('#largeLink').attr('href',$(this).find('.image a').attr('data-lpv'));
				$('#imageMask').after('<img id="largeImage" src="" />');
					$('#largeImageMask').find('#largeImage').attr('src', $(this).find('.image img').attr('src').split('.')[0] + '-large.jpg');
					largeName.text($(this).find('.tooltip').text());
				$('#largeImage').rotate(3);
				$('.buyButton').attr('href',$(this).find('.image a').attr('data-lpv'));				
				Shadowbox.setup();
				return false;
				
				});
}
				$('#catProducts .image, #catFeatures .trustMarkersList a').tooltip({ position: "bottom center", effect: "fade", relative: true, offset: [-10,0]});
				$('#largeImage').rotate(3);
				
				
				var collection, range;
				
				collection = $('div.breadcrumbs').find('a:last').text().substring(8);
				range = document.title;
		
				
				$('#requestQuote').find('a').attr('href', '/request-a-quote?Collection=' + collection + '&range=' + range + '&colour=' + pFirstName);
				$('#catNav').find('ul > li:eq(1) > a').attr('href', '/got-a-question?Collection=' + collection + '&range=' + range + '&colour=' + pFirstName);








//FLOORING CALC
$('#calcFlooringType').change(function(){
	if ($(this).attr('value') !== 'Carpet') {
		
		$('.broadloam').hide();
	} else {
		$('.broadloam').show();

	}
});

$('#calcFlooringType').change();
$('#calculate').click(function(e){

	var width, height, m2, broadloom;



	width = $('#floorWidth').attr('value');
	height = $('#floorHeight').attr('value');

if (!width || !height) { return false; } else {
	m2 = $('#outputM2').attr('value', width * height);
	broadloom = $('#outputBroad').attr('value', Math.ceil((width * height) / 3.66));

	e.preventDefault();
}
});







				}); //END JQUERY
			})(jQuery);
		
		
		
		}, shopCart : function(){
				//jQuery
			jQuery.noConflict();
			
			(function($) {
				$(document).ready(function(){		
		//shop cart

$('.val').find('td').each(function(){

	$(this).find('.productitemcell:odd').addClass('odd');
	
	

}).end().find('td.sizeCol').find('.productitemcell').each(function(){

	$(this).text($(this).text().split(' - ')[1]);

});

function removeItem(){
	if (typeof UpdateItemQuantity !== 'function') return;
	
	var fncdd = UpdateItemQuantity;
	UpdateItemQuantity = function() {
      $('.val').find('td').each(function(){

	$(this).find('.productitemcell:odd').addClass('odd');
	
	

}).end().find('td.sizeCol').find('.productitemcell').each(function(){

	$(this).text($(this).text().split(' - ')[1]);

});  
Cufon.refresh();
        var res = fncdd.apply(this, arguments);
       $('.val').find('td').each(function(){

	$(this).find('.productitemcell:odd').addClass('odd');
	
	

}).end().find('td.sizeCol').find('.productitemcell').each(function(){

	$(this).text($(this).text().split(' - ')[1]);

}); 	
	
	Cufon.refresh();
	
	}
Cufon.refresh();


}
removeItem();
window.alert = function (msg) {

    $.jGrowl(msg, {
        beforeOpen: function () {
$('.val').find('td').each(function(){

	$(this).find('.productitemcell:odd').addClass('odd');
	
	

}).end().find('td.sizeCol').find('.productitemcell').each(function(){

	$(this).text($(this).text().split(' - ')[1]);

});
        }

    });
};






		
				}); //END JQUERY
			})(jQuery);		
		}, noShop : function(){
				//jQuery
			jQuery.noConflict();
			
			(function($) {
				$(document).ready(function(){	
				
				

//FLOORING CALC
$('#calcFlooringType').change(function(){
	if ($(this).attr('value') !== 'Carpet') {
		
		$('.broadloam').hide();
	} else {
		$('.broadloam').show();

	}
});

$('#calcFlooringType').change();
$('#calculate').click(function(e){

	var width, height, m2, broadloom;



	width = $('#floorWidth').attr('value');
	height = $('#floorHeight').attr('value');

if (!width || !height) { return false; } else {
	m2 = $('#outputM2').attr('value', width * height);
	broadloom = $('#outputBroad').attr('value', Math.ceil((width * height) / 3.66));

	e.preventDefault();
}
});



				
		$('#largeLink').find('img').each(function(){
		
			$(this).appendTo('#largeImageMask');
		
		});
					$('#largeLink').removeAttr('href').removeAttr('rel').remove();

					$('.policyAndBuy').remove();
		
				}); //END JQUERY
			})(jQuery);	
		}	
	}
		
	Site.init();
