$j = jQuery.noConflict();

$j(document).ready(function(){
		
		if($j.support.leadingWhitespace) {
/* 			alert('IE'); */
			// NON IE = true
			// IE = false
		}
		else
		{
/* 			alert('NOT IE'); */
		}
		
if($j.support.leadingWhitespace){
	
		if($j('#banner #slides .aside').length>0){
		$j('#banner .dots ul').remove();	
		$j('#banner #slides > .aside').show();
		$j('#banner #slides').anythingSlider({
			width               : 1231,      //1454// Override the default CSS width
			height              : 328,      // Override the default CSS height
			expand              : false,     // If true, the entire slider will expand to fit the parent element
			resizeContents      : false,      // If true, solitary images/objects in the panel will expand to fit the viewport
			showMultiple        : false,     // Set this value to a number and it will show that many slides at once
			theme               : 'default', // Theme name - adds a class name to the base element "anythingSlider-{theme}" so the loaded theme will work.
			startPanel          : 1,         // This sets the initial panel
			changeBy            : 1,         // Amount to go forward or back when changing panels.
			hashTags            : false,      // Should links change the hashtag in the URL?
			infiniteSlides      : true,      // if false, the slider will not wrap
			enableKeyboard      : false,      // if false, keyboard arrow keys will not work for the current panel.
			buildArrows         : false,      // If true, builds the forwards and backwards buttons
			buildNavigation     : true,      // If true, builds a list of anchor links to link to each panel
			enableNavigation    : true,      // if false, navigation links will still be visible, but not clickable.
			toggleControls      : false,     // if true, slide in controls (navigation + play/stop button) on hover and slide change, hide @ other times
			appendControlsTo    : $j('#banner .dots'),      // A HTML element (jQuery Object, selector or HTMLNode) to which the controls will be appended if not null
			enablePlay          : false,      // if false, the play/stop button will still be visible, but not clickable.
			autoPlay            : true,      // This turns off the entire slideshow FUNCTIONALY, not just if it starts running or not
			autoPlayLocked      : false,     // If true, user changing slides will not stop the slideshow
			startStopped        : false,     // If autoPlay is on, this can force it to start stopped
			pauseOnHover        : false,      // If true & the slideshow is active, the slideshow will pause on hover
			stopAtEnd           : false,     // If true & the slideshow is active, the slideshow will stop on the last page. This also stops the rewind effect when infiniteSlides is false.
			playRtl             : false,     // If true, the slideshow will move right-to-left
			delay               : 22000,      // How long between slideshow transitions in AutoPlay mode (in milliseconds)
			resumeDelay         : 0,     // Resume slideshow after user interaction, only if autoplayLocked is true (in milliseconds).
			animationTime       : 1300,       // How long the slideshow transition takes (in milliseconds)
			easing              : "easeInOutExpo",   // Anything other than "linear" or "swing" requires the easing plugin
			maxOverallWidth     : 32766     // Max width (in pixels) of combined sliders (side-to-side); set to 32766 to prevent problems with Opera			
			/*
onSlideBegin        : function(event, slider){
				if(slider.$targetPage.text().indexOf("Site does matter")!= -1){
					$j('#banner #mac').delay(1000).show().animate({top:0,opacity:1}, 1000, "easeOutExpo");
				}else if(slider.$currentPage.text().indexOf("Site does matter")!= -1){
					$j('#banner #mac').animate({top:1080,opacity:0}, 1000, "easeOutExpo", function(){
						$j(this).hide();
					});
				}
			}
*/
		});
		
			//First Slide (animate)
		$j('.slide1:first h2').css('right','0px').css('right','1250px').css('opacity','0').delay(1400).animate({right:0,opacity:1}, 1000, "easeOutExpo");
		$j('.slide1:first h3').css('right','0px').css('right','550px').css('opacity','0').delay(1000).animate({right:0,opacity:1}, 1200, "easeOutExpo");
		$j('.slide1:first h4').css('right','0px').css('right','550px').css('opacity','0').delay(1100).animate({right:0,opacity:1}, 1100, "easeOutExpo");
		$j('.slide1:first h5').css('right','0px').css('right','550px').css('opacity','0').delay(1200).animate({right:0,opacity:1}, 1000, "easeOutExpo");
		$j('.slide1:first .figure').css('top','0px').css('top','430px').css('opacity','0').delay(1400).animate({top:0,opacity:1}, 1000, "easeOutExpo");
		
		
		$j('#banner #slides').anythingSliderFx({
			inFx : {
                // '.slide1 h2' : { left : '0px', duration: 800, easing : 'easeOutExpo' },
                // '.slide1 h3' : { left : '0px', duration: 1200, easing : 'easeOutExpo' },
				'.slide1 h2' : { right : '0px', duration: 800, opacity:1, easing : 'easeOutExpo' },
				'.slide1 h3' : { right : '0px', duration: 1000, opacity:1, easing : 'easeOutExpo' },
				'.slide1 h4' : { right : '0px', duration: 1100, opacity:1, easing : 'easeOutExpo' },
				'.slide1 h5' : { right : '0px', duration: 1200, opacity:1, easing : 'easeOutExpo' },
				'.slide1 .figure' : { top : '0px', duration: 1400, opacity:1, easing : 'easeOutExpo' },
				'.slide2 h2' : { right : '0px', duration: 800, opacity:1, easing : 'easeOutExpo' },
				'.slide2 h3' : { right : '0px', duration: 1000, opacity:1, easing : 'easeOutExpo' },
				'.slide2 h4' : { right : '0px', duration: 1100, opacity:1, easing : 'easeOutExpo' },
				'.slide2 h5' : { right : '0px', duration: 1200, opacity:1, easing : 'easeOutExpo' },
				'.slide2 .figure' : { top : '0px', duration: 1400, opacity:1, easing : 'easeOutExpo' },
				'.slide3 h2' : { right : '0px', duration: 800, opacity:1, easing : 'easeOutExpo' },
				'.slide3 h3' : { right : '0px', duration: 1000, opacity:1, easing : 'easeOutExpo' },
				'.slide3 h4' : { right : '0px', duration: 1100, opacity:1, easing : 'easeOutExpo' },
				'.slide3 h5' : { right : '0px', duration: 1200, opacity:1, easing : 'easeOutExpo' },
				'.slide3 .figure' : { top : '0px', duration: 1400, opacity:1, easing : 'easeOutExpo' }
			},
			outFx : {
                // '.slide1 h2' : { left : '1231px', duration: 1200, easing : 'easeOutExpo' },
                // '.slide1 h3' : { left : '1231px', duration: 800, easing : 'easeOutExpo' },
				'.slide1 h2' : { right : '1250px', duration: 1400, opacity:0, easing : 'easeOutExpo' },
				'.slide1 h3' : { right : '550px', duration: 1200, opacity:0, easing : 'easeOutExpo' },
				'.slide1 h4' : { right : '550px', duration: 1100, opacity:0, easing : 'easeOutExpo' },
				'.slide1 h5' : { right : '550px', duration: 1000, opacity:0, easing : 'easeOutExpo' },
				'.slide1 .figure' : { top : '430px', duration: 1000, opacity:0, easing : 'easeOutExpo' },
				'.slide2 h2' : { right : '1250px', duration: 1400, opacity:0, easing : 'easeOutExpo' },
				'.slide2 h3' : { right : '550px', duration: 1200, opacity:0, easing : 'easeOutExpo' },
				'.slide2 h4' : { right : '550px', duration: 1100, opacity:0, easing : 'easeOutExpo' },
				'.slide2 h5' : { right : '550px', duration: 1000, opacity:0, easing : 'easeOutExpo' },
				'.slide2 .figure' : { top : '400px', duration: 800, opacity:0, easing : 'easeOutExpo' },	
				'.slide3 h2' : { right : '650px', duration: 1400, opacity:0, easing : 'easeOutExpo' },
				'.slide3 h3' : { right : '500px', duration: 1200, opacity:0, easing : 'easeOutExpo' },
				'.slide3 h4' : { right : '500px', duration: 1100, opacity:0, easing : 'easeOutExpo' },
				'.slide3 h5' : { right : '500px', duration: 1000, opacity:0, easing : 'easeOutExpo' },
				'.slide3 .figure' : { top : '420px', duration: 1000, opacity:0, easing : 'easeOutExpo' }
			}
		});
		$j("#banner .previous a").click(function(){
			$j('#banner #slides').data('AnythingSlider').goBack(true);
			return false;
		});
		$j("#banner .next a").click(function(){
			$j('#banner #slides').data('AnythingSlider').goForward(true);
			return false;
		});
	}
}
else // ********************************************* FOR IE ONLY ********************************
{
			if($j('#banner #slides .aside').length>0){
		$j('#banner .dots ul').remove();	
		$j('#banner #slides > .aside').show();
		$j('#banner #slides').anythingSlider({
			width               : 1231,      //1454// Override the default CSS width
			height              : 328,      // Override the default CSS height
			expand              : false,     // If true, the entire slider will expand to fit the parent element
			resizeContents      : false,      // If true, solitary images/objects in the panel will expand to fit the viewport
			showMultiple        : false,     // Set this value to a number and it will show that many slides at once
			theme               : 'default', // Theme name - adds a class name to the base element "anythingSlider-{theme}" so the loaded theme will work.
			startPanel          : 1,         // This sets the initial panel
			changeBy            : 1,         // Amount to go forward or back when changing panels.
			hashTags            : false,      // Should links change the hashtag in the URL?
			infiniteSlides      : true,      // if false, the slider will not wrap
			enableKeyboard      : false,      // if false, keyboard arrow keys will not work for the current panel.
			buildArrows         : false,      // If true, builds the forwards and backwards buttons
			buildNavigation     : true,      // If true, builds a list of anchor links to link to each panel
			enableNavigation    : true,      // if false, navigation links will still be visible, but not clickable.
			toggleControls      : false,     // if true, slide in controls (navigation + play/stop button) on hover and slide change, hide @ other times
			appendControlsTo    : $j('#banner .dots'),      // A HTML element (jQuery Object, selector or HTMLNode) to which the controls will be appended if not null
			enablePlay          : false,      // if false, the play/stop button will still be visible, but not clickable.
			autoPlay            : true,      // This turns off the entire slideshow FUNCTIONALY, not just if it starts running or not
			autoPlayLocked      : false,     // If true, user changing slides will not stop the slideshow
			startStopped        : false,     // If autoPlay is on, this can force it to start stopped
			pauseOnHover        : false,      // If true & the slideshow is active, the slideshow will pause on hover
			stopAtEnd           : false,     // If true & the slideshow is active, the slideshow will stop on the last page. This also stops the rewind effect when infiniteSlides is false.
			playRtl             : false,     // If true, the slideshow will move right-to-left
			delay               : 22000,      // How long between slideshow transitions in AutoPlay mode (in milliseconds)
			resumeDelay         : 0,     // Resume slideshow after user interaction, only if autoplayLocked is true (in milliseconds).
			animationTime       : 1300,       // How long the slideshow transition takes (in milliseconds)
			easing              : "easeInOutExpo",   // Anything other than "linear" or "swing" requires the easing plugin
			maxOverallWidth     : 32766     // Max width (in pixels) of combined sliders (side-to-side); set to 32766 to prevent problems with Opera			
			/*
onSlideBegin        : function(event, slider){
				if(slider.$targetPage.text().indexOf("Site does matter")!= -1){
					$j('#banner #mac').delay(1000).show().animate({top:0,opacity:1}, 1000, "easeOutExpo");
				}else if(slider.$currentPage.text().indexOf("Site does matter")!= -1){
					$j('#banner #mac').animate({top:1080,opacity:0}, 1000, "easeOutExpo", function(){
						$j(this).hide();
					});
				}
			}
*/
		});
		
			//First Slide (animate)
		$j('.slide1:first h2').css('right','0px').css('right','1250px').delay(1400).animate({right:0}, 1000, "easeOutExpo");
		$j('.slide1:first h3').css('right','0px').css('right','550px').delay(1000).animate({right:0}, 1200, "easeOutExpo");
		$j('.slide1:first h4').css('right','0px').css('right','550px').delay(1100).animate({right:0}, 1100, "easeOutExpo");
		$j('.slide1:first h5').css('right','0px').css('right','550px').delay(1200).animate({right:0}, 1000, "easeOutExpo");
		$j('.slide1:first .figure').css('top','0px').css('top','430px').delay(1400).animate({top:0}, 1000, "easeOutExpo");
		
		
		$j('#banner #slides').anythingSliderFx({
			inFx : {
                // '.slide1 h2' : { left : '0px', duration: 800, easing : 'easeOutExpo' },
                // '.slide1 h3' : { left : '0px', duration: 1200, easing : 'easeOutExpo' },
				'.slide1 h2' : { right : '0px', duration: 800, easing : 'easeOutExpo' },
				'.slide1 h3' : { right : '0px', duration: 1000, easing : 'easeOutExpo' },
				'.slide1 h4' : { right : '0px', duration: 1100, easing : 'easeOutExpo' },
				'.slide1 h5' : { right : '0px', duration: 1200, easing : 'easeOutExpo' },
				'.slide1 .figure' : { top : '0px', duration: 1400, easing : 'easeOutExpo' },
				'.slide2 h2' : { right : '0px', duration: 800, easing : 'easeOutExpo' },
				'.slide2 h3' : { right : '0px', duration: 1000, easing : 'easeOutExpo' },
				'.slide2 h4' : { right : '0px', duration: 1100, easing : 'easeOutExpo' },
				'.slide2 h5' : { right : '0px', duration: 1200, easing : 'easeOutExpo' },
				'.slide2 .figure' : { top : '0px', duration: 1400, easing : 'easeOutExpo' },
				'.slide3 h2' : { right : '0px', duration: 800, easing : 'easeOutExpo' },
				'.slide3 h3' : { right : '0px', duration: 1000, easing : 'easeOutExpo' },
				'.slide3 h4' : { right : '0px', duration: 1100, easing : 'easeOutExpo' },
				'.slide3 h5' : { right : '0px', duration: 1200, easing : 'easeOutExpo' },
				'.slide3 .figure' : { top : '0px', duration: 1400, easing : 'easeOutExpo' }
			},
			outFx : {
                // '.slide1 h2' : { left : '1231px', duration: 1200, easing : 'easeOutExpo' },
                // '.slide1 h3' : { left : '1231px', duration: 800, easing : 'easeOutExpo' },
				'.slide1 h2' : { right : '1250px', duration: 1400, easing : 'easeOutExpo' },
				'.slide1 h3' : { right : '550px', duration: 1200, easing : 'easeOutExpo' },
				'.slide1 h4' : { right : '550px', duration: 1100, easing : 'easeOutExpo' },
				'.slide1 h5' : { right : '550px', duration: 1000, easing : 'easeOutExpo' },
				'.slide1 .figure' : { top : '430px', duration: 1000, easing : 'easeOutExpo' },
				'.slide2 h2' : { right : '1250px', duration: 1400, easing : 'easeOutExpo' },
				'.slide2 h3' : { right : '550px', duration: 1200, easing : 'easeOutExpo' },
				'.slide2 h4' : { right : '550px', duration: 1100, easing : 'easeOutExpo' },
				'.slide2 h5' : { right : '550px', duration: 1000, easing : 'easeOutExpo' },
				'.slide2 .figure' : { top : '400px', duration: 800, easing : 'easeOutExpo' },	
				'.slide3 h2' : { right : '650px', duration: 1400, easing : 'easeOutExpo' },
				'.slide3 h3' : { right : '500px', duration: 1200, easing : 'easeOutExpo' },
				'.slide3 h4' : { right : '500px', duration: 1100, easing : 'easeOutExpo' },
				'.slide3 h5' : { right : '500px', duration: 1000, easing : 'easeOutExpo' },
				'.slide3 .figure' : { top : '420px', duration: 1000, easing : 'easeOutExpo' }
			}
		});
		$j("#banner .previous a").click(function(){
			$j('#banner #slides').data('AnythingSlider').goBack(true);
			return false;
		});
		$j("#banner .next a").click(function(){
			$j('#banner #slides').data('AnythingSlider').goForward(true);
			return false;
		});
	}


}
	
	/********************************
	Contact Form Slidedown
	********************************/
	
	$j(".contact").toggle(function(e){
		$j('.page-wrapper').animate({'margin-top': '320px'}, 400);
		e.preventDefault;
	}, function(e){
		$j('.page-wrapper').animate({'margin-top': '0'}, 400);	
		e.preventDefault;
	});

	
	/********************************
	Brands slideshow top
	********************************/	
	/* $j('#brandslider').nivoSlider(); */
	$j(function(){
			$j('#brandsliderTop').slides({
				preload: true,
				preloadImage: '/backtobasics/wp-content/themes/backtobasics/images/loading.gif',
				play: 0,
				pause: 5500,
				hoverPause: true
			});
		});
		
	/*-----------------------
	Brands slideshow bottom
	-------------------------*/	
	$j(function(){
			$j('#brandsliderBtm').slides({
				preload: true,
				preloadImage: '/backtobasics/wp-content/themes/backtobasics/images/loading.gif',
				play: 0,
				pause: 5500,
				hoverPause: true,
				container: 'slides_containerBtm'
			});
		});
	
	/********************************
	About slideshow top
	********************************/	
	$j(function(){
			$j('#aboutSliderTop').slides({
				preload: true,
				preloadImage: '/backtobasics/wp-content/themes/backtobasics/images/loading.gif',
				play: 0,
				pause: 5500,
				hoverPause: true,
				container: 'slides_containerTop',
				animationStart: function(current){
					$j('.caption').animate({
						top:0
					},100);
					if (window.console && console.log) {
						// example return of current slide number
						console.log('animationStart on slide: ', current);
					};
				},
				animationComplete: function(current){
					$j('.caption').animate({
						bottom:0
					},200);
					if (window.console && console.log) {
						// example return of current slide number
						console.log('animationComplete on slide: ', current);
					};
				},
				slidesLoaded: function() {
					$j('.caption').animate({
						bottom:0
					},200);
				}
			});
		});
				
	/*-----------------------
	About slideshow bottom
	-------------------------*/	
	$j(function(){
			$j('#aboutSliderBtm').slides({
				preload: true,
				preloadImage: '/backtobasics/wp-content/themes/backtobasics/images/loading.gif',
				play: 0,
				pause: 5500,
				hoverPause: true,
				container: 'slides_containerBtm'
			});
		});
	
	
	/********************************
	Meet the team slideup
	********************************/
	//Vertical Sliding
	$j('.boxgrid.slidedown').hover(function(){
		$j(".cover", this).stop().animate({top:'0px'},{queue:false,duration:300});
	}, function() {
		$j(".cover", this).stop().animate({top:'112px'},{queue:false,duration:300});
	});
	
	/********************************
	Contact Form
	********************************/
	$j('#contactform').validate({
		submitHandler : function(form){
			$j(form).ajaxSubmit({
				timeout: 6000,
				success: function(){
					$j('.form-success-msg').css('display','block');
					$j('.loading-img').css('display','none');
					$j('#contactform').each(function(){
						this.reset();
					});					
				},
				beforeSend: function(){
					$j('.loading-img').css('display','block');
				},
				error: function(){
					$j('.form-error-msg').css('display','block');
				}
			});
		}
	});
	
	/********************************
	Contact Form -- Select box
	********************************/
	
	if (!$j.browser.opera) {
    
			// select element styling
			$j('select.select').each(function(){
				var title = $j(this).attr('title');
				if( $j('option:selected', this).val() != ''  ) title = $j('option:selected',this).text();
				$j(this)
					.css({'z-index':10,'opacity':0,'-khtml-appearance':'none'})
					.after('<span class="select">' + title + '</span>')
					.change(function(){
						val = $j('option:selected',this).text();
						$j(this).next().text(val);
						})
			});

		};
		
	/********************************
	Get Page Ranked Form
	********************************/
	$j('#pagerankform').validate({
		submitHandler : function(form){
			$j(form).ajaxSubmit({
				timeout: 6000,
				success: function(){
					$j('#pagerankform .form-success-msg').css('display','block');
					$j('#pagerankform .loading-img').css('display','none');
					$j('#pagerankform').each(function(){
						this.reset();
					});					
				},
				beforeSend: function(){
					$j('#pagerankform .loading-img').css('display','block');
				},
				error: function(){
					$j('#pagerankform .form-error-msg').css('display','block');
				}
			});
		}
	});
	
	
});


