(function($){

	//add getWeek to the Date Obj
	Date.prototype.getWeek = function() {
	var onejan = new Date(this.getFullYear(),0,1);
	return Math.ceil((((this - onejan) / 86400000) + onejan.getDay()+1)/7);
	}
	
function electionCalendar() {
	root = this;
	root.currentDateObj = {};
	root.trueCurrentDateObj = {};
	root.firstDateObj = {};
	root.lastDateObj = {};
	root.duration = "day";
	root.range = "";
	root.candidateId = "";
	root.monthLookup = ["Jan","Feb","Mar","Apr","May","June","July","Aug","Sep","Oct","Nov","Dec"];
	root.state = {"AL":"Alabama","AK":"Alaska","AZ":"Arizona","AR":"Arkansas","CA":"California","CO":"Colorado","CT":"Connecticut","DC":"Washington DC","DE":"Delaware","FL":"Florida","GA":"Georgia","HI":"Hawaii","ID":"Idaho","IL":"Illinois","IN":"Indiana","IA":"Iowa","KS":"Kansas","KY":"Kentucky","LA":"Louisiana","ME":"Maine","MD":"Maryland","MA":"Massachusetts","MI":"Michigan","MN":"Minnesota","MS":"Mississippi","MO":"Missouri","MT":"Montana","NE":"Nebraska","NV":"Nevada","NH":"New Hampshire","NJ":"New Jersey","NM":"New Mexico","NY":"New York","NC":"North Carolina","ND":"North Dakota","OH":"Ohio","OK":"Oklahoma","OR":"Oregon","PA":"Pennsylvania","RI":"Rhode Island","SC":"South Carolina","SD":"South Dakota","TN":"Tennessee","TX":"Texas","UT":"Utah","VT":"Vermont","VA":"Virginia","WA":"Washington","WV":"West Virginia","WI":"Wisconsin","WY":"Wyoming"}		
}	
	
electionCalendar.prototype = {
	init: function(){
		var root = this;
		root.orderDataArr(); // reorder
		root.getCurrentDateObj();
		root.getFirstLastDateObjs();
		root.getCandidateId();
		if(!root.isMobile()){ 
			root.initializeMap();
		}
		root.setArrowControls();
		root.updateArrowControls(); 
		root.findOutDateRange(root.currentDateObj);		
		root.setCandidateItemsByDate(root.currentDateObj);

		root.displayLastMeetandHighlight();
		
	},
	isMobile: function(){
		return location.pathname.indexOf("mobile") > -1;
	},
	orderDataArr: function() {
		var x, z, root = this, arr = [], newArr = [], data = candidates_locations;
		
		// set date object
		var set = function(item) {
			var val = item[0].split("_"), len = val.length,
				dt = [val[len-2],val[len-3],val[len-1]].join("/"),
				date = new Date(dt);
			
			return { date:date, item:item };
		};
		
		for (x = 0; x < data.length; x++) {
			arr.push(set(data[x]));
		}
		
		// bubble sort
		for (x = 0; x < arr.length; x++) {
			for (z = 0; z < arr.length-1; z++) {
				var val1 = arr[z], val2 = arr[z+1];
				if (val1.date > val2.date) {
					arr[z+1] = val1;
					arr[z] = val2;
				}
				
			}
		}
		
		// replace with sorted values
		for (x = 0; x < arr.length; x++) {
			newArr.push(arr[x].item);
		}
		
		window.candidates_locations = newArr;
	},
	getCurrentDateObj: function(){
		var root = this;
		var d = window.CONST_Akamai_TIME || false;
		var dt = [d.mm,d.dd,d.yr].join("/");
		tm = "00:00:00 EST";
		root.currentDateObj = new Date(dt + " " + tm);

		root.trueCurrentDateObj = new Date(d.yr,(d.mm -1),d.dd,d.hr,d.min,d.sec);
		
	    if(root.getDateCookie() && !root.isMobile()){
			root.currentDateObj = new Date(root.getDateCookie());
		}			
		
	},
	getDateCookie: function(){
		return $.cookie("cookieTrackerCurrentDate");
	},
	getDurationCookie: function(){
		return $.cookie("cookieTrackerDuration");
	},	
	setDateCookie: function(dateObj){
		var root = this;
		$.cookie("cookieTrackerCurrentDate",dateObj,{ path: '/' });
	},
	setDurationCookie: function(duration){
		var root = this;
		$.cookie("cookieTrackerDuration",duration,{ path: '/' });
	},			
	getFirstLastDateObjs: function(){
		var root = this;
		var firstEntryArr = candidates_locations[0][0].split("_"),
		firstDay = firstEntryArr[2];
	    firstMonth = firstEntryArr[3],
		firstYear = "20"+firstEntryArr[4];
		
		root.firstDateObj = new Date(firstYear,firstMonth-1,firstDay,0,0,0,0);
		
		var lastEntryArr = candidates_locations[candidates_locations.length-1][0].split("_"),
		lastDay = lastEntryArr[2],
		lastMonth = lastEntryArr[3],
		lastYear = "20"+lastEntryArr[4];
		
		root.lastDateObj = new Date(lastYear,lastMonth-1,lastDay,0,0,0,0);
		
	},
	checkAgainstCurrentDate: function(dateObj,direction){

		var returnVal = false;			
		
		if(direction == "prev"){
			if(dateObj >= root.firstDateObj){					
				returnVal = true;
			}
		}
		if(direction == "next"){
			if(dateObj <= root.lastDateObj){					
				returnVal = true;
			}
		}		
		return returnVal;
	},
	getCandidateId: function(){
		var root = this;
		if(root.isMobile()){
			candList =$('.drop-down option')
		}
		else{
			candList = $('.candidate-list .c-list .c-list-item')
		}
		candList.each(function(){
			var thisCandidateWrapper = $(this);
			if(root.isMobile() && $(this).find('option:selected')){
				root.candidateId = $('.drop-down').find('option:selected').val();					
			}
			else if(thisCandidateWrapper.hasClass("selected")){
				selectedCandidate = thisCandidateWrapper.find('h2').text();	
				root.candidateId = selectedCandidate.match(/[a-z,A-Z]+[a-z,A-Z]+/g).join("").toLowerCase()
			}
		})
	},
	initializeMap: function(){
		var root = this;
		var myOptions = {
	    	zoom: 4,
	    	center: new google.maps.LatLng(38.68549756110551, -97.47067812499995),
	    	mapTypeId: google.maps.MapTypeId.ROADMAP
	  	};
	  	var map = new google.maps.Map(document.getElementById("map_canvas"),myOptions);

	  	root.setMarkers(map, root.currentDateCandidateLocations());
	},
	setMarkers: function(map,locations){
		var shape = {
		     coord: [1, 1, 1, 20, 18, 20, 18 , 1],
		     type: 'poly'
		 };
		for (var i = 0; i < locations.length; i++) {
			var candi = locations[i];

			//make sure there are latatitudes/longitudes
			if (typeof candi[1] != "undefined" || typeof candi[2] != "undefined") {
			
				var image = new google.maps.MarkerImage(candi[4], new google.maps.Size(36, 58), new google.maps.Point(0, 0), new google.maps.Point(0, 58));

			   var myLatLng = new google.maps.LatLng(candi[1],candi[2]);
			   var marker = new google.maps.Marker({
			       position: myLatLng,
			       map: map,
			       icon: image,
			       shape: shape,
			       title: candi[0],
			       zIndex: candi[3]
			   });
		 }		
		 }		
	},
	setArrowDisplay: function(){
		var root = this;
		var day = root.currentDateObj.getDate();
		var month = root.monthLookup[root.currentDateObj.getMonth()];
		var arrowWrapper = $('.arrow-btns');
		var dayDisplay = "";
		var dayDiv = "";
		if(root.isMobile()){
			dayDisplay = arrowWrapper.find('>span');	
		    dayDiv = $('.info-section').find('.day_'+day.toString());			
		}else{
			dayDisplay = arrowWrapper.find('.day>span'); //change made		
		    dayDiv = $('.info-section').find('.day_'+day.toString());			
		}
		dayDisplay.text(root.range);
	},
	findOutWeekRange: function(dateObj){

		var d1 = new Date();
		d1.setFullYear(root.currentDateObj.getFullYear());
		numOfdaysPastSinceLastMonday = eval(d1.getDay()- 1);
		d1.setDate(d1.getDate() - numOfdaysPastSinceLastMonday);
		var weekNoToday = d1.getWeek();
		var weeksInTheFuture = eval( (root.currentDateObj.getWeek()) - weekNoToday );
		d1.setDate(d1.getDate() + eval( 7 * weeksInTheFuture ));
		var rangeIsFrom = root.monthLookup[eval(d1.getMonth())] +" " + d1.getDate();
		
		var weekBegin = new Date(d1.getFullYear(), d1.getMonth(), d1.getDate(),0,0,0,0);
		
		d1.setDate(d1.getDate() + 6);
		var rangeIsTo = root.monthLookup[eval(d1.getMonth())] +" " + d1.getDate();
		
		var weekEnd = new Date(d1.getFullYear(), d1.getMonth(), d1.getDate(),0,0,0,0);

		range = rangeIsFrom +" - "+ rangeIsTo;		
		
		return {"weekBeginObj":weekBegin,"weekEndObj":weekEnd, "range":range}
		
		
	},
	findOutDateRange: function(dateObj){
		var root = this;
		var day = root.currentDateObj.getDate();
		var month = root.monthLookup[root.currentDateObj.getMonth()];
		if(root.duration == "day"){

			root.range = month + " " + day;
		}
		if(root.duration == "week"){
			var curweek = root.currentDateObj.getWeek();
			var rangeInfo = root.findOutWeekRange(dateObj);
			root.currentDateObj = rangeInfo.weekBeginObj;
			root.range = rangeInfo.range;	
		}
		if(root.duration == "month"){
			root.currentDateObj.setDate(1);
			root.range = month;
		}
		
		root.setArrowDisplay();		
		
	},	
	setArrowControls: function(){
		var root = this;
		var arrowWrapper = $('.arrow-btns');
		var next = "";
		var prev = "";
		if(root.isMobile()){
			next = arrowWrapper.find('.r');
			prev = arrowWrapper.find('.l');				
		}else{
			next = arrowWrapper.find('.first');
			prev = arrowWrapper.find('.last');		
		}
		
		if(root.getDurationCookie()){root.duration = root.getDurationCookie();}		
		$('cal-btns a').css("cursor","default");	
		$(".cal-btns a").addClass("off").removeClass("on");
		$(".cal-btns" + " ." +root.duration).addClass("on").removeClass("off"); 
		
		prev.click(function(){					
			
			if(root.duration == "day"){
				var temp = new Date(root.currentDateObj.getFullYear(), root.currentDateObj.getMonth(), root.currentDateObj.getDate()-1,0,0,0,0);	
			}
			if(root.duration == "week"){
				var temp = new Date(root.currentDateObj.getFullYear(), root.currentDateObj.getMonth(), root.currentDateObj.getDate()-1,0,0,0,0);
				var temp2 = new Date(root.currentDateObj.getFullYear(), root.currentDateObj.getMonth(), root.currentDateObj.getDate()-7,0,0,0,0);

			}
			if(root.duration == "month"){
				var temp = new Date(root.currentDateObj.getFullYear(), root.currentDateObj.getMonth(),0,0,0,0,0);						
			}
			if(root.checkAgainstCurrentDate(temp,"prev")){
				if(root.duration == "week"){
					root.currentDateObj = temp2;
				}else{root.currentDateObj = temp;}
				
				root.currentDateObj.setHours(0);
				root.currentDateObj.setMinutes(0);
				root.currentDateObj.setSeconds(0);
				root.currentDateObj.setMilliseconds(0);			
		    	root.findOutDateRange(root.currentDateObj);
				root.setDateCookie(root.currentDateObj);						
				root.updateArrowControls(root.currentDateObj);
				root.setCandidateItemsByDate(root.currentDateObj);
				var cdcl = root.currentDateCandidateLocations(root.currentDateObj);
				if(!root.isMobile()){				
					root.refreshMapPoints(cdcl);
				}									
			}

			return false;
		});
		next.click(function(){
			if(root.duration == "day"){ 
				var temp = new Date(root.currentDateObj.getFullYear(), root.currentDateObj.getMonth(), root.currentDateObj.getDate()+1,0,0,0,0);	
			}
			if(root.duration == "week"){
				var temp = new Date(root.currentDateObj.getFullYear(), root.currentDateObj.getMonth(), root.currentDateObj.getDate()+7,0,0,0,0);
				var temp2 = new Date(root.currentDateObj.getFullYear(), root.currentDateObj.getMonth(), root.currentDateObj.getDate()+7,0,0,0,0);
			}
			if(root.duration == "month"){
				var temp = new Date(root.currentDateObj.getFullYear(), root.currentDateObj.getMonth() + 1, root.currentDateObj.getDate(),0,0,0,0);						
			}
			if(root.checkAgainstCurrentDate(temp,"next")){	
				if(root.duration == "week"){
					root.currentDateObj = temp2;
				}else{
					root.currentDateObj = temp;
				}	
			
				root.currentDateObj.setHours(0);
				root.currentDateObj.setMinutes(0);
				root.currentDateObj.setSeconds(0);
				root.currentDateObj.setMilliseconds(0);			
			    root.findOutDateRange(root.currentDateObj);	
				root.setDateCookie(root.currentDateObj);				
				root.updateArrowControls(root.currentDateObj);
				root.setCandidateItemsByDate(root.currentDateObj);
				var cdcl = root.currentDateCandidateLocations(root.currentDateObj);	
				if(!root.isMobile()){
					root.refreshMapPoints(cdcl);												
				}
			}			
						
			return false;
		});
		$('#ct-header select').change(function(){
			var selectedOption = $(this).find('option:selected');
			root.candidateId = selectedOption.val();
			$('.current-location').hide();
			$('.who_'+root.candidateId).show();
		})	
		$('.cal-btns a').click(function(){
			var timeElm = $(this);
			$('.cal-btns a').removeClass("on").addClass("off");
			if(timeElm.hasClass("day")){root.duration = "day";}
			if(timeElm.hasClass("week")){root.duration = "week";}
			if(timeElm.hasClass("month")){root.duration = "month";}								
			timeElm.removeClass("off").addClass("on")
			root.findOutDateRange(root.currentDateObj);	
			root.updateArrowControls();
			root.setCandidateItemsByDate(root.currentDateObj);
			var cdcl = root.currentDateCandidateLocations(root.currentDateObj);	
			if(!root.isMobile()){
				root.refreshMapPoints(cdcl);					
			}
			root.setDurationCookie(root.duration)
						
			return false;
		})
		
		
		
				
	},	
	setCandidateItemsByDate: function(currentDateObj){

		var root = this;
		var allDateDivs = $('.content .info-section .c-list');
		allDateDivs.hide();

		if(root.duration == "day"){
		     $(".month_"+(currentDateObj.getMonth()+1) +".day_"+currentDateObj.getDate()).show().addClass("active-on");			
		}
		if(root.duration == "week"){
			for(i = 0;i < 7; i++){
				var temp = new Date(currentDateObj.getFullYear(), currentDateObj.getMonth(), (currentDateObj.getDate()+i),0,0,0,0);		
			 	var week = (temp.getWeek() < 10)? "0"+temp.getWeek():temp.getWeek();
				$(".week_"+week +".day_"+ temp.getDate()).show().addClass("active-on");
			}
		}
		if(root.duration == "month"){
			$('.c-list.month_'+(currentDateObj.getMonth()+1)).show().addClass("active-on");
		} 
		if(root.isMobile()){
				$('.current-location').hide().addClass("active-on");	
		}
		if(root.candidateId = "allcandidates"){
			$('.current-location').show();
		}else{
			$('.who_'+root.candidateId).show();
		}
	},
	updateArrowControls: function(){
		var root = this;
		var prev = "";
		var next = "";
			
		if(root.isMobile()){
			prev = $('.btn-arrow.l'),next = $('.btn-arrow.r');
		}else{
			prev = $('.arrow-btns .last a'),next = $('.arrow-btns .first a');	
		}	
		prev.addClass("off").removeClass("on").css("cursor","default");
		next.addClass("off").removeClass("on").css("cursor","default");

		firstVal = root.firstDateObj;
		lastVal = root.lastDateObj;

		var currentVal = root.currentDateObj;


		if(root.duration == "day"){
			if(firstVal < currentVal  && currentVal < lastVal){
				prev.addClass("on").removeClass("off").css("cursor","pointer");
				next.addClass("on").removeClass("off").css("cursor","pointer");		

			}else if(currentVal > lastVal){//prev
				prev.addClass("on").removeClass("off").css("cursor","pointer");	
				next.addClass("off").removeClass("on").css("cursor","default");				
			}else if(currentVal < lastVal){//next
				next.addClass("on").removeClass("off").css("cursor","pointer");
				prev.addClass("off").removeClass("on").css("cursor","pointer");				
			}else if(firstVal < currentVal){
				prev.addClass("on").removeClass("off").css("cursor","pointer");	
				next.addClass("off").removeClass("on").css("cursor","default");				
			}
		}
		if(root.duration == "week"){
			var rangeInfo = root.findOutWeekRange(root.currentDateObj);
			if(rangeInfo.weekEndObj < root.lastDateObj){
				//next
				next.addClass("on").removeClass("off").css("cursor","pointer");				
			}
			if(rangeInfo.weekBeginObj > root.firstDateObj){
				//prev	
				prev.addClass("on").removeClass("off").css("cursor","pointer");				
			}				
		}
		if(root.duration == "month"){
			var firstDayNextMonth = new Date(root.currentDateObj.getFullYear(), root.currentDateObj.getMonth()+1, root.currentDateObj.getDate(),0,0,0,0);
			var lastDayPrevMonth = new Date(root.currentDateObj.getFullYear(), root.currentDateObj.getMonth(), 0,0,0,0,0);

			var rangeForPrevMonth = root.findOutWeekRange(root.currentDateObj);
			
			if(lastVal >= firstDayNextMonth){
				next.addClass("on").removeClass("off").css("cursor","pointer");
			}
			if(firstVal <= lastDayPrevMonth){
				prev.addClass("on").removeClass("off").css("cursor","pointer");
			}			
			
		}

		
	},
	currentDateCandidateLocations: function(){
		var root = this;
		var new_candidates_locations = [];
		
		for(i=0;i < candidates_locations.length;i++){
			if(typeof root.candidateId != "undefined"){
				var candArr = candidates_locations[i][0].split("_");
				var candName = candArr[0];
				var candWeek = candArr[1];
				var candDay = candArr[2];
				var candMonth = candArr[3];

				if(root.duration == "day"){
					if(root.currentDateObj.getWeek() == candWeek && root.currentDateObj.getDate() == candDay){
						if(root.candidateId == "allcandidates"){
							new_candidates_locations.push(candidates_locations[i]);		
						}else{
							if(root.candidateId+"_"+candWeek+"_"+ candDay+"_"+ root.currentDateObj.getMonth()+"_11" == candidates_locations[i][0]){
								new_candidates_locations.push(candidates_locations[i]);
							}	
						}					
					}
				}
				if(root.duration == "week"){ 
					if(root.currentDateObj.getWeek() == candWeek){
						new_candidates_locations.push(candidates_locations[i]);
					}
				}
				if(root.duration == "month"){
					if((root.currentDateObj.getMonth()+1) == candMonth){
						new_candidates_locations.push(candidates_locations[i]);
					}				
				}					
			}
		}
		return new_candidates_locations;			
	},
	refreshMapPoints: function(locations){
		var myOptions = {
	    	zoom: 4,
	    	center: new google.maps.LatLng(38.68549756110551, -97.47067812499995),
	    	mapTypeId: google.maps.MapTypeId.ROADMAP
	  	};
	  	var map = new google.maps.Map(document.getElementById("map_canvas"),myOptions);
	    root.setMarkers(map, locations);
	},
	displayLastMeetandHighlight: function(){
		var root = this;
		var cList = $('.info-section .c-list');
		var pastEventElm = false;
		var selectedElm = "";
		var lastLocation = "";
		var foundLatest = false;
		//var currentTimeObj = new Date(root.trueCurrentDateObj.getFullYear(),10,29,1,0,0,0); //for testing
		var currentTimeObj = root.trueCurrentDateObj;

		cList.each(function(){
			var cListElm = $(this);
			var cListElmClass = cListElm.attr("class");
			var day = cListElmClass.match(/day_([0-9]+)/)[1];
			var month = cListElmClass.match(/month_([0-9]+)/)[1];		
			
			//take out ending time for mobile pages
			cListElm.find('.current-location').each(function(){
				var currentLocationItem = $(this);
				var timeElm = currentLocationItem.find('.day-time');
				var timeText = timeElm.text();
				var timeTextArr = timeText.split("-");	
				timeElm.text(timeTextArr[0]);			
			})
			
			
			cListElm.find('.c-list-item').each(function(){
				var cListItem = $(this);
				var timeElm = cListItem.find('.day-time');
				var dayTimes = timeElm.text();
				var dayTimesArr = dayTimes.split(" ");
				var beginTime = dayTimesArr[0],beginAmPm = dayTimesArr[1],endTime = dayTimesArr[3],endAmPm = dayTimesArr[4]; 
				var beginTimeArr = beginTime.split(":"),endTimeArr = endTime.split(":");

				var beginHour = Number(beginTimeArr[0]),beginMin = Number(beginTimeArr[1]),endHour = Number(endTimeArr[0]),endMin = Number(endTimeArr[1]);

				if(beginAmPm == "pm" && beginHour != 12){beginHour = beginHour+12;}
				if(endAmPm == "pm" && endHour != 12){endHour = endHour+12;}				
				var timeBeginObj = new Date(root.trueCurrentDateObj.getFullYear(),(month-1),day,beginHour,beginMin,0,0);
				var timeEndObj = new Date(root.trueCurrentDateObj.getFullYear(),(month-1),day,endHour,endMin,0,0);

				var locationText = "";
				var locationTextArr = "";

				var targetDayElm = $('.day_'+day+'.month_'+ month);

				if(cListElm.hasClass('month_'+ month) && cListElm.hasClass('day_'+(day))){

					if(timeBeginObj < currentTimeObj && currentTimeObj < timeEndObj){
						selectedElm = cListItem;	
						cListItem.addClass('highlight');
						foundLastest = true;

					}
				}
											
			})
		})
		if(!foundLatest && !root.isMobile()){
			
			cList.each(function(){
				var cListElm = $(this);
				var foundNext = false;
			
				cListElm.find('.c-list-item').each(function(){
					var cListItem = $(this);
					
					var cListElmClass = cListElm.attr("class");
					var day = cListElmClass.match(/day_([0-9]+)/)[1];
					var month = cListElmClass.match(/month_([0-9]+)/)[1];
										
					var timeElm = cListItem.find('.day-time');					
					var dayTimes = timeElm.text();
					var dayTimesArr = dayTimes.split(" ");
					var beginTime = dayTimesArr[0],beginAmPm = dayTimesArr[1],endTime = dayTimesArr[3],endAmPm = dayTimesArr[4]; 
					var beginTimeArr = beginTime.split(":"),endTimeArr = endTime.split(":");

					var beginHour = Number(beginTimeArr[0]),beginMin = Number(beginTimeArr[1]),endHour = Number(endTimeArr[0]),endMin = Number(endTimeArr[1]);

					if(beginAmPm == "pm" && beginHour != 12){beginHour = beginHour+12;}
					if(endAmPm == "pm" && endHour != 12){endHour = endHour+12;}				
					var timeBeginObj = new Date(root.trueCurrentDateObj.getFullYear(),(month-1),day,beginHour,beginMin,0,0);
					var timeEndObj = new Date(root.trueCurrentDateObj.getFullYear(),(month-1),day,endHour,endMin,0,0);

					var locationText = "";
					var locationTextArr = "";

					if(timeBeginObj > currentTimeObj){
							foundNext = true;
					}else if(!foundNext && currentTimeObj > timeBeginObj){
						selectedElm = cListItem;
						}
					
					timeElm.text(dayTimes.split("-")[0])
					
				})
			})
		}
		if(!root.isMobile()){	
			$('.candidate-info .data li:eq(1)').hide();
			if(selectedElm != "" && typeof selectedElm != "undefined"){
				var locationText = selectedElm.find('.c-list-font').text();
				var locArr = locationText.match(/([a-z,A-Z]{2})[ 0-9]{6}/);
				if(locArr != null){
					$('.candidate-info .data li:eq(1) span.r').text(root.state[locArr[1]]); 
					$('.candidate-info .data li:eq(1)').show();		
				}		
			}
			
		}				
	}	
}	

var cal = new electionCalendar();

$(document).ready(function(){
     if (window.candidates_locations) { 
		if(window.candidates_locations.length > 0){
			cal.init(); 
		}
		else{
		  var prev = "", next = "";
			if(root.isMobile()){
			    prev = $('.btn-arrow.l'),next = $('.btn-arrow.r');
			}else{
				prev = $('.arrow-btns .last a'),next = $('.arrow-btns .first a');	
			}			
			prev.addClass("off").removeClass("on").css("cursor","default");
			next.addClass("off").removeClass("on").css("cursor","default");
		}
	} 
})


})(jQuery);


