//Public javascript functions


/*
	Slimbox v1.7 - The ultimate lightweight Lightbox clone
	(c) 2007-2009 Christophe Beyls <http://www.digitalia.be>
	MIT-style license.
*/
var Slimbox=(function(){var F=window,n=Browser.Engine.trident4,u,g,G=-1,o,w,E,v,y,M,s,m={},t=new Image(),K=new Image(),I,a,h,q,J,e,H,c,A,L,x,i,d,C;F.addEvent("domready",function(){$(document.body).adopt($$(I=new Element("div",{id:"lbOverlay",events:{click:D}}),a=new Element("div",{id:"lbCenter"}),H=new Element("div",{id:"lbBottomContainer"})).setStyle("display","none"));h=new Element("div",{id:"lbImage"}).injectInside(a).adopt(q=new Element("div",{styles:{position:"relative"}}).adopt(J=new Element("a",{id:"lbPrevLink",href:"#",events:{click:B}}),e=new Element("a",{id:"lbNextLink",href:"#",events:{click:f}})));c=new Element("div",{id:"lbBottom"}).injectInside(H).adopt(new Element("a",{id:"lbCloseLink",href:"#",events:{click:D}}),A=new Element("div",{id:"lbCaption"}),L=new Element("div",{id:"lbNumber"}),new Element("div",{styles:{clear:"both"}}))});function z(){var N=F.getScroll(),O=F.getSize();$$(a,H).setStyle("left",N.x+(O.x/2));if(v){I.setStyles({left:N.x,top:N.y,width:O.x,height:O.y})}}function l(N){["object",n?"select":"embed"].forEach(function(P){Array.forEach(document.getElementsByTagName(P),function(Q){if(N){Q._slimbox=Q.style.visibility}Q.style.visibility=N?"hidden":Q._slimbox})});I.style.display=N?"":"none";var O=N?"addEvent":"removeEvent";F[O]("scroll",z)[O]("resize",z);document[O]("keydown",p)}function p(O){var N=O.code;return u.closeKeys.contains(N)?D():u.nextKeys.contains(N)?f():u.previousKeys.contains(N)?B():false}function B(){return b(w)}function f(){return b(E)}function b(N){if(N>=0){G=N;o=g[N][0];w=(G||(u.loop?g.length:0))-1;E=((G+1)%g.length)||(u.loop?0:-1);r();a.className="lbLoading";m=new Image();m.onload=k;m.src=o}return false}function k(){a.className="";d.set(0);h.setStyles({backgroundImage:"url("+o+")",display:""});q.setStyle("width",m.width);$$(q,J,e).setStyle("height",m.height);A.set("html",g[G][1]||"");L.set("html",(((g.length>1)&&u.counterText)||"").replace(/{x}/,G+1).replace(/{y}/,g.length));if(w>=0){t.src=g[w][0]}if(E>=0){K.src=g[E][0]}M=h.offsetWidth;s=h.offsetHeight;var P=Math.max(0,y-(s/2)),N=0,O;if(a.offsetHeight!=s){N=i.start({height:s,top:P})}if(a.offsetWidth!=M){N=i.start({width:M,marginLeft:-M/2})}O=function(){H.setStyles({width:M,top:P+s,marginLeft:-M/2,visibility:"hidden",display:""});d.start(1)};if(N){i.chain(O)}else{O()}}function j(){if(w>=0){J.style.display=""}if(E>=0){e.style.display=""}C.set(-c.offsetHeight).start(0);H.style.visibility=""}function r(){m.onload=$empty;m.src=t.src=K.src=o;i.cancel();d.cancel();C.cancel();$$(J,e,h,H).setStyle("display","none")}function D(){if(G>=0){r();G=w=E=-1;a.style.display="none";x.cancel().chain(l).start(0)}return false}Element.implement({slimbox:function(N,O){$$(this).slimbox(N,O);return this}});Elements.implement({slimbox:function(N,Q,P){Q=Q||function(R){return[R.href,R.title]};P=P||function(){return true};var O=this;O.removeEvents("click").addEvent("click",function(){var R=O.filter(P,this);return Slimbox.open(R.map(Q),R.indexOf(this),N)});return O}});return{open:function(P,O,N){u=$extend({loop:false,overlayOpacity:0.8,overlayFadeDuration:400,resizeDuration:400,resizeTransition:false,initialWidth:250,initialHeight:250,imageFadeDuration:400,captionAnimationDuration:400,counterText:"Image {x} of {y}",closeKeys:[27,88,67],previousKeys:[37,80],nextKeys:[39,78]},N||{});x=new Fx.Tween(I,{property:"opacity",duration:u.overlayFadeDuration});i=new Fx.Morph(a,$extend({duration:u.resizeDuration,link:"chain"},u.resizeTransition?{transition:u.resizeTransition}:{}));d=new Fx.Tween(h,{property:"opacity",duration:u.imageFadeDuration,onComplete:j});C=new Fx.Tween(c,{property:"margin-top",duration:u.captionAnimationDuration});if(typeof P=="string"){P=[[P,O]];O=0}y=F.getScrollTop()+(F.getHeight()/2);M=u.initialWidth;s=u.initialHeight;a.setStyles({top:Math.max(0,y-(s/2)),width:M,height:s,marginLeft:-M/2,display:""});v=n||(I.currentStyle&&(I.currentStyle.position!="fixed"));if(v){I.style.position="absolute"}x.set(0).start(u.overlayOpacity);z();l(1);g=P;u.loop=u.loop&&(g.length>1);return b(O)}}})();

