//
//	===========================================================
//	Pam Treece - Interface JS
//	Author: Mark C. Garity, Anchorwave.com
//	===========================================================
//	Description: Interface functions and initialization.
//	===========================================================
//

jQuery(function( $ ){	
	
	// JavaScript Easing - borrowed from jQuery easing plugin
	// http://gsgd.co.uk/sandbox/jquery.easing.php
	$.easing.elasout = function(x, t, b, c, d) {
		var s=1.70158;var p=0;var a=c;
		if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
		if (a < Math.abs(c)) { a=c; var s=p/4; }
		else var s = p/(2*Math.PI) * Math.asin (c/a);
		return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
	};
	
	// Sliding Quotes of Awesomeness
	var $HLTarget = $('#quote-time');
	var slideRotate = 1;
	$.scrollTo.defaults.axis = 'x'; 
	$HLTarget.stop().scrollTo( '0px', 0 );
	
	function HlSlide (item) {
		if (item==1){
			$HLTarget.stop().scrollTo( '0px', 1000 );
			slideRotate = 1;
		}
		
		else if (item==2){
			$HLTarget.stop().scrollTo( '248px', 1000 );
			slideRotate = 2;
		}
		
		else if (item==3){
			$HLTarget.stop().scrollTo( '496px', 1000 );
			slideRotate = 3;
		}
		
		
		else if (item==4){
			$HLTarget.stop().scrollTo( '744px', 1000 );
			slideRotate = 4;			
		}
		
		else if (item==5){
			$HLTarget.stop().scrollTo( '992px', 1000 );
			slideRotate = 5;
		}
		
		else if (item==6){
			$HLTarget.stop().scrollTo( '1240px', 1000 );
			slideRotate = 6;
		}
		
		else if (item==7){
			$HLTarget.stop().scrollTo( '1488px', 1000 );
			slideRotate = 7;
		}
				
		else if (item==8){
			$HLTarget.stop().scrollTo( '1736px', 1000 );
			slideRotate = 8;
		}
		
		else if (item==9){
			$HLTarget.stop().scrollTo( '1984px', 1000 );
			slideRotate = 9;
		}
		
		else if (item==10){
			$HLTarget.stop().scrollTo( '2232px', 1000 );
			slideRotate = 10;
		}
		
		else if (item==11){
			$HLTarget.stop().scrollTo( '2480px', 1000 );
			slideRotate = 11;
		}
		
		else if (item==12){
			$HLTarget.stop().scrollTo( '2728px', 1000 );
			slideRotate = 12;
		}
		
		else if (item==13){
			$HLTarget.stop().scrollTo( '2976px', 1000 );
			slideRotate = 13;
		}
	}
	
	$(document).ready(function(){
		setInterval( function() {
			if (slideRotate==1){
				HlSlide(2);
			}else if (slideRotate==2){
				HlSlide(3);
			}else if (slideRotate==3){
				HlSlide(4);
			}else if (slideRotate==4){
				HlSlide(5);
				}else if (slideRotate==5){
				HlSlide(6);
				}else if (slideRotate==6){
				HlSlide(7);
				}else if (slideRotate==7){
				HlSlide(8);
				}else if (slideRotate==8){
				HlSlide(9);
				}else if (slideRotate==9){
				HlSlide(10);
				}else if (slideRotate==10){
				HlSlide(11);
				}else if (slideRotate==12){
				HlSlide(13);
				}else if (slideRotate==13){
				HlSlide(1);
			}
		}, 9000);
	});
	
});