// AUTOLOAD CODE BLOCK (MAY BE CHANGED OR REMOVED)
Slimbox.scanPage = function() {
	$$(document.links).filter(function(el) {
		return el.rel && el.rel.test(/^lightbox/i);
	}).slimbox({/* Put custom options here */}, null, function(el) {
		return (this == el) || ((this.rel.length > 8) && (this.rel == el.rel));
	});
};
window.addEvent("domready", Slimbox.scanPage);

/*
Mootools Content Slider Class v2
Daniel Stout
http://stoutlabs.com
*/
var SL_Slider=new Class({Implements:[Options],numNav:new Array(),timer:null,isSliding:0,direction:1,options:{slideTimer:8000,orientation:"horizontal",fade:false,isPaused:false,transitionTime:1100,transitionType:"cubic:out",container:null,items:null,itemNum:0,numNavActive:false,numNavHolder:null,playBtn:null,prevBtn:null,nextBtn:null},initialize:function(b){var a=this;this.setOptions(b);a.options.container.setStyle("overflow","hidden");if(a.options.playBtn!=null){a.options.playBtn.set("text","pause");a.options.playBtn.addEvents({click:function(){a.pauseIt()},mouseenter:function(){this.setStyle("cursor","pointer")},mouseleave:function(){}})}if(a.options.prevBtn&&a.options.nextBtn){a.options.prevBtn.addEvents({click:function(){if(a.isSliding==0){if(a.options.isPaused==false){$clear(a.timer);a.timer=a.slideIt.periodical(a.options.slideTimer,a,null)}a.direction=0;a.slideIt()}},mouseenter:function(){this.setStyle("cursor","pointer")},mouseleave:function(){}});this.options.nextBtn.addEvents({click:function(){if(a.isSliding==0){if(a.options.isPaused==false){$clear(a.timer);a.timer=a.slideIt.periodical(a.options.slideTimer,a,null)}a.direction=1;a.slideIt()}},mouseenter:function(){this.setStyle("cursor","pointer")},mouseleave:function(){}})}a.options.items.each(function(e,d){e.setStyle("position","absolute");var c=e.getSize().y;var j=e.getSize().x;if(a.options.orientation=="vertical"){e.setStyle("top",(-1*c));e.setStyle("left",0)}else{if(a.options.orientation=="none"){e.setStyle("left",0);e.setStyle("top",0);e.set("opacity",0)}else{e.setStyle("left",(-1*j))}}if(a.options.numNavActive==true){var h=new Element("li",{id:"num"+d});var g=new Element("a",{"class":"numbtn",html:(d+1)});h.adopt(g);a.options.numNavHolder.adopt(h);a.numNav.push(g);g.set("morph",{duration:100,transition:Fx.Transitions.linear,link:"ignore"});g.addEvents({click:function(){a.numPress(d)},mouseenter:function(){this.setStyle("cursor","pointer")}});if(d==a.options.itemNum){var f=a.numNav[d];f.addClass("active")}}})},start:function(){var a=this;a.slideIt(a.options.itemNum);if(a.options.isPaused==false){a.timer=a.slideIt.periodical(a.options.slideTimer,a,null);if(a.options.playBtn){a.options.playBtn.set("text","pause")}}else{if(a.options.playBtn){a.options.playBtn.set("text","play")}}},slideIt:function(i){var j=this;var l=j.options.items[j.options.itemNum];if(j.options.numNavActive==true){var h=j.numNav[j.options.itemNum]}if(i!=null){if(j.options.itemNum!=i){if(j.options.itemNum>i){j.direction=0}else{j.direction=1}j.options.itemNum=i}}else{j.changeIndex()}var e=j.options.items[j.options.itemNum];if(j.direction==0){var c=j.options.container.getSize().x;var a=(-1*e.getSize().x);var b=j.options.container.getSize().y;var k=(-1*e.getSize().y)}else{var c=(-1*j.options.container.getSize().x);var a=e.getSize().x;var b=(-1*j.options.container.getSize().y);var k=e.getSize().y}if(j.options.numNavActive==true){var g=j.numNav[j.options.itemNum];g.addClass("active")}var f=new Fx.Morph(e,{duration:j.options.transitionTime,transition:j.options.transitionType,link:"ignore",onStart:function(){j.isSliding=1},onComplete:function(){j.isSliding=0}});if(j.options.orientation=="vertical"){if(j.options.fade==true){f.start({opacity:[0,1],top:[k,0]})}else{f.start({top:[k,0]})}}else{if(j.options.orientation=="none"){f.start({opacity:[0,1]})}else{if(j.options.fade==true){f.start({opacity:[0,1],left:[a,0]})}else{f.start({left:[a,0]})}}}if(l!=e){var d=new Fx.Morph(l,{duration:j.options.transitionTime,transition:j.options.transitionType,link:"ignore"});if(j.options.numNavActive==true){h.removeClass("active")}if(j.options.orientation=="vertical"){if(j.options.fade==true){d.start({opacity:[0],top:[(b)]})}else{d.start({top:[(b)]})}}else{if(j.options.orientation=="none"){d.start({opacity:[1,0]})}else{if(j.options.fade==true){d.start({opacity:[0],left:[(c)]})}else{d.start({left:[(c)]})}}}}},pauseIt:function(){var a=this;if(a.isSliding==0){if(a.options.isPaused==false){a.options.isPaused=true;$clear(a.timer);a.options.playBtn.set("text","play")}else{a.options.isPaused=false;a.slideIt();a.timer=a.slideIt.periodical(a.options.slideTimer,this,null);a.options.playBtn.set("text","pause")}}},changeIndex:function(){var a=this;var b=a.options.items.length;if(a.direction==1){if(a.options.itemNum<(b-1)){a.options.itemNum++}else{a.options.itemNum=0}}else{if(a.direction==0){if(a.options.itemNum>0){a.options.itemNum--}else{a.options.itemNum=(b-1)}}}},numPress:function(b){var a=this;if((a.isSliding==0)&&(a.options.itemNum!=b)){if(a.options.isPaused==false){$clear(a.timer);a.timer=a.slideIt.periodical(a.options.slideTimer,this,null)}a.slideIt(b)}}});

/* ----------------------------------------------------------------------------------------------- End third party classes */


/* ----------------------------------------------------------------------------------------------- modalBox class */

//Display modal overlay box
var modalBox = new Class({
	
	Implements: Options,

	options: {
		closeOnClick:   true,
		showCloseButton:true,
		overlayOpacity: 0.8,
		titleText:      'Message',
		content:        $empty,
		width:          '500px'
	},
	
	
	initialize: function(options){
		this.setOptions(options);
		this.closeOnClick    = this.options.closeOnClick;
		this.showCloseButton = this.options.showCloseButton;
		this.overlayOpacity  = this.options.overlayOpacity;
		this.titleText       = this.options.titleText;
		this.width           = this.options.width;
		this.overlay         = $empty;
		this.contentBox      = $empty;
	},
	
	
	//Show the current modalBox
	show: function(){
		
		//Create an overlay
		this.overlay = new Element('div',{
		'id':'modalOverlay', 
		'class':'modalOverlay', 
		'styles':{
			'width':'100%',
			'height':window.getScrollSize().y,
			'position':'absolute',
			'top':0,
			'left':0,
			'z-index':1000,
			'opacity':0
			}
		});
		
		//Inject overlay into document body
		this.overlay.inject(document.body);
		
		//Create title bar
		var titleBar = new Element('div',{'id':'modalTitleBar'});
		
		//Create title
		var title = new Element('h1',{'id':'modalTitle','html':this.titleText});
		
		//Check if including close button
		if(this.showCloseButton){
		
			//Create close button
			var closeButton = new Element('a',{
				'id':'modalCloseButton',
				'href':'#',
				'html':'<span>Close</span>',
				'events':{
					'click': function(e){
						e.stop();
						this.hide();
					}.bind(this)
				}
			});
			//Inject close button into title bar
			titleBar.adopt(title, closeButton);
		}
		
		//Create content box
		this.contentBox = new Element('div',{
		'id':'modalContentBox',
		'styles':{
			'width':this.width,
			'position':'absolute',
			'z-index':1001
			}
		});
		
		//Inject title bar
		this.contentBox.adopt(titleBar);
		
		//Check if content is just a string
		if($type(this.options.content) == "string"){
			this.options.content = '<p>'+this.options.content+'</p>';
		}
		
		//Inject content into box
		this.contentBox.adopt(this.options.content);
		
		//Inject content box into document body
		this.contentBox.inject(document.body);
		
		//Get size of content box
		var contentBoxSize = this.contentBox.getSize();

		//Update content box position
		this.contentBox.setStyles({
			'top': (window.getScroll().y+((window.getSize().y/2)-(contentBoxSize.y/2))),
			'left': (window.getSize().x/2)-((this.width).toInt()/2)
		});
		
		//Hide things like select lists and embeded flash
		this.iframeShim(0);

		//Show the overlay
		this.overlay.set('opacity',this.overlayOpacity);
		
		//If closeOnClick is set to true
		if(this.closeOnClick){
			//Add click event to overlay
			this.overlay.addEvent('click',function(el){
				this.hide();
			}.bind(this));
		}
	
	},//End show the current modalBox
	
	
	//Hide (destroy) modalBox
	hide: function(){
		//Destroy content and overlay
		this.contentBox.destroy();
		this.overlay.destroy();
		//Bring select lists and embeded flash back
		this.iframeShim(1);
	},
	
	
	//Set the opacity of iframe shim objects
	iframeShim: function(overlayOpacity){
		if(Browser.Engine.trident4 || (Browser.Engine.gecko && Browser.Platform.mac)) {
			$$('select').each(function(select){
				select.setStyle('opacity', overlayOpacity);
			});
		}
	}
	
});//End modalBox



/* ----------------------------------------------------------------------------------------------- confirmationDialog class */

//Confirmation dialog, displays a modal box with a message and Yes/No buttons
var confirmationDialog = new Class({
	
	Implements: Options,

	options: {
		onConfirm: $empty,
		onDeny:    $empty
	},
	
	initialize: function(message,options){
		this.setOptions(options);
		this.message   = message;
		this.modal     = new modalBox({'closeOnClick':false,'titleText':'Are you sure?','width':'300px'});
	},
	
	
	//Show the dialog
	show: function(){

		var dialogWrapper = new Element('div');
		
		var messageContainer = new Element('p',{'html':this.message});
		
		var yesButton = new Element('button',{
			'id':'confirmButtonYes',
			'name':'confirmButtonYes',
			'class':'dialogButton',
			'html':'<span>Yes</span>',
			'events':{
				'click':this.options.onConfirm
			}
		});
		
		var noButton = new Element('button',{
			'id':'confirmButtonNo',
			'name':'confirmButtonNo',
			'class':'dialogButton',
			'html':'<span>No</span>',
			'events':{
				'click':this.options.onDeny
			}
		});

		messageContainer.inject(dialogWrapper);
		yesButton.inject(dialogWrapper);
		noButton.inject(dialogWrapper);
		
		this.modal.setOptions({'content':dialogWrapper});
		this.modal.show();
		
	},//End show the dialog
	
	
	//Hide (destroy) dialog
	hide: function(){
		this.modal.hide();
	}
	
});//End confirmationDialog


//Setup cs functions
var csFunctions = {//Start csFunctions

/* ----------------------------------------------------------------------------------------------- waitDialog function */
	
	//Display the please wait dialog
	waitDialog: function(triggers,message){
		
		//Stick message in paragraph
		var dialogMessage = new Element('p',{'html':message});
		
		//Create confirmation dialog
		var waitModal = new modalBox({'closeOnClick':false,'closeButton':false,'content':dialogMessage,'width':'100px'});
		
		triggers.each(function(el){
			el.addEvent('click',function(e){	
				waitModal.show();		   
			});					 
		});
	},
	
	

/* ----------------------------------------------------------------------------------------------- confirmDialog function */
	
	//Display a dialog confirming the user's choice
	confirmDialog: function(triggers,message){

		//Create confirmation dialog
		var confirmDialog = new confirmationDialog(message,{});
		
		triggers.each(function(el){
			el.addEvent('click',function(e){
				
				e.stop();
				
				confirmDialog.setOptions({
					'onConfirm':function(){ 
						//Continue to original link
						window.location = el.getProperty('href');
					},
					'onDeny':function(){ 
						confirmDialog.hide();
					}
				});
				
				confirmDialog.show();		   
			});					 
		});
		
	},//End confirmDialog
	
/* ----------------------------------------------------------------------------------------------- displayCartDetails function */
	
	//Display cart details drop down
	displayCartDetails: function(){
		
		//Get cart default wrapper (only exists if items in cart)
		var cartDefaultWrapper = $('cartDefaultWrapper');
		
		//Get header
		var header = $('header');
		
		//Check cart and header exists
		if(cartDefaultWrapper && header){//Start cart and header exists
			
			//Move to header
			header.grab(cartDefaultWrapper);
			
			//Change id to cartWrapper
			cartDefaultWrapper.set('id','cartWrapper');
			
			//Now get as cartWrapper
			var cartWrapper = $('cartWrapper');

			//Get cart edit wrapper
			var cartEditWrapper = $('cartEditWrapper');
			
			//Create toggle cart button
			var cartToggleButton = new Element('button',{'id':'toggleCart'});
			
			//Inject toggle button into header
			cartToggleButton.inject(header);
			
			//Set slide FX for cart drop down
			var cartDropDown = new Fx.Slide(cartEditWrapper,{transition:Fx.Transitions.Quart.easeOut});
			
			//Get cartToggleState cookie
			var cartToggleState = parseInt(Cookie.read('cartToggleState'));
			
			//Quick function to hide selects in IE6
			function shimSelects(opacity){
				if(Browser.Engine.trident4 || (Browser.Engine.gecko && Browser.Platform.mac)) {
					$$('select').each(function(select){
						select.setStyle('opacity', opacity);
					});
				}
			}
				
			//Check initial toggle state
			if(cartToggleState){//Start check initial state
				
				//Is set
				
				//Hide any selects in IE6
				shimSelects(0);
				
				//Show cart
				cartDropDown.show();
				
				//Set button text and toggle classes
				cartToggleButton.set('html','<span>Hide cart</span>');
				cartToggleButton.removeClass('cartOpen');
				cartToggleButton.addClass('cartClose');
				
			}else{//Else check initial state
				
				//Not set
				
				//Hide cart
				cartDropDown.hide();
				
				//Show any selects in IE6
				shimSelects(1);
				
				//Set button text and toggle classes
				cartToggleButton.set('html','<span>View cart</span>');
				cartToggleButton.removeClass('cartClose');
				cartToggleButton.addClass('cartOpen');
				
			}//End check initial state
			
			//Click event for cart toggle
			cartToggleButton.addEvent('click', function(e){//Start toggle click event
				
				//Check current state of cart container
				if(cartToggleState){//Start check state
					
					//Is open
					
					//Close container
					cartDropDown.slideOut();
					
					//Show any selects in IE6
					shimSelects(1);
				
					//Set internal state
					cartToggleState = 0;
					
					//Set cartToggleState cookie
					Cookie.write('cartToggleState','0',{duration: 1, path: "/"});
					
					//Set button text and toggle classes
					cartToggleButton.set('html','<span>View cart</span>');
					cartToggleButton.removeClass('cartClose');
					cartToggleButton.addClass('cartOpen');
	
				}else{//Else check state
					
					//Is closed
					
					//Hide any selects in IE6
					shimSelects(0);
				
					//Open container
					cartDropDown.slideIn();
					
					//Set internal state
					cartToggleState = 1;
					
					//Set cartToggleState cookie
					Cookie.write('cartToggleState','1',{duration: 1, path: "/"});
					
					//Set button text and toggle classes
					cartToggleButton.set('html','<span>Hide cart</span>');
					cartToggleButton.removeClass('cartOpen');
					cartToggleButton.addClass('cartClose');
					
				}//End check state
				
				
			}.bind(this));//End toggle click event
	
		}//End cart and header exists
		
	},

/* ----------------------------------------------------------------------------------------------- featuredProduct function */
	
	//Update featured product
	featuredProduct: function(){//Start featuredProducts
		
		//Get featured product thumbs
		var productThumbs = $$('.featuredProduct');
		
		//Set ajax request url
		var requestURL = 'http://www.hdasecurity.com.au/ajax_get_featured_product/';

		//If product thumbs exist
		if(productThumbs){//Start check exists
			
			//Get total number of thumbnails
			var numContainers = productThumbs.length;
			
			//Thumbnail update function
			var updateThumb = function() {
				
				//Set vars
				var container     = this.container;
				var requestURL    = this.requestURL;
				var startPosition = this.startPosition;
				var thumbnail     = this.container.getElement('a');
				var updateChain   = new Chain();
				
				//New thumbnail holder
				var newThumbnail;
				
				//New thumbnail request
				var requestThumb = new Request({
					method:    'get',
					onSuccess: function(html){
						if(html.length<1){
							//Return start to orignal position
							this.startPosition = this.index;
						}else{
							//Get new content
							newThumbnail = html;
							//Fire update chain
							updateChain.callChain();
						}
					}.bind(this)
				});
				
				//New conainer fx
				var containerFx = new Fx.Tween(container, {
					duration:   '1000',
					transition: 'sine:in:out',
					onComplete: function(){
						updateChain.callChain();
					}
				});
				 
				//Set update chain
				updateChain.chain(
					function(){ requestThumb.send({url:requestURL+startPosition}); },//Request new thumbnail
					function(){ containerFx.start('opacity',0); },//Fade container out
					function(){
						//Replace thumbnail
						container.set('html', newThumbnail);
						//Make sure new image has loaded
						container.getElement('img').addEvent('load',function(e){
							//Continue chain
							this.callChain();
						}.bind(this));
					},
					function(){
						containerFx.start('opacity',1);
					}//Fade container back in
				);
				
				//Call chain
				updateChain.callChain();

				//If limit reached
				if(this.startPosition < this.limit){					
					//Start is number of thumbs + current start position
					this.startPosition = this.numContainers + this.startPosition;
				}else{
					//Return start to orignal position
					this.startPosition = this.index;
				}
				
			};
				
			//Loop each product thumb
			productThumbs.each(function(container,index){

				var args = new Hash({container: container, requestURL: requestURL, startPosition: index+numContainers, index: index, numContainers: numContainers, limit: index+50});
				
				var updatePeriodical = updateThumb.periodical(10000,args);

			}.bind(this));
			
		}//End check exists
		
	},//End featuredProduct

/* ----------------------------------------------------------------------------------------------- featuredProducts function */
	
	//Turn slide lists into content sliders
	featuredProducts: function(){
		
		//Get container
		var container = $('featuredProducts');
		
		//Check container exist
		if(container){//Start containers exist
				
			//Get array of content blocks
			var contentBlocks = container.getElements('.featuredProducts');
		
			//Check blocks exist
			if(contentBlocks){//Start blocks exists
				
				//Change class of container
				container.set('class','listSlider');
				
				//Create wrapper
				var wrapper = new Element('div',{'class':'listSlideWrapper'}).wraps(container);
				
				//Create and insert prev next controls
				var prevBtn = new Element('div',{'class':'prevButton','title':'View previous','html':'<span>Previous</span>'}).inject(wrapper);
				var nextBtn = new Element('div',{'class':'nextButton','title':'View next','html':'<span>Next</span>'}).inject(wrapper);
	
				//Create slider instance       
				var containerSlider = new SL_Slider({
					slideTimer: 10000,
					fade: true,
					transitionTime: 1000,
					isPaused: false,
					container: container,
					items: contentBlocks,
					prevBtn: prevBtn,
					nextBtn: nextBtn
				});
				
				//Start slider
				containerSlider.start();
				
			}//End blocks exists
			
		}//End containers exist
		
	},//End featuredProducts

/* ----------------------------------------------------------------------------------------------- listingClick function */
	
	//Makes entire listing block hoverable and clickable
	listingClick: function(arr_listingBlocks){//Start listingClick
		
		if(arr_listingBlocks){//Start is listing blocks
			
			arr_listingBlocks.each(function(listingBlock,i){
				
				listingBlock.addEvents({
					'mouseenter':function(e){
						this.addClass('listingHover');
					},
					'mouseleave':function(e){
						this.removeClass('listingHover');
					},
					'click':function(e){
						//Go to link specified in the title
						window.location = this.getElement('.title a').get('href');
					}
					
				});		
											
			});
			
		}//End is listing blocks
		
	},//End listingClick
	
/* ----------------------------------------------------------------------------------------------- init function */
	
	//Initialise cs functions
	init: function(){
		
		this.waitDialog($$('.waitModal'),'Please wait...');
		this.confirmDialog($$('.linkDelete'),'Are you sure you want to delete this?');
		this.displayCartDetails();
		this.listingClick($$('.helpArticle'));
		this.listingClick($$('.productCategoryBlock'));
		this.featuredProducts();
		
	}//End init
									 
};//End csFunctions


window.addEvent('domready', csFunctions.init.bind(csFunctions));